I searched on Google and I couldn't find a function to calculate the inverse of Rectangular Matrix using GSL. Being that it was hard to find, an answer here would help others when they need to find an inverse of a rectangular matrix. If it is not possible using GSL, then please suggest some alternative library which is easy to use and provides the inverse of rectangular matrix.
Asked
Active
Viewed 5,039 times
5
-
You can apply [SVD](http://www.gnu.org/software/gsl/manual/html_node/Singular-Value-Decomposition.html) and then calculate the pseudoinverse, as suggested in for example the [R documentation](http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/corpcor/html/pseudoinverse.html) – Aug 14 '13 at 12:14
-
There's an SVD solver in the GSL, and then it's just matrix multiplication. – Aug 15 '13 at 09:05
1 Answers
3
Yes, it is possible! You probably did not fin it because it is in the chapter Linear Algebra, not Matrices.
In GSL you first compute the LU decomposition and then use it to determine the inverse via
int gsl_linalg_LU_invert (const gsl_matrix * LU, const gsl_permutation * p, gsl_matrix * inverse)
See here for a detailed example https://lists.gnu.org/archive/html/help-gsl/2008-11/msg00001.html

Ludi
- 451
- 4
- 17
-
-
In the [example](https://lists.gnu.org/archive/html/help-gsl/2008-11/msg00001.html) cited, the original matrix a_data is modified after calculating its inverse. Is there a way to avoid this issue ? @Ludi – alpha027 Jun 23 '21 at 14:02