How to quickly do the calculation?

Dear All,
I have a code to calculate an array using several arrays. The code is as follows:
Ieq1 = Haltmr(mmm(jbb2),IndBus(solvedbuses))*v(IndBus(solvedbuses));
Where Haltmr is a complex 6000x3000 sparse matrix, v is a complex 3000 column vector, mmm (for example, 20 rows in Haltmr) is a selected rows from Haltmr and jbb2 ( 5 rows in mmm) is the part of mmm, and IndBus is the order of columns in Haltmr, and solvebuses ( 15 indecies) is a part of the columns.
I am wondering if there is a faster way to do the calculation.
Thanks.
Benson

3 件のコメント

Steven Lord
Steven Lord 2021 年 6 月 30 日
That's impossible to answer without seeing what Haltmr, mmm, jbb2, IndBus, solvedbuses, and v are. Which of those are variables (and what sizes and types are they?) and for those that are functions what are those functions do?
dpb
dpb 2021 年 6 月 30 日
All depends on what the definitions of the quantities are -- are they variables or functions? It's indeterminate in isolation.
dpb
dpb 2021 年 6 月 30 日
sparse saves memory; the cost is execution speed to decode.
If you have enough memory, you could try moving to full storage; H is "only" 138 MB on machines these days with GB memory.
I didn't try to see if could do something with the matrix algebra...

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

 採用された回答

Matt J
Matt J 2021 年 7 月 1 日
編集済み: Matt J 2021 年 7 月 1 日

0 投票

This might be faster.
r=false(6000,1); r(mmm(jbb2))=1;
c=false(3000,1); c(IndBus(solvedbuses))=1;
Ieq1=Haltmr*sparse(v.*c);
Ieq1=Ieq1(r);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2021 年 6 月 30 日

編集済み:

2021 年 7 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by