From 3ac01b1400dccefcb2db85ab1caf88fc3bd379db Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 6 Aug 2009 16:41:54 +0200 Subject: [PATCH] compilation fix in EigenSolver, bugfix in PartialLU --- Eigen/src/Core/Product.h | 7 +++++++ Eigen/src/LU/PartialLU.h | 31 +++++++++++++++---------------- Eigen/src/QR/EigenSolver.h | 14 +++++++------- test/CMakeLists.txt | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 29a0f9cac..18f14f75a 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -132,6 +132,13 @@ struct ProductReturnType * Implementation of Inner Vector Vector Product ***********************************************************************/ +// FIXME : maybe the "inner product" could return a Scalar +// instead of a 1x1 matrix ?? +// Pro: more natural for the user +// Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix +// product ends up to a row-vector times col-vector product... To tackle this use +// case, we could have a specialization for Block with: operator=(Scalar x); + template struct ei_traits > : ei_traits, Lhs, Rhs> > diff --git a/Eigen/src/LU/PartialLU.h b/Eigen/src/LU/PartialLU.h index 1cca1c7db..10d39055a 100644 --- a/Eigen/src/LU/PartialLU.h +++ b/Eigen/src/LU/PartialLU.h @@ -245,11 +245,10 @@ struct ei_partial_lu_impl if(k::orthes(MatrixType& matH, RealVectorType& ort) // H = (I-u*u'/h)*H*(I-u*u')/h) int bSize = high-m+1; matH.block(m, m, bSize, n-m) -= ((ort.segment(m, bSize)/h) - * (ort.segment(m, bSize).transpose() * matH.block(m, m, bSize, n-m)).lazy()).lazy(); + * (ort.segment(m, bSize).transpose() * matH.block(m, m, bSize, n-m))).lazy(); - matH.block(0, m, high+1, bSize) -= ((matH.block(0, m, high+1, bSize) * ort.segment(m, bSize)).lazy() + matH.block(0, m, high+1, bSize) -= ((matH.block(0, m, high+1, bSize) * ort.segment(m, bSize)) * (ort.segment(m, bSize)/h).transpose()).lazy(); ort.coeffRef(m) = scale*ort.coeff(m); @@ -264,8 +264,8 @@ void EigenSolver::orthes(MatrixType& matH, RealVectorType& ort) ort.segment(m+1, high-m) = matH.col(m-1).segment(m+1, high-m); int bSize = high-m+1; - m_eivec.block(m, m, bSize, bSize) += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m) ) ) - * (ort.segment(m, bSize).transpose() * m_eivec.block(m, m, bSize, bSize)).lazy()); + m_eivec.block(m, m, bSize, bSize) += ( (ort.segment(m, bSize) / (matH.coeff(m,m-1) * ort.coeff(m))) + * (ort.segment(m, bSize).transpose() * m_eivec.block(m, m, bSize, bSize)) ).lazy(); } } } @@ -585,7 +585,7 @@ void EigenSolver::hqr2(MatrixType& matH) for (int i = n-1; i >= 0; i--) { w = matH.coeff(i,i) - p; - r = (matH.row(i).segment(l,n-l+1) * matH.col(n).segment(l, n-l+1))(0,0); + r = matH.row(i).segment(l,n-l+1).dot(matH.col(n).segment(l, n-l+1)); if (m_eivalues.coeff(i).imag() < 0.0) { @@ -644,8 +644,8 @@ void EigenSolver::hqr2(MatrixType& matH) for (int i = n-2; i >= 0; i--) { Scalar ra,sa,vr,vi; - ra = (matH.block(i,l, 1, n-l+1) * matH.block(l,n-1, n-l+1, 1)).lazy()(0,0); - sa = (matH.block(i,l, 1, n-l+1) * matH.block(l,n, n-l+1, 1)).lazy()(0,0); + ra = matH.row(i).segment(l, n-l+1).dot(matH.col(n-1).segment(l, n-l+1)); + sa = matH.row(i).segment(l, n-l+1).dot(matH.col(n).segment(l, n-l+1)); w = matH.coeff(i,i) - p; if (m_eivalues.coeff(i).imag() < 0.0) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f3c477374..ac4eb7633 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -120,7 +120,7 @@ ei_add_test(bandmatrix) ei_add_test(cholesky " " "${GSL_LIBRARIES}") ei_add_test(lu ${EI_OFLAG}) ei_add_test(determinant) -ei_add_test(inverse) +ei_add_test(inverse ${EI_OFLAG}) ei_add_test(qr) ei_add_test(eigensolver_selfadjoint " " "${GSL_LIBRARIES}") ei_add_test(eigensolver_generic " " "${GSL_LIBRARIES}")