How to solve a sparse matrix efficiently?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hallo everyone,
I am trying to solve a linear equation system A*x=b that describes a 3D grid and heat transfer between adjecent cells and mass convection by an upwind scheme. As the upwind scheme is somewhat asymmetric, the sparse Matrix that looks like the one below. So far I use x = A\b, but when the problem starts to get bigger this appears to be rather slow. Therefore I am looking for a way to speed up the computation. As the thermal conductivity and so are temperature dependent, I have to solve this equation system a couple of times till a global convergence is achieved.
There are some iterative methods implemented (<http://www.mathworks.de/de/help/matlab/linear-equations-iterative-methods.html>) but I am not sure, which one to chose.
I guess, that lsqr(A,b,tol,maxit,M1,M2,x0) might be a good choice (just maybe ;-) ) but now I am wondering how to chose an appropriate preconditioning M1 and M2. As mentioned before, I have to solve this problem a couple of times, therefore I think that I should be able to provide an good guess on x0 the second time a try to solve this problem - but I am not really sure how to do this... Plus: when I use lsqr or bicq without any changes, the results looks like crap ;-)
You might have figured, that I am more of an engineer than a mathematician, therefore I'm not really sure what to do.
It would be so great, if you could give me decent advice :-)
Best regards Nils
5 commentaires
Patrik Ek
le 10 Mar 2014
Modifié(e) : Patrik Ek
le 10 Mar 2014
You should try wikipedia instead, matlabs function svd, does a singular value decomposition. It does not invert matrices. However, this can be used as a tool for matrix inversion. I know that this is nothing automatical or even simple, but if matlabs functions does not work, this may be necessary. I am not sure it works, but it is worth a try. The thing is that one application of svd is that its relation to pseudo inverses makes it possible to split up the matrix and calculate the inverse of all the non-zero parts.
@John D'Errico, are you sure pinv is still slower if the matrix is sparse?
Réponses (2)
Paul
le 10 Mar 2014
Did you try defining A and b as sparse? So:
A=sparse(A);
b=sparse(b);
x=A\b;
0 commentaires
Nils
le 10 Mar 2014
6 commentaires
Paul
le 10 Mar 2014
Well, a solution may not exist. Are you sure you need to solve x=A\b, because afaik an upwind scheme for solving differential equations means that you use values from the previous time step and at the grid points around the point you consider to calculate the new value. What you basically do is :
x_new = A * x_old
Where A is the matrix which defines the points you use for the calculation at each point. So you really don't need to find the inverse since this is just a simple matrix multiplication.
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!