Re: [Lapackpp-devel] SVD that ignores U, Sigma or VT
Status: Beta
Brought to you by:
cstim
|
From: Christian S. <sti...@tu...> - 2004-09-03 08:24:07
|
Jacob (Jack) Gryn schrieb: > I=92m writing some code that only uses data from VT of an SVD, and don=92= t=20 > need the data in U and Sigma. Although I can ignore it; the resulting = U=20 > is significantly large (512^2x512^2), which is too large a matrix for=20 > the system to handle; and is clearly a waste. Absolutely agreed. I guess you mean the JOBZ argument of the LAPACK=20 function dgesdd http://docs.sun.com/source/817-6700/dgesdd.html, where=20 currently only the settings 'A' and 'N' are used, and instead you would=20 like to use either the 'O' or the 'S' setting. > I=92ve noticed that there is a function that ignores both U and VT, by=20 > essentially setting ldv and ldu to 0, that seemingly tells LAPACK to=20 > ignore the data. =20 The point here is that the argument JOBZ was set to 'N'. Only this is=20 the reason for LAPACK not to use the U and VT arguments. Look into the=20 man page mentioned above. > Maybe it would be better just to use a single LaSVD_IP=20 > function, and allow uninitialized LaGenMat[Double/Complex] as input.=20 > If, for example U is declared with the default constructor, since=20 > U.gdim(0) =3D=3D 0, I would guess that LAPACK will ignore writing outpu= t to U. For people who only want the singular values but not the vectors, I=20 would rather want to leave that extra function in there, since it is=20 totally unambiguous what this function will do. But for your case where=20 you want only some of the singular vectors, there are several=20 possibilities. As you say, one possibility would be to do different=20 things according to what the input arguments U and VT have been set to.=20 Let's assume A to be M-by-N and M !=3D N. Right now we do the following: If (U.size =3D=3D M-by-M) && (VT.size =3D=3D N-by-N) calculate all singular vectors (JOBZ=3D'A') else error. Instead, we could also do the following: MNmin =3D min(M,N); If (U.size =3D=3D M-by-M) && (VT.size =3D=3D N-by-N) calculate all singular vectors (JOBZ=3D'A') else if (U.size =3D=3D M-by-MNmin) && (VT.size =3D=3D MNmin-by-N) calculate the MNmin first singular vectors (JOBZ=3D'S') else if (M >=3D N) && (U.size =3D 0) && (VT.size =3D=3D N-by-N) calculate full VT and first N vectors of U (JOBZ=3D'O') else if (M < N) && (U.size =3D M-by-M) && (VT.size =3D 0) calculate full U and first M vectors of VT (JOBZ=3D'O') else error Does this meet your requirements? On the other hand, this increases the=20 risk of the programmer to be totally confused about what the arguments=20 are supposed to be. But nevertheless I think it would be possible. Do=20 you want me to implement this? Or do you want to give it a try for yourse= lf? Christian |