Vaucanson  1.4.1
q_number.hh
Go to the documentation of this file.
1 // q_number.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2011 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HH
19 
20 #include <iostream>
21 /* @{ *//* @{ */
35 namespace vcsn
36 {
37 /* @{ */
39  namespace algebra
40  {/* @{ */
42 
57  template<typename IntType>
59  {
60  public:
64  inline
65  TRationalNumber ();
67  inline
68  TRationalNumber (const IntType num);
70  inline
71  TRationalNumber (const IntType num, const IntType den);
73  inline
75  // Object destructor.
76  inline
79  public:
83  inline
84  TRationalNumber& set (const IntType num, const IntType den = 1);
89  inline
90  IntType num_get () const;
92  inline
93  IntType den_get () const;
95  inline
96  std::ostream& print (std::ostream& ostr) const;
97 
99  public:
103  inline
105  inline
107  inline
109  inline
111  inline
113 
114  inline
116  inline
118  inline
120  inline
122 
124  inline
125  bool operator== (const TRationalNumber<IntType>& nb) const;
126  inline
127  bool operator!= (const TRationalNumber<IntType>& nb) const;
128  inline
129  bool operator< (const TRationalNumber<IntType>& nb) const;
130  inline
131  bool operator<= (const TRationalNumber<IntType>& nb) const;
132  inline
133  bool operator> (const TRationalNumber<IntType>& nb) const;
134  inline
135  bool operator>= (const TRationalNumber<IntType>& nb) const;
136 
137  // @}
138 
142  // operator int () const;
143  //operator float () const;
144  inline
145  operator double () const;
146 
148  inline
149  IntType to_integer () const;
150  inline
151  float to_float () const;
152  inline
153  double to_double () const;
155  protected:
158 
166  inline void set_rational ();
167  inline void set_rational (const IntType num, const IntType den);
168  inline void set_unsafe_rational (const IntType num, const IntType den);
170  protected:
174  IntType num_;
176  IntType den_;
178  }; // TRationalNumber<IntType>
179 
180  template<typename IntType>
181  inline
182  std::ostream& operator<< (std::ostream&, const TRationalNumber<IntType>&);
183 
184  template<typename IntType>
185  inline
186  std::istream& operator>> (std::istream&, TRationalNumber<IntType>&);
187 
189 
191  } // !algebra
192 
194 } // !vcsn
195 
196 
197 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
198 # include <vaucanson/algebra/implementation/semiring/q_number.hxx>
199 # endif // VCSN_USE_INTERFACE_ONLY
200 
201 
202 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SEMIRING_Q_NUMBER_HH