mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
in all decs, make the compute() methods return *this
(implements feature request #18)
This commit is contained in:
@@ -118,7 +118,7 @@ template<typename _MatrixType> class EigenSolver
|
||||
return m_eivalues;
|
||||
}
|
||||
|
||||
void compute(const MatrixType& matrix);
|
||||
EigenSolver& compute(const MatrixType& matrix);
|
||||
|
||||
private:
|
||||
|
||||
@@ -189,7 +189,7 @@ typename EigenSolver<MatrixType>::EigenvectorType EigenSolver<MatrixType>::eigen
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
void EigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||
EigenSolver<MatrixType>& EigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
assert(matrix.cols() == matrix.rows());
|
||||
int n = matrix.cols();
|
||||
@@ -205,6 +205,7 @@ void EigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
||||
hqr2(matH);
|
||||
|
||||
m_isInitialized = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Nonsymmetric reduction to Hessenberg form.
|
||||
|
||||
@@ -101,7 +101,7 @@ template<typename MatrixType> class HouseholderQR
|
||||
*/
|
||||
const MatrixType& matrixQR() const { return m_qr; }
|
||||
|
||||
void compute(const MatrixType& matrix);
|
||||
HouseholderQR& compute(const MatrixType& matrix);
|
||||
|
||||
protected:
|
||||
MatrixType m_qr;
|
||||
@@ -112,7 +112,7 @@ template<typename MatrixType> class HouseholderQR
|
||||
#ifndef EIGEN_HIDE_HEAVY_CODE
|
||||
|
||||
template<typename MatrixType>
|
||||
void HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
m_qr = matrix;
|
||||
m_hCoeffs.resize(matrix.cols());
|
||||
@@ -175,6 +175,7 @@ void HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
|
||||
}
|
||||
}
|
||||
m_isInitialized = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
|
||||
@@ -90,9 +90,9 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
|
||||
compute(matA, matB, computeEigenvectors);
|
||||
}
|
||||
|
||||
void compute(const MatrixType& matrix, bool computeEigenvectors = true);
|
||||
SelfAdjointEigenSolver& compute(const MatrixType& matrix, bool computeEigenvectors = true);
|
||||
|
||||
void compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors = true);
|
||||
SelfAdjointEigenSolver& compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors = true);
|
||||
|
||||
/** \returns the computed eigen vectors as a matrix of column vectors */
|
||||
MatrixType eigenvectors(void) const
|
||||
@@ -182,7 +182,7 @@ static void ei_tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, int st
|
||||
* \sa SelfAdjointEigenSolver(MatrixType,bool), compute(MatrixType,MatrixType,bool)
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
void SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
|
||||
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
m_eigenvectorsOk = computeEigenvectors;
|
||||
@@ -195,7 +195,7 @@ void SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool
|
||||
{
|
||||
m_eivalues.coeffRef(0,0) = ei_real(matrix.coeff(0,0));
|
||||
m_eivec.setOnes();
|
||||
return;
|
||||
return *this;
|
||||
}
|
||||
|
||||
m_eivec = matrix;
|
||||
@@ -240,6 +240,7 @@ void SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool
|
||||
m_eivec.col(i).swap(m_eivec.col(k+i));
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Computes the eigenvalues of the generalized eigen problem
|
||||
@@ -250,7 +251,7 @@ void SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool
|
||||
* \sa SelfAdjointEigenSolver(MatrixType,MatrixType,bool), compute(MatrixType,bool)
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
void SelfAdjointEigenSolver<MatrixType>::
|
||||
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>::
|
||||
compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors)
|
||||
{
|
||||
ei_assert(matA.cols()==matA.rows() && matB.rows()==matA.rows() && matB.cols()==matB.rows());
|
||||
@@ -282,6 +283,7 @@ compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors
|
||||
for (int i=0; i<m_eivec.cols(); ++i)
|
||||
m_eivec.col(i) = m_eivec.col(i).normalized();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // EIGEN_HIDE_HEAVY_CODE
|
||||
|
||||
Reference in New Issue
Block a user