• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

floatings.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_VALUE_BUILTIN_FLOATINGS_HH
00027 # define MLN_VALUE_BUILTIN_FLOATINGS_HH
00028 
00032 
00033 # include <mln/value/internal/limits.hh>
00034 
00035 # include <mln/value/concept/built_in.hh>
00036 # include <mln/value/concept/floating.hh>
00037 # include <mln/trait/value_.hh>
00038 
00039 
00040 namespace mln
00041 {
00042 
00043 
00044   template <>
00045   struct category< float >
00046   {
00047     typedef value::Built_In< value::Floating<void> > ret;
00048   };
00049 
00050   template <>
00051   struct category< double >
00052   {
00053     typedef value::Built_In< value::Floating<void> > ret;
00054   };
00055 
00056 
00057   namespace trait
00058   {
00059 
00060 
00061     // float.
00062 
00063     template <>
00064     struct value_< float >
00065     {
00066       enum {
00067         dim   = 1,
00068         nbits = 8 * sizeof(float),
00069         card  = 0
00070       };
00071 
00072       typedef value::nature::floating nature;
00073       typedef value::kind::data       kind;
00074       typedef value::quant::high      quant;
00075 
00076       static float min()
00077       {
00078         static const float min_ = mln::value::internal::limits<float>::min();
00079         return min_;
00080       }
00081       static float max()
00082       {
00083         static const float max_ = mln::value::internal::limits<float>::max();
00084         return max_;
00085       }
00086       static float epsilon()
00087       {
00088         static const float epsilon_ = mln::value::internal::limits<float>::epsilon();
00089         return epsilon_;
00090       }
00091 
00092       typedef float                        sum;
00093 
00094       static const char* name()
00095       { return "float"; }
00096 
00097     };
00098 
00099 
00100     // double.
00101 
00102     template <>
00103     struct value_< double >
00104     {
00105       enum {
00106         dim   = 1,
00107         nbits = 8 * sizeof(double),
00108         card  = 0
00109       };
00110 
00111       typedef value::nature::floating nature;
00112       typedef value::kind::data       kind;
00113       typedef value::quant::high      quant;
00114 
00115       static double min()
00116       {
00117         static const double min_ = mln::value::internal::limits<double>::min();
00118         return min_;
00119       }
00120       static double max()
00121       {
00122         static const double max_ = mln::value::internal::limits<double>::max();
00123         return max_;
00124       }
00125       static double epsilon()
00126       {
00127         static const double epsilon_ = mln::value::internal::limits<double>::epsilon();
00128         return epsilon_;
00129       }
00130 
00131       typedef double                        sum;
00132 
00133       static const char* name()
00134       { return "float"; }
00135 
00136     };
00137 
00138   } // end of namespace mln::trait
00139 
00140 } // end of namespace mln
00141 
00142 
00143 #endif // ! MLN_VALUE_BUILTIN_FLOATINGS_HH

Generated on Tue Oct 4 2011 15:23:47 for Milena (Olena) by  doxygen 1.7.1