mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-12 09:23:12 +08:00
Make all compute() methods return a reference to *this.
This commit is contained in:
parent
4c6d182c42
commit
e3e2380548
@ -200,6 +200,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
|||||||
* \param[in] computeEigenvectors If true, both the eigenvectors and the
|
* \param[in] computeEigenvectors If true, both the eigenvectors and the
|
||||||
* eigenvalues are computed; if false, only the eigenvalues are
|
* eigenvalues are computed; if false, only the eigenvalues are
|
||||||
* computed.
|
* computed.
|
||||||
|
* \returns Reference to \c *this
|
||||||
*
|
*
|
||||||
* This function computes the eigenvalues of the complex matrix \p matrix.
|
* This function computes the eigenvalues of the complex matrix \p matrix.
|
||||||
* The eigenvalues() function can be used to retrieve them. If
|
* The eigenvalues() function can be used to retrieve them. If
|
||||||
@ -217,7 +218,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
|||||||
* Example: \include ComplexEigenSolver_compute.cpp
|
* Example: \include ComplexEigenSolver_compute.cpp
|
||||||
* Output: \verbinclude ComplexEigenSolver_compute.out
|
* Output: \verbinclude ComplexEigenSolver_compute.out
|
||||||
*/
|
*/
|
||||||
void compute(const MatrixType& matrix, bool computeEigenvectors = true);
|
ComplexEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EigenvectorType m_eivec;
|
EigenvectorType m_eivec;
|
||||||
@ -230,7 +231,7 @@ template<typename _MatrixType> class ComplexEigenSolver
|
|||||||
|
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
|
ComplexEigenSolver<MatrixType>& ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
|
||||||
{
|
{
|
||||||
// this code is inspired from Jampack
|
// this code is inspired from Jampack
|
||||||
assert(matrix.cols() == matrix.rows());
|
assert(matrix.cols() == matrix.rows());
|
||||||
@ -292,6 +293,8 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool comp
|
|||||||
m_eivec.col(i).swap(m_eivec.col(k));
|
m_eivec.col(i).swap(m_eivec.col(k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ template<typename _MatrixType> class ComplexSchur
|
|||||||
*
|
*
|
||||||
* \param[in] matrix Square matrix whose Schur decomposition is to be computed.
|
* \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.
|
* \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
|
* The Schur decomposition is computed by first reducing the
|
||||||
* matrix to Hessenberg form using the class
|
* matrix to Hessenberg form using the class
|
||||||
@ -189,7 +190,7 @@ template<typename _MatrixType> class ComplexSchur
|
|||||||
* Example: \include ComplexSchur_compute.cpp
|
* Example: \include ComplexSchur_compute.cpp
|
||||||
* Output: \verbinclude ComplexSchur_compute.out
|
* Output: \verbinclude ComplexSchur_compute.out
|
||||||
*/
|
*/
|
||||||
void compute(const MatrixType& matrix, bool computeU = true);
|
ComplexSchur& compute(const MatrixType& matrix, bool computeU = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComplexMatrixType m_matT, m_matU;
|
ComplexMatrixType m_matT, m_matU;
|
||||||
@ -296,7 +297,7 @@ typename ComplexSchur<MatrixType>::ComplexScalar ComplexSchur<MatrixType>::compu
|
|||||||
|
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
ComplexSchur<MatrixType>& ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
||||||
{
|
{
|
||||||
m_matUisUptodate = false;
|
m_matUisUptodate = false;
|
||||||
ei_assert(matrix.cols() == matrix.rows());
|
ei_assert(matrix.cols() == matrix.rows());
|
||||||
@ -307,11 +308,12 @@ void ComplexSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
|||||||
if(computeU) m_matU = ComplexMatrixType::Identity(1,1);
|
if(computeU) m_matU = ComplexMatrixType::Identity(1,1);
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
m_matUisUptodate = computeU;
|
m_matUisUptodate = computeU;
|
||||||
return;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ei_complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>::run(*this, matrix, computeU);
|
ei_complex_schur_reduce_to_hessenberg<MatrixType, NumTraits<Scalar>::IsComplex>::run(*this, matrix, computeU);
|
||||||
reduceToTriangularForm(computeU);
|
reduceToTriangularForm(computeU);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reduce given matrix to Hessenberg form */
|
/* Reduce given matrix to Hessenberg form */
|
||||||
|
@ -141,6 +141,7 @@ template<typename _MatrixType> class HessenbergDecomposition
|
|||||||
/** \brief Computes Hessenberg decomposition of given matrix.
|
/** \brief Computes Hessenberg decomposition of given matrix.
|
||||||
*
|
*
|
||||||
* \param[in] matrix Square matrix whose Hessenberg decomposition is to be computed.
|
* \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
|
* The Hessenberg decomposition is computed by bringing the columns of the
|
||||||
* matrix successively in the required form using Householder reflections
|
* matrix successively in the required form using Householder reflections
|
||||||
@ -154,17 +155,18 @@ template<typename _MatrixType> class HessenbergDecomposition
|
|||||||
* Example: \include HessenbergDecomposition_compute.cpp
|
* Example: \include HessenbergDecomposition_compute.cpp
|
||||||
* Output: \verbinclude HessenbergDecomposition_compute.out
|
* Output: \verbinclude HessenbergDecomposition_compute.out
|
||||||
*/
|
*/
|
||||||
void compute(const MatrixType& matrix)
|
HessenbergDecomposition& compute(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
m_matrix = matrix;
|
m_matrix = matrix;
|
||||||
if(matrix.rows()<2)
|
if(matrix.rows()<2)
|
||||||
{
|
{
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
return;
|
return *this;
|
||||||
}
|
}
|
||||||
m_hCoeffs.resize(matrix.rows()-1,1);
|
m_hCoeffs.resize(matrix.rows()-1,1);
|
||||||
_compute(m_matrix, m_hCoeffs, m_temp);
|
_compute(m_matrix, m_hCoeffs, m_temp);
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Returns the Householder coefficients.
|
/** \brief Returns the Householder coefficients.
|
||||||
|
@ -161,6 +161,7 @@ template<typename _MatrixType> class RealSchur
|
|||||||
*
|
*
|
||||||
* \param[in] matrix Square matrix whose Schur decomposition is to be computed.
|
* \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.
|
* \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
|
* The Schur decomposition is computed by first reducing the matrix to
|
||||||
* Hessenberg form using the class HessenbergDecomposition. The Hessenberg
|
* Hessenberg form using the class HessenbergDecomposition. The Hessenberg
|
||||||
@ -173,7 +174,7 @@ template<typename _MatrixType> class RealSchur
|
|||||||
* Example: \include RealSchur_compute.cpp
|
* Example: \include RealSchur_compute.cpp
|
||||||
* Output: \verbinclude RealSchur_compute.out
|
* Output: \verbinclude RealSchur_compute.out
|
||||||
*/
|
*/
|
||||||
void compute(const MatrixType& matrix, bool computeU = true);
|
RealSchur& compute(const MatrixType& matrix, bool computeU = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -196,7 +197,7 @@ template<typename _MatrixType> class RealSchur
|
|||||||
|
|
||||||
|
|
||||||
template<typename MatrixType>
|
template<typename MatrixType>
|
||||||
void RealSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
RealSchur<MatrixType>& RealSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
||||||
{
|
{
|
||||||
assert(matrix.cols() == matrix.rows());
|
assert(matrix.cols() == matrix.rows());
|
||||||
|
|
||||||
@ -251,6 +252,7 @@ void RealSchur<MatrixType>::compute(const MatrixType& matrix, bool computeU)
|
|||||||
|
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
m_matUisUptodate = computeU;
|
m_matUisUptodate = computeU;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal Computes and returns vector L1 norm of T */
|
/** \internal Computes and returns vector L1 norm of T */
|
||||||
|
@ -137,6 +137,7 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
*
|
*
|
||||||
* \param[in] matrix Selfadjoint matrix whose tridiagonal decomposition
|
* \param[in] matrix Selfadjoint matrix whose tridiagonal decomposition
|
||||||
* is to be computed.
|
* is to be computed.
|
||||||
|
* \returns Reference to \c *this
|
||||||
*
|
*
|
||||||
* The tridiagonal decomposition is computed by bringing the columns of
|
* The tridiagonal decomposition is computed by bringing the columns of
|
||||||
* the matrix successively in the required form using Householder
|
* the matrix successively in the required form using Householder
|
||||||
@ -149,12 +150,13 @@ template<typename _MatrixType> class Tridiagonalization
|
|||||||
* Example: \include Tridiagonalization_compute.cpp
|
* Example: \include Tridiagonalization_compute.cpp
|
||||||
* Output: \verbinclude Tridiagonalization_compute.out
|
* Output: \verbinclude Tridiagonalization_compute.out
|
||||||
*/
|
*/
|
||||||
void compute(const MatrixType& matrix)
|
Tridiagonalization& compute(const MatrixType& matrix)
|
||||||
{
|
{
|
||||||
m_matrix = matrix;
|
m_matrix = matrix;
|
||||||
m_hCoeffs.resize(matrix.rows()-1, 1);
|
m_hCoeffs.resize(matrix.rows()-1, 1);
|
||||||
_compute(m_matrix, m_hCoeffs);
|
_compute(m_matrix, m_hCoeffs);
|
||||||
m_isInitialized = true;
|
m_isInitialized = true;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Returns the Householder coefficients.
|
/** \brief Returns the Householder coefficients.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user