Re: [eigen] RFC: BasicSVD class |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
The fast mode struggles when the
singular values are really close. That is the main reason it is
not the default mode. The SelfAdjointEigenSolver mode seems to do
just as well as JacobiSVD in this challenging case (sometimes
better).
You can test this by playing with the arguments of the test utility I attached in the previous email. arg 1 : m (rows of matrix X) arg 2 : n (cols of matrix X) arg 3 : k (number of dimensions to test) arg 4 : spread : sets the difference in singular values of the matrix to be solved (see example below) Here's an octave/matlab representation of the test matrix that gets created at the beginning of the testType<T> function: m=500;n=400; %problem dimensions k=3; % number of dimensions that will be larger in magnitude than the rest spread=.1; % the range of the first K singular values [U,junk,V]=svds(randn(m,n),k); %need orthonormal vectors U,V (the C++ code uses GramSchmidt ) S=diag( linspace( 2 + spread , 2 , k ) ); %descending singular values X1 = U*S*V'; % low rank matrix R=randn(m,n)/sqrt(m); % completely random matrix R = R - U*U'*R; % remove columnspace projection R = R - R*V*V'; % remove rowspace projection X= X1 + R; % The test matrix with known vectors and distinct values for the first k dimensions, the rest of the dimensions are filled with randomnesss at a lower level. octave:13> svds(X,5) ans = 2.1000 <-- corresponds to U(:,1)*V(:,1)' 2.0500 <-- U(:,2)*V(:,2)' 2.0000 <-- U(:,3)*V(:,3)' 1.8941 <-- the remaining dimensions are from random R 1.8594 Note: the singular values associated with the random dimensions will take on values between 1 and 2 depending on how rectangular the matrix is. Note m==n would give you an occasional testing glitch since the SVD should find one of the random dimensions instead of a vector in U,V. On 12/07/2012 09:35 AM, Gael Guennebaud wrote: Indeed, this simple algorithm seems pretty fast and it could even be even faster once we have fully optimized SelfAdjointEigenSolver. However I'm skeptical about its accuracy since it is squaring the entries that is typically something you want to avoid when using a SVD solver. I guess that in your case you are more interested in the singular values/vectors rather than in solving a least square problem? otherwise QR would offer a better accuracy/perf option. |
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |