Sum of sparse matrices - Matlab numerical error -
i have following problem:
n=500; = sparse(1:500,10*ones(n,1),0.005*ones(n,1),n,n); a(:,300) = -0.005*ones(n,1); >> sum(a,2) ans = 0 sparse: 500-by-1 b = spdiags(0.45*ones(n,1),0,n,n); b(:,34) = -0.45*ones(n,1); b(34,34) = 0; >> sum(b,2) ans = 0 sparse: 500-by-1 c = a+b; >>max(sum(c,2)) ans = (1,1) 4.3368e-18.
since sum of rows of , b 0, sum of rows of c should 0 too. large sparse matrices, not case. if e-18, need closer 0.
how can make matlab improve precision in kind of computations?
thank you
Comments
Post a Comment