Hisham Mohammad
Hisham Mohammad

Reputation: 71

Eigen Library - Pseudo-Inverse of Matrix (Matlab - pinv)

I am trying to find the pseudo-inverse of a matrix using the Eigen Library. They have a class that does implement it, however I do not know how to put script the syntax.

This is how it is shown on the website (https://eigen.tuxfamily.org/dox/classEigen_1_1CompleteOrthogonalDecomposition.html#ab2fd4c81aa1cd8bc917c7f135505cb7f):

const Inverse Eigen::CompleteOrthogonalDecomposition< MatrixType >::pseudoInverse ( ) const

Upvotes: 5

Views: 22261

Answers (1)

Sean
Sean

Reputation: 3052

It's a method of the CompleteOrthogonalDecomposition class. So you have to perform that decomposition of a matrix before you use it. For example

#include <Eigen/QR>    

Eigen::MatrixXd A = ... // fill in A
Eigen::MatrixXd pinv = A.completeOrthogonalDecomposition().pseudoInverse();

Upvotes: 13

Related Questions