csmith

dgesvd - errors in solution

Discussion created by csmith on Jul 15, 2011
Latest reply on Aug 8, 2011 by csmith

I'm trying to calculate the svd of a matrix, to no avail. 

I'm calling into the ACML libraries using DllImport from C#.  My function call is the following:

dgesvd('A', 'A', nr, nc, mm.Values, lda, s, u.Values, ldu, v.Values, ldvt, ref info);

where *.Values is a double[,].  The problem is I don't get the correct solution.  So far I've been testing on very simple matrices all of which produce garbage solutions. 

 

Ex: [[-4.0 2.0][3.0 -5.0]]

 

nr = 2, nc = 2, lda = 2, ldu = 2, ldvt = 2, mm.Values is the above matrix, u and v are empty double[2,2] and s is an empty double[2]

The eigenvalues should be -7 and -2, but I don't see that coming out. 

The solution coming out though does have the correct property of A = U*Sigma*Vt, with incorrect values in Sigma.  U and Vt contain orthogonal vectors.  Any insight would be welcomed into this problem.

Outcomes