Further improvement of matrix inversion

6 views (last 30 days)
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 Comment
John Chilleri
John Chilleri on 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.

Sign in to comment.

Accepted Answer

James Tursa
James Tursa on 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 Comments
John D'Errico
John D'Errico on 28 Apr 2017
Edited: John D'Errico on 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 on 29 Apr 2017
Thank you very much for your answers!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!