- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# cyclic_semiring.hh

    00001 // cyclic_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, 2007, 2011 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_CYCLIC_SEMIRING_HH
    00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_CYCLIC_SEMIRING_HH
    00019
    00020 # include <vaucanson/algebra/concept/cyclic_semiring.hh>
    00021
    00022 namespace vcsn {
    00023
    00024   namespace algebra {
    00025
    00026     // We provide a generic implementation of cyclic semirings
    00027     // formed with C++-builtins and standard operations (+, *, %).
    00028
    00029     /*---------------.
    00030     | Identity value |
    00031     `---------------*/
    00032     template<unsigned int n, typename T>
    00033     T identity_value(SELECTOR(algebra::CyclicSemiring<n>),
    00034                      SELECTOR(T));
    00035
    00036     template<unsigned int n, typename T>
    00037     bool show_identity_value(SELECTOR(algebra::CyclicSemiring<n>),
    00038                              SELECTOR(T));
    00039
    00040     template<unsigned int n, typename T>
    00041     bool
    00042     is_positive_semiring(SELECTOR(algebra::CyclicSemiring<n>), SELECTOR(T));
    00043
    00044     template<unsigned int n, typename T>
    00045     T zero_value(SELECTOR(algebra::CyclicSemiring<n>),
    00046                  SELECTOR(T));
    00047
    00048     template<unsigned int n, typename T>
    00049     T zero_value(SELECTOR(algebra::CyclicSemiring<n>),
    00050                  SELECTOR(T));
    00051
    00052     /*------------.
    00053     | op_contains |
    00054     `------------*/
    00055     template<unsigned int n, typename T>
    00056     bool op_contains(const algebra::CyclicSemiring<n>& s, T c);
    00057
    00058     /*---------------.
    00059     | Multiplication |
    00060     `---------------*/
    00061     template<unsigned int n, typename T, typename U>
    00062     void op_in_mul(const algebra::CyclicSemiring<n>& s1,
    00063                    T& dst, U arg);
    00064
    00065     template<unsigned int n, typename T, typename U>
    00066     T op_mul(const algebra::CyclicSemiring<n>& s, T a, U b);
    00067
    00068     /*-----------------------.
    00069     | Mutiplication for Z/2Z |
    00070     `-----------------------*/
    00071
    00072     template<>
    00073     void op_in_mul<2, bool, bool>(const algebra::CyclicSemiring<2>&,
    00074                                   bool& dst, bool arg);
    00075
    00076     template<>
    00077     bool op_mul<2, bool, bool>(const algebra::CyclicSemiring<2>&, bool a, bool b);
    00078
    00079     /*---------.
    00080     | Addition |
    00081     `---------*/
    00082     template<unsigned int n, typename T, typename U>
    00083     void op_in_add(const algebra::CyclicSemiring<n>& s1,
    00084                    T& dst, U arg);
    00085
    00086     template<unsigned int n, typename T, typename U>
    00087     T op_add(const algebra::CyclicSemiring<n>& s,
    00088              T a, U b);
    00089
    00090     /*------------------.
    00091     | Addition for Z/2Z |
    00092     `------------------*/
    00093
    00094     template<>
    00095     void op_in_add<2, bool, bool>(const algebra::CyclicSemiring<2>&,
    00096                                   bool& dst, bool arg);
    00097
    00098     template<>
    00099     bool op_add<2, bool, bool>(const algebra::CyclicSemiring<2>&, bool a, bool b);
    00100
    00101     /*---------.
    00102     | Division |
    00103     `---------*/
    00104
    00105     template<unsigned int n, typename T, typename U>
    00106     void op_in_div(const algebra::CyclicSemiring<n>& s1,
    00107                    T& dst, U arg);
    00108
    00109     template<unsigned int n, typename T, typename U>
    00110     T op_div(const algebra::CyclicSemiring<n>& s, T a, U b);
    00111
    00112     /*------------------.
    00113     | Division for Z/2Z |
    00114     `------------------*/
    00115
    00116     template<>
    00117     void op_in_div<2, bool, bool> (const algebra::CyclicSemiring<2>& s1,
    00118                                    bool& dst, bool arg);
    00119
    00120     template<>
    00121     bool op_div<2, bool, bool> (const algebra::CyclicSemiring<2>& s, bool a, bool b);
    00122
    00123     /*-------------.
    00124     | Substraction |
    00125     `-------------*/
    00126
    00127     template<unsigned int n, typename T, typename U>
    00128     void op_in_sub(const algebra::CyclicSemiring<n>& s1,
    00129                    T& dst, U arg);
    00130
    00131     template<unsigned int n, typename T, typename U>
    00132     T op_sub(const algebra::CyclicSemiring<n>& s,
    00133              T a, U b);
    00134
    00135     /*----------------------.
    00136     | Substraction for Z/2Z |
    00137     `----------------------*/
    00138
    00139     template<>
    00140     void op_in_sub<2, bool, bool> (const algebra::CyclicSemiring<2>& s1,
    00141                                    bool& dst, bool arg);
    00142
    00143     template<>
    00144     bool op_sub(const algebra::CyclicSemiring<2>& s,
    00145                 bool a, bool b);
    00146
    00147     /*-----.
    00148     | Star |
    00149     `-----*/
    00150     template <unsigned int n, typename T>
    00151     bool
    00152     op_starable(const algebra::CyclicSemiring<n>&, T b);
    00153
    00154     template <unsigned int n, class T>
    00155     void
    00156     op_in_star(const algebra::CyclicSemiring<n>& s, T& b);
    00157
    00158     template <unsigned int n, class T>
    00159     Element<algebra::CyclicSemiring<n>, T>
    00160     op_choose(const algebra::CyclicSemiring<n>& set, SELECTOR(T));
    00161
    00162     template <unsigned int n, typename T>
    00163     bool
    00164     op_can_choose_non_starable(const algebra::CyclicSemiring<n>&
    00165                                set, SELECTOR(T));
    00166
    00167     template <unsigned int n, typename T>
    00168     Element<algebra::CyclicSemiring<n>, T>
    00169     op_choose_starable(const algebra::CyclicSemiring<n>& set,
    00170                        SELECTOR(T));
    00171
    00172     template <unsigned int n, typename T>
    00173     Element<algebra::CyclicSemiring<n>, T>
    00174     op_choose_non_starable(const algebra::CyclicSemiring<n>& set,
    00175                            SELECTOR(T));
    00176
    00177     /*---------------.
    00178     | Pretty printer |
    00179     `---------------*/
    00180     template<unsigned int n, typename St, typename T>
    00181     St& op_rout(const algebra::CyclicSemiring<n>& s,
    00182                 St& st, const T& v);
    00183
    00184   } // algebra
    00185
    00186 } // vcsn
    00187
    00188
    00189 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00190 #  include <vaucanson/algebra/implementation/semiring/cyclic_semiring.hxx>
    00191 # endif // VCSN_USE_INTERFACE_ONLY
    00192
    00193
    00194 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_CYCLIC_SEMIRING_HH