参考
intel MTK实例
https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_dgesvd_row.c.htm
http://www.netlib.org/lapack/explore-html/d0/dee/lapacke__dgesvd_8c.html
https://blog.csdn.net/helei001/article/details/18447001
查询函数
http://www.netlib.org/lapack/explore-html/de/ddd/lapacke_8h_source.html
c接口
http://www.netlib.org/lapack/lapacke.html
原理
http://www.netlib.org/lapack/lug/node53.html
#include <stdio.h> #include <lapacke.h> void print_matrix(double *src, int m, int n) { for(int i =0 ;i < m; ++i) { for(int j = 0; j < n;++j) { printf("%lf ", src[i * n + j] ); } printf(" " ); } printf(" " ); } int main (int argc, const char * argv[]) { double a[2*2] = {4.0,4.0,-3.0,3.0}; int matrix_layout = LAPACK_ROW_MAJOR; char jobz = 'N'; lapack_int info,m,n,lda,ldu,ldvt; m = 2; n = 2; lda = 2; ldu = 2; ldvt = 2; double s[4]; double u[4]; double vt[4]; double superb[4]; // lapack_int LAPACKE_dgesvd (int matrix_layout, char jobu, char jobvt, // lapack_int m, lapack_int n, double *a, lapack_int lda, // double *s, double *u, lapack_int ldu, double *vt, // lapack_int ldvt, double *superb) info = LAPACKE_dgesvd( matrix_layout, 'A', 'A', m, n, a, lda, s, u, ldu, vt, ldvt, superb); printf("%d ",info); print_matrix(s,2,2); print_matrix(u,2,2); print_matrix(vt,2,2); return 0; }
$ gfortran main.c -llapacke -llapack -lrefblas && ./a.out
0
5.656854 4.242641
0.000000 0.000000
-1.000000 0.000000
0.000000 1.000000
-0.707107 -0.707107
-0.707107 0.707107