how i can use Singular value decomposition function with big size matrix?
8 次查看(过去 30 天)
显示 更早的评论
I need to extract the matrices U,S,V from the given matrix A. the size of A is 271250*225.
but when i run svd function in matlab, i have error " Requested 271250x271250 (548.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information".
0 个评论
回答(3 个)
Steven Lord
2017-5-19
Compute the economy sized svd by passing the 'econ' flag into svd. Or get a machine with at least a terabyte of RAM (one and a half or two would be even better) and be prepared to wait.
0 个评论
John D'Errico
2017-5-19
As Steve says, buy some memory, LOTS of it. Have some coffee. Read a good book while you wait. Or better yet, read a bad book, as it may take you longer to wade through something you hate.
Often people think they need to do something computationally intensive, when they really don't. I can think of at least one other person I answered today who surely did not in fact need to do what they were trying to do. But if you don't know differently, then you can only follow the formula you have taken rom some book.
So look at your problem. If the economy SVD is not an option, then look at what you are doing. There may well be other ways to solve it, other factorizations that will do nearly as well for your problem. Since we don't know the problem you are trying to solve, that is impossible to know.
0 个评论
Anubhav Dwivedi
2021-10-1
For an economy svd, the solution is straight forward. Using the relation between eigen decomposition and SVD we can do something like this:
At = A'; % get the smaller dimension matrix
[v,d] = eig(At*A);
[s,I] = sqrt(sort(diag(d),'descend')); % compute the singular vectors
v = v(:,I); %compute right singular vectors
u = zeros(size(A));
for i = 1:size(v,1)
u(:,i) = (A*v(:,i))/s(i); %compute left singular vectors
end
1 个评论
Christine Tobler
2021-10-4
It's a better idea to directly use the svd command with the "econ" option:
[U, S, V] = svd(A, "econ");
The code above will work in most cases, but breaks down if one of the singular values of A is zero, for example. This also has better accuracy, in particular for a matrix A that is ill-conditioned.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!