Further improvement of matrix inversion

7 visualizzazioni (ultimi 30 giorni)
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 Commento
John Chilleri
John Chilleri il 28 Apr 2017
Not sure if this is the place to ask for help on such a problem, but here's a hint on number 1.

Accedi per commentare.

Risposta accettata

James Tursa
James Tursa il 28 Apr 2017
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 Commenti
John D'Errico
John D'Errico il 28 Apr 2017
Modificato: John D'Errico il 28 Apr 2017
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
Or, you can use this nice alternative from Tim Davis: factorize .
acivil acivil
acivil acivil il 29 Apr 2017
Thank you very much for your answers!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by