Ask Your Question
0

Get k largest singular values from SVD

asked 2013-02-05 15:46:53 -0500

monstropizza gravatar image

updated 2013-02-05 15:47:49 -0500

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-02-08 10:20:59 -0500

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?

edit flag offensive delete link more

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 ( 2013-02-09 07:22:24 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-02-05 15:46:53 -0500

Seen: 914 times

Last updated: Feb 08 '13