00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef NTG_OPTRAITS_REAL_HH_
00029 # define NTG_OPTRAITS_REAL_HH_
00030
00031 # include <cmath>
00032
00033 # include <mlc/is_a.hh>
00034
00035 # include <ntg/real/real_value.hh>
00036 # include <ntg/core/type_traits.hh>
00037 # include <ntg/core/abstract_hierarchy.hh>
00038
00039
00040
00041 # include <ntg/core/internal/global_ops_traits.hh>
00042 # include <ntg/core/macros.hh>
00043
00044
00045 # include <ntg/real/optraits_real_defs.hh>
00046
00047 namespace ntg {
00048
00049 namespace internal {
00050
00051
00052
00053
00054
00056 template <class E>
00057 class optraits<real_value<E> > : public optraits<value<E> >
00058 {
00059 private:
00060 typedef typename typetraits<E>::storage_type storage_type_;
00061
00062 public:
00063 static storage_type_ zero () { return 0; }
00064 static storage_type_ unit () { return 1; }
00065 static storage_type_ default_val() { return zero(); }
00066
00067
00068
00069
00070
00071
00072
00073
00074 ASSIGN_SCALAR_OPERATOR(plus)
00075 ASSIGN_SCALAR_OPERATOR(minus)
00076 ASSIGN_SCALAR_OPERATOR(times)
00077 ASSIGN_SCALAR_OPERATOR(div)
00078
00079 ARITH_SCALAR_OPERATOR(plus)
00080 ARITH_SCALAR_OPERATOR(minus)
00081 ARITH_SCALAR_OPERATOR(times)
00082 ARITH_SCALAR_OPERATOR(div)
00083
00084 CMP_SCALAR_OPERATOR(cmp_eq, ==)
00085 CMP_SCALAR_OPERATOR(cmp_lt, <)
00086 };
00087
00088
00089
00090
00091
00092 template <class E>
00093 class optraits<float_value<E> > : public optraits<real_value<E> >
00094 {
00095 public:
00096
00097 static unsigned max_print_width () { return 11U; }
00098 };
00099
00100
00101
00102
00103
00104 template <class E>
00105 class optraits<int_value<E> > : public optraits<real_value<E> >
00106 {
00107 typedef typename typetraits<E>::storage_type storage_type_;
00108
00109 public:
00110 static storage_type_ inf () { return optraits<E>::min(); }
00111 static storage_type_ sup () { return optraits<E>::max(); }
00112
00113 static unsigned max_print_width ()
00114 {
00115 return (unsigned) log10(double(optraits<E>::max())) + 1;
00116 }
00117
00118 ASSIGN_INT_OPERATOR(mod_equal, %)
00119 ARITH_INT_OPERATOR(mod, %=)
00120 };
00121
00122
00123
00124
00125
00126 template <class E>
00127 class optraits<uint_value<E> > : public optraits<int_value<E> >
00128 {
00129 private:
00130 typedef typename typetraits<E>::storage_type storage_type_;
00131
00132 public:
00133 static storage_type_ min () { return 0; }
00134 };
00135
00136
00137
00138
00139
00140 template <class E>
00141 class optraits<sint_value<E> > : public optraits<int_value<E> >
00142 {};
00143
00144 }
00145
00146 }
00147
00148 #endif // ndef NTG_OPTRAITS_REAL_HH_