I want to do singular value decomposition of a matrix A, which is very big but simply structured. Specifically, it is a rank-2 matrix plus a diagonal matrix. I just need the first few singular values. So I want to call "svds", and I do not want to construct A explicitly as a matrix, as that is too costy in memory. The idea is to write a function to perform the multiplication x---> A*x
This is the nested function for the multiplication:
function y = fun_A_times_x(x)
y = sum(phi2.*x)*kphi1 + sum(phi1.*x)*kphi2...
+ sum(kphi1.*x)*phi2 + sum(kphi2.*x)*phi1...
+ diagonal.*x - E*sum(phi1.*x)*phi2 - E* sum(phi2.*x)*phi1;
How should I write the svds part?
[UU,SS,VV] = svds(@(x) myfun, [dim dim], 2);
This does not work.
I still do not understand the mechanism of the function handle. Can anyone help me out? My matlab is R2017a.