- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 GSL 来计算两个 vector 之间的点积。 vector 是矩阵列的 View 。我将该函数称为 gsl_blas_dsdot( &view1.vector, &view2.vector, &val)
,但在编译时,我收到警告,指出该函数需要参数类型 const gsl_vector_float *
,我得到了一个荒谬的结果。下面是一个演示代码:
#include<stdio.h>
#include<gsl/gsl_matrix.h>
#include<gsl/gsl_vector.h>
#include<gsl/gsl_blas.h>
void main(void){
int i;
double val = 111.111; // Initialize to something
gsl_matrix *A = gsl_matrix_alloc(3,3); //Initialize mx
gsl_matrix_set_identity(A); // Set mx to identity
gsl_matrix_set(A,0,1,3.14);
gsl_vector_view a1 = gsl_matrix_column(A,0); // Vector allocations
gsl_vector_view a2 = gsl_matrix_column(A,1);
/* Print the vectors */
printf("a1 = ");
for(i=0; i<3; i++){
printf("%g ", gsl_vector_get(&a1.vector,i));}
printf("\na2 = ");
for(i=0; i<3; i++){
printf("%g ", gsl_vector_get(&a2.vector,i));}
printf("\n");
gsl_blas_dsdot(&a1.vector, &a2.vector, &val); // Dot product
printf("a1.a2 = %.2f\n", val); // Print result
}
我使用 gcc 版本 5.4.0、GSL 版本 2.2.1 进行编译,内容如下:
gcc example.c -o example -lgsl -lgslcblas
我收到以下警告,尽管程序执行了,但结果是无意义的:
gsl_dot.c: In function ‘main’:
gsl_dot.c:22:18: warning: passing argument 1 of ‘gsl_blas_dsdot’ from incompatible pointer type [-Wincompatible-pointer-types]
gsl_blas_dsdot(&a1.vector, &a2.vector, &val); // Dot product
^
In file included from gsl_dot.c:4:0:
/usr/local/include/gsl/gsl_blas.h:56:5: note: expected ‘const gsl_vector_float * {aka const struct <anonymous> *}’ but argument is of type ‘gsl_vector * {aka struct <anonymous> *}’
int gsl_blas_dsdot (const gsl_vector_float * X,
^
gsl_dot.c:22:30: warning: passing argument 2 of ‘gsl_blas_dsdot’ from incompatible pointer type [-Wincompatible-pointer-types]
gsl_blas_dsdot(&a1.vector, &a2.vector, &val); // Dot product
^
In file included from gsl_dot.c:4:0:
/usr/local/include/gsl/gsl_blas.h:56:5: note: expected ‘const gsl_vector_float * {aka const struct <anonymous> *}’ but argument is of type ‘gsl_vector * {aka struct <anonymous> *}’
int gsl_blas_dsdot (const gsl_vector_float *
另请注意,使用 get_matrix_get_col()
将矩阵列复制到 gsl_vector
类型会导致相同的警告。
有人可以帮忙吗?这些 gsl vector 和 vector View 是什么使它们成为不兼容的类型?这些 const gsl_vector_float
类型是什么?
最佳答案
我仍然不知道 const gsl_vector_float
是什么,但我确实发现使用函数 gsl_blas_ddot
而不是 gsl_blas_dsdot
进行编译没有警告并正确执行。
According to the documentation ,我希望提供更多详细信息,gsl_blas_ddot
采用 const gsl_vector *
作为参数。这显然与所讨论的 const gsl_vector_float *
不同。
关于c - GSL BLAS 函数所需的 "const gsl_vector_float"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40849025/
我有一个依赖于包 B 的包 A。当包 A 中的代码运行并访问包 B 中的类时,包 B 的状态将被解析 (4),而不是 Activity (32) 和包 B 的激活器也没跑好。我认为 bundle B
这个问题在这里已经有了答案: How to remove the space between inline/inline-block elements? (41 个回答) 关闭 7 年前。
我正在尝试使用 Java OpenAL 库。我在导入名为 libsoft_oal.so 的 native 库时遇到问题。 Java OpenAL 依赖于 OpenAL 软实现。我尝试根据他们在 git
我正在尝试启动我的应用程序。是一个 unicorn +工头+sinatra的应用。 这是我的 config.ru 文件: require "rubygems" require "sinatra" Bu
我有一个下拉列表,其中包含一些从数据库表中检索的值,我想要的是当单击按钮时它应该只获得选项标签的中间值,但只有那些类名为“get_this”的选项标签并离开那些选项,如果他们没有这个类 预期输出:值
我有一个index.php文件,需要一个通用的head.php文件,head.php文件中有几个Javascript文件,当这样尝试时,代码在源代码中看起来很好,但文件却不是实际上对文档做任何事情。
有人能帮帮我吗? 我已经像这样运行了 imsmod: $ insmod /data/mm/mmdev.ko epoll_rate=100 但是我得到一个错误: insmod: init_module
是否有键盘快捷键或插件可以在 Notepad++ 中打开 PHP 所需或包含的文件?我知道,在 Dreamweaver 中,执行此操作的命令是 Ctrl+D,但我似乎无法在 Notepad++ 中找到
我已经用 js 设置了一个显示/隐藏 div,但我很难弄清楚如何一次显示一个 div。目前发生的情况是,除非我再次单击原始链接来关闭该 div,否则每个 div 都会显示。 http://www.li
当我尝试将未分配的辅助分片分配给节点时出现错误。 { "error": { "root_cause": [ { "type": "remote_transpor
我正在构建一个 C++ 应用程序,使用 Netbeans 6.9 作为我的 IDE。我有一个 C++ 库,它是一个纯 C 库的包装器。 我已将文件正确添加到项目中(使用添加库文件选项)。这是 g++
我是一名优秀的程序员,十分优秀!