23 #ifndef NDARRAY_types_h_INCLUDED
24 #define NDARRAY_types_h_INCLUDED
31 #include <boost/type_traits/is_complex.hpp>
45 template <typename T, typename U=typename boost::remove_const<T>::type,
46 typename is_complex=
typename boost::is_complex<U>::type,
47 typename is_arithmetic=
typename boost::is_arithmetic<U>::type>
51 template <
typename T,
typename U>
52 struct NumericTraits<T,U,boost::false_type,boost::true_type> {
54 typedef boost::true_type IsReal;
56 typedef std::complex<U> ComplexType;
59 static const int PRIORITY =
sizeof(U) + (
sizeof(
long long) * (!std::numeric_limits<U>::is_integer));
62 template <
typename T,
typename U>
63 struct NumericTraits<T,U,boost::true_type,boost::false_type> {
65 typedef boost::false_type IsReal;
66 typedef typename U::value_type RealType;
67 typedef U ComplexType;
68 typedef U
const & ParamType;
70 static const int PRIORITY = NumericTraits<RealType>::PRIORITY;
78 template <
typename T1,
typename T2,
79 bool winner=(NumericTraits<T1>::PRIORITY > NumericTraits<T2>::PRIORITY),
80 bool is_complex=(NumericTraits<T1>::IsReal::value && NumericTraits<T2>::IsReal::value)
88 template <
typename T1,
typename T2>
89 struct Promote<T1,T2,false,true> {
94 template <
typename T1,
typename T2>
95 struct Promote<T1,T2,true,true> {
96 typedef typename NumericTraits<T1>::Type Type;
100 template <
typename T1,
typename T2>
101 struct Promote<T1,T2,false,false> {
102 typedef typename NumericTraits<T2>::ComplexType Type;
106 template <
typename T1,
typename T2>
107 struct Promote<T1,T2,true,false> {
108 typedef typename NumericTraits<T1>::ComplexType Type;
123 template <
typename T>
127 if (b < static_cast<T>(1) && a > b*std::numeric_limits<T>::max())
128 return std::numeric_limits<T>::max();
129 if (a == static_cast<T>(0) || (b > static_cast<T>(1) && a < b*std::numeric_limits<T>::min()))
130 return static_cast<T
>(0);
134 static inline T
abs(T a) {
135 return (a < static_cast<T>(0)) ? -a : a;
148 template <
typename T1,
typename T2=T1>
176 template <
typename U1,
typename U2>
185 return _real(a.real(),b.real()) && _real(a.imag(),b.imag());
198 #endif // !NDARRAY_types_h_INCLUDED
result_type operator()(std::complex< U1 > const &a, std::complex< U2 > const &b) const
ApproximatelyEqual(Promoted tolerance)
std::complex< U2 > second_argument_type
result_type operator()(T1 a, T2 b) const
ApproximatelyEqual(Promoted tolerance)
Binary predicate for floating point equality comparison with tolerance.
static T divide(T a, T b)
Promote< T1, T2 >::Type Promoted
std::complex< U1 > first_argument_type
afw::table::Key< double > b
Promote< U1, U2 >::Type Promoted
detail::SafeFloatingPointOps< Promoted > Ops
ApproximatelyEqual< U1, U2 > _real