Lost of precision using sparse matrices?
3 views (last 30 days)
Show older comments
I have two matrices J1 (sparse) = J2(full).
The dimension of the matrices are ~ 5200x2600
Then when I do:
hlm1 = (J1'*J1 + u*I)\g, where I = eye(n);
and
hlm2 = (J2'*J2 + u*I)\g, where I = eye(n);
i have after that: norm(hlm1 - hlm12, Inf) is 4.8625e-05 ...
That difference is my problem, is correct the way to use the matrice sparse ?.
Thx.
2 Comments
Matt J
on 9 May 2014
You should also be looking at percent error, rather than absolute error
percentError = norm(hlm1 - hlm12, Inf)/norm(hlm2,inf)*100
Answers (1)
Matt J
on 9 May 2014
Edited: Matt J
on 9 May 2014
Precision should improve if you do
[J;sqrt(u)*I]\g
but it's also possible that your J matrices are just very ill-conditioned. What does rcond(J2) say?
6 Comments
Matt J
on 9 May 2014
Well the algorithms used to solve linear equations are different for sparse and full matrices. If the solution is unstable, as it inevitably will be for ill-conditioned (J'*J+u*I), the result will be sensitive to the solution method used.
See Also
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!