From 8f0e80fe304ad34b520a869ae58bbff8b64c63f2 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 14 Oct 2010 10:14:43 -0400 Subject: JacobiSVD: * fix preallocating constructors, allocate U and V of the right size for computation options * complete documentation and internal comments * improve unit test, test inf/nan values --- doc/snippets/JacobiSVD_basic.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 doc/snippets/JacobiSVD_basic.cpp (limited to 'doc/snippets') diff --git a/doc/snippets/JacobiSVD_basic.cpp b/doc/snippets/JacobiSVD_basic.cpp new file mode 100644 index 000000000..ab24b9bca --- /dev/null +++ b/doc/snippets/JacobiSVD_basic.cpp @@ -0,0 +1,9 @@ +MatrixXf m = MatrixXf::Random(3,2); +cout << "Here is the matrix m:" << endl << m << endl; +JacobiSVD svd(m, ComputeThinU | ComputeThinV); +cout << "Its singular values are:" << endl << svd.singularValues() << endl; +cout << "Its left singular vectors are the columns of the thin U matrix:" << endl << svd.matrixU() << endl; +cout << "Its right singular vectors are the columns of the thin V matrix:" << endl << svd.matrixV() << endl; +Vector3f rhs(1, 0, 0); +cout << "Now consider this rhs vector:" << endl << rhs << endl; +cout << "A least-squares solution of m*x = rhs is:" << endl << svd.solve(rhs) << endl; -- cgit v1.2.3