From 9a97dac4d91ee20c0bbdef39270d5a1bc743c20e Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 2 Jul 2012 16:33:32 +0200 Subject: Doc: add an example for HouseholderQR::householderQ() --- Eigen/src/QR/HouseholderQR.h | 8 ++++++++ doc/snippets/HouseholderQR_householderQ.cpp | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 doc/snippets/HouseholderQR_householderQ.cpp diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h index 59f6fcaa2..970672832 100644 --- a/Eigen/src/QR/HouseholderQR.h +++ b/Eigen/src/QR/HouseholderQR.h @@ -128,6 +128,14 @@ template class HouseholderQR return internal::solve_retval(*this, b.derived()); } + /** This method returns an expression of the unitary matrix Q as a sequence of Householder transformations. + * + * The returned expression can directly be used to perform matrix products. It can also be assigned to a dense Matrix object. + * Here is an example showing how to recover the full or thin matrix Q, as well as how to perform matrix products using operator*: + * + * Example: \include HouseholderQR_householderQ.cpp + * Output: \verbinclude HouseholderQR_householderQ.out + */ HouseholderSequenceType householderQ() const { eigen_assert(m_isInitialized && "HouseholderQR is not initialized."); diff --git a/doc/snippets/HouseholderQR_householderQ.cpp b/doc/snippets/HouseholderQR_householderQ.cpp new file mode 100644 index 000000000..e859ce55b --- /dev/null +++ b/doc/snippets/HouseholderQR_householderQ.cpp @@ -0,0 +1,7 @@ +MatrixXf A(MatrixXf::Random(5,3)), thinQ(MatrixXf::Identity(5,3)), Q; +A.setRandom(); +HouseholderQR qr(A); +Q = qr.householderQ(); +thinQ = qr.householderQ() * thinQ; +std::cout << "The complete unitary matrix Q is:\n" << Q << "\n\n"; +std::cout << "The thin matrix Q is:\n" << thinQ << "\n\n"; -- cgit v1.2.3