Using the Eigen library: SVD decomposition, shaped like A = U * S * VT.
eigen::jacobisvd< _matrix_type_ > SvD (A, Eigen::computethinu | EIGEN::COMPUTETHINV);
//EigenTest.cpp: Defines the entry point of the console application. //#include"stdafx.h"#include<iostream>#include<Eigen/SVD>#include<Eigen/Dense>//using EIGEN::MATRIXXF; using namespaceEigen; using namespaceEigen::Internal; using namespaceeigen::architecture; intMain () {matrix3f A; A (0,0)=1A0,1)=0A0,2)=1; A (1,0)=0A1,1)=1A1,2)=1; A (2,0)=0A2,1)=0A2,2)=0; JACOBISVD<Eigen::MatrixXf> SVD (A, Computethinu |COMPUTETHINV); matrix3f V= SVD.MATRIXV (), U =Svd.matrixu (); matrix3f S= U.inverse () * A * v.transpose (). Inverse ();//S = u^-1 * A * VT *-1std::cout<<"A: \ n"<<A<<Std::endl; Std::cout<<"U: \ n"<<U<<Std::endl; Std::cout<<"S: \ n"<<S<<Std::endl; Std::cout<<"V: \ n"<<V<<Std::endl; Std::cout<<"U * S * VT: \ n"<<u * S * v.transpose () <<Std::endl; System ("Pause"); return 0; }
SVD decomposition Eigen Library OPENCV Library-CSDN Blog 68491414
SVD-decomposed C + + code (Eigen library)