Backslash for solving very big sparse matrix in Ax=b

14 ビュー (過去 30 日間)
Alireza Moghaddam
Alireza Moghaddam 2015 年 7 月 16 日
回答済み: Royi Avital 2015 年 8 月 9 日
In my code at each time step sparse matrix A is built as follows:
1< DX <120000
A = sparse(i,j,s,DX,DX,6*DX)
b = (1,DX)
The problem that I am dealing is a sort of discretization problem. I have maximum 120000 nodes. Each of these nodes are having special charachters and I choose only the ones that meet my criteria. the number of these chosen ones is DX and is completely dependent on the physical process.
I am using backslash in x = A\b. But as the size of A could become quite big, the computational time rises drastically (more than 10e5 time steps are having DX > 6e4). As far as I know, backslash operation is already well optimized in MATLAB but I would like to know:
1. Would it make sense to use codegen and convert the code to C?
2. Does any one know an alternative method instead of backslash, so that the compuattional time decreases (maybe an iterative method?)?

回答 (3 件)

Sean de Wolski
Sean de Wolski 2015 年 7 月 16 日

John D'Errico
John D'Errico 2015 年 7 月 16 日
NO. The solver in backslash is ALREADY compiled and highly optimized. Why do you think that converting the call to C would help? NOT.
You can try an iterative method. They are designed for problems that are too large to solve in memory. Don't be surprised if you need to learn about preconditioning matrices.
  1 件のコメント
Alireza Moghaddam
Alireza Moghaddam 2015 年 7 月 17 日
Thanks! I will try the iterative methods.

サインインしてコメントする。


Royi Avital
Royi Avital 2015 年 8 月 9 日
If you're memory limited the best solution I know of is Conjugate Gradient.
MATLAB has Preconditioned Conjugate Gradient (The function ` pcg`).
You can use it without a preconditioner to have classic Conjugate Gradient.
If you want it to be faster, a suitable preconditioner to your problem can do wonders.
The beauty of this method is you never multiply the whole matrix by the vector. You only use do products as needed.
Its speeds depends on the condition number of the Matrix, hence with a good preconditioner things gets much better.

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by