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インストールに動的にリンクしようとしているわけではありません)。