File kernel/src/utils/SiconosAlgebra/InvertMatrix.hpp

Contents

File kernel/src/utils/SiconosAlgebra/InvertMatrix.hpp#

Go to the source code of this file

The following code inverts the matrix input using LU-decomposition with backsubstitution of unit vectors. Reference: Numerical Recipies in C, 2nd ed., by Press, Teukolsky, Vetterling & Flannery.

you can solve Ax=b using three lines of ublas code:

permutation_matrix<> piv; lu_factorize(A, piv); lu_substitute(A, piv, x);

Functions

template<class T, class U, class V>
bool InvertMatrix(const boost::numeric::ublas::matrix<T, U, V> &input, boost::numeric::ublas::matrix<T, U, V> &inverse)#

Matrix inversion routine.

Uses lu_factorize and lu_substitute in uBLAS to invert a matrix

Parameters:
  • input – source matrix

  • output – inverted matrix.