do_svd - Calculates the (reduced) SVD


#include "n/n_svd.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int do_svd
	const Matrix *a_mp,
	Matrix **u_mpp,
	Vector **d_vpp,
	Matrix **v_trans_mpp,
	int *rank_ptr


Given a matrix A, this routine computes A = U*D*VT, where D is diagonal, and contains the singular values of A. The reduced SVD is computed, so, letting m be the number of rows in A, n be the number of columns in A, and letting r=min(m,n), then the dimensions of U are mxr, the dimensions of D are rxn, and the dimensions of VT are nxn. (D is actually returned as a vector of length r, and if D is needed as a matrix, the caller will have to put the vector into a zero matrix of dimension rxn). The matrices U and VT are put into *u_mpp and *vt_mpp, respectively, which are created or resized as needed. The diagonal matrix of singular values is put into the vector pointed to by *d_vpp, which is also created or resized as needed. Also, an estimate of the rank of A is put into *rank_ptr. This is the number of singular values of A such that the ratio of the first singular value to the singular values is less than the maximum allowed condition number. The maximum allowed condition number is normally exposed to the user through the option "max-matrix-condition-number". (The condition number of matrix is the raio of the largest (first) singular value to the smallest (last) singular value). If you are not interested in one or more of U, D, VT, or rank, then the corresponding pointer argument may be set to NULL. The method used to compute the svd is also user settable. The default method is to use the LAPACK routine, if it is available. If the LAPACK library is not available, then code from numerical recipes in C is used, provided that it is available. Note that the terms of use for numerical recipes excludes making those routines available in code exported to the world.


NO_ERROR on success, and ERROR on failure, with an appropriate error message being set.


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard