C ++ inverted matrix

The following dynamic array contains a non-symmetric n * n matrix (with n <= 100):

int **matrix;
matrix = new int*[n];
for (int i = 0; i < n; i++)
    matrix[i] = new int[n];

      

Is there a very easy way to invert it? Ideally, I would only use something from the STL, or download a single header file.

+3


source to share


2 answers


Using Eigen.

http://eigen.tuxfamily.org/index.php?title=Main_Page

You can map your array to your own matrix and then perform efficient matrix inversion.



You should only include it.

I add that usually, if you need to perform inversion to solve linear systems, it is better to use matrix decomposition based on matrix properties that you can use.

http://eigen.tuxfamily.org/dox/TutorialLinearAlgebra.html

+7


source


Not extremely easy, but it works: Numerical recipes in page 48 using LU decomposition.



+2


source







All Articles