fastest way for multiplication of symmetric matrix and sparse matrix

12 ビュー (過去 30 日間)
Nguyen Van Hieu
Nguyen Van Hieu 2021 年 5 月 16 日
コメント済み: Nguyen Van Hieu 2021 年 5 月 18 日
I am doing a multiplication as: P=A*P*A'
where size of A and P are 6640x6640. The nonzero element of A and P is 309028 and 0. P is symmetric.
If I use sparse matrix for A, the time to calculate A*P*A' is twice as if I use dense matrix for A.
I want to reduce the computational time for this calculation, can you recommend a method? I am planning to use PARDISO solver from https://www.pardiso-project.org/
Thank you!

採用された回答

Matt J
Matt J 2021 年 5 月 18 日
編集済み: Matt J 2021 年 5 月 18 日
If I use sparse matrix for A, the time to calculate A*P*A' is twice as if I use dense matrix for A.
You have a strange computer. I see very much the opposite. One thing you can check is whether nzmax(A)=nnz(A). You can also shave off some time by precomputing A'.
N=6640/2;
A=sprand(N,N,.007);
At=A;
P=rand(N); P=P+P.';
Af=full(A);
Aft=Af';
tic
A*P*A';
toc
Elapsed time is 0.738674 seconds.
tic
A*P*At;
toc
Elapsed time is 0.631558 seconds.
tic;
Af*P*Aft;
toc;
Elapsed time is 2.053788 seconds.
  1 件のコメント
Nguyen Van Hieu
Nguyen Van Hieu 2021 年 5 月 18 日
precomputing A' works for my calculation. Thank you so much!!!

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

その他の回答 (0 件)

カテゴリ

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