
I haven't found anywhere in the documentation for a method that does matrix inversion. Does such a method exist but isn't well documented? Ryan

On Wed, Mar 2, 2011 at 9:04 AM, Matwey V. Kornilov
`solve' does matrix inversion for triangular matrices. LU decomposition is also present in lu.hpp
Hi, take a look here: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBL... Best, -- Marco
Ryan wrote:
I haven't found anywhere in the documentation for a method that does matrix inversion. Does such a method exist but isn't well documented?
Ryan

sguazt wrote:
Hi,
take a look here: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBL...
This is the matrix inversion that I've tried. It is lacking in checks and at that point I wanted to know if there was an inversion built into uBLAS. If there was an inversion built in then it would have the normal quality checks that I've come to expect from Boost. Was there a reason that an inversion method wasn't included in the uBLAS library? It seems a pretty basic matrix manipulation. Is there a complexity I'm not familiar with that would prohibit it's implementation? Ryan

On Wed, Mar 2, 2011 at 2:08 PM, Ryan
sguazt wrote:
Hi,
take a look here:
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBL...
This is the matrix inversion that I've tried. It is lacking in checks and at that point I wanted to know if there was an inversion built into uBLAS. If there was an inversion built in then it would have the normal quality checks that I've come to expect from Boost.
Sorry, but I don't understand why you can't use http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inv... It is based on LU factorization (which is part of uBLAS). Apart from checking at the beginning if the input matrix is square, what kind of other "checks" does it lack?
Was there a reason that an inversion method wasn't included in the uBLAS library? It seems a pretty basic matrix manipulation. Is there a complexity I'm not familiar with that would prohibit it's implementation?
From my little experience with the implementation of math problems, you rarely use matrix inversion. Anyway, don't know why this function has not been included yet. Personally I use (a variant of) the one above, with the addition that in case of a singular matrix, I return a matrix with all values set to infinity (just like MATLAB does)
-- Marco
Ryan

On Wed, Mar 2, 2011 at 9:05 AM, sguazt
Sorry, but I don't understand why you can't use
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inv...
It is based on LU factorization (which is part of uBLAS).
I am using this function. It was my starting point. I just wanted to use an "official" method if that was an option.
Apart from checking at the beginning if the input matrix is square, what kind of other "checks" does it lack?
That is one of the checks I added. I also check if the inverse matrix is the same size as the input matrix. If the inverse is a different size I resize it to match the input matrix. A try/catch was also needed around the lu_substitute if it failed.
Personally I use (a variant of) the one above,
This is what I wanted to avoid by using an "official" method. I may not have caught everything in my variant of the function and would really like it not to give me problems. Ryan

I'm not a uBLAS developer, but I suspect that it isn't included simply because matrix inversion is not a common problem in practice. More common is solving a linear system. Computing the matrix inverse to solve a linear system is probably the worst way to solve it.
On Mar 02, 2011, at 05:08 AM, Ryan
sguazt wrote:
Hi,
take a look here: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBL...
This is the matrix inversion that I've tried. It is lacking in checks and at that point I wanted to know if there was an inversion built into uBLAS. If there was an inversion built in then it would have the normal quality checks that I've come to expect from Boost.
Was there a reason that an inversion method wasn't included in the uBLAS library? It seems a pretty basic matrix manipulation. Is there a complexity I'm not familiar with that would prohibit it's implementation?
Ryan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Wed, Mar 2, 2011 at 7:52 PM, Curtis Gehman
I'm not a uBLAS developer, but I suspect that it isn't included simply because matrix inversion is not a common problem in practice. More common is solving a linear system. Computing the matrix inverse to solve a linear system is probably the worst way to solve it.
Agree. I also noted about the headline in : http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inv... LU is a factorization of the matrix not a inverse...in real life inverting the matrix is only for small examples.
On Mar 02, 2011, at 05:08 AM, Ryan
wrote: sguazt wrote:
Hi,
take a look here:
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBL...
This is the matrix inversion that I've tried. It is lacking in checks and at that point I wanted to know if there was an inversion built into uBLAS. If there was an inversion built in then it would have the normal quality checks that I've come to expect from Boost.
Was there a reason that an inversion method wasn't included in the uBLAS library? It seems a pretty basic matrix manipulation. Is there a complexity I'm not familiar with that would prohibit it's implementation?
Ryan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Thu, Mar 3, 2011 at 4:04 PM, Ryan
On Wed, Mar 2, 2011 at 2:06 PM, Bo Jensen
wrote: LU is a factorization of the matrix not a inverse...in real life inverting the matrix is only for small examples.
Since I'm dealing with a Kalman Filter in my real life the inverse is needed.
Sorry my mistake, I did not know of Kalman Filter. I work with high performance linear algebra where inversion is a no no.
Ryan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

LU is a good method for Matrix Inverse (see Numerical Recipes). Been using it for quite a while. You can always calculate the determinant of the inverse and multiply it with the determinant of the original Matrix to determine how good the inversion is. Boost implements are available online somewhere - i copied them as is.
For Kalman filters, ensure that the matrices are stable ie Determinants are not near zero.
have fun
----- Original Message -----
From: "Bo Jensen"
On Wed, Mar 2, 2011 at 2:06 PM, Bo Jensen
wrote: LU is a factorization of the matrix not a inverse...in real life inverting the matrix is only for small examples.
Since I'm dealing with a Kalman Filter in my real life the inverse is needed.
Sorry my mistake, I did not know of Kalman Filter. I work with high performance linear algebra where inversion is a no no.
Ryan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

http://www.nr.com/
----- Original Message -----
From: "Ryan"

On Thu, Mar 3, 2011 at 1:16 PM, Bo Jensen
Sorry my mistake, I did not know of Kalman Filter. I work with high performance linear algebra where inversion is a no no.
Not a problem. I just figured that since matrix inversion was one of those basic things you learned in college Calculus it would be in the uBLAS matrix library. Ryan

http://www.anderswallin.net/2010/05/matrix-determinant-with-boostublas/
http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?LU_Matrix_Inv...
Ryan,
hope this helps. be aware of floating point limitations on your system. It will impact the max Matrix size and its stability criterion
----- Original Message -----
From: "Ryan"

A triangular matrix has zero elements below the diagonal (upper triangular) or above the diagonal (lower triangular). This way a nonsingular triangular matrix can be inverted in straightforward manner. LU decomposition allows to produce two triangular matrices which product is your source matrix. A matrix inversion can be implemented by means of these succeeding operations. Ryan wrote:
Matwey V. Kornilov wrote:
`solve' does matrix inversion for triangular matrices. LU decomposition is also present in lu.hpp
What is the difference between a triangular matrix and the plain matrix?
Ryan

On Wed, Mar 2, 2011 at 8:07 PM, Matwey V. Kornilov
A triangular matrix has zero elements below the diagonal (upper triangular) or above the diagonal (lower triangular). This way a nonsingular triangular matrix can be inverted in straightforward manner. LU decomposition allows to produce two triangular matrices which product is your source matrix. A matrix inversion can be implemented by means of these succeeding operations.
Even the matrix is triangular, you still don't invert it, you use forward and backward substitution to solve the linear system. I am sorry to be a pain, but I think this thread needs to be concise about the use of inverse.
Ryan wrote:
Matwey V. Kornilov wrote:
`solve' does matrix inversion for triangular matrices. LU decomposition is also present in lu.hpp
What is the difference between a triangular matrix and the plain matrix?
Ryan
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (6)
-
Bo Jensen
-
Curtis Gehman
-
Matwey V. Kornilov
-
rpuri6@comcast.net
-
Ryan
-
sguazt