dgesvd函数

来源:互联网 发布:ipadmini安装不了软件 编辑:程序博客网 时间:2024/06/02 01:02

    用到svd分解,老师用的是 svdcmp(float **a, int m, int n, float w[], float **v) 函数。这函数的解释是Given a matrix a[1..m][1..n], this routine computes its singular value decomposition, A = U.W.VT.  The matrix U replaces a on output.  The diagonal matrix of singular values W is output as a vector w[1..n].  The matrix V (not the transpose VT) is output as v[1..n][1..n]。

    具体算法:http://www.tina-vision.net/tina4/doxygen/html/dc/df5/svd_8c.html

    但是关于这个函数,还有些疑问(我没看这函数的源码,也没用过,所以不确定,若有人知道,请告诉我,THX~)

    1、返回值W的储存形式,是有W(i+1)>W(i),还是奇异值按照任意形式储存

    2、关于a,w,v的储存形式,我看到老师算2*2的矩阵svd时,用的是3*3的a来储存,矩阵存在a的右下角2*2里面,w,v也是一样的,要多加一维。

    

     因为想直接用MKL,所以查了一下,发现可以直接用

dgesvd( char *jobu, char *jobvt, MKL_INT *m, MKL_INT *n, double *a, MKL_INT *lda, double *s, double *u, MKL_INT *ldu, double *vt, MKL_INT *ldvt, double *work, MKL_INT *lwork, MKL_INT *info );


这个函数,这里要特别注意储存方式(column major)!!

具体参数含义,请参看http://software.intel.com/sites/products/documentation/hpc/mkl/mklman/index.htm

PS:

1、work is a workspace array, its dimensionmax(1,lwork).

2、lwork Constraints:  ( lwork:The dimension of the arraywork.)

lwork 1

lwork max(3*min(m, n)+max(m, n), 5*min(m,n)) (for real flavors);

lwork 2*min(m, n)+max(m, n) (for complex flavors).

For good performance, lwork must generally be larger.

If lwork = -1, then a workspace query is assumed; the routine only calculates the optimal size of thework array, returns this value as the first entry of thework array, and no error message related tolwork is issued byxerbla.SeeApplication Notes for details.

 3、s(i) >= s(i+1)

 

原创粉丝点击