diff options
Diffstat (limited to 'Eigen/src/Core/ProductBase.h')
-rw-r--r-- | Eigen/src/Core/ProductBase.h | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index bc2a0f743..87702f4db 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -29,29 +29,32 @@ * \ingroup Core_Module * */ + +namespace internal { template<typename Derived, typename _Lhs, typename _Rhs> -struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > +struct traits<ProductBase<Derived,_Lhs,_Rhs> > { typedef MatrixXpr XprKind; - typedef typename ei_cleantype<_Lhs>::type Lhs; - typedef typename ei_cleantype<_Rhs>::type Rhs; - typedef typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; - typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageKind, - typename ei_traits<Rhs>::StorageKind>::ret StorageKind; - typedef typename ei_promote_index_type<typename ei_traits<Lhs>::Index, - typename ei_traits<Rhs>::Index>::type Index; + typedef typename cleantype<_Lhs>::type Lhs; + typedef typename cleantype<_Rhs>::type Rhs; + typedef typename scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar; + typedef typename promote_storage_type<typename traits<Lhs>::StorageKind, + typename traits<Rhs>::StorageKind>::ret StorageKind; + typedef typename promote_index_type<typename traits<Lhs>::Index, + typename traits<Rhs>::Index>::type Index; enum { - RowsAtCompileTime = ei_traits<Lhs>::RowsAtCompileTime, - ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime, - MaxRowsAtCompileTime = ei_traits<Lhs>::MaxRowsAtCompileTime, - MaxColsAtCompileTime = ei_traits<Rhs>::MaxColsAtCompileTime, + RowsAtCompileTime = traits<Lhs>::RowsAtCompileTime, + ColsAtCompileTime = traits<Rhs>::ColsAtCompileTime, + MaxRowsAtCompileTime = traits<Lhs>::MaxRowsAtCompileTime, + MaxColsAtCompileTime = traits<Rhs>::MaxColsAtCompileTime, Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0) | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, // Note that EvalBeforeNestingBit and NestByRefBit - // are not used in practice because ei_nested is overloaded for products + // are not used in practice because nested is overloaded for products CoeffReadCost = 0 // FIXME why is it needed ? }; }; +} #define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ typedef ProductBase<Derived, Lhs, Rhs > Base; \ @@ -77,16 +80,16 @@ class ProductBase : public MatrixBase<Derived> EIGEN_DENSE_PUBLIC_INTERFACE(ProductBase) protected: typedef typename Lhs::Nested LhsNested; - typedef typename ei_cleantype<LhsNested>::type _LhsNested; - typedef ei_blas_traits<_LhsNested> LhsBlasTraits; + typedef typename internal::cleantype<LhsNested>::type _LhsNested; + typedef internal::blas_traits<_LhsNested> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; - typedef typename ei_cleantype<ActualLhsType>::type _ActualLhsType; + typedef typename internal::cleantype<ActualLhsType>::type _ActualLhsType; typedef typename Rhs::Nested RhsNested; - typedef typename ei_cleantype<RhsNested>::type _RhsNested; - typedef ei_blas_traits<_RhsNested> RhsBlasTraits; + typedef typename internal::cleantype<RhsNested>::type _RhsNested; + typedef internal::blas_traits<_RhsNested> RhsBlasTraits; typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType; - typedef typename ei_cleantype<ActualRhsType>::type _ActualRhsType; + typedef typename internal::cleantype<ActualRhsType>::type _ActualRhsType; // Diagonal of a product: no need to evaluate the arguments because they are going to be evaluated only once typedef CoeffBasedProduct<LhsNested, RhsNested, 0> FullyLazyCoeffBaseProductType; @@ -98,7 +101,7 @@ class ProductBase : public MatrixBase<Derived> ProductBase(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) { - ei_assert(lhs.cols() == rhs.rows() + eigen_assert(lhs.cols() == rhs.rows() && "invalid matrix product" && "if you wanted a coeff-wise or a dot product use the respective explicit functions"); } @@ -157,11 +160,13 @@ class ProductBase : public MatrixBase<Derived> // here we need to overload the nested rule for products // such that the nested type is a const reference to a plain matrix +namespace internal { template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject> -struct ei_nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject> +struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject> { typedef PlainObject const& type; }; +} template<typename NestedProduct> class ScaledProduct; @@ -178,7 +183,7 @@ operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::Scalar x) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> -typename ei_enable_if<!ei_is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, +typename internal::enable_if<!internal::is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, const ScaledProduct<Derived> >::type operator*(const ProductBase<Derived,Lhs,Rhs>& prod, typename Derived::RealScalar x) { return ScaledProduct<Derived>(prod.derived(), x); } @@ -190,20 +195,21 @@ operator*(typename Derived::Scalar x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } template<typename Derived,typename Lhs,typename Rhs> -typename ei_enable_if<!ei_is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, +typename internal::enable_if<!internal::is_same_type<typename Derived::Scalar,typename Derived::RealScalar>::ret, const ScaledProduct<Derived> >::type operator*(typename Derived::RealScalar x,const ProductBase<Derived,Lhs,Rhs>& prod) { return ScaledProduct<Derived>(prod.derived(), x); } - +namespace internal { template<typename NestedProduct> -struct ei_traits<ScaledProduct<NestedProduct> > - : ei_traits<ProductBase<ScaledProduct<NestedProduct>, +struct traits<ScaledProduct<NestedProduct> > + : traits<ProductBase<ScaledProduct<NestedProduct>, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested> > { - typedef typename ei_traits<NestedProduct>::StorageKind StorageKind; + typedef typename traits<NestedProduct>::StorageKind StorageKind; }; +} template<typename NestedProduct> class ScaledProduct |