From 1d4fea48b57ef2fdd20df909c65e3432e26e91f9 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 6 Aug 2009 14:10:02 +0200 Subject: [PATCH] fix a couple of compilations issues --- Eigen/src/Cholesky/LDLT.h | 4 ++-- Eigen/src/Core/Product.h | 2 +- Eigen/src/Geometry/Transform.h | 6 +----- Eigen/src/Geometry/Umeyama.h | 6 ++++-- Eigen/src/QR/HessenbergDecomposition.h | 9 +++++---- test/product_notemporary.cpp | 8 ++++---- test/submatrices.cpp | 2 +- test/triangular.cpp | 6 +++--- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index 200b428af..e652fd213 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -205,8 +205,8 @@ void LDLT::compute(const MatrixType& a) continue; } - RealScalar Djj = ei_real(m_matrix.coeff(j,j) - (m_matrix.row(j).start(j) - * m_matrix.col(j).start(j).conjugate()).coeff(0,0)); + RealScalar Djj = ei_real(m_matrix.coeff(j,j) - m_matrix.row(j).start(j) + .dot(m_matrix.col(j).start(j))); m_matrix.coeffRef(j,j) = Djj; // Finish early if the matrix is not full rank. diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index fe559a991..29a0f9cac 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -149,7 +149,7 @@ class GeneralProduct template void addTo(Dest& dst, Scalar alpha) const { ei_assert(dst.rows()==1 && dst.cols()==1); - dst.coeffRef(0,0) += (m_lhs.cwise()*m_rhs).sum(); + dst.coeffRef(0,0) += alpha * (m_lhs.cwise()*m_rhs).sum(); } }; diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 2762ea2b5..bc06598c1 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -911,11 +911,7 @@ Transform::inverse(TransformTraits hint) const } // translation and remaining parts res.template corner(TopRight) = - res.template corner(TopLeft) * translation(); - if (int(Mode)!=AffineCompact) - { - res.template corner<1,Dim>(BottomLeft).setZero(); - res.coeffRef(Dim,Dim) = Scalar(1); - } + makeAffine(); return res; } } diff --git a/Eigen/src/Geometry/Umeyama.h b/Eigen/src/Geometry/Umeyama.h index 67747d94f..64c06fe66 100644 --- a/Eigen/src/Geometry/Umeyama.h +++ b/Eigen/src/Geometry/Umeyama.h @@ -174,8 +174,10 @@ umeyama(const MatrixBase& src, const MatrixBase& dst, boo const Scalar c = 1/src_var * svd.singularValues().dot(S); // Eq. (41) - // TODO: lazyness does not make much sense over here, right? - Rt.col(m).segment(0,m) = dst_mean - c*Rt.block(0,0,m,m)*src_mean; + // Note that we first assign dst_mean to the destination so that there no need + // for a temporary. + Rt.col(m).start(m) = dst_mean; + Rt.col(m).start(m) -= (c*Rt.corner(TopLeft,m,m)*src_mean).lazy(); if (with_scaling) Rt.block(0,0,m,m) *= c; diff --git a/Eigen/src/QR/HessenbergDecomposition.h b/Eigen/src/QR/HessenbergDecomposition.h index e7b086cb4..6ba90fb3a 100644 --- a/Eigen/src/QR/HessenbergDecomposition.h +++ b/Eigen/src/QR/HessenbergDecomposition.h @@ -170,7 +170,7 @@ void HessenbergDecomposition::_compute(MatrixType& matA, CoeffVector // i.e., A = H' A H where H = I - h v v' and v = matA.col(i).end(n-i-1) matA.col(i).coeffRef(i+1) = 1; - // first let's do A = H A + // first let's do A = H' A matA.corner(BottomRight,n-i-1,n-i-1) -= ((ei_conj(h) * matA.col(i).end(n-i-1)) * (matA.col(i).end(n-i-1).adjoint() * matA.corner(BottomRight,n-i-1,n-i-1))).lazy(); @@ -213,14 +213,15 @@ HessenbergDecomposition::matrixQ(void) const { int n = m_matrix.rows(); MatrixType matQ = MatrixType::Identity(n,n); + Matrix temp(n); for (int i = n-2; i>=0; i--) { Scalar tmp = m_matrix.coeff(i+1,i); m_matrix.const_cast_derived().coeffRef(i+1,i) = 1; - matQ.corner(BottomRight,n-i-1,n-i-1) -= - ((m_hCoeffs.coeff(i) * m_matrix.col(i).end(n-i-1)) * - (m_matrix.col(i).end(n-i-1).adjoint() * matQ.corner(BottomRight,n-i-1,n-i-1)).lazy()).lazy(); + int rs = n-i-1; + temp.end(rs) = (m_matrix.col(i).end(rs).adjoint() * matQ.corner(BottomRight,rs,rs)).lazy(); + matQ.corner(BottomRight,rs,rs) -= (m_hCoeffs.coeff(i) * m_matrix.col(i).end(rs) * temp.end(rs)).lazy(); m_matrix.const_cast_derived().coeffRef(i+1,i) = tmp; } diff --git a/test/product_notemporary.cpp b/test/product_notemporary.cpp index 0d4ed27bb..f4311e495 100644 --- a/test/product_notemporary.cpp +++ b/test/product_notemporary.cpp @@ -103,15 +103,15 @@ template void product_notemporary(const MatrixType& m) VERIFY_EVALUATION_COUNT( m3.col(c0) = ((s1 * m1).adjoint().template selfadjointView() * (-m2.row(c0)*s3).adjoint()).lazy(), 0); VERIFY_EVALUATION_COUNT( m3.col(c0) -= ((s1 * m1).adjoint().template selfadjointView() * (-m2.row(c0)*s3).adjoint()).lazy(), 0); - VERIFY_EVALUATION_COUNT( m3.block(r0,r0,r1,r1) += ((m1.block(r0,r0,r1,r1).template selfadjointView() * (s1*m2.block(c0,r0,c1,r1)) )).lazy(), 0); - VERIFY_EVALUATION_COUNT( m3.block(r0,r0,r1,r1) = ((m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(c0,r0,c1,r1) )).lazy(), 0); + VERIFY_EVALUATION_COUNT( m3.block(r0,c0,r1,c1) += ((m1.block(r0,r0,r1,r1).template selfadjointView() * (s1*m2.block(r0,c0,r1,c1)) )).lazy(), 0); + VERIFY_EVALUATION_COUNT( m3.block(r0,c0,r1,c1) = ((m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(r0,c0,r1,c1) )).lazy(), 0); VERIFY_EVALUATION_COUNT( m3.template selfadjointView().rankUpdate(m2.adjoint()), 0); m3.resize(1,1); - VERIFY_EVALUATION_COUNT( m3 = ((m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(c0,r0,c1,r1) )).lazy(), 0); + VERIFY_EVALUATION_COUNT( m3 = ((m1.block(r0,r0,r1,r1).template selfadjointView() * m2.block(r0,c0,r1,c1) )).lazy(), 0); m3.resize(1,1); - VERIFY_EVALUATION_COUNT( m3 = ((m1.block(r0,r0,r1,r1).template triangularView() * m2.block(c0,r0,c1,r1) )).lazy(), 0); + VERIFY_EVALUATION_COUNT( m3 = ((m1.block(r0,r0,r1,r1).template triangularView() * m2.block(r0,c0,r1,c1) )).lazy(), 0); } void test_product_notemporary() diff --git a/test/submatrices.cpp b/test/submatrices.cpp index d876f9593..fc7fd09ea 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -86,7 +86,7 @@ template void submatrices(const MatrixType& m) //check row() and col() VERIFY_IS_APPROX(m1.col(c1).transpose(), m1.transpose().row(c1)); - VERIFY_IS_APPROX(m1.col(c1).dot(square.row(r1)), (square.lazy() * m1.conjugate())(r1,c1)); + VERIFY_IS_APPROX(m1.col(c1).dot(square.row(r1)), (square.lazy() * m1.conjugate()).eval()(r1,c1)); //check operator(), both constant and non-constant, on row() and col() m1.row(r1) += s1 * m1.row(r2); m1.col(c1) += s1 * m1.col(c2); diff --git a/test/triangular.cpp b/test/triangular.cpp index 39430034d..1e0782523 100644 --- a/test/triangular.cpp +++ b/test/triangular.cpp @@ -72,13 +72,13 @@ template void triangular(const MatrixType& m) // test overloaded operator= m1.setZero(); - m1.template triangularView() = (m2.transpose() * m2).lazy(); - m3 = m2.transpose() * m2; + m1.template triangularView() = m2.transpose() + m2; + m3 = m2.transpose() + m2; VERIFY_IS_APPROX(m3.template triangularView().transpose().toDense(), m1); // test overloaded operator= m1.setZero(); - m1.template triangularView() = (m2.transpose() * m2).lazy(); + m1.template triangularView() = m2.transpose() + m2; VERIFY_IS_APPROX(m3.template triangularView().toDense(), m1); m1 = MatrixType::Random(rows, cols);