Further improvement of matrix inversion
6 ビュー (過去 30 日間)
古いコメントを表示
Using A\b instead of A^(-1) can be used to speed up a code. 1) How can we further speed up this inversion if we know from the beginning that Cholesky decomposition can apply in our matrix? 2)If we are about to use the inverse matrix to multiply it for more than one b vectors then A\b is still faster or we should save the inverse A^(-1) and then only do the multiplications? Is there a general rule for the number of inversions that one way is faster than the other? 3)If we create a mex file from a function that only contains the A\b command can we speed up the code execution or A\b is fully optimized?
Thank you in advance!
1 件のコメント
John Chilleri
2017 年 4 月 28 日
Not sure if this is the place to ask for help on such a problem, but here's a hint on number 1.
採用された回答
James Tursa
2017 年 4 月 28 日
How can we further speed up this inversion if we know from the beginning that Cholesky decomposition can apply in our matrix?
You could possibly speed things up by a small fraction by skipping some of the up-front checking, but I don't know if the effort would be worth it.
If we are about to use the inverse matrix to multiply it for more than one b vectors then A\b is still faster or we should save the inverse A^(-1) and then only do the multiplications? Is there a general rule for the number of inversions that one way is faster than the other?
It would be faster to simply combine all of your b vectors into one matrix and then do A\bcombined.
If we create a mex file from a function that only contains the A\b command can we speed up the code execution or A\b is fully optimized?
For speed & accuracy the mex file would likely simply call the exact same BLAS and LAPACK library routines that MATLAB is already calling. So no speed improvement would be expected.
7 件のコメント
John D'Errico
2017 年 4 月 28 日
編集済み: John D'Errico
2017 年 4 月 28 日
Call linsolve with L and L', using the OPTS argument to indicate if the matrix is lower or upper triangular.
Linsolve is indeed faster than simple use of backslash, since it does not need to determine if the matrix is really lower or upper triangular. Not needing to check will give a little improve speed boost.
The possible field names in OPTS and their corresponding matrix
properties are:
Field Name : Matrix Property
------------------------------------------------
LT : Lower Triangular
UT : Upper Triangular
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!