Ask Your Question
0

Get k largest singular values from SVD

asked Feb 5 '13

monstropizza gravatar image

updated Feb 5 '13

Hi all, I'm using OpenCV to implement a PLS algorithm, and I need to run SVD in a big matrix. But I don't want all the singular values, just the largest one.

In matlab I can do this by calling:

[u,s,v] = svds(A, 1);

In OpenCV I'm doing:

cv::SVD::compute(A, s, u, v);

Anyone has any idea?

thx

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Feb 8 '13

monstropizza gravatar image

For now I'm just getting the first column of each matrix, like:

cv::SVD::compute(A, s, u, v);
u = u.col(0);
v = v.col(0);

With this, I'm getting a mean error of less than 0,0002 in my Wstar matrix (comparing with matlab result).

Anyone has a better idea than this?

Preview: (hide)

Comments

You could use the SVD flags SVD::MODIFY_A (if you don't need A anymore) and/ or the flag SVD::NO_UV if you only need the singular values. Both flags will speed up your computation process, i.e. cv::SVD::compute(A, s, u, v, cv::SVD::MODIFY_A | cv::SVD::NO_UV);

Guanta gravatar imageGuanta (Feb 9 '13)edit

Question Tools

Stats

Asked: Feb 5 '13

Seen: 1,121 times

Last updated: Feb 08 '13