From fa55cf5ce7b318bffa580573cba06ed2a7c60cde Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 6 Aug 2009 11:19:36 +0200 Subject: [PATCH] fix compilation and segfault issues --- Eigen/src/Geometry/Homogeneous.h | 6 ++++++ Eigen/src/QR/QR.h | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index 0b154f47b..4a113cfc7 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -217,6 +217,9 @@ struct ei_homogeneous_left_product_impl,Lhs> : m_lhs(lhs), m_rhs(rhs) {} + inline int rows() const { m_lhs.rows(); } + inline int cols() const { m_rhs.cols(); } + template void evalTo(Dest& dst) const { // FIXME investigate how to allow lazy evaluation of this product when possible @@ -243,6 +246,9 @@ struct ei_homogeneous_right_product_impl,Rhs> : m_lhs(lhs), m_rhs(rhs) {} + inline int rows() const { m_lhs.rows(); } + inline int cols() const { m_rhs.cols(); } + template void evalTo(Dest& dst) const { // FIXME investigate how to allow lazy evaluation of this product when possible diff --git a/Eigen/src/QR/QR.h b/Eigen/src/QR/QR.h index ba41c0fc4..98ef4da25 100644 --- a/Eigen/src/QR/QR.h +++ b/Eigen/src/QR/QR.h @@ -120,6 +120,7 @@ void HouseholderQR::compute(const MatrixType& matrix) int rows = matrix.rows(); int cols = matrix.cols(); RealScalar eps2 = precision()*precision(); + Matrix temp(cols); for (int k = 0; k < cols; ++k) { @@ -161,8 +162,10 @@ void HouseholderQR::compute(const MatrixType& matrix) if (remainingCols>0) { m_qr.coeffRef(k,k) = Scalar(1); - m_qr.corner(BottomRight, remainingSize, remainingCols) -= ei_conj(h) * m_qr.col(k).end(remainingSize) - * (m_qr.col(k).end(remainingSize).adjoint() * m_qr.corner(BottomRight, remainingSize, remainingCols)); + temp.end(remainingCols) = (m_qr.col(k).end(remainingSize).adjoint() + * m_qr.corner(BottomRight, remainingSize, remainingCols)).lazy(); + m_qr.corner(BottomRight, remainingSize, remainingCols) -= (ei_conj(h) * m_qr.col(k).end(remainingSize) + * temp.end(remainingCols)).lazy(); m_qr.coeffRef(k,k) = beta; } } @@ -207,6 +210,7 @@ MatrixType HouseholderQR::matrixQ() const int rows = m_qr.rows(); int cols = m_qr.cols(); MatrixType res = MatrixType::Identity(rows, cols); + Matrix temp(cols); for (int k = cols-1; k >= 0; k--) { // to make easier the computation of the transformation, let's temporarily @@ -214,8 +218,9 @@ MatrixType HouseholderQR::matrixQ() const Scalar beta = m_qr.coeff(k,k); m_qr.const_cast_derived().coeffRef(k,k) = 1; int endLength = rows-k; - res.corner(BottomRight,endLength, cols-k) -= ((m_hCoeffs.coeff(k) * m_qr.col(k).end(endLength)) - * (m_qr.col(k).end(endLength).adjoint() * res.corner(BottomRight,endLength, cols-k)).lazy()).lazy(); + + temp.end(cols-k) = (m_qr.col(k).end(endLength).adjoint() * res.corner(BottomRight,endLength, cols-k)).lazy(); + res.corner(BottomRight,endLength, cols-k) -= ((m_hCoeffs.coeff(k) * m_qr.col(k).end(endLength)) * temp.end(cols-k)).lazy(); m_qr.const_cast_derived().coeffRef(k,k) = beta; } return res;