Awali
Another Weighted Automata library
qfraction.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2021 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  struct q_fraction_t {
27  int num;
28  unsigned int den;
29 
30  q_fraction_t(int n = 0, unsigned d = 1);
31 
32  q_fraction_t(int n, int d);
33 
35 
36  bool operator==(const q_fraction_t& w) const;
37 
38  bool operator<(const q_fraction_t& w) const;
39 
40  };
41 
42  std::ostream& operator<<(std::ostream& o, const q_fraction_t& v);
43 
44 }
45 
46 namespace std {
47  //hash_function
48 
49  bool operator< (const std::complex<double>& lhs,
50  const std::complex<double>& rhs);
51 
52  std::ostream& operator<<(std::ostream& o, const std::complex<double>& v);
53  ostream& operator<<(ostream& o, basic_string<int>& s);
54 
55  template<>
56  struct hash<awali::q_fraction_t> {
57  size_t operator()(const awali::q_fraction_t& f) const {
58  size_t res = 0;
61  return res;
62  }
63  };
64 
65  template<typename T>
66  struct hash<std::complex<T>> {
67  size_t operator()(const std::complex<T>& c) const {
68  size_t res = 0;
71  return res;
72  }
73  };
74 
75 }//end of ns std
76 
77 #endif
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)
Definition: qfraction.hh:26
q_fraction_t & reduce()
q_fraction_t(int n, int d)
q_fraction_t(int n=0, unsigned d=1)
int num
Definition: qfraction.hh:27
bool operator<(const q_fraction_t &w) const
unsigned int den
Definition: qfraction.hh:28
bool operator==(const q_fraction_t &w) const
size_t operator()(const awali::q_fraction_t &f) const
Definition: qfraction.hh:57
size_t operator()(const std::complex< T > &c) const
Definition: qfraction.hh:67
void hash_combine(std::size_t &seed, const T &v)
Definition: hash.hh:27