フィルターのクリア

What is the difference between lu() and decomposition([],'lu')?

2 ビュー (過去 30 日間)
Sebastian Raabe
Sebastian Raabe 2021 年 10 月 31 日
コメント済み: Sebastian Raabe 2021 年 11 月 6 日
Hello Matlab-Community,
I have a matrix (called SystemMatrix see atteched file) which I want to decompose in L and U. Matlab has 2 functions to do this:
  1. [L,U] = lu(A)
  2. da = decomposition(A,'lu').
If I run the following code on my PC I can see that decomposition(,'lu') is much faster than lu() (about a factor of 137).
load('SystemMatrix.mat')
disp('Loading done')
disp('Start LU decomposition with lu()')
tic
[L,U] = lu(SystemMatrix);
toc
Elapsed time is 30.138829 seconds.
disp('Start LU decomposition with decomposition([],''lu'')')
tic
da = decomposition(SystemMatrix,'lu');
toc
Elapsed time is 0.221673 seconds.
This is only a smaller example of my system matrix. If I want to decompose my full matrix, than lu() uses more than 32 GB of RAM (the calculation stops because out of memory), while decomposition(,'lu') uses only 10 to 13 GB of RAM and is finished after ca. 1 minute.
Here are my questions:
Why is decomposition(A,'lu') so much faster than lu(A)? Didn't they use the same algorithm?
Is there any way to get L and U from the decomposition object da? Because I want to solve an equation system with the same coefficient matrix several times (in parallel on different Computers) and I don't want to decompose the matrix on every Computer again.

採用された回答

Mike Croucher
Mike Croucher 2021 年 11 月 6 日
The two output form of lu() does use a different algorithm compared to the decomposition object. Also, it is not possible to save the results of a decomposition object.
The reasons for both of these facts are a little complex and I’m not well qualified to answer them. However, once way to solve your problem would be use the 4 or 5 output forms of lu() which use similar algorithms to decomposition:
[L,U,P,Q,D] = lu(SystemMatrix)
The extra matrices P,Q,D are defined in the lu() documentation. These can be used to solve your system and could be saved for use on multiple machines as you describe.
Timings on my machine are:
>> tic;[L,U] = lu(SystemMatrix);toc
Elapsed time is 19.708687 seconds.
>> tic;da = decomposition(SystemMatrix,'lu');toc
Elapsed time is 0.221085 seconds.
>> tic;[L,U,P,Q,D] = lu(SystemMatrix);toc
Elapsed time is 0.255020 seconds.
  1 件のコメント
Sebastian Raabe
Sebastian Raabe 2021 年 11 月 6 日
Hello Mike, thank you for your answer. I will try your proposal in the next few days.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by