Inverse matrix pseudoinverse of matrices with non-matrices
Pseudo-inverse matrices are generalized forms of inverse matrices, generalized inverse matrices
MATLAB is PINV (a)-"inv (a)."
#include"stdafx.h"#include<iostream>#include<Eigen/Core>#include<Eigen/SVD>Template<typename _matrix_type_>_matrix_type_ pseudoinverse (Const_matrix_type_ &a,DoubleEpsilon =std::numeric_limits<Double>:: Epsilon ()) {EIGEN::JACOBISVD< _matrix_type_ > SvD (A, Eigen::computethinu |EIGEN::COMPUTETHINV); Doubletolerance = Epsilon * Std::max (A.cols (), A.rows ()) *svd.singularvalues (). Array (). ABS () (0); returnSVD.MATRIXV () * (Svd.singularvalues (). Array (). ABS () > Tolerance).Select(Svd.singularvalues (). Array (). Inverse (),0). Matrix (). Asdiagonal () *Svd.matrixu (). adjoint ();} intMain () {Eigen::matrixxd A (2,3); A<<1,2,3,4,5,7; Std::cout<<A<<std::endl<<Std::endl; Std::cout<<pseudoinverse (A) <<Std::endl; Eigen::matrixxd B (3,2); B<<1,2,3,4,5,7; Std::cout<<B<<std::endl<<Std::endl; Std::cout<<pseudoinverse (B) <<Std::endl; GetChar (); return 0; }
Pseudo inverse of matrices (pseudoinverse)-Feng Jin-Blog Park https://www.cnblogs.com/Rambler1995/p/5583645.html
Matrix pseudo-Inverse introduction and c++/opencv/eigen of three kinds of implementation, not directly run-csdn blog 72874623
The above open source code Github-fengbingchun/eigen_test:eigen ' s usage https://github.com/fengbingchun/Eigen_Test
Find pseudo-inverse matrix C + + code (Eigen library)