From e3e23805488d701b9f3a463ed226949c05d726c8 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Tue, 1 Jun 2010 17:40:51 +0100 Subject: [PATCH] Make all compute() methods return a reference to *this. --- Eigen/src/Eigenvalues/ComplexEigenSolver.h | 7 +++++-- Eigen/src/Eigenvalues/ComplexSchur.h | 8 +++++--- Eigen/src/Eigenvalues/HessenbergDecomposition.h | 6 ++++-- Eigen/src/Eigenvalues/RealSchur.h | 6 ++++-- Eigen/src/Eigenvalues/Tridiagonalization.h | 4 +++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index a3a4a4eba..bc44b899a 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -200,6 +200,7 @@ template class ComplexEigenSolver * \param[in] computeEigenvectors If true, both the eigenvectors and the * eigenvalues are computed; if false, only the eigenvalues are * computed. + * \returns Reference to \c *this * * This function computes the eigenvalues of the complex matrix \p matrix. * The eigenvalues() function can be used to retrieve them. If @@ -217,7 +218,7 @@ template class ComplexEigenSolver * Example: \include ComplexEigenSolver_compute.cpp * Output: \verbinclude ComplexEigenSolver_compute.out */ - void compute(const MatrixType& matrix, bool computeEigenvectors = true); + ComplexEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors = true); protected: EigenvectorType m_eivec; @@ -230,7 +231,7 @@ template class ComplexEigenSolver template -void ComplexEigenSolver::compute(const MatrixType& matrix, bool computeEigenvectors) +ComplexEigenSolver& ComplexEigenSolver::compute(const MatrixType& matrix, bool computeEigenvectors) { // this code is inspired from Jampack assert(matrix.cols() == matrix.rows()); @@ -292,6 +293,8 @@ void ComplexEigenSolver::compute(const MatrixType& matrix, bool comp m_eivec.col(i).swap(m_eivec.col(k)); } } + + return *this; } diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index 84da40f22..a4812dac6 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -175,6 +175,7 @@ template class ComplexSchur * * \param[in] matrix Square matrix whose Schur decomposition is to be computed. * \param[in] computeU If true, both T and U are computed; if false, only T is computed. + * \returns Reference to \c *this * * The Schur decomposition is computed by first reducing the * matrix to Hessenberg form using the class @@ -189,7 +190,7 @@ template class ComplexSchur * Example: \include ComplexSchur_compute.cpp * Output: \verbinclude ComplexSchur_compute.out */ - void compute(const MatrixType& matrix, bool computeU = true); + ComplexSchur& compute(const MatrixType& matrix, bool computeU = true); protected: ComplexMatrixType m_matT, m_matU; @@ -296,7 +297,7 @@ typename ComplexSchur::ComplexScalar ComplexSchur::compu template -void ComplexSchur::compute(const MatrixType& matrix, bool computeU) +ComplexSchur& ComplexSchur::compute(const MatrixType& matrix, bool computeU) { m_matUisUptodate = false; ei_assert(matrix.cols() == matrix.rows()); @@ -307,11 +308,12 @@ void ComplexSchur::compute(const MatrixType& matrix, bool computeU) if(computeU) m_matU = ComplexMatrixType::Identity(1,1); m_isInitialized = true; m_matUisUptodate = computeU; - return; + return *this; } ei_complex_schur_reduce_to_hessenberg::IsComplex>::run(*this, matrix, computeU); reduceToTriangularForm(computeU); + return *this; } /* Reduce given matrix to Hessenberg form */ diff --git a/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/Eigen/src/Eigenvalues/HessenbergDecomposition.h index 220531bf5..4f3c357a8 100644 --- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -141,6 +141,7 @@ template class HessenbergDecomposition /** \brief Computes Hessenberg decomposition of given matrix. * * \param[in] matrix Square matrix whose Hessenberg decomposition is to be computed. + * \returns Reference to \c *this * * The Hessenberg decomposition is computed by bringing the columns of the * matrix successively in the required form using Householder reflections @@ -154,17 +155,18 @@ template class HessenbergDecomposition * Example: \include HessenbergDecomposition_compute.cpp * Output: \verbinclude HessenbergDecomposition_compute.out */ - void compute(const MatrixType& matrix) + HessenbergDecomposition& compute(const MatrixType& matrix) { m_matrix = matrix; if(matrix.rows()<2) { m_isInitialized = true; - return; + return *this; } m_hCoeffs.resize(matrix.rows()-1,1); _compute(m_matrix, m_hCoeffs, m_temp); m_isInitialized = true; + return *this; } /** \brief Returns the Householder coefficients. diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index c92b72a94..41f74e530 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -161,6 +161,7 @@ template class RealSchur * * \param[in] matrix Square matrix whose Schur decomposition is to be computed. * \param[in] computeU If true, both T and U are computed; if false, only T is computed. + * \returns Reference to \c *this * * The Schur decomposition is computed by first reducing the matrix to * Hessenberg form using the class HessenbergDecomposition. The Hessenberg @@ -173,7 +174,7 @@ template class RealSchur * Example: \include RealSchur_compute.cpp * Output: \verbinclude RealSchur_compute.out */ - void compute(const MatrixType& matrix, bool computeU = true); + RealSchur& compute(const MatrixType& matrix, bool computeU = true); private: @@ -196,7 +197,7 @@ template class RealSchur template -void RealSchur::compute(const MatrixType& matrix, bool computeU) +RealSchur& RealSchur::compute(const MatrixType& matrix, bool computeU) { assert(matrix.cols() == matrix.rows()); @@ -251,6 +252,7 @@ void RealSchur::compute(const MatrixType& matrix, bool computeU) m_isInitialized = true; m_matUisUptodate = computeU; + return *this; } /** \internal Computes and returns vector L1 norm of T */ diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h index e204c30ea..acf21e2da 100644 --- a/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -137,6 +137,7 @@ template class Tridiagonalization * * \param[in] matrix Selfadjoint matrix whose tridiagonal decomposition * is to be computed. + * \returns Reference to \c *this * * The tridiagonal decomposition is computed by bringing the columns of * the matrix successively in the required form using Householder @@ -149,12 +150,13 @@ template class Tridiagonalization * Example: \include Tridiagonalization_compute.cpp * Output: \verbinclude Tridiagonalization_compute.out */ - void compute(const MatrixType& matrix) + Tridiagonalization& compute(const MatrixType& matrix) { m_matrix = matrix; m_hCoeffs.resize(matrix.rows()-1, 1); _compute(m_matrix, m_hCoeffs); m_isInitialized = true; + return *this; } /** \brief Returns the Householder coefficients.