Pseudo Inverse of singular matrix

Hello every one,

How to calculate the pseudoInverse of a singular matrix with FreeFem++?

Best regards.

Uset PETSc, with the following options: -pc_type lu -pc_factor_mat_solver_type mumps -mat_mumps_icntl_24 1. The pseudo-inverse is not unique, this will compute a pseudo-inverse inverse. You can lookup the option ICNTL(24) from the MUMPS guide.

Hello prj,

First of all, I would like to thank you for your response.

I tried to work with the PETSc package. I wrote the code below, but I can’t upload the PETSc package. Could you please tell me how to upload the PETSc package and if possible tell me your opinion about the code?

Thank you very much.

Code :
load “PETSc”

// Matrix
int n = 16;
real[int, int] MM(n, n), A(n, n);

cout << "read the matrix MM "<< endl;
{
ifstream file1(“MM.dat”);
for(int i=0;i<16 ; i++){
for(int j=0;j<16 ; j++){
file1 >> MM(i,j) ;
}
}
}

//Compute the Pseudo inverse of MM
set(MM, sparams = “-pc_type lu -pc_factor_mat_solver_type mumps -mat_mumps_icntl_24 1”);

The code looks good. You probably don’t have the PETSc package installed with FreeFEM. You need to fix that of you want to compute pseudo-inverses.

Hello prj,

is there a way to compute the pseudo-inverse which gives the solution with the smallest norm?

With -pc_type svd, but that will be extremely slow.