SVD-decomposed C + + code (Eigen library)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.