mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 18:59:01 +08:00
fix a couple of issues making the eigensolver test compile and run without aborting
on an assert. Had to fix a stupid bug in Block -- very strange we hadn't hit it before. However the test still fails.
This commit is contained in:
parent
001b01a290
commit
92b7e2d6a1
@ -90,7 +90,7 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
|||||||
// It is a row if and only if BlockRows==1 and BlockCols==MatrixType::ColsAtCompileTime,
|
// It is a row if and only if BlockRows==1 and BlockCols==MatrixType::ColsAtCompileTime,
|
||||||
// and it is a column if and only if BlockRows==MatrixType::RowsAtCompileTime and BlockCols==1,
|
// and it is a column if and only if BlockRows==MatrixType::RowsAtCompileTime and BlockCols==1,
|
||||||
// all other cases are invalid.
|
// all other cases are invalid.
|
||||||
// The case a 1x1 matrix looks ambibuous, but the result is the same anyway.
|
// The case a 1x1 matrix seems ambiguous, but the result is the same anyway.
|
||||||
m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0),
|
m_startRow( (BlockRows==1) && (BlockCols==MatrixType::ColsAtCompileTime) ? i : 0),
|
||||||
m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
|
m_startCol( (BlockRows==MatrixType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
|
||||||
m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it
|
m_blockRows(matrix.rows()), // if it is a row, then m_blockRows has a fixed-size of 1, so no pb to try to overwrite it
|
||||||
@ -119,8 +119,8 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
|||||||
: m_matrix(matrix), m_startRow(startRow), m_startCol(startCol),
|
: m_matrix(matrix), m_startRow(startRow), m_startCol(startCol),
|
||||||
m_blockRows(blockRows), m_blockCols(blockCols)
|
m_blockRows(blockRows), m_blockCols(blockCols)
|
||||||
{
|
{
|
||||||
ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==1)
|
ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)
|
||||||
&& (ColsAtCompileTime==Dynamic || ColsAtCompileTime==1));
|
&& (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols));
|
||||||
ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows()
|
ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows()
|
||||||
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
|
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ static void ei_givens_rotation(Scalar a, Scalar b, Scalar& c, Scalar& s)
|
|||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
* Performs a QR step on a tridiagonal symmetric matrix represented as a
|
||||||
* pair of two vectors \a diag \a subdiag.
|
* pair of two vectors \a diag and \a subdiag.
|
||||||
*
|
*
|
||||||
* \param matA the input selfadjoint matrix
|
* \param matA the input selfadjoint matrix
|
||||||
* \param hCoeffs returned Householder coefficients
|
* \param hCoeffs returned Householder coefficients
|
||||||
@ -142,7 +142,7 @@ void SelfAdjointEigenSolver<MatrixType>::compute(const MatrixType& matrix)
|
|||||||
|
|
||||||
Tridiagonalization<MatrixType> tridiag(m_eivec);
|
Tridiagonalization<MatrixType> tridiag(m_eivec);
|
||||||
RealVectorType& diag = m_eivalues;
|
RealVectorType& diag = m_eivalues;
|
||||||
RealVectorType subdiag(n-1);
|
RealVectorTypeX subdiag(n-1);
|
||||||
diag = tridiag.diagonal();
|
diag = tridiag.diagonal();
|
||||||
subdiag = tridiag.subDiagonal();
|
subdiag = tridiag.subDiagonal();
|
||||||
|
|
||||||
|
@ -38,14 +38,14 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
|
|||||||
MatrixType a = MatrixType::random(rows,cols);
|
MatrixType a = MatrixType::random(rows,cols);
|
||||||
MatrixType covMat = a.adjoint() * a;
|
MatrixType covMat = a.adjoint() * a;
|
||||||
|
|
||||||
EigenSolver<MatrixType,true> eiSymm(covMat);
|
SelfAdjointEigenSolver<MatrixType> eiSymm(covMat);
|
||||||
VERIFY_IS_APPROX(covMat * eiSymm.eigenvectors(), eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal());
|
VERIFY_IS_APPROX(covMat * eiSymm.eigenvectors(), eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal());
|
||||||
|
|
||||||
EigenSolver<MatrixType,false> eiNotSymmButSymm(covMat);
|
EigenSolver<MatrixType> eiNotSymmButSymm(covMat);
|
||||||
VERIFY_IS_APPROX((covMat.template cast<Complex>()) * (eiNotSymmButSymm.eigenvectors().template cast<Complex>()),
|
VERIFY_IS_APPROX((covMat.template cast<Complex>()) * (eiNotSymmButSymm.eigenvectors().template cast<Complex>()),
|
||||||
(eiNotSymmButSymm.eigenvectors().template cast<Complex>()) * (eiNotSymmButSymm.eigenvalues().asDiagonal()));
|
(eiNotSymmButSymm.eigenvectors().template cast<Complex>()) * (eiNotSymmButSymm.eigenvalues().asDiagonal()));
|
||||||
|
|
||||||
EigenSolver<MatrixType,false> eiNotSymm(a);
|
EigenSolver<MatrixType> eiNotSymm(a);
|
||||||
// VERIFY_IS_APPROX(a.template cast<Complex>() * eiNotSymm.eigenvectors().template cast<Complex>(),
|
// VERIFY_IS_APPROX(a.template cast<Complex>() * eiNotSymm.eigenvectors().template cast<Complex>(),
|
||||||
// eiNotSymm.eigenvectors().template cast<Complex>() * eiNotSymm.eigenvalues().asDiagonal());
|
// eiNotSymm.eigenvectors().template cast<Complex>() * eiNotSymm.eigenvalues().asDiagonal());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user