From 92b7e2d6a16a6c52fb74f00601f0cfd213810426 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 2 Jun 2008 02:06:33 +0000 Subject: [PATCH] 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. --- Eigen/src/Core/Block.h | 6 +++--- Eigen/src/QR/SelfAdjointEigenSolver.h | 4 ++-- test/eigensolver.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 65b9ad649..1f3bc84bc 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -90,7 +90,7 @@ template class Block // 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, // 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_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 @@ -119,8 +119,8 @@ template class Block : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols) { - ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==1) - && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==1)); + ei_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) + && (ColsAtCompileTime==Dynamic || ColsAtCompileTime==blockCols)); ei_assert(startRow >= 0 && blockRows >= 1 && startRow + blockRows <= matrix.rows() && startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols()); } diff --git a/Eigen/src/QR/SelfAdjointEigenSolver.h b/Eigen/src/QR/SelfAdjointEigenSolver.h index 2ac12fc6e..0df0db0b7 100644 --- a/Eigen/src/QR/SelfAdjointEigenSolver.h +++ b/Eigen/src/QR/SelfAdjointEigenSolver.h @@ -88,7 +88,7 @@ static void ei_givens_rotation(Scalar a, Scalar b, Scalar& c, Scalar& s) /** \internal * 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 hCoeffs returned Householder coefficients @@ -142,7 +142,7 @@ void SelfAdjointEigenSolver::compute(const MatrixType& matrix) Tridiagonalization tridiag(m_eivec); RealVectorType& diag = m_eivalues; - RealVectorType subdiag(n-1); + RealVectorTypeX subdiag(n-1); diag = tridiag.diagonal(); subdiag = tridiag.subDiagonal(); diff --git a/test/eigensolver.cpp b/test/eigensolver.cpp index f63d7a535..64e21f99c 100644 --- a/test/eigensolver.cpp +++ b/test/eigensolver.cpp @@ -38,14 +38,14 @@ template void eigensolver(const MatrixType& m) MatrixType a = MatrixType::random(rows,cols); MatrixType covMat = a.adjoint() * a; - EigenSolver eiSymm(covMat); + SelfAdjointEigenSolver eiSymm(covMat); VERIFY_IS_APPROX(covMat * eiSymm.eigenvectors(), eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal()); - EigenSolver eiNotSymmButSymm(covMat); + EigenSolver eiNotSymmButSymm(covMat); VERIFY_IS_APPROX((covMat.template cast()) * (eiNotSymmButSymm.eigenvectors().template cast()), (eiNotSymmButSymm.eigenvectors().template cast()) * (eiNotSymmButSymm.eigenvalues().asDiagonal())); - EigenSolver eiNotSymm(a); + EigenSolver eiNotSymm(a); // VERIFY_IS_APPROX(a.template cast() * eiNotSymm.eigenvectors().template cast(), // eiNotSymm.eigenvectors().template cast() * eiNotSymm.eigenvalues().asDiagonal());