Pseudoinverse of singular matrix

I have a singular matrix which determinant is about 1e-19 and TMatrix Invert() doesn’t work. Is there any function to calculate the Moore-Penrose pseudoinverse in root?

TDecompSVD can manipulate singular matrices.


TDecompSVD covMatrixSVD(covMatrix); // covMatrix is a TMatrixD or a TMatrixDSym
Double_t d1, d2;
covMatrixSVD.Det(d1, d2);
cout << "determinant = " << d1 * TMath::Power(2., d2) << endl;

We don’t have this algorithm in ROOT.

We do have the algorithm(s) to calculate the (Moore-Penrose) pseudo inverse, please see the tutorial here , entry 3 and 4.

I will write them out explicitly for future reference:

  1. The Invert function of the TDecompSVD class returns the Moore-Penrose matrix
TMatrixD A;
TDecompSVD svd(A);
const TMatrixD pseudo_A = svd.Invert()


  1. An explicit matrix multiplication
TMatrixD A;
TMatrixDSym AtA(TMatrixDSym::kAtA,A);
const TMatrixD pseudo_A = AtA.Invert() * A.T();

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.