From 9a16519d62c7315c8ecf00c6c4cb2dbd4a12f9d3 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 13 Jul 2013 12:36:55 +0200 Subject: Extend the "functions taking Eigen type" doc page to present the Ref<> option. --- doc/examples/function_taking_ref.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/examples/function_taking_ref.cpp (limited to 'doc/examples') diff --git a/doc/examples/function_taking_ref.cpp b/doc/examples/function_taking_ref.cpp new file mode 100644 index 000000000..162a202e4 --- /dev/null +++ b/doc/examples/function_taking_ref.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace Eigen; +using namespace std; + +float inv_cond(const Ref& a) +{ + const VectorXf sing_vals = a.jacobiSvd().singularValues(); + return sing_vals(sing_vals.size()-1) / sing_vals(0); +} + +int main() +{ + Matrix4f m = Matrix4f::Random(); + cout << "matrix m:" << endl << m << endl << endl; + cout << "inv_cond(m): " << inv_cond(m) << endl; + cout << "inv_cond(m(1:3,1:3)): " << inv_cond(m.topLeftCorner(3,3)) << endl; + cout << "inv_cond(m+I): " << inv_cond(m+Matrix4f::Identity()) << endl; +} -- cgit v1.2.3