From c893917d65724aee15cad8c2d5d711d991c361c9 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 3 Sep 2009 10:45:32 +0200 Subject: [PATCH] Fix serious bug discovered with gcc 4.2 --- Eigen/src/Core/Product.h | 12 ++++++------ Eigen/src/Core/SolveTriangular.h | 4 ++-- Eigen/src/Core/products/GeneralMatrixMatrix.h | 6 +++--- Eigen/src/Core/products/SelfadjointMatrixVector.h | 4 ++-- Eigen/src/Core/products/SelfadjointProduct.h | 2 +- Eigen/src/Core/products/SelfadjointRank2Update.h | 2 +- Eigen/src/Core/products/TriangularMatrixVector.h | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index f4c8af6ea..5c6cee426 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -63,7 +63,7 @@ template struct ei_product_type Cols = Rhs::ColsAtCompileTime, Depth = EIGEN_ENUM_MIN(Lhs::ColsAtCompileTime,Rhs::RowsAtCompileTime) }; - + // the splitting into different lines of code here, introducing the _select enums and the typedef below, // is to work around an internal compiler error with gcc 4.1 and 4.2. private: @@ -73,7 +73,7 @@ private: depth_select = Depth>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ? Large : (Depth==1 ? 1 : Small) }; typedef ei_product_type_selector product_type_selector; - + public: enum { value = product_type_selector::ret @@ -144,7 +144,7 @@ struct ProductReturnType ***********************************************************************/ // FIXME : maybe the "inner product" could return a Scalar -// instead of a 1x1 matrix ?? +// 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 @@ -201,7 +201,7 @@ class GeneralProduct template void scaleAndAddTo(Dest& dest, Scalar alpha) const { - ei_outer_product_selector::run(*this, dest, alpha); + ei_outer_product_selector<(int(Dest::Flags)&RowMajorBit) ? RowMajor : ColMajor>::run(*this, dest, alpha); } }; @@ -259,7 +259,7 @@ class GeneralProduct template void scaleAndAddTo(Dest& dst, Scalar alpha) const { ei_assert(m_lhs.rows() == dst.rows() && m_rhs.cols() == dst.cols()); - ei_gemv_selector::ActualAccess)>::run(*this, dst, alpha); } }; @@ -339,7 +339,7 @@ template<> struct ei_gemv_selector Scalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs()) * RhsBlasTraits::extractScalarFactor(prod.rhs()); - + enum { DirectlyUseRhs = ((ei_packet_traits::size==1) || (_ActualRhsType::Flags&ActualPacketAccessBit)) && (!(_ActualRhsType::Flags & RowMajorBit)) diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index 810b08240..c7f0cd227 100644 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -30,7 +30,7 @@ template struct ei_triangular_solver_selector; @@ -157,7 +157,7 @@ struct ei_triangular_solver_selector + (Rhs::Flags&RowMajorBit) ? RowMajor : ColMajor> ::run(lhs.rows(), Side==OnTheLeft? rhs.cols() : rhs.rows(), &actualLhs.coeff(0,0), actualLhs.stride(), &rhs.coeffRef(0,0), rhs.stride()); } }; diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h index 8b3b13266..c4692b872 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -149,9 +149,9 @@ class GeneralProduct ei_general_matrix_matrix_product< Scalar, - (_ActualLhsType::Flags&RowMajorBit)?RowMajor:ColMajor, bool(LhsBlasTraits::NeedToConjugate), - (_ActualRhsType::Flags&RowMajorBit)?RowMajor:ColMajor, bool(RhsBlasTraits::NeedToConjugate), - (Dest::Flags&RowMajorBit)?RowMajor:ColMajor> + (_ActualLhsType::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(LhsBlasTraits::NeedToConjugate), + (_ActualRhsType::Flags&RowMajorBit) ? RowMajor : ColMajor, bool(RhsBlasTraits::NeedToConjugate), + (Dest::Flags&RowMajorBit) ? RowMajor : ColMajor> ::run( this->rows(), this->cols(), lhs.cols(), (const Scalar*)&(lhs.const_cast_derived().coeffRef(0,0)), lhs.stride(), diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index d5927307d..c27454bee 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -41,7 +41,7 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( const int PacketSize = sizeof(Packet)/sizeof(Scalar); enum { - IsRowMajor = StorageOrder==RowMajorBit ? 1 : 0, + IsRowMajor = StorageOrder==RowMajor ? 1 : 0, IsLower = UpLo == LowerTriangularBit ? 1 : 0, FirstTriangular = IsRowMajor == IsLower }; @@ -186,7 +186,7 @@ struct SelfadjointProductMatrix * RhsBlasTraits::extractScalarFactor(m_rhs); ei_assert(dst.stride()==1 && "not implemented yet"); - ei_product_selfadjoint_vector::Flags&RowMajorBit, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)> + ei_product_selfadjoint_vector::Flags&RowMajorBit) ? RowMajor : ColMajor, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)> ( lhs.rows(), // size &lhs.coeff(0,0), lhs.stride(), // lhs info diff --git a/Eigen/src/Core/products/SelfadjointProduct.h b/Eigen/src/Core/products/SelfadjointProduct.h index d3fc962d9..f9cdda637 100644 --- a/Eigen/src/Core/products/SelfadjointProduct.h +++ b/Eigen/src/Core/products/SelfadjointProduct.h @@ -132,7 +132,7 @@ SelfAdjointView& SelfAdjointView Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()); - enum { IsRowMajor = (ei_traits::Flags&RowMajorBit)?1:0 }; + enum { IsRowMajor = (ei_traits::Flags&RowMajorBit) ? 1 : 0 }; ei_selfadjoint_product& SelfAdjointView Scalar actualAlpha = alpha * UBlasTraits::extractScalarFactor(u.derived()) * VBlasTraits::extractScalarFactor(v.derived()); - enum { IsRowMajor = (ei_traits::Flags&RowMajorBit)?1:0 }; + enum { IsRowMajor = (ei_traits::Flags&RowMajorBit) ? 1 : 0 }; ei_selfadjoint_rank2_update_selector::ret>::type, typename ei_cleantype::ret>::type, diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h index 620b090b9..291177445 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector.h +++ b/Eigen/src/Core/products/TriangularMatrixVector.h @@ -145,7 +145,7 @@ struct TriangularProduct Mode, LhsBlasTraits::NeedToConjugate, RhsBlasTraits::NeedToConjugate, - ei_traits::Flags&RowMajorBit> + (int(ei_traits::Flags)&RowMajorBit) ? RowMajor : ColMajor> ::run(lhs,rhs,dst,actualAlpha); } };