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

- File List
- File Members

# q_number.hh

Go to the documentation of this file.

    00001 // q_number.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 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_Q_NUMBER_HH
    00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HH
    00019
    00020 #include <iostream>
    00021 /* @{ *//* @{ */
    00035 namespace vcsn
    00036 {
    00037 /* @{ */
    00039   namespace algebra
    00040   {/* @{ */
    00042
    00057     template<typename NUMType, typename DENType>
    00058     class TRationalNumber
    00059     {
    00060     public:
    00064       inline
    00065       TRationalNumber ();
    00067       inline
    00068       TRationalNumber (const NUMType num);
    00070       inline
    00071       TRationalNumber (const NUMType num, const DENType den);
    00073       inline
    00074       TRationalNumber (const TRationalNumber<NUMType, DENType>& nb);
    00075       // Object destructor.
    00076       inline
    00077       ~TRationalNumber ();
    00079     public:
    00083       inline
    00084       TRationalNumber& set (const NUMType num, const DENType den = 1);
    00089       inline
    00090       NUMType num_get () const;
    00092       inline
    00093       DENType den_get () const;
    00095       inline
    00096       std::ostream& print (std::ostream& ostr) const;
    00097
    00099     public:
    00103       inline
    00104       TRationalNumber<NUMType, DENType> operator+ (const TRationalNumber<NUMType, DENType>& nb) const;
    00105       inline
    00106       TRationalNumber<NUMType, DENType> operator- (const TRationalNumber<NUMType, DENType>& nb) const;
    00107       inline
    00108       TRationalNumber<NUMType, DENType> operator- () const;
    00109       inline
    00110       TRationalNumber<NUMType, DENType> operator* (const TRationalNumber<NUMType, DENType>& nb) const;
    00111       inline
    00112       TRationalNumber<NUMType, DENType> operator/ (const TRationalNumber<NUMType, DENType>& nb) const;
    00113
    00114       inline
    00115       TRationalNumber<NUMType, DENType>& operator+= (const TRationalNumber<NUMType, DENType>& nb);
    00116       inline
    00117       TRationalNumber<NUMType, DENType>& operator-= (const TRationalNumber<NUMType, DENType>& nb);
    00118       inline
    00119       TRationalNumber<NUMType, DENType>& operator*= (const TRationalNumber<NUMType, DENType>& nb);
    00120       inline
    00121       TRationalNumber<NUMType, DENType>& operator/= (const TRationalNumber<NUMType, DENType>& nb);
    00122
    00124       inline
    00125       bool operator== (const TRationalNumber<NUMType, DENType>& nb) const;
    00126       inline
    00127       bool operator!= (const TRationalNumber<NUMType, DENType>& nb) const;
    00128       inline
    00129       bool operator< (const TRationalNumber<NUMType, DENType>& nb) const;
    00130       inline
    00131       bool operator<= (const TRationalNumber<NUMType, DENType>& nb) const;
    00132       inline
    00133       bool operator> (const TRationalNumber<NUMType, DENType>& nb) const;
    00134       inline
    00135       bool operator>= (const TRationalNumber<NUMType, DENType>& nb) const;
    00136
    00137       // @}
    00138
    00142       // operator int () const;
    00143       inline
    00144       operator float () const;
    00145       // operator double () const;
    00146
    00148       inline
    00149       int to_int () const;
    00150       inline
    00151       float to_float () const;
    00152       inline
    00153       double to_double () const;
    00155     protected:
    00158
    00166       inline void set_rational ();
    00167       inline void set_rational (const NUMType num, const DENType den);
    00168       inline void set_unsafe_rational (const NUMType num, const DENType den);
    00170     protected:
    00174       NUMType num_;
    00176       DENType den_;
    00178     }; // TRationalNumber<NUMType, DENType>
    00179
    00180     template<typename NUMType, typename DENType>
    00181     inline
    00182     std::ostream& operator<< (std::ostream&, const TRationalNumber<NUMType, DENType>&);
    00183
    00184     template<typename NUMType, typename DENType>
    00185     inline
    00186     std::istream& operator>> (std::istream&, TRationalNumber<NUMType, DENType>&);
    00187
    00188     typedef TRationalNumber<long long, unsigned long long> RationalNumber;
    00189
    00191   } // !algebra
    00192
    00194 } // !vcsn
    00195
    00196
    00197 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00198 #  include <vaucanson/algebra/implementation/semiring/q_number.hxx>
    00199 # endif // VCSN_USE_INTERFACE_ONLY
    00200
    00201
    00202 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HH