eigen: svd example, use pkg-config

This commit is contained in:
Ciro Santilli
2018-05-08 22:24:18 +01:00
parent 6b61365556
commit 7cf9f23ae0
5 changed files with 36 additions and 18 deletions

View File

@@ -0,0 +1,24 @@
/* Adapted from: https://eigen.tuxfamily.org/dox/classEigen_1_1JacobiSVD.html */
#include <iostream>
using std::cout;
using std::endl;
#include <Eigen/Core>
#include <Eigen/SVD>
using Eigen::ComputeThinU;
using Eigen::ComputeThinV;
using Eigen::JacobiSVD;
using Eigen::MatrixXf;
using Eigen::Vector3f;
int main() {
MatrixXf m = MatrixXf::Random(3,2);
JacobiSVD<MatrixXf> svd(m, ComputeThinU | ComputeThinV);
Vector3f rhs(1, 0, 0);
cout << "m = " << endl << m << endl << endl;
cout << "svd.singularValues() = " << endl << svd.singularValues() << endl << endl;
cout << "svd.MatrixU() = " << endl << svd.matrixU() << endl << endl;
cout << "svd.MatrixV() = " << endl << svd.matrixV() << endl << endl;
cout << "svd.solve() = " << endl << svd.solve(rhs) << endl << endl;
}