我正在尝试从 C 调用 CLAPACK 函数。我下载了 CLAPACK-3.2.1 (来自http://www.netlib.org/clapack/clapack.tgz)并按照此处的说明进行操作(http://people.sc.fsu .edu/~%20jburkardt/c_src/clapack/clapack.html)。我的 CLAPACK 分布是这样的:
$ ls
BLAS/ COPYING F2CLIBS/ INCLUDE/ INSTALL/ Makefile make.inc.example my_example.c README.install SRC/ TESTING/
我的文件my_example.c
很简单:
#include <stdio.h>
#include "blaswrap.h"
#include "f2c.h"
#include "clapack.h"
int main()
{
char ta = 'N';
char tb = 'N';
double a[3][3];
a[0][0] = 1;
a[0][1] = 2;
a[0][2] = 3;
a[1][0] = 4;
a[1][1] = 5;
a[1][2] = 6;
a[2][0] = 7;
a[2][1] = 8;
a[2][2] = 9;
double b[3][3];
b[0][0] = 1;
b[0][1] = 0;
b[0][2] = 0;
b[1][0] = 0;
b[1][1] = 0;
b[1][2] = 0;
b[2][0] = 5;
b[2][1] = 5;
b[2][2] = 5;
double c[3][3];
long int m = 3;
long int n = 3;
long int k = 3;
double alpha = 1.0;
double beta = 0.0;
long int lda = 3;
long int ldb = 3;
long int ldc = 3;
f2c_dgemm(&ta, &tb, &m, &n, &k, &alpha, &a[0][0], &lda, &b[0][0], &ldb, &beta, &c[0][0], &ldc);
printf("Resulting C[0][0]: %f\n", c[0][0]);
return 0;
}
当我编译它时,我得到了这个:
$ gcc -I./INCLUDE -I./F2CLIBS/libf2c/ -I./BLAS/WRAP/ my_example.c BLAS/SRC/dgemm.c BLAS/SRC/xerbla.c BLAS/SRC/lsame.c -o my_example.o
How can I get this to compile and run correctly?
BLAS/SRC/xerbla.c: In function ‘xerbla_’:
BLAS/SRC/xerbla.c:69:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
BLAS/SRC/xerbla.c:70:3: warning: format ‘%i’ expects argument of type ‘int’, but argument 3 has type ‘integer’ [-Wformat]
这是调用 clapack 函数的正确方法吗?数组传递是否正确?
(PS 我不想动态链接到现有的 clapack 安装)。