I’m looking to invert a square matrix A in order to solve the problem Ax=b. The problem is, this matrix A, has no reason to be invertible, so when it’s the case, I would like to compute the more-penrose pseudoinverse solution to the problem : min_{Y\in R^{n\times n} ||AY-I_n||.
I was going through the lapack FreeFem sources on Github (FreeFem-sources/lapack.cpp at 897a6ed0606d497b043b593e0d7db86448731889 · FreeFem/FreeFem-sources · GitHub) and found that we can call on the lapack function dgelsy from Freefem, which would take care of this.
I can’t seem to make it work though, as the following example returns an error message :
" Intel MKL ERROR: Parameter 5 was incorrect on entry to DGELSY."

Can anyone please confirm if my calling of the function is correct? and in case dgelsy is not the way to go, are there other ways to compute pseudo-inverses?

I am not familiar with how Github works, but my feeling is that I would have to rebuild FreeFem (installed initially through the dmg image) to get the changes, and inform the university to rebuild it on the cluster. I wanted to ask before I mess with my installation files if just correcting my source file would do the trick?

If you are using the .dmg, then yes, you’d need to rebuild FreeFEM from the sources (there is probably a release coming up soon though if you are not in a rush).
For the installation on the cluster, the admin can just fetch the file on GitHub, and then recompile only the plugin.

$ cd FreeFem-sources/plugin/seq
$ ./ff-c++ -auto lapack.cpp

Assuming lapack.cpp as been overwritten by the latest version from GitHub. Then, the corresponding library (lapack.so) must be copied in the installation directory.