diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index bf5ede1bc..fa64cb790 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -112,9 +112,6 @@ template inline Derived& MatrixBase ::lazyAssign(const MatrixBase& other) { -// std::cout << typeid(OtherDerived).name() << "\n"; -// std::cout << "lazyAssign = " << (Derived::Flags&VectorizableBit) << " " << (OtherDerived::Flags&VectorizableBit) << "\n"; -// std::cout << __PRETTY_FUNCTION__ << std::endl; ei_assignment_impl::execute(derived(),other.derived()); return derived(); } @@ -186,7 +183,6 @@ struct ei_assignment_impl const bool unroll = Derived::SizeAtCompileTime * OtherDerived::CoeffReadCost <= EIGEN_UNROLLING_LIMIT; if(unroll) { -// std::cout << "vectorized unrolled\n"; ei_matrix_assignment_packet_unroller =int(ei_packet_traits::size) @@ -201,7 +197,6 @@ struct ei_assignment_impl && (Derived::ColsAtCompileTime==Dynamic || Derived::ColsAtCompileTime%ei_packet_traits::size!=0)) { -// std::cout << "vectorized linear row major\n"; const int size = dst.rows() * dst.cols(); const int alignedSize = (size/ei_packet_traits::size)*ei_packet_traits::size; int index = 0; @@ -218,7 +213,6 @@ struct ei_assignment_impl } else { -// std::cout << "vectorized normal row major\n"; for(int i = 0; i < dst.rows(); i++) for(int j = 0; j < dst.cols(); j+=ei_packet_traits::size) dst.template writePacketCoeff(i, j, src.template packetCoeff(i, j)); @@ -230,7 +224,6 @@ struct ei_assignment_impl && ( Derived::RowsAtCompileTime==Dynamic || Derived::RowsAtCompileTime%ei_packet_traits::size!=0)) { -// std::cout << "vectorized linear col major\n"; const int size = dst.rows() * dst.cols(); const int alignedSize = (size/ei_packet_traits::size)*ei_packet_traits::size; int index = 0; @@ -247,7 +240,6 @@ struct ei_assignment_impl } else { -// std::cout << "vectorized normal col major\n"; for(int j = 0; j < dst.cols(); j++) for(int i = 0; i < dst.rows(); i+=ei_packet_traits::size) dst.template writePacketCoeff(i, j, src.template packetCoeff(i, j)); diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 2c8c73c88..1b62e0750 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -134,8 +134,6 @@ template struct ProductPacketCoeffImpl { * This class represents an expression of the product of two matrices. * It is the return type of the operator* between matrices, and most of the time * this is the only way it is used. - * - * \sa class Sum, class Difference */ template struct ei_product_eval_mode { @@ -162,6 +160,7 @@ template class ei_product_eval_to_column_major ei_traits::MaxColsAtCompileTime> type; }; +// as ei_nested, but evaluate to a column-major matrix if an evaluation is required template struct ei_product_nested_rhs { typedef typename ei_meta_if< @@ -176,51 +175,11 @@ template struct ei_product_nested_rhs >::ret type; }; -// template struct ei_product_nested_lhs -// { -// typedef typename ei_meta_if< -// ei_must_nest_by_value::ret && (int(ei_traits::Flags) & DirectAccessBit), -// T, -// typename ei_meta_if< -// int(ei_traits::Flags) & EvalBeforeNestingBit -// || (!(int(ei_traits::Flags) & DirectAccessBit)) -// || (n+1) * int(NumTraits::Scalar>::ReadCost) < (n-1) * int(T::CoeffReadCost), -// typename ei_eval::type, -// const T& -// >::ret -// >::ret type; -// }; - -template struct ei_product_copy_rhs -{ - typedef typename ei_meta_if< - (ei_traits::Flags & RowMajorBit) - || (!(ei_traits::Flags & DirectAccessBit)), - typename ei_product_eval_to_column_major::type, - const T& - >::ret type; -}; - -template struct ei_product_copy_lhs -{ - typedef typename ei_meta_if< - (!(int(ei_traits::Flags) & DirectAccessBit)), - typename ei_eval::type, - const T& - >::ret type; -}; - template struct ei_traits > { typedef typename Lhs::Scalar Scalar; - // the cache friendly product evals lhs once only - // FIXME what to do if we chose to dynamically call the normal product from the cache friendly one for small matrices ? - typedef /*typename ei_meta_if::type, - typename ei_nested::type/*>::ret*/ LhsNested; - - // NOTE that rhs must be ColumnMajor, so we might need a special nested type calculation + typedef typename ei_nested::type LhsNested; typedef typename ei_meta_if::type, typename ei_nested::type>::ret RhsNested; @@ -385,7 +344,6 @@ template inline Derived& MatrixBase::operator+=(const Flagged, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other) { - std::cout << "_cacheFriendlyEvalAndAdd\n"; other._expression()._cacheFriendlyEvalAndAdd(const_cast_derived()); return derived(); } @@ -398,92 +356,35 @@ inline Derived& MatrixBase::lazyAssign(const Product -struct ei_cache_friendly_selector +template struct ei_product_copy_rhs { - typedef Product Prod; - typedef typename Prod::_LhsNested _LhsNested; - typedef typename Prod::_RhsNested _RhsNested; - typedef typename Prod::Scalar Scalar; - static inline void eval(const Prod& product, DestDerived& res) - { - if ( product._rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - && product._cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - && product.m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - ) - { - res.setZero(); -// typename ei_product_copy_lhs<>::type - ei_cache_friendly_product( - product._rows(), product._cols(), product.m_lhs.cols(), - _LhsNested::Flags&RowMajorBit, &(product.m_lhs.const_cast_derived().coeffRef(0,0)), product.m_lhs.stride(), - _RhsNested::Flags&RowMajorBit, &(product.m_rhs.const_cast_derived().coeffRef(0,0)), product.m_rhs.stride(), - Prod::Flags&RowMajorBit, &(res.coeffRef(0,0)), res.stride() - ); - } - else - { - res = Product<_LhsNested,_RhsNested,NormalProduct>(product.m_lhs, product.m_rhs).lazy(); - } - } - - static inline void eval_and_add(const Prod& product, DestDerived& res) - { - if ( product._rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - && product._cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - && product.m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD - ) - { - ei_cache_friendly_product( - product._rows(), product._cols(), product.m_lhs.cols(), - _LhsNested::Flags&RowMajorBit, &(product.m_lhs.const_cast_derived().coeffRef(0,0)), product.m_lhs.stride(), - _RhsNested::Flags&RowMajorBit, &(product.m_rhs.const_cast_derived().coeffRef(0,0)), product.m_rhs.stride(), - Prod::Flags&RowMajorBit, &(res.coeffRef(0,0)), res.stride() - ); - } - else - { - res += Product<_LhsNested,_RhsNested,NormalProduct>(product.m_lhs, product.m_rhs).lazy(); - } - } + typedef typename ei_meta_if< + (ei_traits::Flags & RowMajorBit) + || (!(ei_traits::Flags & DirectAccessBit)), + typename ei_product_eval_to_column_major::type, + const T& + >::ret type; }; -template -struct ei_cache_friendly_selector +template struct ei_product_copy_lhs { - typedef Product Prod; - typedef typename Prod::_LhsNested _LhsNested; - typedef typename Prod::_RhsNested _RhsNested; - typedef typename Prod::Scalar Scalar; - static inline void eval(const Prod& product, DestDerived& res) - { - res = Product<_LhsNested,_RhsNested,NormalProduct>(product.m_lhs, product.m_rhs).lazy(); - } - - static inline void eval_and_add(const Prod& product, DestDerived& res) - { - res += Product<_LhsNested,_RhsNested,NormalProduct>(product.m_lhs, product.m_rhs).lazy(); - } + typedef typename ei_meta_if< + (!(int(ei_traits::Flags) & DirectAccessBit)), + typename ei_eval::type, + const T& + >::ret type; }; template template inline void Product::_cacheFriendlyEval(DestDerived& res) const { -// ei_cache_friendly_selector -// ::eval(*this, res); - if ( _rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD && _cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD && m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ) { res.setZero(); - - -// typedef typename ei_eval<_LhsNested>::type LhsCopy; -// typedef typename ei_product_eval_to_column_major<_RhsNested>::type RhsCopy; typedef typename ei_product_copy_lhs<_LhsNested>::type LhsCopy; typedef typename ei_unref::type _LhsCopy; typedef typename ei_product_copy_rhs<_RhsNested>::type RhsCopy; @@ -501,17 +402,12 @@ inline void Product::_cacheFriendlyEval(DestDerived& res) cons { res = Product<_LhsNested,_RhsNested,NormalProduct>(m_lhs, m_rhs).lazy(); } - } template template inline void Product::_cacheFriendlyEvalAndAdd(DestDerived& res) const { - std::cout << "_cacheFriendlyEvalAndAdd\n"; -// ei_cache_friendly_selector -// ::eval_and_add(*this, res); if ( _rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD && _cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD && m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 306144218..a31e73bb9 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -107,7 +107,7 @@ using Eigen::MatrixBase; template \ Derived& operator Op(const MatrixBase& other) \ { \ - return Eigen::MatrixBase::operator Op(other); \ + return Eigen::MatrixBase::operator Op(other.derived()); \ } \ Derived& operator Op(const Derived& other) \ { \