This forum has been archived. All content is frozen. Please use KDE Discuss instead.

SVD matrix size

Tags: None
(comma "," separated)
renorm
Registered Member
Posts
31
Karma
0

SVD matrix size

Wed Aug 25, 2010 4:07 am
Why U matrix is always square? It is very wasteful with OLS type matrices. My design matrix has many thousand rows and only several columns. Transposing won't help, because it makes V matrix huge.

Any tips?
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Wed Aug 25, 2010 11:39 am
Yep, we know about that problem. We have plans for an improved, more flexible SVD, just haven't gotten around to coding it yet.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
renorm
Registered Member
Posts
31
Karma
0

Re: SVD matrix size

Wed Aug 25, 2010 7:42 pm
Did you look at Jama?
http://math.nist.gov/javanumerics/jama/

It is in public domain and not copyrighted.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Wed Aug 25, 2010 7:44 pm
JAMA is where we took code for the old implementation we have in Eigen 2.0.

The current SVD in Eigen3 is already much faster than that, it just has various issues that leave room for improvement, such as the one mentioned in this thread.
renorm
Registered Member
Posts
31
Karma
0

Re: SVD matrix size

Wed Aug 25, 2010 7:55 pm
I see.

Btw, how dot product works in Eigen? Does it use SIMD? Also, does it split large vector into blocks for the sake of numerical accuracy?
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Wed Aug 25, 2010 8:01 pm
Yes it is using SIMD; no it is not using a divide-and-conquer approach (would be a welcome addition, if done well i.e. not slowing us down wrt vectorization).


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
renorm
Registered Member
Posts
31
Karma
0

Re: SVD matrix size

Wed Aug 25, 2010 8:39 pm
Block dot product makes sense only with large vectors. If block size is multiple of 64, 128, 256, 512, etc, then each block is automatically aligned to 16 byte boundaries. The tail block (max 3 with floats and max 1 with doubles) maybe not vectorized, but the overhead should be negligible.

Btw, is there a way to change the aliment from 16 to 128 bytes? I want to align to cache line, which should be good for SIMD as well.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Wed Aug 25, 2010 8:43 pm
Yep, exactly. If you want to tackle it, this is in Eigen/src/Core/Redux.h. This is not specific to dot-product, it's shared with all reduction operations (sum, product, max, etc).


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: SVD matrix size

Wed Aug 25, 2010 9:13 pm
Note that for small fixed sizes our meta unroller already uses a divide and conquer strategy to reduce instruction dependency and thus speed up reductions. So for performance reasons, it might be interesting to treat large objects as many small fixed size ones. However, this has little impact on the numerical accuracy. If what you want is to compute the L2 norm in a stable way then we have a set of robust functions for that.
grekop
Registered Member
Posts
10
Karma
0

Re: SVD matrix size

Thu Aug 26, 2010 12:59 am
Hello out there!
I am a fan of Eigen-It is very usefull.
So I cannot calculate rectangular SVDs?
Or I should "square" my matrix using zero-padding?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: SVD matrix size

Thu Aug 26, 2010 7:08 am
no no, that only means currently it is not as efficient as it could be when you don't want a full orthogonalization of the null space, e.g., for linear solving.
renorm
Registered Member
Posts
31
Karma
0

Re: SVD matrix size

Fri Sep 03, 2010 7:32 pm
bjacob wrote:JAMA is where we took code for the old implementation we have in Eigen 2.0.

The current SVD in Eigen3 is already much faster than that, it just has various issues that leave room for improvement, such as the one mentioned in this thread.


I tried SVD with 8192x4 matrix and its about 100 times slower than Jama. Strangely, all U matrix columns except first 4 are filled with zeros.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Fri Sep 03, 2010 7:42 pm
If JAMA allows to skip computation of U and we don't, that explains it.

If you want to compute SVD of a 8192x4 matrix with Eigen3, just use JacobiSVD, it's much more reliable and also faster.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
renorm
Registered Member
Posts
31
Karma
0

Re: SVD matrix size

Sat Sep 04, 2010 4:50 am
Jama doesn't skip computation of U matrix. Eigen computes full SVD, whereas Jama computes thin version. I think that is the reason for performance difference. With 8192x4 matrix we need only 8192x4 U matrix, but Eigen's U matrix is 8192x8192. JacobiSVD computes the same big U matrix.
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: SVD matrix size

Sat Sep 04, 2010 12:43 pm
Right, OK. All I can say is "we're working on it" :-)


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]