diff options
Diffstat (limited to 'Eigen/src/Core/util')
-rw-r--r-- | Eigen/src/Core/util/BlasUtil.h | 120 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 117 | ||||
-rw-r--r-- | Eigen/src/Core/util/Macros.h | 52 | ||||
-rw-r--r-- | Eigen/src/Core/util/Memory.h | 215 | ||||
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 188 | ||||
-rw-r--r-- | Eigen/src/Core/util/StaticAssert.h | 18 | ||||
-rw-r--r-- | Eigen/src/Core/util/XprHelper.h | 248 |
7 files changed, 500 insertions, 458 deletions
diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index 972814dc9..7c976a5bc 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -28,109 +28,111 @@ // This file contains many lightweight helper classes used to // implement and control fast level 2 and level 3 BLAS-like routines. +namespace internal { + // forward declarations template<typename LhsScalar, typename RhsScalar, typename Index, int mr, int nr, bool ConjugateLhs=false, bool ConjugateRhs=false> -struct ei_gebp_kernel; +struct gebp_kernel; template<typename Scalar, typename Index, int nr, int StorageOrder, bool Conjugate = false, bool PanelMode=false> -struct ei_gemm_pack_rhs; +struct gemm_pack_rhs; template<typename Scalar, typename Index, int Pack1, int Pack2, int StorageOrder, bool Conjugate = false, bool PanelMode = false> -struct ei_gemm_pack_lhs; +struct gemm_pack_lhs; template< typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, int RhsStorageOrder, bool ConjugateRhs, int ResStorageOrder> -struct ei_general_matrix_matrix_product; +struct general_matrix_matrix_product; template<typename Index, typename LhsScalar, int LhsStorageOrder, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs> -struct ei_general_matrix_vector_product; +struct general_matrix_vector_product; -template<bool Conjugate> struct ei_conj_if; +template<bool Conjugate> struct conj_if; -template<> struct ei_conj_if<true> { +template<> struct conj_if<true> { template<typename T> - inline T operator()(const T& x) { return ei_conj(x); } + inline T operator()(const T& x) { return conj(x); } }; -template<> struct ei_conj_if<false> { +template<> struct conj_if<false> { template<typename T> inline const T& operator()(const T& x) { return x; } }; -template<typename Scalar> struct ei_conj_helper<Scalar,Scalar,false,false> +template<typename Scalar> struct conj_helper<Scalar,Scalar,false,false> { - EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return ei_pmadd(x,y,c); } - EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const { return ei_pmul(x,y); } + EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return internal::pmadd(x,y,c); } + EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const { return internal::pmul(x,y); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, false,true> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, false,true> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) + ei_imag(x)*ei_imag(y), ei_imag(x)*ei_real(y) - ei_real(x)*ei_imag(y)); } + { return Scalar(real(x)*real(y) + imag(x)*imag(y), imag(x)*real(y) - real(x)*imag(y)); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,false> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,false> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) + ei_imag(x)*ei_imag(y), ei_real(x)*ei_imag(y) - ei_imag(x)*ei_real(y)); } + { return Scalar(real(x)*real(y) + imag(x)*imag(y), real(x)*imag(y) - imag(x)*real(y)); } }; -template<typename RealScalar> struct ei_conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,true> +template<typename RealScalar> struct conj_helper<std::complex<RealScalar>, std::complex<RealScalar>, true,true> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const Scalar& y, const Scalar& c) const { return c + pmul(x,y); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const Scalar& y) const - { return Scalar(ei_real(x)*ei_real(y) - ei_imag(x)*ei_imag(y), - ei_real(x)*ei_imag(y) - ei_imag(x)*ei_real(y)); } + { return Scalar(real(x)*real(y) - imag(x)*imag(y), - real(x)*imag(y) - imag(x)*real(y)); } }; -template<typename RealScalar,bool Conj> struct ei_conj_helper<std::complex<RealScalar>, RealScalar, Conj,false> +template<typename RealScalar,bool Conj> struct conj_helper<std::complex<RealScalar>, RealScalar, Conj,false> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const Scalar& x, const RealScalar& y, const Scalar& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Scalar pmul(const Scalar& x, const RealScalar& y) const - { return ei_conj_if<Conj>()(x)*y; } + { return conj_if<Conj>()(x)*y; } }; -template<typename RealScalar,bool Conj> struct ei_conj_helper<RealScalar, std::complex<RealScalar>, false,Conj> +template<typename RealScalar,bool Conj> struct conj_helper<RealScalar, std::complex<RealScalar>, false,Conj> { typedef std::complex<RealScalar> Scalar; EIGEN_STRONG_INLINE Scalar pmadd(const RealScalar& x, const Scalar& y, const Scalar& c) const - { return ei_padd(c, pmul(x,y)); } + { return padd(c, pmul(x,y)); } EIGEN_STRONG_INLINE Scalar pmul(const RealScalar& x, const Scalar& y) const - { return x*ei_conj_if<Conj>()(y); } + { return x*conj_if<Conj>()(y); } }; -template<typename From,typename To> struct ei_get_factor { +template<typename From,typename To> struct get_factor { EIGEN_STRONG_INLINE static To run(const From& x) { return x; } }; -template<typename Scalar> struct ei_get_factor<Scalar,typename NumTraits<Scalar>::Real> { - EIGEN_STRONG_INLINE static typename NumTraits<Scalar>::Real run(const Scalar& x) { return ei_real(x); } +template<typename Scalar> struct get_factor<Scalar,typename NumTraits<Scalar>::Real> { + EIGEN_STRONG_INLINE static typename NumTraits<Scalar>::Real run(const Scalar& x) { return real(x); } }; // Lightweight helper class to access matrix coefficients. // Yes, this is somehow redundant with Map<>, but this version is much much lighter, // and so I hope better compilation performance (time and code quality). template<typename Scalar, typename Index, int StorageOrder> -class ei_blas_data_mapper +class blas_data_mapper { public: - ei_blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {} + blas_data_mapper(Scalar* data, Index stride) : m_data(data), m_stride(stride) {} EIGEN_STRONG_INLINE Scalar& operator()(Index i, Index j) { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; } protected: @@ -140,10 +142,10 @@ class ei_blas_data_mapper // lightweight helper class to access matrix coefficients (const version) template<typename Scalar, typename Index, int StorageOrder> -class ei_const_blas_data_mapper +class const_blas_data_mapper { public: - ei_const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {} + const_blas_data_mapper(const Scalar* data, Index stride) : m_data(data), m_stride(stride) {} EIGEN_STRONG_INLINE const Scalar& operator()(Index i, Index j) const { return m_data[StorageOrder==RowMajor ? j + i*m_stride : i + j*m_stride]; } protected: @@ -155,9 +157,9 @@ class ei_const_blas_data_mapper /* Helper class to analyze the factors of a Product expression. * In particular it allows to pop out operator-, scalar multiples, * and conjugate */ -template<typename XprType> struct ei_blas_traits +template<typename XprType> struct blas_traits { - typedef typename ei_traits<XprType>::Scalar Scalar; + typedef typename traits<XprType>::Scalar Scalar; typedef const XprType& ExtractType; typedef XprType _ExtractType; enum { @@ -168,10 +170,10 @@ template<typename XprType> struct ei_blas_traits && ( /* Uncomment this when the low-level matrix-vector product functions support strided vectors bool(XprType::IsVectorAtCompileTime) || */ - int(ei_inner_stride_at_compile_time<XprType>::ret) == 1) + int(inner_stride_at_compile_time<XprType>::ret) == 1) ) ? 1 : 0 }; - typedef typename ei_meta_if<bool(HasUsableDirectAccess), + typedef typename meta_if<bool(HasUsableDirectAccess), ExtractType, typename _ExtractType::PlainObject >::ret DirectLinearAccessType; @@ -181,11 +183,11 @@ template<typename XprType> struct ei_blas_traits // pop conjugate template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; enum { @@ -193,16 +195,16 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, NestedXpr> > NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex }; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } - static inline Scalar extractScalarFactor(const XprType& x) { return ei_conj(Base::extractScalarFactor(x.nestedExpression())); } + static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); } }; // pop scalar multiple template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) @@ -211,11 +213,11 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, NestedXpr> > // pop opposite template<typename Scalar, typename NestedXpr> -struct ei_blas_traits<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> > + : blas_traits<NestedXpr> { - typedef ei_blas_traits<NestedXpr> Base; - typedef CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> XprType; + typedef blas_traits<NestedXpr> Base; + typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType; typedef typename Base::ExtractType ExtractType; static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); } static inline Scalar extractScalarFactor(const XprType& x) @@ -224,15 +226,15 @@ struct ei_blas_traits<CwiseUnaryOp<ei_scalar_opposite_op<Scalar>, NestedXpr> > // pop/push transpose template<typename NestedXpr> -struct ei_blas_traits<Transpose<NestedXpr> > - : ei_blas_traits<NestedXpr> +struct blas_traits<Transpose<NestedXpr> > + : blas_traits<NestedXpr> { typedef typename NestedXpr::Scalar Scalar; - typedef ei_blas_traits<NestedXpr> Base; + typedef blas_traits<NestedXpr> Base; typedef Transpose<NestedXpr> XprType; typedef Transpose<typename Base::_ExtractType> ExtractType; typedef Transpose<typename Base::_ExtractType> _ExtractType; - typedef typename ei_meta_if<bool(Base::HasUsableDirectAccess), + typedef typename meta_if<bool(Base::HasUsableDirectAccess), ExtractType, typename ExtractType::PlainObject >::ret DirectLinearAccessType; @@ -243,22 +245,24 @@ struct ei_blas_traits<Transpose<NestedXpr> > static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); } }; -template<typename T, bool HasUsableDirectAccess=ei_blas_traits<T>::HasUsableDirectAccess> -struct ei_extract_data_selector { +template<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess> +struct extract_data_selector { static const typename T::Scalar* run(const T& m) { - return &ei_blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data() + return &blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data() } }; template<typename T> -struct ei_extract_data_selector<T,false> { +struct extract_data_selector<T,false> { static typename T::Scalar* run(const T&) { return 0; } }; -template<typename T> const typename T::Scalar* ei_extract_data(const T& m) +template<typename T> const typename T::Scalar* extract_data(const T& m) { - return ei_extract_data_selector<T>::run(m); + return extract_data_selector<T>::run(m); } +} // end namespace internal + #endif // EIGEN_BLASUTIL_H diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 4b1740c82..0d0b905ea 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -26,19 +26,22 @@ #ifndef EIGEN_FORWARDDECLARATIONS_H #define EIGEN_FORWARDDECLARATIONS_H -template<typename T> struct ei_traits; -template<typename T> struct NumTraits; +namespace internal { +template<typename T> struct traits; -template<typename Derived> struct ei_has_direct_access +template<typename Derived> struct has_direct_access { - enum { ret = (ei_traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 }; + enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 }; }; +} // end namespace internal + +template<typename T> struct NumTraits; template<typename Derived> struct EigenBase; template<typename Derived> class DenseBase; template<typename Derived, - AccessorLevels Level = (ei_traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors - : (ei_traits<Derived>::Flags & LvalueBit) ? WriteAccessors + AccessorLevels Level = (internal::traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors + : (internal::traits<Derived>::Flags & LvalueBit) ? WriteAccessors : ReadOnlyAccessors> class DenseCoeffsBase; @@ -61,7 +64,7 @@ template<typename ExpressionType> class ForceAlignedAccess; template<typename ExpressionType> class SwapWrapper; template<typename XprType, int BlockRows=Dynamic, int BlockCols=Dynamic, bool InnerPanel = false, - bool HasDirectAccess = ei_has_direct_access<XprType>::ret> class Block; + bool HasDirectAccess = internal::has_direct_access<XprType>::ret> class Block; template<typename MatrixType, int Size=Dynamic> class VectorBlock; template<typename MatrixType> class Transpose; @@ -95,58 +98,67 @@ template<typename MatrixType> struct CommaInitializer; template<typename Derived> class ReturnByValue; template<typename ExpressionType> class ArrayWrapper; -template<typename DecompositionType, typename Rhs> struct ei_solve_retval_base; -template<typename DecompositionType, typename Rhs> struct ei_solve_retval; -template<typename DecompositionType> struct ei_kernel_retval_base; -template<typename DecompositionType> struct ei_kernel_retval; -template<typename DecompositionType> struct ei_image_retval_base; -template<typename DecompositionType> struct ei_image_retval; +namespace internal { +template<typename DecompositionType, typename Rhs> struct solve_retval_base; +template<typename DecompositionType, typename Rhs> struct solve_retval; +template<typename DecompositionType> struct kernel_retval_base; +template<typename DecompositionType> struct kernel_retval; +template<typename DecompositionType> struct image_retval_base; +template<typename DecompositionType> struct image_retval; +} // end namespace internal template<typename _Scalar, int Rows=Dynamic, int Cols=Dynamic, int Supers=Dynamic, int Subs=Dynamic, int Options=0> class BandMatrix; -template<typename Lhs, typename Rhs> struct ei_product_type; +namespace internal { +template<typename Lhs, typename Rhs> struct product_type; +} + template<typename Lhs, typename Rhs, - int ProductType = ei_product_type<Lhs,Rhs>::value> + int ProductType = internal::product_type<Lhs,Rhs>::value> struct ProductReturnType; // this is a workaround for sun CC template<typename Lhs, typename Rhs> struct LazyProductReturnType; +namespace internal { + // Provides scalar/packet-wise product and product with accumulation // with optional conjugation of the arguments. -template<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct ei_conj_helper; - -template<typename Scalar> struct ei_scalar_sum_op; -template<typename Scalar> struct ei_scalar_difference_op; -template<typename Scalar> struct ei_scalar_conj_product_op; -template<typename Scalar> struct ei_scalar_quotient_op; -template<typename Scalar> struct ei_scalar_opposite_op; -template<typename Scalar> struct ei_scalar_conjugate_op; -template<typename Scalar> struct ei_scalar_real_op; -template<typename Scalar> struct ei_scalar_imag_op; -template<typename Scalar> struct ei_scalar_abs_op; -template<typename Scalar> struct ei_scalar_abs2_op; -template<typename Scalar> struct ei_scalar_sqrt_op; -template<typename Scalar> struct ei_scalar_exp_op; -template<typename Scalar> struct ei_scalar_log_op; -template<typename Scalar> struct ei_scalar_cos_op; -template<typename Scalar> struct ei_scalar_sin_op; -template<typename Scalar> struct ei_scalar_pow_op; -template<typename Scalar> struct ei_scalar_inverse_op; -template<typename Scalar> struct ei_scalar_square_op; -template<typename Scalar> struct ei_scalar_cube_op; -template<typename Scalar, typename NewType> struct ei_scalar_cast_op; -template<typename Scalar> struct ei_scalar_multiple_op; -template<typename Scalar> struct ei_scalar_quotient1_op; -template<typename Scalar> struct ei_scalar_min_op; -template<typename Scalar> struct ei_scalar_max_op; -template<typename Scalar> struct ei_scalar_random_op; -template<typename Scalar> struct ei_scalar_add_op; -template<typename Scalar> struct ei_scalar_constant_op; -template<typename Scalar> struct ei_scalar_identity_op; - -template<typename LhsScalar,typename RhsScalar=LhsScalar> struct ei_scalar_product_op; -template<typename LhsScalar,typename RhsScalar> struct ei_scalar_multiple2_op; +template<typename LhsScalar, typename RhsScalar, bool ConjLhs=false, bool ConjRhs=false> struct conj_helper; + +template<typename Scalar> struct scalar_sum_op; +template<typename Scalar> struct scalar_difference_op; +template<typename Scalar> struct scalar_conj_product_op; +template<typename Scalar> struct scalar_quotient_op; +template<typename Scalar> struct scalar_opposite_op; +template<typename Scalar> struct scalar_conjugate_op; +template<typename Scalar> struct scalar_real_op; +template<typename Scalar> struct scalar_imag_op; +template<typename Scalar> struct scalar_abs_op; +template<typename Scalar> struct scalar_abs2_op; +template<typename Scalar> struct scalar_sqrt_op; +template<typename Scalar> struct scalar_exp_op; +template<typename Scalar> struct scalar_log_op; +template<typename Scalar> struct scalar_cos_op; +template<typename Scalar> struct scalar_sin_op; +template<typename Scalar> struct scalar_pow_op; +template<typename Scalar> struct scalar_inverse_op; +template<typename Scalar> struct scalar_square_op; +template<typename Scalar> struct scalar_cube_op; +template<typename Scalar, typename NewType> struct scalar_cast_op; +template<typename Scalar> struct scalar_multiple_op; +template<typename Scalar> struct scalar_quotient1_op; +template<typename Scalar> struct scalar_min_op; +template<typename Scalar> struct scalar_max_op; +template<typename Scalar> struct scalar_random_op; +template<typename Scalar> struct scalar_add_op; +template<typename Scalar> struct scalar_constant_op; +template<typename Scalar> struct scalar_identity_op; + +template<typename LhsScalar,typename RhsScalar=LhsScalar> struct scalar_product_op; +template<typename LhsScalar,typename RhsScalar> struct scalar_multiple2_op; + +} // end namespace internal struct IOFormat; @@ -165,7 +177,9 @@ template<typename MatrixType, int Direction = BothDirections> class Reverse; template<typename MatrixType> class FullPivLU; template<typename MatrixType> class PartialPivLU; -template<typename MatrixType> struct ei_inverse_impl; +namespace internal { +template<typename MatrixType> struct inverse_impl; +} template<typename MatrixType> class HouseholderQR; template<typename MatrixType> class ColPivHouseholderQR; template<typename MatrixType> class FullPivHouseholderQR; @@ -192,12 +206,15 @@ template<typename MatrixType,int Direction> class Homogeneous; // MatrixFunctions module template<typename Derived> struct MatrixExponentialReturnValue; template<typename Derived> class MatrixFunctionReturnValue; + +namespace internal { template <typename Scalar> -struct ei_stem_function +struct stem_function { typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar; typedef ComplexScalar type(ComplexScalar, int); }; +} #ifdef EIGEN2_SUPPORT diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 2bf509f8f..0cea94852 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -128,18 +128,18 @@ # endif #endif -#ifndef ei_assert +#ifndef eigen_assert #ifdef EIGEN_NO_DEBUG -#define ei_assert(x) +#define eigen_assert(x) #else -#define ei_assert(x) assert(x) +#define eigen_assert(x) assert(x) #endif #endif #ifdef EIGEN_INTERNAL_DEBUGGING -#define ei_internal_assert(x) ei_assert(x) +#define eigen_internal_assert(x) eigen_assert(x) #else -#define ei_internal_assert(x) +#define eigen_internal_assert(x) #endif #ifdef EIGEN_NO_DEBUG @@ -295,35 +295,35 @@ **/ #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ + typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::ei_nested<Derived>::type Nested; \ - typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::ei_traits<Derived>::Index Index; \ - enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \ - Flags = Eigen::ei_traits<Derived>::Flags, \ - CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \ + typedef typename Eigen::internal::nested<Derived>::type Nested; \ + typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ + typedef typename Eigen::internal::traits<Derived>::Index Index; \ + enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ + ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ + Flags = Eigen::internal::traits<Derived>::Flags, \ + CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ + typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ typedef typename Base::PacketScalar PacketScalar; \ typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::ei_nested<Derived>::type Nested; \ - typedef typename Eigen::ei_traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::ei_traits<Derived>::Index Index; \ - enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \ - MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \ - MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \ - Flags = Eigen::ei_traits<Derived>::Flags, \ - CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \ + typedef typename Eigen::internal::nested<Derived>::type Nested; \ + typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ + typedef typename Eigen::internal::traits<Derived>::Index Index; \ + enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ + ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ + MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \ + MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \ + Flags = Eigen::internal::traits<Derived>::Flags, \ + CoeffReadCost = Eigen::internal::traits<Derived>::CoeffReadCost, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ @@ -371,9 +371,9 @@ // the expression type of a cwise product #define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \ CwiseBinaryOp< \ - ei_scalar_product_op< \ - typename ei_traits<LHS>::Scalar, \ - typename ei_traits<RHS>::Scalar \ + internal::scalar_product_op< \ + typename internal::traits<LHS>::Scalar, \ + typename internal::traits<RHS>::Scalar \ >, \ LHS, \ RHS \ diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 362ccf18e..51ec78f1a 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -80,6 +80,8 @@ #define EIGEN_HAS_MM_MALLOC 0 #endif +namespace internal { + /***************************************************************************** *** Implementation of handmade aligned functions *** *****************************************************************************/ @@ -89,7 +91,7 @@ /** \internal Like malloc, but the returned pointer is guaranteed to be 16-byte aligned. * Fast, but wastes 16 additional bytes of memory. Does not throw any exception. */ -inline void* ei_handmade_aligned_malloc(size_t size) +inline void* handmade_aligned_malloc(size_t size) { void *original = std::malloc(size+16); if (original == 0) return 0; @@ -98,8 +100,8 @@ inline void* ei_handmade_aligned_malloc(size_t size) return aligned; } -/** \internal Frees memory allocated with ei_handmade_aligned_malloc */ -inline void ei_handmade_aligned_free(void *ptr) +/** \internal Frees memory allocated with handmade_aligned_malloc */ +inline void handmade_aligned_free(void *ptr) { if (ptr) std::free(*(reinterpret_cast<void**>(ptr) - 1)); } @@ -109,9 +111,9 @@ inline void ei_handmade_aligned_free(void *ptr) * Since we know that our handmade version is based on std::realloc * we can use std::realloc to implement efficient reallocation. */ -inline void* ei_handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) +inline void* handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) { - if (ptr == 0) return ei_handmade_aligned_malloc(size); + if (ptr == 0) return handmade_aligned_malloc(size); void *original = *(reinterpret_cast<void**>(ptr) - 1); original = std::realloc(original,size+16); if (original == 0) return 0; @@ -124,26 +126,26 @@ inline void* ei_handmade_aligned_realloc(void* ptr, size_t size, size_t = 0) *** Implementation of generic aligned realloc (when no realloc can be used)*** *****************************************************************************/ -void* ei_aligned_malloc(size_t size); -void ei_aligned_free(void *ptr); +void* aligned_malloc(size_t size); +void aligned_free(void *ptr); /** \internal * \brief Reallocates aligned memory. * Allows reallocation with aligned ptr types. This implementation will * always create a new memory chunk and copy the old data. */ -inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) +inline void* generic_aligned_realloc(void* ptr, size_t size, size_t old_size) { if (ptr==0) - return ei_aligned_malloc(size); + return aligned_malloc(size); if (size==0) { - ei_aligned_free(ptr); + aligned_free(ptr); return 0; } - void* newptr = ei_aligned_malloc(size); + void* newptr = aligned_malloc(size); if (newptr == 0) { #ifdef EIGEN_HAS_ERRNO @@ -155,7 +157,7 @@ inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) if (ptr != 0) { std::memcpy(newptr, ptr, std::min(size,old_size)); - ei_aligned_free(ptr); + aligned_free(ptr); } return newptr; @@ -168,10 +170,10 @@ inline void* ei_generic_aligned_realloc(void* ptr, size_t size, size_t old_size) /** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 bytes alignment. * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. */ -inline void* ei_aligned_malloc(size_t size) +inline void* aligned_malloc(size_t size) { #ifdef EIGEN_NO_MALLOC - ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); + eigen_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); #endif void *result; @@ -186,7 +188,7 @@ inline void* ei_aligned_malloc(size_t size) #elif (defined _MSC_VER) result = _aligned_malloc(size, 16); #else - result = ei_handmade_aligned_malloc(size); + result = handmade_aligned_malloc(size); #endif #ifdef EIGEN_EXCEPTIONS @@ -196,8 +198,8 @@ inline void* ei_aligned_malloc(size_t size) return result; } -/** \internal Frees memory allocated with ei_aligned_malloc. */ -inline void ei_aligned_free(void *ptr) +/** \internal Frees memory allocated with aligned_malloc. */ +inline void aligned_free(void *ptr) { #if !EIGEN_ALIGN std::free(ptr); @@ -210,7 +212,7 @@ inline void ei_aligned_free(void *ptr) #elif defined(_MSC_VER) _aligned_free(ptr); #else - ei_handmade_aligned_free(ptr); + handmade_aligned_free(ptr); #endif } @@ -219,7 +221,7 @@ inline void ei_aligned_free(void *ptr) * \brief Reallocates an aligned block of memory. * \throws std::bad_alloc if EIGEN_EXCEPTIONS are defined. **/ -inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) +inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) { EIGEN_UNUSED_VARIABLE(old_size); @@ -229,7 +231,7 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) #elif EIGEN_MALLOC_ALREADY_ALIGNED result = std::realloc(ptr,new_size); #elif EIGEN_HAS_POSIX_MEMALIGN - result = ei_generic_aligned_realloc(ptr,new_size,old_size); + result = generic_aligned_realloc(ptr,new_size,old_size); #elif EIGEN_HAS_MM_MALLOC // The defined(_mm_free) is just here to verify that this MSVC version // implements _mm_malloc/_mm_free based on the corresponding _aligned_ @@ -237,12 +239,12 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) #if defined(_MSC_VER) && defined(_mm_free) result = _aligned_realloc(ptr,new_size,16); #else - result = ei_generic_aligned_realloc(ptr,new_size,old_size); + result = generic_aligned_realloc(ptr,new_size,old_size); #endif #elif defined(_MSC_VER) result = _aligned_realloc(ptr,new_size,16); #else - result = ei_handmade_aligned_realloc(ptr,new_size,old_size); + result = handmade_aligned_realloc(ptr,new_size,old_size); #endif #ifdef EIGEN_EXCEPTIONS @@ -259,15 +261,15 @@ inline void* ei_aligned_realloc(void *ptr, size_t new_size, size_t old_size) /** \internal Allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned. * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. */ -template<bool Align> inline void* ei_conditional_aligned_malloc(size_t size) +template<bool Align> inline void* conditional_aligned_malloc(size_t size) { - return ei_aligned_malloc(size); + return aligned_malloc(size); } -template<> inline void* ei_conditional_aligned_malloc<false>(size_t size) +template<> inline void* conditional_aligned_malloc<false>(size_t size) { #ifdef EIGEN_NO_MALLOC - ei_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); + eigen_assert(false && "heap allocation is forbidden (EIGEN_NO_MALLOC is defined)"); #endif void *result = std::malloc(size); @@ -277,23 +279,23 @@ template<> inline void* ei_conditional_aligned_malloc<false>(size_t size) return result; } -/** \internal Frees memory allocated with ei_conditional_aligned_malloc */ -template<bool Align> inline void ei_conditional_aligned_free(void *ptr) +/** \internal Frees memory allocated with conditional_aligned_malloc */ +template<bool Align> inline void conditional_aligned_free(void *ptr) { - ei_aligned_free(ptr); + aligned_free(ptr); } -template<> inline void ei_conditional_aligned_free<false>(void *ptr) +template<> inline void conditional_aligned_free<false>(void *ptr) { std::free(ptr); } -template<bool Align> inline void* ei_conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) +template<bool Align> inline void* conditional_aligned_realloc(void* ptr, size_t new_size, size_t old_size) { - return ei_aligned_realloc(ptr, new_size, old_size); + return aligned_realloc(ptr, new_size, old_size); } -template<> inline void* ei_conditional_aligned_realloc<false>(void* ptr, size_t new_size, size_t) +template<> inline void* conditional_aligned_realloc<false>(void* ptr, size_t new_size, size_t) { return std::realloc(ptr, new_size); } @@ -305,7 +307,7 @@ template<> inline void* ei_conditional_aligned_realloc<false>(void* ptr, size_t /** \internal Constructs the elements of an array. * The \a size parameter tells on how many objects to call the constructor of T. */ -template<typename T> inline T* ei_construct_elements_of_array(T *ptr, size_t size) +template<typename T> inline T* construct_elements_of_array(T *ptr, size_t size) { for (size_t i=0; i < size; ++i) ::new (ptr + i) T; return ptr; @@ -314,7 +316,7 @@ template<typename T> inline T* ei_construct_elements_of_array(T *ptr, size_t siz /** \internal Destructs the elements of an array. * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T> inline void ei_destruct_elements_of_array(T *ptr, size_t size) +template<typename T> inline void destruct_elements_of_array(T *ptr, size_t size) { // always destruct an array starting from the end. if(ptr) @@ -329,41 +331,41 @@ template<typename T> inline void ei_destruct_elements_of_array(T *ptr, size_t si * On allocation error, the returned pointer is undefined, but if exceptions are enabled then a std::bad_alloc is thrown. * The default constructor of T is called. */ -template<typename T> inline T* ei_aligned_new(size_t size) +template<typename T> inline T* aligned_new(size_t size) { - T *result = reinterpret_cast<T*>(ei_aligned_malloc(sizeof(T)*size)); - return ei_construct_elements_of_array(result, size); + T *result = reinterpret_cast<T*>(aligned_malloc(sizeof(T)*size)); + return construct_elements_of_array(result, size); } -template<typename T, bool Align> inline T* ei_conditional_aligned_new(size_t size) +template<typename T, bool Align> inline T* conditional_aligned_new(size_t size) { - T *result = reinterpret_cast<T*>(ei_conditional_aligned_malloc<Align>(sizeof(T)*size)); - return ei_construct_elements_of_array(result, size); + T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size)); + return construct_elements_of_array(result, size); } -/** \internal Deletes objects constructed with ei_aligned_new +/** \internal Deletes objects constructed with aligned_new * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T> inline void ei_aligned_delete(T *ptr, size_t size) +template<typename T> inline void aligned_delete(T *ptr, size_t size) { - ei_destruct_elements_of_array<T>(ptr, size); - ei_aligned_free(ptr); + destruct_elements_of_array<T>(ptr, size); + aligned_free(ptr); } -/** \internal Deletes objects constructed with ei_conditional_aligned_new +/** \internal Deletes objects constructed with conditional_aligned_new * The \a size parameters tells on how many objects to call the destructor of T. */ -template<typename T, bool Align> inline void ei_conditional_aligned_delete(T *ptr, size_t size) +template<typename T, bool Align> inline void conditional_aligned_delete(T *ptr, size_t size) { - ei_destruct_elements_of_array<T>(ptr, size); - ei_conditional_aligned_free<Align>(ptr); + destruct_elements_of_array<T>(ptr, size); + conditional_aligned_free<Align>(ptr); } -template<typename T, bool Align> inline T* ei_conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) +template<typename T, bool Align> inline T* conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) { - T *result = reinterpret_cast<T*>(ei_conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size)); + T *result = reinterpret_cast<T*>(conditional_aligned_realloc<Align>(reinterpret_cast<void*>(pts), sizeof(T)*new_size, sizeof(T)*old_size)); if (new_size > old_size) - ei_construct_elements_of_array(result+old_size, new_size-old_size); + construct_elements_of_array(result+old_size, new_size-old_size); return result; } @@ -383,13 +385,13 @@ template<typename T, bool Align> inline T* ei_conditional_aligned_realloc_new(T* * other hand, we do not assume that the array address is a multiple of sizeof(Scalar), as that fails for * example with Scalar=double on certain 32-bit platforms, see bug #79. * - * There is also the variant ei_first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h. + * There is also the variant first_aligned(const MatrixBase&) defined in DenseCoeffsBase.h. */ template<typename Scalar, typename Index> -inline static Index ei_first_aligned(const Scalar* array, Index size) +inline static Index first_aligned(const Scalar* array, Index size) { - typedef typename ei_packet_traits<Scalar>::type Packet; - enum { PacketSize = ei_packet_traits<Scalar>::size, + typedef typename packet_traits<Scalar>::type Packet; + enum { PacketSize = packet_traits<Scalar>::size, PacketAlignedMask = PacketSize-1 }; @@ -412,6 +414,8 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) } } +} // end namespace internal + /***************************************************************************** *** Implementation of runtime stack allocation (falling back to malloc) *** *****************************************************************************/ @@ -431,20 +435,20 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) #if (defined __linux__) #define ei_aligned_stack_alloc(SIZE) (SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) \ ? alloca(SIZE) \ - : ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) ei_aligned_free(PTR) + : Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) Eigen::internal::aligned_free(PTR) #elif defined(_MSC_VER) #define ei_aligned_stack_alloc(SIZE) (SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) \ ? _alloca(SIZE) \ - : ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) ei_aligned_free(PTR) + : Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) if(SIZE>EIGEN_STACK_ALLOCATION_LIMIT) Eigen::internal::aligned_free(PTR) #else - #define ei_aligned_stack_alloc(SIZE) ei_aligned_malloc(SIZE) - #define ei_aligned_stack_free(PTR,SIZE) ei_aligned_free(PTR) + #define ei_aligned_stack_alloc(SIZE) Eigen::internal::aligned_malloc(SIZE) + #define ei_aligned_stack_free(PTR,SIZE) Eigen::internal::aligned_free(PTR) #endif -#define ei_aligned_stack_new(TYPE,SIZE) ei_construct_elements_of_array(reinterpret_cast<TYPE*>(ei_aligned_stack_alloc(sizeof(TYPE)*SIZE)), SIZE) -#define ei_aligned_stack_delete(TYPE,PTR,SIZE) do {ei_destruct_elements_of_array<TYPE>(PTR, SIZE); \ +#define ei_aligned_stack_new(TYPE,SIZE) Eigen::internal::construct_elements_of_array(reinterpret_cast<TYPE*>(ei_aligned_stack_alloc(sizeof(TYPE)*SIZE)), SIZE) +#define ei_aligned_stack_delete(TYPE,PTR,SIZE) do {Eigen::internal::destruct_elements_of_array<TYPE>(PTR, SIZE); \ ei_aligned_stack_free(PTR,sizeof(TYPE)*SIZE);} while(0) @@ -456,26 +460,26 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) #ifdef EIGEN_EXCEPTIONS #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void* operator new(size_t size, const std::nothrow_t&) throw() { \ - try { return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); } \ + try { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \ catch (...) { return 0; } \ return 0; \ } #else #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void* operator new(size_t size, const std::nothrow_t&) throw() { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } #endif #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) \ void *operator new(size_t size) { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } \ void *operator new[](size_t size) { \ - return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \ + return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); \ } \ - void operator delete(void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \ - void operator delete[](void * ptr) throw() { Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ /* in-place new and delete. since (at least afaik) there is no actual */ \ /* memory allocated we can safely let the default implementation handle */ \ /* this particular case. */ \ @@ -484,9 +488,9 @@ inline static Index ei_first_aligned(const Scalar* array, Index size) /* nothrow-new (returns zero instead of std::bad_alloc) */ \ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \ void operator delete(void *ptr, const std::nothrow_t&) throw() { \ - Eigen::ei_conditional_aligned_free<NeedsToAlign>(ptr); \ + Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); \ } \ - typedef void ei_operator_new_marker_type; + typedef void eigen_aligned_operator_new_marker_type; #else #define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) #endif @@ -564,7 +568,7 @@ public: pointer allocate( size_type num, const_pointer* hint = 0 ) { static_cast<void>( hint ); // suppress unused variable warning - return static_cast<pointer>( ei_aligned_malloc( num * sizeof(T) ) ); + return static_cast<pointer>( internal::aligned_malloc( num * sizeof(T) ) ); } void construct( pointer p, const T& value ) @@ -579,7 +583,7 @@ public: void deallocate( pointer p, size_type /*num*/ ) { - ei_aligned_free( p ); + internal::aligned_free( p ); } bool operator!=(const aligned_allocator<T>& ) const @@ -605,13 +609,16 @@ public: # endif #endif +namespace internal { + #ifdef EIGEN_CPUID -inline bool ei_cpuid_is_vendor(int abcd[4], const char* vendor) + +inline bool cpuid_is_vendor(int abcd[4], const char* vendor) { return abcd[1]==((int*)(vendor))[0] && abcd[3]==((int*)(vendor))[1] && abcd[2]==((int*)(vendor))[2]; } -inline void ei_queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) +inline void queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) { int abcd[4]; l1 = l2 = l3 = 0; @@ -643,7 +650,7 @@ inline void ei_queryCacheSizes_intel_direct(int& l1, int& l2, int& l3) } while(cache_type>0 && cache_id<16); } -inline void ei_queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) +inline void queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) { int abcd[4]; abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0; @@ -723,15 +730,15 @@ inline void ei_queryCacheSizes_intel_codes(int& l1, int& l2, int& l3) l3 *= 1024; } -inline void ei_queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs) +inline void queryCacheSizes_intel(int& l1, int& l2, int& l3, int max_std_funcs) { if(max_std_funcs>=4) - ei_queryCacheSizes_intel_direct(l1,l2,l3); + queryCacheSizes_intel_direct(l1,l2,l3); else - ei_queryCacheSizes_intel_codes(l1,l2,l3); + queryCacheSizes_intel_codes(l1,l2,l3); } -inline void ei_queryCacheSizes_amd(int& l1, int& l2, int& l3) +inline void queryCacheSizes_amd(int& l1, int& l2, int& l3) { int abcd[4]; abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0; @@ -746,7 +753,7 @@ inline void ei_queryCacheSizes_amd(int& l1, int& l2, int& l3) /** \internal * Queries and returns the cache sizes in Bytes of the L1, L2, and L3 data caches respectively */ -inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) +inline void queryCacheSizes(int& l1, int& l2, int& l3) { #ifdef EIGEN_CPUID int abcd[4]; @@ -754,27 +761,27 @@ inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) // identify the CPU vendor EIGEN_CPUID(abcd,0x0,0); int max_std_funcs = abcd[1]; - if(ei_cpuid_is_vendor(abcd,"GenuineIntel")) - ei_queryCacheSizes_intel(l1,l2,l3,max_std_funcs); - else if(ei_cpuid_is_vendor(abcd,"AuthenticAMD") || ei_cpuid_is_vendor(abcd,"AMDisbetter!")) - ei_queryCacheSizes_amd(l1,l2,l3); + if(cpuid_is_vendor(abcd,"GenuineIntel")) + queryCacheSizes_intel(l1,l2,l3,max_std_funcs); + else if(cpuid_is_vendor(abcd,"AuthenticAMD") || cpuid_is_vendor(abcd,"AMDisbetter!")) + queryCacheSizes_amd(l1,l2,l3); else // by default let's use Intel's API - ei_queryCacheSizes_intel(l1,l2,l3,max_std_funcs); + queryCacheSizes_intel(l1,l2,l3,max_std_funcs); // here is the list of other vendors: -// ||ei_cpuid_is_vendor(abcd,"VIA VIA VIA ") -// ||ei_cpuid_is_vendor(abcd,"CyrixInstead") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") -// ||ei_cpuid_is_vendor(abcd,"GenuineTMx86") -// ||ei_cpuid_is_vendor(abcd,"TransmetaCPU") -// ||ei_cpuid_is_vendor(abcd,"RiseRiseRise") -// ||ei_cpuid_is_vendor(abcd,"Geode by NSC") -// ||ei_cpuid_is_vendor(abcd,"SiS SiS SiS ") -// ||ei_cpuid_is_vendor(abcd,"UMC UMC UMC ") -// ||ei_cpuid_is_vendor(abcd,"NexGenDriven") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") -// ||ei_cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"VIA VIA VIA ") +// ||cpuid_is_vendor(abcd,"CyrixInstead") +// ||cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"GenuineTMx86") +// ||cpuid_is_vendor(abcd,"TransmetaCPU") +// ||cpuid_is_vendor(abcd,"RiseRiseRise") +// ||cpuid_is_vendor(abcd,"Geode by NSC") +// ||cpuid_is_vendor(abcd,"SiS SiS SiS ") +// ||cpuid_is_vendor(abcd,"UMC UMC UMC ") +// ||cpuid_is_vendor(abcd,"NexGenDriven") +// ||cpuid_is_vendor(abcd,"CentaurHauls") +// ||cpuid_is_vendor(abcd,"CentaurHauls") #else l1 = l2 = l3 = -1; #endif @@ -782,20 +789,22 @@ inline void ei_queryCacheSizes(int& l1, int& l2, int& l3) /** \internal * \returns the size in Bytes of the L1 data cache */ -inline int ei_queryL1CacheSize() +inline int queryL1CacheSize() { int l1(-1), l2, l3; - ei_queryCacheSizes(l1,l2,l3); + queryCacheSizes(l1,l2,l3); return l1; } /** \internal * \returns the size in Bytes of the L2 or L3 cache if this later is present */ -inline int ei_queryTopLevelCacheSize() +inline int queryTopLevelCacheSize() { int l1, l2(-1), l3(-1); - ei_queryCacheSizes(l1,l2,l3); + queryCacheSizes(l1,l2,l3); return std::max(l2,l3); } +} // end namespace internal + #endif // EIGEN_MEMORY_H diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 3d28680b6..56330db9b 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -26,6 +26,8 @@ #ifndef EIGEN_META_H #define EIGEN_META_H +namespace internal { + /** \internal * \file Meta.h * This file contains generic metaprogramming classes which are not specifically related to Eigen. @@ -33,72 +35,72 @@ * we however don't want to add a dependency to Boost. */ -struct ei_meta_true { enum { ret = 1 }; }; -struct ei_meta_false { enum { ret = 0 }; }; +struct meta_true { enum { ret = 1 }; }; +struct meta_false { enum { ret = 0 }; }; template<bool Condition, typename Then, typename Else> -struct ei_meta_if { typedef Then ret; }; +struct meta_if { typedef Then ret; }; template<typename Then, typename Else> -struct ei_meta_if <false, Then, Else> { typedef Else ret; }; - -template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; }; -template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; }; - -template<typename T> struct ei_unref { typedef T type; }; -template<typename T> struct ei_unref<T&> { typedef T type; }; - -template<typename T> struct ei_unpointer { typedef T type; }; -template<typename T> struct ei_unpointer<T*> { typedef T type; }; -template<typename T> struct ei_unpointer<T*const> { typedef T type; }; - -template<typename T> struct ei_unconst { typedef T type; }; -template<typename T> struct ei_unconst<const T> { typedef T type; }; -template<typename T> struct ei_unconst<T const &> { typedef T & type; }; -template<typename T> struct ei_unconst<T const *> { typedef T * type; }; - -template<typename T> struct ei_cleantype { typedef T type; }; -template<typename T> struct ei_cleantype<const T> { typedef typename ei_cleantype<T>::type type; }; -template<typename T> struct ei_cleantype<const T&> { typedef typename ei_cleantype<T>::type type; }; -template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleantype<T>::type type; }; -template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; }; -template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; }; - -template<typename T> struct ei_is_arithmetic { enum { ret = false }; }; -template<> struct ei_is_arithmetic<float> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<double> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<long double> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<bool> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned char> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed short> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned short>{ enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed int> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned int> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<signed long long> { enum { ret = true }; }; -template<> struct ei_is_arithmetic<unsigned long long> { enum { ret = true }; }; - -template<typename T> struct ei_makeconst { typedef const T type; }; -template<typename T> struct ei_makeconst<const T> { typedef const T type; }; -template<typename T> struct ei_makeconst<T&> { typedef const T& type; }; -template<typename T> struct ei_makeconst<const T&> { typedef const T& type; }; -template<typename T> struct ei_makeconst<T*> { typedef const T* type; }; -template<typename T> struct ei_makeconst<const T*> { typedef const T* type; }; - -template<typename T> struct ei_makeconst_return_type +struct meta_if <false, Then, Else> { typedef Else ret; }; + +template<typename T, typename U> struct is_same_type { enum { ret = 0 }; }; +template<typename T> struct is_same_type<T,T> { enum { ret = 1 }; }; + +template<typename T> struct unref { typedef T type; }; +template<typename T> struct unref<T&> { typedef T type; }; + +template<typename T> struct unpointer { typedef T type; }; +template<typename T> struct unpointer<T*> { typedef T type; }; +template<typename T> struct unpointer<T*const> { typedef T type; }; + +template<typename T> struct unconst { typedef T type; }; +template<typename T> struct unconst<const T> { typedef T type; }; +template<typename T> struct unconst<T const &> { typedef T & type; }; +template<typename T> struct unconst<T const *> { typedef T * type; }; + +template<typename T> struct cleantype { typedef T type; }; +template<typename T> struct cleantype<const T> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<const T&> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<T&> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<const T*> { typedef typename cleantype<T>::type type; }; +template<typename T> struct cleantype<T*> { typedef typename cleantype<T>::type type; }; + +template<typename T> struct is_arithmetic { enum { ret = false }; }; +template<> struct is_arithmetic<float> { enum { ret = true }; }; +template<> struct is_arithmetic<double> { enum { ret = true }; }; +template<> struct is_arithmetic<long double> { enum { ret = true }; }; +template<> struct is_arithmetic<bool> { enum { ret = true }; }; +template<> struct is_arithmetic<char> { enum { ret = true }; }; +template<> struct is_arithmetic<signed char> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned char> { enum { ret = true }; }; +template<> struct is_arithmetic<signed short> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned short>{ enum { ret = true }; }; +template<> struct is_arithmetic<signed int> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned int> { enum { ret = true }; }; +template<> struct is_arithmetic<signed long> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned long> { enum { ret = true }; }; +template<> struct is_arithmetic<signed long long> { enum { ret = true }; }; +template<> struct is_arithmetic<unsigned long long> { enum { ret = true }; }; + +template<typename T> struct makeconst { typedef const T type; }; +template<typename T> struct makeconst<const T> { typedef const T type; }; +template<typename T> struct makeconst<T&> { typedef const T& type; }; +template<typename T> struct makeconst<const T&> { typedef const T& type; }; +template<typename T> struct makeconst<T*> { typedef const T* type; }; +template<typename T> struct makeconst<const T*> { typedef const T* type; }; + +template<typename T> struct makeconst_return_type { - typedef typename ei_meta_if<ei_is_arithmetic<T>::ret, T, typename ei_makeconst<T>::type>::ret type; + typedef typename meta_if<is_arithmetic<T>::ret, T, typename makeconst<T>::type>::ret type; }; /** \internal Allows to enable/disable an overload * according to a compile time condition. */ -template<bool Condition, typename T> struct ei_enable_if; +template<bool Condition, typename T> struct enable_if; -template<typename T> struct ei_enable_if<true,T> +template<typename T> struct enable_if<true,T> { typedef T type; }; /** \internal @@ -108,67 +110,67 @@ template<typename T> struct ei_enable_if<true,T> * upcoming next STL generation (using a templated result member). * If none of these members is provided, then the type of the first argument is returned. FIXME, that behavior is a pretty bad hack. */ -template<typename T> struct ei_result_of {}; +template<typename T> struct result_of {}; -struct ei_has_none {int a[1];}; -struct ei_has_std_result_type {int a[2];}; -struct ei_has_tr1_result {int a[3];}; +struct has_none {int a[1];}; +struct has_std_result_type {int a[2];}; +struct has_tr1_result {int a[3];}; -template<typename Func, typename ArgType, int SizeOf=sizeof(ei_has_none)> -struct ei_unary_result_of_select {typedef ArgType type;}; +template<typename Func, typename ArgType, int SizeOf=sizeof(has_none)> +struct unary_result_of_select {typedef ArgType type;}; template<typename Func, typename ArgType> -struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_std_result_type)> {typedef typename Func::result_type type;}; +struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typedef typename Func::result_type type;}; template<typename Func, typename ArgType> -struct ei_unary_result_of_select<Func, ArgType, sizeof(ei_has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;}; +struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;}; template<typename Func, typename ArgType> -struct ei_result_of<Func(ArgType)> { +struct result_of<Func(ArgType)> { template<typename T> - static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); + static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template<typename T> - static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0); - static ei_has_none testFunctor(...); + static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0); + static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; - typedef typename ei_unary_result_of_select<Func, ArgType, FunctorType>::type type; + typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type; }; -template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(ei_has_none)> -struct ei_binary_result_of_select {typedef ArgType0 type;}; +template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(has_none)> +struct binary_result_of_select {typedef ArgType0 type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_std_result_type)> +struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)> {typedef typename Func::result_type type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_binary_result_of_select<Func, ArgType0, ArgType1, sizeof(ei_has_tr1_result)> +struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;}; template<typename Func, typename ArgType0, typename ArgType1> -struct ei_result_of<Func(ArgType0,ArgType1)> { +struct result_of<Func(ArgType0,ArgType1)> { template<typename T> - static ei_has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); + static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template<typename T> - static ei_has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0); - static ei_has_none testFunctor(...); + static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0); + static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))}; - typedef typename ei_binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type; + typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type; }; /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. - * Usage example: \code ei_meta_sqrt<1023>::ret \endcode + * Usage example: \code meta_sqrt<1023>::ret \endcode */ template<int Y, int InfX = 0, int SupX = ((Y==1) ? 1 : Y/2), bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) > // use ?: instead of || just to shut up a stupid gcc 4.3 warning -class ei_meta_sqrt +class meta_sqrt { enum { MidX = (InfX+SupX)/2, @@ -177,49 +179,51 @@ class ei_meta_sqrt NewSup = int(TakeInf) ? int(MidX) : SupX }; public: - enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret }; + enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret }; }; template<int Y, int InfX, int SupX> -class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; +class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; }; /** \internal determines whether the product of two numeric types is allowed and what the return type is */ -template<typename T, typename U> struct ei_scalar_product_traits; +template<typename T, typename U> struct scalar_product_traits; -template<typename T> struct ei_scalar_product_traits<T,T> +template<typename T> struct scalar_product_traits<T,T> { //enum { Cost = NumTraits<T>::MulCost }; typedef T ReturnType; }; -template<typename T> struct ei_scalar_product_traits<T,std::complex<T> > +template<typename T> struct scalar_product_traits<T,std::complex<T> > { //enum { Cost = 2*NumTraits<T>::MulCost }; typedef std::complex<T> ReturnType; }; -template<typename T> struct ei_scalar_product_traits<std::complex<T>, T> +template<typename T> struct scalar_product_traits<std::complex<T>, T> { //enum { Cost = 2*NumTraits<T>::MulCost }; typedef std::complex<T> ReturnType; }; -// FIXME quick workaround around current limitation of ei_result_of +// FIXME quick workaround around current limitation of result_of // template<typename Scalar, typename ArgType0, typename ArgType1> -// struct ei_result_of<ei_scalar_product_op<Scalar>(ArgType0,ArgType1)> { -// typedef typename ei_scalar_product_traits<typename ei_cleantype<ArgType0>::type, typename ei_cleantype<ArgType1>::type>::ReturnType type; +// struct result_of<scalar_product_op<Scalar>(ArgType0,ArgType1)> { +// typedef typename scalar_product_traits<typename cleantype<ArgType0>::type, typename cleantype<ArgType1>::type>::ReturnType type; // }; -template<typename T> struct ei_is_diagonal +template<typename T> struct is_diagonal { enum { ret = false }; }; -template<typename T> struct ei_is_diagonal<DiagonalBase<T> > +template<typename T> struct is_diagonal<DiagonalBase<T> > { enum { ret = true }; }; -template<typename T> struct ei_is_diagonal<DiagonalWrapper<T> > +template<typename T> struct is_diagonal<DiagonalWrapper<T> > { enum { ret = true }; }; -template<typename T, int S> struct ei_is_diagonal<DiagonalMatrix<T,S> > +template<typename T, int S> struct is_diagonal<DiagonalMatrix<T,S> > { enum { ret = true }; }; +} // end namespace internal + #endif // EIGEN_META_H diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 323273e6a..71e8eef1b 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -29,11 +29,11 @@ /* Some notes on Eigen's static assertion mechanism: * * - in EIGEN_STATIC_ASSERT(CONDITION,MSG) the parameter CONDITION must be a compile time boolean - * expression, and MSG an enum listed in struct ei_static_assert<true> + * expression, and MSG an enum listed in struct internal::static_assertion<true> * * - define EIGEN_NO_STATIC_ASSERT to disable them (and save compilation time) * in that case, the static assertion is converted to the following runtime assert: - * ei_assert(CONDITION && "MSG") + * eigen_assert(CONDITION && "MSG") * * - currently EIGEN_STATIC_ASSERT can only be used in function scope * @@ -48,11 +48,13 @@ #else // not CXX0X + namespace internal { + template<bool condition> - struct ei_static_assert {}; + struct static_assertion {}; template<> - struct ei_static_assert<true> + struct static_assertion<true> { enum { YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX, @@ -94,18 +96,20 @@ }; }; + } // end namespace internal + // Specialized implementation for MSVC to avoid "conditional // expression is constant" warnings. This implementation doesn't // appear to work under GCC, hence the multiple implementations. #ifdef _MSC_VER #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - {Eigen::ei_static_assert<(CONDITION)>::MSG;} + {Eigen::internal::static_assertion<(CONDITION)>::MSG;} #else #define EIGEN_STATIC_ASSERT(CONDITION,MSG) \ - if (Eigen::ei_static_assert<(CONDITION)>::MSG) {} + if (Eigen::internal::static_assertion<(CONDITION)>::MSG) {} #endif @@ -113,7 +117,7 @@ #else // EIGEN_NO_STATIC_ASSERT - #define EIGEN_STATIC_ASSERT(CONDITION,MSG) ei_assert((CONDITION) && #MSG); + #define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG); #endif // EIGEN_NO_STATIC_ASSERT diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 7232fa0f8..9f5bd7d71 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -1,4 +1,4 @@ -// // This file is part of Eigen, a lightweight C++ template library +// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> @@ -37,46 +37,48 @@ #define EIGEN_EMPTY_STRUCT_CTOR(X) #endif -//classes inheriting ei_no_assignment_operator don't generate a default operator=. -class ei_no_assignment_operator +typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; + +namespace internal { + +//classes inheriting no_assignment_operator don't generate a default operator=. +class no_assignment_operator { private: - ei_no_assignment_operator& operator=(const ei_no_assignment_operator&); + no_assignment_operator& operator=(const no_assignment_operator&); }; -typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; - /** \internal return the index type with the largest number of bits */ template<typename I1, typename I2> -struct ei_promote_index_type +struct promote_index_type { - typedef typename ei_meta_if<(sizeof(I1)<sizeof(I2)), I2, I1>::ret type; + typedef typename meta_if<(sizeof(I1)<sizeof(I2)), I2, I1>::ret type; }; /** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that * can be accessed using value() and setValue(). * Otherwise, this class is an empty structure and value() just returns the template parameter Value. */ -template<typename T, int Value> class ei_variable_if_dynamic +template<typename T, int Value> class variable_if_dynamic { public: - EIGEN_EMPTY_STRUCT_CTOR(ei_variable_if_dynamic) - explicit ei_variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); ei_assert(v == T(Value)); } + EIGEN_EMPTY_STRUCT_CTOR(variable_if_dynamic) + explicit variable_if_dynamic(T v) { EIGEN_ONLY_USED_FOR_DEBUG(v); assert(v == T(Value)); } static T value() { return T(Value); } void setValue(T) {} }; -template<typename T> class ei_variable_if_dynamic<T, Dynamic> +template<typename T> class variable_if_dynamic<T, Dynamic> { T m_value; - ei_variable_if_dynamic() { ei_assert(false); } + variable_if_dynamic() { assert(false); } public: - explicit ei_variable_if_dynamic(T value) : m_value(value) {} + explicit variable_if_dynamic(T value) : m_value(value) {} T value() const { return m_value; } void setValue(T value) { m_value = value; } }; -template<typename T> struct ei_functor_traits +template<typename T> struct functor_traits { enum { @@ -85,9 +87,9 @@ template<typename T> struct ei_functor_traits }; }; -template<typename T> struct ei_packet_traits; +template<typename T> struct packet_traits; -template<typename T> struct ei_unpacket_traits +template<typename T> struct unpacket_traits { typedef T type; enum {size=1}; @@ -100,7 +102,7 @@ template<typename _Scalar, int _Rows, int _Cols, : EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ), int _MaxRows = _Rows, int _MaxCols = _Cols -> class ei_make_proper_matrix_type +> class make_proper_matrix_type { enum { IsColVector = _Cols==1 && _Rows!=1, @@ -114,7 +116,7 @@ template<typename _Scalar, int _Rows, int _Cols, }; template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> -class ei_compute_matrix_flags +class compute_matrix_flags { enum { row_major_bit = Options&RowMajor ? RowMajorBit : 0, @@ -123,10 +125,10 @@ class ei_compute_matrix_flags aligned_bit = ( ((Options&DontAlign)==0) - && ei_packet_traits<Scalar>::Vectorizable + && packet_traits<Scalar>::Vectorizable && ( #if EIGEN_ALIGN_STATICALLY - ((!is_dynamic_size_storage) && (((MaxCols*MaxRows) % ei_packet_traits<Scalar>::size) == 0)) + ((!is_dynamic_size_storage) && (((MaxCols*MaxRows) % packet_traits<Scalar>::size) == 0)) #else 0 #endif @@ -141,95 +143,95 @@ class ei_compute_matrix_flags ) ) ? AlignedBit : 0, - packet_access_bit = ei_packet_traits<Scalar>::Vectorizable && aligned_bit ? PacketAccessBit : 0 + packet_access_bit = packet_traits<Scalar>::Vectorizable && aligned_bit ? PacketAccessBit : 0 }; public: enum { ret = LinearAccessBit | LvalueBit | DirectAccessBit | NestByRefBit | packet_access_bit | row_major_bit | aligned_bit }; }; -template<int _Rows, int _Cols> struct ei_size_at_compile_time +template<int _Rows, int _Cols> struct size_at_compile_time { enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols }; }; -/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type, - * whereas ei_eval is a const reference in the case of a matrix +/* plain_matrix_type : the difference from eval is that plain_matrix_type is always a plain matrix type, + * whereas eval is a const reference in the case of a matrix */ -template<typename T, typename StorageKind = typename ei_traits<T>::StorageKind> struct ei_plain_matrix_type; -template<typename T, typename BaseClassType> struct ei_plain_matrix_type_dense; -template<typename T> struct ei_plain_matrix_type<T,Dense> +template<typename T, typename StorageKind = typename traits<T>::StorageKind> struct plain_matrix_type; +template<typename T, typename BaseClassType> struct plain_matrix_type_dense; +template<typename T> struct plain_matrix_type<T,Dense> { - typedef typename ei_plain_matrix_type_dense<T,typename ei_traits<T>::XprKind>::type type; + typedef typename plain_matrix_type_dense<T,typename traits<T>::XprKind>::type type; }; -template<typename T> struct ei_plain_matrix_type_dense<T,MatrixXpr> +template<typename T> struct plain_matrix_type_dense<T,MatrixXpr> { - typedef Matrix<typename ei_traits<T>::Scalar, - ei_traits<T>::RowsAtCompileTime, - ei_traits<T>::ColsAtCompileTime, - AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<T>::MaxRowsAtCompileTime, - ei_traits<T>::MaxColsAtCompileTime + typedef Matrix<typename traits<T>::Scalar, + traits<T>::RowsAtCompileTime, + traits<T>::ColsAtCompileTime, + AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), + traits<T>::MaxRowsAtCompileTime, + traits<T>::MaxColsAtCompileTime > type; }; -template<typename T> struct ei_plain_matrix_type_dense<T,ArrayXpr> +template<typename T> struct plain_matrix_type_dense<T,ArrayXpr> { - typedef Array<typename ei_traits<T>::Scalar, - ei_traits<T>::RowsAtCompileTime, - ei_traits<T>::ColsAtCompileTime, - AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), - ei_traits<T>::MaxRowsAtCompileTime, - ei_traits<T>::MaxColsAtCompileTime + typedef Array<typename traits<T>::Scalar, + traits<T>::RowsAtCompileTime, + traits<T>::ColsAtCompileTime, + AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), + traits<T>::MaxRowsAtCompileTime, + traits<T>::MaxColsAtCompileTime > type; }; -/* ei_eval : the return type of eval(). For matrices, this is just a const reference +/* eval : the return type of eval(). For matrices, this is just a const reference * in order to avoid a useless copy */ -template<typename T, typename StorageKind = typename ei_traits<T>::StorageKind> struct ei_eval; +template<typename T, typename StorageKind = typename traits<T>::StorageKind> struct eval; -template<typename T> struct ei_eval<T,Dense> +template<typename T> struct eval<T,Dense> { - typedef typename ei_plain_matrix_type<T>::type type; + typedef typename plain_matrix_type<T>::type type; // typedef typename T::PlainObject type; -// typedef T::Matrix<typename ei_traits<T>::Scalar, -// ei_traits<T>::RowsAtCompileTime, -// ei_traits<T>::ColsAtCompileTime, -// AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), -// ei_traits<T>::MaxRowsAtCompileTime, -// ei_traits<T>::MaxColsAtCompileTime +// typedef T::Matrix<typename traits<T>::Scalar, +// traits<T>::RowsAtCompileTime, +// traits<T>::ColsAtCompileTime, +// AutoAlign | (traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor), +// traits<T>::MaxRowsAtCompileTime, +// traits<T>::MaxColsAtCompileTime // > type; }; // for matrices, no need to evaluate, just use a const reference to avoid a useless copy template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> +struct eval<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> { typedef const Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> -struct ei_eval<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> +struct eval<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Dense> { typedef const Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; -/* ei_plain_matrix_type_column_major : same as ei_plain_matrix_type but guaranteed to be column-major +/* plain_matrix_type_column_major : same as plain_matrix_type but guaranteed to be column-major */ -template<typename T> struct ei_plain_matrix_type_column_major +template<typename T> struct plain_matrix_type_column_major { - enum { Rows = ei_traits<T>::RowsAtCompileTime, - Cols = ei_traits<T>::ColsAtCompileTime, - MaxRows = ei_traits<T>::MaxRowsAtCompileTime, - MaxCols = ei_traits<T>::MaxColsAtCompileTime + enum { Rows = traits<T>::RowsAtCompileTime, + Cols = traits<T>::ColsAtCompileTime, + MaxRows = traits<T>::MaxRowsAtCompileTime, + MaxCols = traits<T>::MaxColsAtCompileTime }; - typedef Matrix<typename ei_traits<T>::Scalar, + typedef Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxRows==1&&MaxCols!=1) ? RowMajor : ColMajor, @@ -238,16 +240,16 @@ template<typename T> struct ei_plain_matrix_type_column_major > type; }; -/* ei_plain_matrix_type_row_major : same as ei_plain_matrix_type but guaranteed to be row-major +/* plain_matrix_type_row_major : same as plain_matrix_type but guaranteed to be row-major */ -template<typename T> struct ei_plain_matrix_type_row_major +template<typename T> struct plain_matrix_type_row_major { - enum { Rows = ei_traits<T>::RowsAtCompileTime, - Cols = ei_traits<T>::ColsAtCompileTime, - MaxRows = ei_traits<T>::MaxRowsAtCompileTime, - MaxCols = ei_traits<T>::MaxColsAtCompileTime + enum { Rows = traits<T>::RowsAtCompileTime, + Cols = traits<T>::ColsAtCompileTime, + MaxRows = traits<T>::MaxRowsAtCompileTime, + MaxCols = traits<T>::MaxColsAtCompileTime }; - typedef Matrix<typename ei_traits<T>::Scalar, + typedef Matrix<typename traits<T>::Scalar, Rows, Cols, (MaxCols==1&&MaxRows!=1) ? RowMajor : ColMajor, @@ -257,16 +259,16 @@ template<typename T> struct ei_plain_matrix_type_row_major }; // we should be able to get rid of this one too -template<typename T> struct ei_must_nest_by_value { enum { ret = false }; }; +template<typename T> struct must_nest_by_value { enum { ret = false }; }; template<class T> -struct ei_is_reference +struct is_reference { enum { ret = false }; }; template<class T> -struct ei_is_reference<T&> +struct is_reference<T&> { enum { ret = true }; }; @@ -277,10 +279,10 @@ struct ei_is_reference<T&> * objects which should generate no copying overhead. **/ template <typename T> -struct ei_ref_selector +struct ref_selector { - typedef typename ei_meta_if< - bool(ei_traits<T>::Flags & NestByRefBit), + typedef typename meta_if< + bool(traits<T>::Flags & NestByRefBit), T const&, T >::ret type; @@ -298,70 +300,70 @@ struct ei_ref_selector * * Example. Suppose that a, b, and c are of type Matrix3d. The user forms the expression a*(b+c). * b+c is an expression "sum of matrices", which we will denote by S. In order to determine how to nest it, - * the Product expression uses: ei_nested<S, 3>::ret, which turns out to be Matrix3d because the internal logic of - * ei_nested determined that in this case it was better to evaluate the expression b+c into a temporary. On the other hand, - * since a is of type Matrix3d, the Product expression nests it as ei_nested<Matrix3d, 3>::ret, which turns out to be - * const Matrix3d&, because the internal logic of ei_nested determined that since a was already a matrix, there was no point + * the Product expression uses: nested<S, 3>::ret, which turns out to be Matrix3d because the internal logic of + * nested determined that in this case it was better to evaluate the expression b+c into a temporary. On the other hand, + * since a is of type Matrix3d, the Product expression nests it as nested<Matrix3d, 3>::ret, which turns out to be + * const Matrix3d&, because the internal logic of nested determined that since a was already a matrix, there was no point * in copying it into another matrix. */ -template<typename T, int n=1, typename PlainObject = typename ei_eval<T>::type> struct ei_nested +template<typename T, int n=1, typename PlainObject = typename eval<T>::type> struct nested { // this is a direct port of the logic used when Dynamic was 33331, to make an atomic commit. enum { - _ScalarReadCost = NumTraits<typename ei_traits<T>::Scalar>::ReadCost, + _ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, ScalarReadCost = _ScalarReadCost == Dynamic ? 33331 : int(_ScalarReadCost), - _CoeffReadCost = int(ei_traits<T>::CoeffReadCost), + _CoeffReadCost = int(traits<T>::CoeffReadCost), CoeffReadCost = _CoeffReadCost == Dynamic ? 33331 : int(_CoeffReadCost), N = n == Dynamic ? 33331 : n, CostEval = (N+1) * int(ScalarReadCost), CostNoEval = (N-1) * int(CoeffReadCost) }; - typedef typename ei_meta_if< - ( int(ei_traits<T>::Flags) & EvalBeforeNestingBit ) || + typedef typename meta_if< + ( int(traits<T>::Flags) & EvalBeforeNestingBit ) || ( int(CostEval) <= int(CostNoEval) ), PlainObject, - typename ei_ref_selector<T>::type + typename ref_selector<T>::type >::ret type; /* this is what the above logic should be updated to look like: enum { - ScalarReadCost = NumTraits<typename ei_traits<T>::Scalar>::ReadCost, - CoeffReadCost = ei_traits<T>::CoeffReadCost, + ScalarReadCost = NumTraits<typename traits<T>::Scalar>::ReadCost, + CoeffReadCost = traits<T>::CoeffReadCost, CostEval = n == Dynamic || ScalarReadCost == Dynamic ? int(Dynamic) : (n+1) * int(ScalarReadCost), CostNoEval = n == Dynamic || (CoeffReadCost == Dynamic && n>1) ? int(Dynamic) : (n-1) * int(CoeffReadCost) }; - typedef typename ei_meta_if< - ( int(ei_traits<T>::Flags) & EvalBeforeNestingBit ) || + typedef typename meta_if< + ( int(traits<T>::Flags) & EvalBeforeNestingBit ) || ( int(CostNoEval) == Dynamic ? true : int(CostEval) == Dynamic ? false : int(CostEval) <= int(CostNoEval) ), PlainObject, - typename ei_ref_selector<T>::type + typename ref_selector<T>::type >::ret type; */ }; -template<unsigned int Flags> struct ei_are_flags_consistent +template<unsigned int Flags> struct are_flags_consistent { enum { ret = EIGEN_IMPLIES(bool(Flags&DirectAccessBit), bool(Flags&LvalueBit)) }; }; -template<typename Derived, typename XprKind = typename ei_traits<Derived>::XprKind> -struct ei_dense_xpr_base +template<typename Derived, typename XprKind = typename traits<Derived>::XprKind> +struct dense_xpr_base { - /* ei_dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */ + /* dense_xpr_base should only ever be used on dense expressions, thus falling either into the MatrixXpr or into the ArrayXpr cases */ }; template<typename Derived> -struct ei_dense_xpr_base<Derived, MatrixXpr> +struct dense_xpr_base<Derived, MatrixXpr> { typedef MatrixBase<Derived> type; }; template<typename Derived> -struct ei_dense_xpr_base<Derived, ArrayXpr> +struct dense_xpr_base<Derived, ArrayXpr> { typedef ArrayBase<Derived> type; }; @@ -369,27 +371,27 @@ struct ei_dense_xpr_base<Derived, ArrayXpr> /** \internal Helper base class to add a scalar multiple operator * overloads for complex types */ template<typename Derived,typename Scalar,typename OtherScalar, - bool EnableIt = !ei_is_same_type<Scalar,OtherScalar>::ret > -struct ei_special_scalar_op_base : public DenseCoeffsBase<Derived> + bool EnableIt = !is_same_type<Scalar,OtherScalar>::ret > +struct special_scalar_op_base : public DenseCoeffsBase<Derived> { // dummy operator* so that the - // "using ei_special_scalar_op_base::operator*" compiles + // "using special_scalar_op_base::operator*" compiles void operator*() const; }; template<typename Derived,typename Scalar,typename OtherScalar> -struct ei_special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCoeffsBase<Derived> +struct special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCoeffsBase<Derived> { - const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> + const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> operator*(const OtherScalar& scalar) const { - return CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> - (*static_cast<const Derived*>(this), ei_scalar_multiple2_op<Scalar,OtherScalar>(scalar)); + return CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> + (*static_cast<const Derived*>(this), scalar_multiple2_op<Scalar,OtherScalar>(scalar)); } - inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived> + inline friend const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived> operator*(const OtherScalar& scalar, const Derived& matrix) - { return static_cast<const ei_special_scalar_op_base&>(matrix).operator*(scalar); } + { return static_cast<const special_scalar_op_base&>(matrix).operator*(scalar); } }; template<typename ExpressionType> struct HNormalizedReturnType { @@ -399,24 +401,24 @@ template<typename ExpressionType> struct HNormalizedReturnType { SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1 }; typedef Block<ExpressionType, - ei_traits<ExpressionType>::ColsAtCompileTime==1 ? SizeMinusOne : 1, - ei_traits<ExpressionType>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; - typedef CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<ExpressionType>::Scalar>, + traits<ExpressionType>::ColsAtCompileTime==1 ? SizeMinusOne : 1, + traits<ExpressionType>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne; + typedef CwiseUnaryOp<scalar_quotient1_op<typename traits<ExpressionType>::Scalar>, StartMinusOne > Type; }; -template<typename XprType, typename CastType> struct ei_cast_return_type +template<typename XprType, typename CastType> struct cast_return_type { typedef typename XprType::Scalar CurrentScalarType; - typedef typename ei_cleantype<CastType>::type _CastType; + typedef typename cleantype<CastType>::type _CastType; typedef typename _CastType::Scalar NewScalarType; - typedef typename ei_meta_if<ei_is_same_type<CurrentScalarType,NewScalarType>::ret, + typedef typename meta_if<is_same_type<CurrentScalarType,NewScalarType>::ret, const XprType&,CastType>::ret type; }; -template <typename A, typename B> struct ei_promote_storage_type; +template <typename A, typename B> struct promote_storage_type; -template <typename A> struct ei_promote_storage_type<A,A> +template <typename A> struct promote_storage_type<A,A> { typedef A ret; }; @@ -425,37 +427,37 @@ template <typename A> struct ei_promote_storage_type<A,A> * \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType. */ template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_row_type +struct plain_row_type { typedef Matrix<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> MatrixRowType; typedef Array<Scalar, 1, ExpressionType::ColsAtCompileTime, ExpressionType::PlainObject::Options | RowMajor, 1, ExpressionType::MaxColsAtCompileTime> ArrayRowType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixRowType, ArrayRowType >::ret type; }; template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_col_type +struct plain_col_type { typedef Matrix<Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> MatrixColType; typedef Array<Scalar, ExpressionType::RowsAtCompileTime, 1, ExpressionType::PlainObject::Options & ~RowMajor, ExpressionType::MaxRowsAtCompileTime, 1> ArrayColType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixColType, ArrayColType >::ret type; }; template<typename ExpressionType, typename Scalar = typename ExpressionType::Scalar> -struct ei_plain_diag_type +struct plain_diag_type { enum { diag_size = EIGEN_SIZE_MIN_PREFER_DYNAMIC(ExpressionType::RowsAtCompileTime, ExpressionType::ColsAtCompileTime), max_diag_size = EIGEN_SIZE_MIN_PREFER_FIXED(ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxColsAtCompileTime) @@ -463,11 +465,13 @@ struct ei_plain_diag_type typedef Matrix<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> MatrixDiagType; typedef Array<Scalar, diag_size, 1, ExpressionType::PlainObject::Options & ~RowMajor, max_diag_size, 1> ArrayDiagType; - typedef typename ei_meta_if< - ei_is_same_type< typename ei_traits<ExpressionType>::XprKind, MatrixXpr >::ret, + typedef typename meta_if< + is_same_type< typename traits<ExpressionType>::XprKind, MatrixXpr >::ret, MatrixDiagType, ArrayDiagType >::ret type; }; +} // end namespace internal + #endif // EIGEN_XPRHELPER_H |