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.


source to share

2 answers

Using Eigen.


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.




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



All Articles