numerical_semiring.hh

00001 // numerical_semiring.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 //
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_NUMERICAL_SEMIRING_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_NUMERICAL_SEMIRING_HH
00019 
00020 # include <vaucanson/algebra/concept/numerical_semiring.hh>
00021 # include <vaucanson/algebra/implementation/semiring/rational_number.hh>
00022 
00023 namespace vcsn {
00024 
00025   template<typename T>
00026   bool op_contains(const algebra::NumericalSemiring& s, T c);
00027 
00028   template<typename T, typename U>
00029   void op_in_mul(const algebra::NumericalSemiring& s1, T& dst, U arg);
00030 
00031   template<typename T, typename U>
00032   void op_in_add(const algebra::NumericalSemiring& s1, T& dst, U arg);
00033 
00034   template<typename T, typename U>
00035   T op_mul(const algebra::NumericalSemiring& s, T a, U b);
00036 
00037   template<typename T, typename U>
00038   T op_add(const algebra::NumericalSemiring& s, T a, U b);
00039 
00040   template<typename T>
00041   T identity_value(SELECTOR(algebra::NumericalSemiring), SELECTOR(T));
00042 
00043   template<typename T>
00044   T zero_value(SELECTOR(algebra::NumericalSemiring), SELECTOR(T));
00045 
00046   template <class T>
00047   Element<algebra::NumericalSemiring, T>
00048   op_choose(const algebra::NumericalSemiring& s, SELECTOR(T));
00049 
00050   /*-----------------------------.
00051   | specializations for integers |
00052   `-----------------------------*/
00053 
00054   bool
00055   op_can_choose_non_starable(const algebra::NumericalSemiring& set, SELECTOR(int));
00056 
00057   Element<algebra::NumericalSemiring, int>
00058   op_choose_starable(const algebra::NumericalSemiring& set, SELECTOR(int));
00059 
00060   Element<algebra::NumericalSemiring, int>
00061   op_choose_non_starable(const algebra::NumericalSemiring& set, SELECTOR(int));
00062 
00063   /*-----------------------------.
00064   | specializations for Booleans |
00065   `-----------------------------*/
00066   template<typename T>
00067   void op_in_mul(const algebra::NumericalSemiring& s1,
00068                         bool& dst, bool src);
00069 
00070   inline bool op_mul(const algebra::NumericalSemiring& s, bool a, bool b);
00071 
00072   inline void op_in_add(const algebra::NumericalSemiring& s1,
00073                         bool& dst, bool src);
00074 
00075   inline bool op_add(const algebra::NumericalSemiring& s, bool a, bool b);
00076 
00077   inline bool identity_value(SELECTOR(algebra::NumericalSemiring),
00078                              SELECTOR(bool));
00079 
00080   inline bool zero_value(SELECTOR(algebra::NumericalSemiring),
00081                          SELECTOR(bool));
00082 
00083   inline bool op_starable(const algebra::NumericalSemiring& s, bool b);
00084 
00085   inline void op_in_star(const algebra::NumericalSemiring& s, bool& b);
00086 
00087   Element<algebra::NumericalSemiring, bool>
00088   op_choose_starable(const algebra::NumericalSemiring& set, SELECTOR(bool));
00089 
00090   Element<algebra::NumericalSemiring, bool>
00091   op_choose_non_starable(const algebra::NumericalSemiring& set, SELECTOR(bool));
00092 
00093   /*-------------------------.
00094   | goodies for real numbers |
00095   `-------------------------*/
00096   template<typename T>
00097   bool op_starable(const algebra::NumericalSemiring& s, T v);
00098 
00099   inline bool op_starable(const algebra::NumericalSemiring& s,
00100                           const float& f);
00101 
00102   inline bool op_starable(const algebra::NumericalSemiring& s,
00103                           const double& f);
00104 
00105   inline void op_in_star(const algebra::NumericalSemiring& s, float& f);
00106 
00107   inline void op_in_star(const algebra::NumericalSemiring& s, double& f);
00108 
00109   bool
00110   op_can_choose_non_starable(const algebra::NumericalSemiring& set,
00111                               SELECTOR(float));
00112 
00113   Element<algebra::NumericalSemiring, float>
00114   op_choose_starable(const algebra::NumericalSemiring& set,
00115                      SELECTOR(float));
00116 
00117   Element<algebra::NumericalSemiring, float>
00118   op_choose_non_starable(const algebra::NumericalSemiring& set,
00119                          SELECTOR(float));
00120 
00121   bool
00122   op_can_choose_non_starable(const algebra::NumericalSemiring& set,
00123                               SELECTOR(double));
00124 
00125   Element<algebra::NumericalSemiring, double>
00126   op_choose_starable(const algebra::NumericalSemiring& set,
00127                      SELECTOR(double));
00128 
00129   Element<algebra::NumericalSemiring, double>
00130   op_choose_non_starable(const algebra::NumericalSemiring& set,
00131                          SELECTOR(double));
00132 
00133   /*-------------------------------------.
00134   | specializations for rational numbers |
00135   `-------------------------------------*/
00136 
00137   inline algebra::RationalNumber
00138   identity_value(SELECTOR(algebra::NumericalSemiring),
00139                  SELECTOR(algebra::RationalNumber));
00140 
00141   inline algebra::RationalNumber
00142   zero_value(SELECTOR(algebra::NumericalSemiring),
00143              SELECTOR(algebra::RationalNumber));
00144 
00145   template<typename T>
00146   bool op_starable(const algebra::NumericalSemiring& s, T v);
00147 
00148   inline bool op_starable(const algebra::NumericalSemiring& s,
00149                           const algebra::RationalNumber& r);
00150 
00151   inline void op_in_star(const algebra::NumericalSemiring& s,
00152                          algebra::RationalNumber& r);
00153 
00154   bool
00155   op_can_choose_non_starable(const algebra::NumericalSemiring& set,
00156                              SELECTOR(algebra::RationalNumber));
00157 
00158   Element<algebra::NumericalSemiring, algebra::RationalNumber>
00159   op_choose_starable(const algebra::NumericalSemiring& set,
00160                      SELECTOR(algebra::RationalNumber));
00161 
00162   Element<algebra::NumericalSemiring, algebra::RationalNumber>
00163   op_choose_non_starable(const algebra::NumericalSemiring& set,
00164                          SELECTOR(algebra::RationalNumber));
00165 
00166 } // vcsn
00167 
00168 
00169 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00170 # include <vaucanson/algebra/implementation/semiring/numerical_semiring.hxx>
00171 #endif // VCSN_USE_INTERFACE_ONLY
00172 
00173 
00174 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_NUMERICAL_SEMIRING_HH

Generated on Sun Jul 29 19:35:28 2007 for Vaucanson by  doxygen 1.5.2