Awali
Another Weighted Automata library
qfraction.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef COMMON_QFRACTION_HH
18 #define COMMON_QFRACTION_HH
19 
20 #include <awali/utils/arith.hh>
21 #include <awali/utils/hash.hh>
22 #include <complex>
23 
24 namespace awali {
25 
26  class q_fraction_t {
27  public:
28  using num_t = int;
29  using den_t = unsigned int;
30 
33 
34 
36 
37  q_fraction_t(num_t n, den_t d = 1u);
38 
39  q_fraction_t(long n, long d);
40 
42 
43  bool operator==(const q_fraction_t& w) const;
44  bool operator!=(const q_fraction_t& w) const;
45  bool operator<(const q_fraction_t& w) const;
46 
47 
52 
53  };
54 
55  std::ostream& operator<<(std::ostream& o, const q_fraction_t& v);
56 
57 }
58 
59 namespace std {
60  //hash_function
61 
62  bool operator< (const std::complex<double>& lhs,
63  const std::complex<double>& rhs);
64 
65  std::ostream& operator<<(std::ostream& o, const std::complex<double>& v);
66  ostream& operator<<(ostream& o, const basic_string<int>& s);
67 
68  template<>
69  struct hash<awali::q_fraction_t> {
70  size_t operator()(const awali::q_fraction_t& f) const {
71  size_t res = 0;
74  return res;
75  }
76  };
77 
78  template<typename T>
79  struct hash<std::complex<T>> {
80  size_t operator()(const std::complex<T>& c) const {
81  size_t res = 0;
84  return res;
85  }
86  };
87 
88 }//end of ns std
89 
90 #endif
Definition: qfraction.hh:26
q_fraction_t & reduce()
q_fraction_t(long n, long d)
q_fraction_t operator+(q_fraction_t const &) const
q_fraction_t(num_t n, den_t d=1u)
den_t den
Definition: qfraction.hh:32
int num_t
Definition: qfraction.hh:28
num_t num
Definition: qfraction.hh:31
bool operator<(const q_fraction_t &w) const
q_fraction_t operator/(q_fraction_t const &) const
bool operator!=(const q_fraction_t &w) const
unsigned int den_t
Definition: qfraction.hh:29
bool operator==(const q_fraction_t &w) const
q_fraction_t operator*(q_fraction_t const &) const
q_fraction_t operator-(q_fraction_t const &) const
std::size_t hash_value(const T &v)
Definition: hash.hh:76
Main namespace of Awali.
Definition: ato.hh:22
std::ostream & operator<<(std::ostream &o, const q_fraction_t &v)
size_t operator()(const awali::q_fraction_t &f) const
Definition: qfraction.hh:70
size_t operator()(const std::complex< T > &c) const
Definition: qfraction.hh:80
void hash_combine(std::size_t &seed, const T &v)
Definition: hash.hh:27