From 41c523a0ab8432a3f3276abaeb8a869cccab6b93 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 24 Jan 2017 09:39:49 +0100 Subject: [PATCH] Rename fix_t to FixedInt --- Eigen/src/Core/ArithmeticSequence.h | 18 +++---- Eigen/src/Core/util/IndexedViewHelper.h | 4 +- Eigen/src/Core/util/IntegralConstant.h | 67 +++++++++++++------------ Eigen/src/Core/util/SymbolicIndex.h | 34 ++++++------- 4 files changed, 63 insertions(+), 60 deletions(-) diff --git a/Eigen/src/Core/ArithmeticSequence.h b/Eigen/src/Core/ArithmeticSequence.h index 646eb5770..c5c8bb105 100644 --- a/Eigen/src/Core/ArithmeticSequence.h +++ b/Eigen/src/Core/ArithmeticSequence.h @@ -21,12 +21,12 @@ template<> struct aseq_negate { typedef Index type; }; -template struct aseq_negate > { - typedef fix_t<-N> type; +template struct aseq_negate > { + typedef FixedInt<-N> type; }; // Compilation error in the following case: -template<> struct aseq_negate > {}; +template<> struct aseq_negate > {}; template::value, @@ -38,7 +38,7 @@ struct aseq_reverse_first_type { template struct aseq_reverse_first_type { typedef Symbolic::AddExpr > >, + Symbolic::ProductExpr > >, Symbolic::ValueExpr > > type; }; @@ -50,7 +50,7 @@ struct aseq_reverse_first_type { template struct aseq_reverse_first_type { - typedef Symbolic::AddExpr > >, + typedef Symbolic::AddExpr > >, Symbolic::ValueExpr >, Symbolic::ValueExpr<> > type; }; @@ -67,7 +67,7 @@ template struct cleanup_seq_incr { // seq(first,last,incr) and seqN(first,size,incr) //-------------------------------------------------------------------------------- -template > +template > class ArithmeticSequence; template @@ -222,7 +222,7 @@ seq(FirstType f, LastType l) template typename internal::enable_if::value, ArithmeticSequence,Symbolic::ValueExpr<> >, - Symbolic::ValueExpr > > > >::type + Symbolic::ValueExpr > > > >::type seq(const Symbolic::BaseExpr &f, LastType l) { return seqN(f.derived(),(typename internal::cleanup_index_type::type(l)-f.derived()+fix<1>())); @@ -232,7 +232,7 @@ template typename internal::enable_if::value, ArithmeticSequence::type, Symbolic::AddExpr >, - Symbolic::ValueExpr > > > >::type + Symbolic::ValueExpr > > > >::type seq(FirstType f, const Symbolic::BaseExpr &l) { return seqN(typename internal::cleanup_index_type::type(f),(l.derived()-typename internal::cleanup_index_type::type(f)+fix<1>())); @@ -240,7 +240,7 @@ seq(FirstType f, const Symbolic::BaseExpr &l) template ArithmeticSequence >,Symbolic::ValueExpr > > > + Symbolic::AddExpr >,Symbolic::ValueExpr > > > seq(const Symbolic::BaseExpr &f, const Symbolic::BaseExpr &l) { return seqN(f.derived(),(l.derived()-f.derived()+fix<1>())); diff --git a/Eigen/src/Core/util/IndexedViewHelper.h b/Eigen/src/Core/util/IndexedViewHelper.h index 1171b2b2e..ab01c857f 100644 --- a/Eigen/src/Core/util/IndexedViewHelper.h +++ b/Eigen/src/Core/util/IndexedViewHelper.h @@ -60,7 +60,7 @@ static const auto end = last+1; #else // Using a FixedExpr<1> expression is important here to make sure the compiler // can fully optimize the computation starting indices with zero overhead. -static const Symbolic::AddExpr,Symbolic::ValueExpr > > end(last+fix<1>()); +static const Symbolic::AddExpr,Symbolic::ValueExpr > > end(last+fix<1>()); #endif } // end namespace placeholders @@ -71,7 +71,7 @@ namespace internal { inline Index eval_expr_given_size(Index x, Index /* size */) { return x; } template -fix_t eval_expr_given_size(fix_t x, Index /*size*/) { return x; } +FixedInt eval_expr_given_size(FixedInt x, Index /*size*/) { return x; } template Index eval_expr_given_size(const Symbolic::BaseExpr &x, Index size) diff --git a/Eigen/src/Core/util/IntegralConstant.h b/Eigen/src/Core/util/IntegralConstant.h index 178e4893c..e81cc45f2 100644 --- a/Eigen/src/Core/util/IntegralConstant.h +++ b/Eigen/src/Core/util/IntegralConstant.h @@ -15,39 +15,42 @@ namespace Eigen { namespace internal { -template struct fix_t; -template class variable_or_fixed; +template class FixedInt; +template class VariableAndFixedInt; -template struct fix_t { +template class FixedInt +{ +public: static const int value = N; operator int() const { return value; } - fix_t() {} - fix_t(variable_or_fixed other) { + FixedInt() {} + FixedInt( VariableAndFixedInt other) { EIGEN_ONLY_USED_FOR_DEBUG(other); eigen_internal_assert(int(other)==N); } - fix_t<-N> operator-() const { return fix_t<-N>(); } + FixedInt<-N> operator-() const { return FixedInt<-N>(); } template - fix_t operator+(fix_t) const { return fix_t(); } + FixedInt operator+( FixedInt) const { return FixedInt(); } template - fix_t operator-(fix_t) const { return fix_t(); } + FixedInt operator-( FixedInt) const { return FixedInt(); } #if EIGEN_HAS_CXX14 // Needed in C++14 to allow fix(): - fix_t operator() () const { return *this; } + FixedInt operator() () const { return *this; } - variable_or_fixed operator() (int val) const { return variable_or_fixed(val); } + VariableAndFixedInt operator() (int val) const { return VariableAndFixedInt(val); } #else - fix_t (fix_t (*)() ) {} + FixedInt ( FixedInt (*)() ) {} #endif }; -template class variable_or_fixed { +template class VariableAndFixedInt +{ public: static const int value = N; operator int() const { return m_value; } - variable_or_fixed(int val) { m_value = val; } + VariableAndFixedInt(int val) { m_value = val; } protected: int m_value; }; @@ -56,17 +59,17 @@ template struct get_fixed_value { static const int value = Default; }; -template struct get_fixed_value,Default> { +template struct get_fixed_value,Default> { static const int value = N; }; #if !EIGEN_HAS_CXX14 -template struct get_fixed_value (*)(),Default> { +template struct get_fixed_value (*)(),Default> { static const int value = N; }; #endif -template struct get_fixed_value,Default> { +template struct get_fixed_value,Default> { static const int value = N ; }; @@ -77,10 +80,10 @@ struct get_fixed_value,Default> { template Index get_runtime_value(const T &x) { return x; } #if !EIGEN_HAS_CXX14 -template Index get_runtime_value(fix_t (*)()) { return N; } +template Index get_runtime_value(FixedInt (*)()) { return N; } #endif -// Cleanup integer/fix_t/variable_or_fixed/etc types: +// Cleanup integer/FixedInt/VariableAndFixedInt/etc types: // By default, no cleanup: template struct cleanup_index_type { typedef T type; }; @@ -89,14 +92,14 @@ template struct clea template struct cleanup_index_type::value>::type> { typedef Index type; }; #if !EIGEN_HAS_CXX14 -// In c++98/c++11, fix is a pointer to function that we better cleanup to a true fix_t: -template struct cleanup_index_type (*)(), DynamicKey> { typedef fix_t type; }; +// In c++98/c++11, fix is a pointer to function that we better cleanup to a true FixedInt: +template struct cleanup_index_type (*)(), DynamicKey> { typedef FixedInt type; }; #endif -// If variable_or_fixed does not match DynamicKey, then we turn it to a pure compile-time value: -template struct cleanup_index_type, DynamicKey> { typedef fix_t type; }; -// If variable_or_fixed matches DynamicKey, then we turn it to a pure runtime-value (aka Index): -template struct cleanup_index_type, DynamicKey> { typedef Index type; }; +// If VariableAndFixedInt does not match DynamicKey, then we turn it to a pure compile-time value: +template struct cleanup_index_type, DynamicKey> { typedef FixedInt type; }; +// If VariableAndFixedInt matches DynamicKey, then we turn it to a pure runtime-value (aka Index): +template struct cleanup_index_type, DynamicKey> { typedef Index type; }; } // end namespace internal @@ -104,15 +107,15 @@ template struct cleanup_index_type #if EIGEN_HAS_CXX14 template -static const internal::fix_t fix{}; +static const internal::FixedInt fix{}; #else template -inline internal::fix_t fix() { return internal::fix_t(); } +inline internal::FixedInt fix() { return internal::FixedInt(); } // The generic typename T is mandatory. Otherwise, a code like fix could refer to either the function above or this next overload. // This way a code like fix can only refer to the previous function. template -inline internal::variable_or_fixed fix(T val) { return internal::variable_or_fixed(val); } +inline internal::VariableAndFixedInt fix(T val) { return internal::VariableAndFixedInt(val); } #endif #else // EIGEN_PARSED_BY_DOXYGEN @@ -133,17 +136,17 @@ inline internal::variable_or_fixed fix(T val) { return internal::variable_or_ * * In c++14, it is implemented as: * \code - * template static const internal::fix_t fix{}; + * template static const internal::FixedInt fix{}; * \endcode - * where internal::fix_t is an internal template class similar to + * where internal::FixedInt is an internal template class similar to * \c std::integral_constant - * Here, \c fix is thus an object of type \c internal::fix_t. + * Here, \c fix is thus an object of type \c internal::FixedInt. * * In c++98/11, it is implemented as a function: * \code - * template inline internal::fix_t fix(); + * template inline internal::FixedInt fix(); * \endcode - * Here internal::fix_t is thus a pointer to function. + * Here internal::FixedInt is thus a pointer to function. * * If for some reason you want a true object in c++98 then you can write: \code fix() \endcode which is also valid in c++14. * diff --git a/Eigen/src/Core/util/SymbolicIndex.h b/Eigen/src/Core/util/SymbolicIndex.h index 62058760b..a52510f6a 100644 --- a/Eigen/src/Core/util/SymbolicIndex.h +++ b/Eigen/src/Core/util/SymbolicIndex.h @@ -61,7 +61,7 @@ protected: // Specialization for compile-time value, // It is similar to ValueExpr(N) but this version helps the compiler to generate better code. template -class ValueExpr > { +class ValueExpr > { public: ValueExpr() {} template @@ -114,30 +114,30 @@ public: { return QuotientExpr,Derived>(a,b.derived()); } template - AddExpr > > operator+(internal::fix_t) const - { return AddExpr > >(derived(), ValueExpr >()); } + AddExpr > > operator+(internal::FixedInt) const + { return AddExpr > >(derived(), ValueExpr >()); } template - AddExpr > > operator-(internal::fix_t) const - { return AddExpr > >(derived(), ValueExpr >()); } + AddExpr > > operator-(internal::FixedInt) const + { return AddExpr > >(derived(), ValueExpr >()); } template - ProductExpr > > operator*(internal::fix_t) const - { return ProductExpr > >(derived(),ValueExpr >()); } + ProductExpr > > operator*(internal::FixedInt) const + { return ProductExpr > >(derived(),ValueExpr >()); } template - QuotientExpr > > operator/(internal::fix_t) const - { return QuotientExpr > >(derived(),ValueExpr >()); } + QuotientExpr > > operator/(internal::FixedInt) const + { return QuotientExpr > >(derived(),ValueExpr >()); } template - friend AddExpr > > operator+(internal::fix_t, const BaseExpr& b) - { return AddExpr > >(b.derived(), ValueExpr >()); } + friend AddExpr > > operator+(internal::FixedInt, const BaseExpr& b) + { return AddExpr > >(b.derived(), ValueExpr >()); } template - friend AddExpr,ValueExpr > > operator-(internal::fix_t, const BaseExpr& b) - { return AddExpr,ValueExpr > >(-b.derived(), ValueExpr >()); } + friend AddExpr,ValueExpr > > operator-(internal::FixedInt, const BaseExpr& b) + { return AddExpr,ValueExpr > >(-b.derived(), ValueExpr >()); } template - friend ProductExpr >,Derived> operator*(internal::fix_t, const BaseExpr& b) - { return ProductExpr >,Derived>(ValueExpr >(),b.derived()); } + friend ProductExpr >,Derived> operator*(internal::FixedInt, const BaseExpr& b) + { return ProductExpr >,Derived>(ValueExpr >(),b.derived()); } template - friend QuotientExpr >,Derived> operator/(internal::fix_t, const BaseExpr& b) - { return QuotientExpr > ,Derived>(ValueExpr >(),b.derived()); } + friend QuotientExpr >,Derived> operator/(internal::FixedInt, const BaseExpr& b) + { return QuotientExpr > ,Derived>(ValueExpr >(),b.derived()); } template