Lost of precision using sparse matrices?

1 view (last 30 days)
Kei
Kei on 9 May 2014
Commented: Matt J on 9 May 2014
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
Matt J on 9 May 2014
Edited: Matt J on 9 May 2014
Incidentally, you've given no information proving that the sparse version is less accurate. How do you know that the problem isn't with the full version?
Matt J
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

Sign in to comment.

Answers (1)

Matt J
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
Kei
Kei on 9 May 2014
Edited: Kei on 9 May 2014
But all this knowing that J1 == J2 ... makes one think that the result of hlm1 is equivalent to hlm2.
When I do hlm1 = (full(J1)'*full(J1) + u*Is)\-g; the result of norm(hlm1 - hlm2,Inf) = 6.78e-18 and for my is OK, but using 'full' .... I think it is something internal to the operation \ with sparse matrix.
Matt J
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.

Sign in to comment.

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!