31 #if defined(NumberTraits_RECURSES) 32 #error Recursive header files inclusion detected in NumberTraits.h 33 #else // defined(NumberTraits_RECURSES) 35 #define NumberTraits_RECURSES 37 #if !defined NumberTraits_h 39 #define NumberTraits_h 46 #include <boost/integer_traits.hpp> 47 #include <boost/call_traits.hpp> 48 #include "DGtal/base/Common.h" 83 typedef typename boost::call_traits<T>::param_type
ParamType;
93 static const T
ZERO = T(0);
102 static const T
ONE = T(1);
131 static unsigned int digits();
156 return static_cast<double>(aT);
191 typedef boost::call_traits<uint16_t>::param_type
ParamType;
204 return boost::integer_traits<uint16_t>::const_min;
208 return boost::integer_traits<uint16_t>::const_max;
212 return boost::integer_traits<uint16_t>::digits;
232 return static_cast<double>(aT);
240 return ( aT & 1 ) == 0;
248 return ( aT & 1 ) != 0;
267 typedef boost::call_traits<int16_t>::param_type
ParamType;
280 return boost::integer_traits<int16_t>::const_min;
284 return boost::integer_traits<int16_t>::const_max;
288 return boost::integer_traits<int16_t>::digits;
308 return static_cast<double>(aT);
316 return ( aT & 1 ) == 0;
324 return ( aT & 1 ) != 0;
343 typedef boost::call_traits<uint8_t>::param_type
ParamType;
356 return boost::integer_traits<uint8_t>::const_min;
360 return boost::integer_traits<uint8_t>::const_max;
364 return boost::integer_traits<uint8_t>::digits;
384 return static_cast<double>(aT);
392 return ( aT & 1 ) == 0;
400 return ( aT & 1 ) != 0;
419 typedef boost::call_traits<int8_t>::param_type
ParamType;
432 return boost::integer_traits<int8_t>::const_min;
436 return boost::integer_traits<int8_t>::const_max;
440 return boost::integer_traits<int8_t>::digits;
460 return static_cast<double>(aT);
468 return ( aT & 1 ) == 0;
476 return ( aT & 1 ) != 0;
494 typedef boost::call_traits<uint32_t>::param_type
ParamType;
507 return boost::integer_traits<uint32_t>::const_min;
511 return boost::integer_traits<uint32_t>::const_max;
515 return boost::integer_traits<uint32_t>::digits;
531 return static_cast<double>(aT);
539 return ( aT & 1 ) == 0;
547 return ( aT & 1 ) != 0;
565 typedef boost::call_traits<int32_t>::param_type
ParamType;
578 return boost::integer_traits<int32_t>::const_min;
582 return boost::integer_traits<int32_t>::const_max;
586 return boost::integer_traits<int32_t>::digits;
606 return static_cast<double>(aT);
614 return ( aT & 1 ) == 0;
622 return ( aT & 1 ) != 0;
640 typedef boost::call_traits<uint64_t>::param_type
ParamType;
653 return boost::integer_traits<uint64_t>::const_min;
657 return boost::integer_traits<uint64_t>::const_max;
661 return boost::integer_traits<uint64_t>::digits;
681 return static_cast<double>(aT);
689 return ( aT & 1 ) == 0;
697 return ( aT & 1 ) != 0;
715 typedef boost::call_traits<int64_t>::param_type
ParamType;
728 return boost::integer_traits<int64_t>::const_min;
732 return boost::integer_traits<int64_t>::const_max;
736 return boost::integer_traits<int64_t>::digits;
752 return static_cast<double>(aT);
760 return ( aT & 1 ) == 0;
768 return ( aT & 1 ) != 0;
786 typedef boost::call_traits<float>::param_type
ParamType;
819 return static_cast<int64_t>( aT );
823 return static_cast<double>(aT);
842 typedef boost::call_traits<double>::param_type
ParamType;
875 return static_cast<int64_t>( aT );
879 return static_cast<double>(aT);
898 typedef boost::call_traits<long double>::param_type
ParamType;
900 static const long double ONE;
931 return static_cast<int64_t>( aT );
935 return static_cast<double>(aT);
946 struct NumberTraits<unsigned long>
956 typedef boost::call_traits<unsigned long>::param_type
ParamType;
957 static const unsigned long ZERO;
958 static const unsigned long ONE;
969 return boost::integer_traits<unsigned long>::const_min;
973 return boost::integer_traits<unsigned long>::const_max;
975 static unsigned int digits()
977 return boost::integer_traits<unsigned long>::digits;
989 return static_cast<int64_t>( aT );
993 return static_cast<double>(aT);
999 #ifdef WITH_BIGINTEGER 1030 FATAL_ERROR_MSG(
false,
"UnBounded interger type does not support min() function");
1035 FATAL_ERROR_MSG(
false,
"UnBounded interger type does not support max() function");
1039 static unsigned int digits()
1041 FATAL_ERROR_MSG(
false,
"UnBounded interger type does not support digits() function");
1066 return mpz_even_p( aT.get_mpz_t() );
1074 return mpz_odd_p( aT.get_mpz_t() );
1082 template<
class A,
class B>
1099 #include "DGtal/kernel/NumberTraits.ih" 1104 #endif // !defined NumberTraits_h 1106 #undef NumberTraits_RECURSES 1107 #endif // else defined(NumberTraits_RECURSES)
static SignEnum isSigned()
boost::uint32_t uint32_t
unsigned 32-bit integer.
static double castToDouble(const uint64_t &aT)
boost::call_traits< uint8_t >::param_type ParamType
static const uint64_t ZERO
static DGtal::int64_t castToInt64_t(const int8_t &aT)
static BoundEnum isBounded()
static BoundEnum isBounded()
static bool even(ParamType aT)
static BoundEnum isBounded()
static unsigned int digits()
boost::int8_t int8_t
signed 8-bit integer.
static bool odd(ParamType aT)
static unsigned int digits()
static BoundEnum isBounded()
static unsigned int digits()
static DGtal::int64_t castToInt64_t(const int64_t &aT)
static unsigned int digits()
static double castToDouble(const uint8_t &aT)
static BoundEnum isBounded()
static const long double ONE
static double castToDouble(const T &aT)
static bool even(ParamType aT)
boost::call_traits< long double >::param_type ParamType
static double castToDouble(const uint32_t &aT)
boost::call_traits< int64_t >::param_type ParamType
static unsigned int digits()
static bool even(ParamType aT)
static unsigned int digits()
static bool odd(ParamType aT)
static bool odd(ParamType aT)
static unsigned int digits()
static DGtal::int64_t castToInt64_t(const float &aT)
static bool even(ParamType aT)
boost::call_traits< int8_t >::param_type ParamType
boost::call_traits< T >::param_type ParamType
static const int16_t ZERO
static bool even(ParamType aT)
mpz_class BigInteger
Multi-precision integer with GMP implementation.
static SignEnum isSigned()
static BoundEnum isBounded()
static double castToDouble(const int32_t &aT)
boost::int16_t int16_t
signed 16-bit integer.
static BoundEnum isBounded()
boost::call_traits< double >::param_type ParamType
static unsigned int digits()
static bool odd(ParamType aT)
static const uint64_t ONE
static BoundEnum isBounded()
static SignEnum isSigned()
static const uint32_t ZERO
long double UnsignedVersion
static bool even(ParamType aT)
static BoundEnum isBounded()
static DGtal::int64_t castToInt64_t(const uint64_t &aT)
boost::call_traits< float >::param_type ParamType
static DGtal::int64_t castToInt64_t(const uint32_t &aT)
boost::call_traits< int16_t >::param_type ParamType
Aim: The traits class for all models of Cinteger.
boost::call_traits< uint32_t >::param_type ParamType
boost::uint16_t uint16_t
unsigned 16-bit integer.
static DGtal::int64_t castToInt64_t(const T &aT)
static const uint8_t ZERO
static double castToDouble(const int16_t &aT)
static DGtal::int64_t castToInt64_t(const uint16_t &aT)
static SignEnum isSigned()
static double castToDouble(const int64_t &aT)
static double castToDouble(const int8_t &aT)
static const uint16_t ZERO
static SignEnum isSigned()
static bool even(ParamType aT)
static SignEnum isSigned()
DGtal is the top-level namespace which contains all DGtal functions and types.
static unsigned int digits()
static SignEnum isSigned()
boost::uint8_t uint8_t
unsigned 8-bit integer.
static const int64_t ZERO
static BoundEnum isBounded()
boost::uint64_t uint64_t
unsigned 64-bit integer.
static DGtal::int64_t castToInt64_t(const int16_t &aT)
static bool odd(ParamType aT)
static bool odd(ParamType aT)
static DGtal::int64_t castToInt64_t(const long double &aT)
static bool even(ParamType aT)
static unsigned int digits()
static const uint16_t ONE
boost::call_traits< int32_t >::param_type ParamType
static DGtal::int64_t castToInt64_t(const int32_t &aT)
static double castToDouble(const long double &aT)
static DGtal::int64_t castToInt64_t(const uint8_t &aT)
static double castToDouble(const double &aT)
static double castToDouble(const float &aT)
static SignEnum isSigned()
static SignEnum isSigned()
static BoundEnum isBounded()
static bool even(ParamType aT)
long double SignedVersion
boost::int32_t int32_t
signed 32-bit integer.
static SignEnum isSigned()
static bool odd(ParamType aT)
static SignEnum isSigned()
boost::call_traits< uint64_t >::param_type ParamType
static const uint32_t ONE
boost::int64_t int64_t
signed 94-bit integer.
static DGtal::int64_t castToInt64_t(const double &aT)
static BoundEnum isBounded()
static bool odd(ParamType aT)
static SignEnum isSigned()
boost::call_traits< uint16_t >::param_type ParamType
static unsigned int digits()
static unsigned int digits()
static const int32_t ZERO
static double castToDouble(const uint16_t &aT)
static const long double ZERO
static bool odd(ParamType aT)