Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast matrix inversion without a package

Assume that I have a square matrix M. Assume that I would like to invert the matrix M.

I am trying to use the the fractions mpq class within gmpy2 as members of my matrix M. If you are not familiar with these fractions, they are functionally similar to python's built-in package fractions. The only problem is, there are no packages that will invert my matrix unless I take them out of fraction form. I require the numbers and the answers in fraction form. So I will have to write my own function to invert M.

There are known algorithms that I could program, such as gaussian elimination. However, performance is an issue, so my question is as follows:

Is there a computationally fast algorithm that I could use to calculate the inverse of a matrix M?

like image 561
Paul Terwilliger Avatar asked Jun 02 '17 14:06

Paul Terwilliger


People also ask

Which method is used for matrix inversion?

We can find the matrix inverse only for square matrices, whose number of rows and columns are equal such as 2 × 2, 3 × 3, etc. In simple words, inverse matrix is obtained by dividing the adjugate of the given matrix by the determinant of the given matrix.

How do you invert a matrix algorithm?

Algorithms for Matrix Inversion A common method to find the inverse of a matrix (if it exists) is to use a technique known as Gauss-Jordan elimination (or Gaussian Elimination). However for a large n × n -dimensional matrix this is an expensive and inefficient mechanism for finding an inverse.


1 Answers

Is there anything else you know about these matrices? For example, for symmetric positive definite matrices, Cholesky decomposition allows you to invert faster than the standard Gauss-Jordan method you mentioned.

For general matrix inversions, the Strassen algorithm will give you a faster result than Gauss-Jordan but slower than Cholesky.

It seems like you want exact results, but if you're fine with approximate inversions, then there are algorithms which approximate the inverse much faster than the previously mentioned algorithms.

However, you might want to ask yourself if you need the entire matrix inverse for your specific application. Depending on what you are doing it might be faster to use another matrix property. In my experience computing the matrix inverse is an unnecessary step.

I hope that helps!

like image 197
Saleh Hindi Avatar answered Sep 23 '22 06:09

Saleh Hindi