source: pacpussensors/trunk/Vislab/lib3dv/eigen/doc/examples/function_taking_ref.cpp@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 594 bytes
Line 
1#include <iostream>
2#include <Eigen/SVD>
3using namespace Eigen;
4using namespace std;
5
6float inv_cond(const Ref<const MatrixXf>& a)
7{
8 const VectorXf sing_vals = a.jacobiSvd().singularValues();
9 return sing_vals(sing_vals.size()-1) / sing_vals(0);
10}
11
12int main()
13{
14 Matrix4f m = Matrix4f::Random();
15 cout << "matrix m:" << endl << m << endl << endl;
16 cout << "inv_cond(m): " << inv_cond(m) << endl;
17 cout << "inv_cond(m(1:3,1:3)): " << inv_cond(m.topLeftCorner(3,3)) << endl;
18 cout << "inv_cond(m+I): " << inv_cond(m+Matrix4f::Identity()) << endl;
19}
Note: See TracBrowser for help on using the repository browser.