Is there any function to calculate Generalized inverse of a matrix using GSL?
Like in R, we have ginv(X, tol = sqrt(.Machine$double.eps))
.
Generalized Inverse function in GSL
1.3k views Asked by Ankit Jain At
1
Is there any function to calculate Generalized inverse of a matrix using GSL?
Like in R, we have ginv(X, tol = sqrt(.Machine$double.eps))
.
No. It seems as if there is no routine to directly calculate the pseudo-inverse of a matrix (although here you can find a discussion on how one could get it).
However, the explicit pseudo-inverse itself is seldom required. Instead, gsl provides the routine
see the documentation here.
It solves the linear system
A x = b
, which is equivalent to applying the pseudo-inverseA^+
ontob
and yieldsx = A^+ b
.Before application, the SVD must be found via the routine
gsl_linalg_SV_decomp
. The tolerance factortol
you mentioned can be incorporated by looping over the singular valuesS
and setting those smaller thantol
to zero.(Further, here is a personal suggestion: drop the gsl and switch to Eigen, armadillo, or comparable modern libraries)