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 #ifndef MLN_VALUE_BUILTIN_FLOATINGS_HH
00028 # define MLN_VALUE_BUILTIN_FLOATINGS_HH
00029
00033
00034 # include <mln/value/internal/limits.hh>
00035
00036 # include <mln/value/concept/built_in.hh>
00037 # include <mln/value/concept/floating.hh>
00038 # include <mln/trait/value_.hh>
00039
00040
00041 namespace mln
00042 {
00043
00044
00045 template <>
00046 struct category< float >
00047 {
00048 typedef value::Built_In< value::Floating<void> > ret;
00049 };
00050
00051 template <>
00052 struct category< double >
00053 {
00054 typedef value::Built_In< value::Floating<void> > ret;
00055 };
00056
00057
00058 namespace trait
00059 {
00060
00061
00062
00063
00064 template <>
00065 struct value_< float >
00066 {
00067 enum {
00068 dim = 1,
00069 nbits = 8 * sizeof(float),
00070 card = 0
00071 };
00072
00073 typedef value::nature::floating nature;
00074 typedef value::kind::data kind;
00075 typedef value::quant::high quant;
00076
00077 static float min()
00078 {
00079
00080
00081
00082
00083
00084 static const float min_ = - mln::value::internal::limits<float>::max();
00085 return min_;
00086 }
00087 static float max()
00088 {
00089 static const float max_ = mln::value::internal::limits<float>::max();
00090 return max_;
00091 }
00092 static float epsilon()
00093 {
00094 static const float epsilon_ = mln::value::internal::limits<float>::epsilon();
00095 return epsilon_;
00096 }
00097
00098 typedef float sum;
00099
00100 static const char* name()
00101 { return "float"; }
00102
00103 };
00104
00105
00106
00107
00108 template <>
00109 struct value_< double >
00110 {
00111 enum {
00112 dim = 1,
00113 nbits = 8 * sizeof(double),
00114 card = 0
00115 };
00116
00117 typedef value::nature::floating nature;
00118 typedef value::kind::data kind;
00119 typedef value::quant::high quant;
00120
00121 static double min()
00122 {
00123
00124
00125
00126
00127
00128 static const double min_ = - mln::value::internal::limits<double>::max();
00129 return min_;
00130 }
00131 static double max()
00132 {
00133 static const double max_ = mln::value::internal::limits<double>::max();
00134 return max_;
00135 }
00136 static double epsilon()
00137 {
00138 static const double epsilon_ = mln::value::internal::limits<double>::epsilon();
00139 return epsilon_;
00140 }
00141
00142 typedef double sum;
00143
00144 static const char* name()
00145 { return "double"; }
00146
00147 };
00148
00149 }
00150
00151 }
00152
00153
00154 #endif // ! MLN_VALUE_BUILTIN_FLOATINGS_HH