CoxIter  1.3
CoxIter - Computing invariants of hyperbolic Coxeter groups
mpz_rational.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2013-2017
3 Rafael Guglielmetti, rafael.guglielmetti@unifr.ch
4 */
5 
6 /*
7 This file is part of CoxIter.
8 
9 CoxIter is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as
11 published by the Free Software Foundation, either version 3 of the
12 License, or (at your option) any later version.
13 
14 CoxIter is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with CoxIter. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
30 #ifndef __NUMBER_RATIONAL_H__
31 #define __NUMBER_RATIONAL_H__
32 
33 #include <iostream>
34 #include <string>
35 
36 using namespace std;
37 
38 #include "../string.h"
39 #include "number_template.h"
40 #ifndef _COMPILE_WITHOUT_REGEXP_
41 #include "../regexp.h"
42 #endif
43 #ifdef _USE_LOCAL_GMP_
44 #include "gmpxx.h"
45 #else
46 #include <gmpxx.h>
47 #endif
48 
49 class MPZ_rational : public Number_template {
50 public:
51  mpz_class a;
52  mpz_class b;
53 
54 private:
58  void update();
59 
60 public:
61  MPZ_rational();
62 
63  MPZ_rational(mpz_class a, mpz_class b);
64  MPZ_rational(mpz_class a);
65 
66  MPZ_rational(const int &i);
67 #ifndef _COMPILE_WITHOUT_REGEXP_
68  MPZ_rational(string rational);
69 #endif
70  bool isInteger() const;
71  bool isCOInteger() const;
72 
73  bool operator>=(int const &) const;
74  bool operator==(int const &) const;
75  bool operator==(MPZ_rational const &) const;
76  bool operator==(mpz_class const &) const;
77  bool operator!=(MPZ_rational const &) const;
78 
79  MPZ_rational &operator=(long int);
80 
81  MPZ_rational operator+(MPZ_rational const &n) const;
82  MPZ_rational &operator+=(MPZ_rational const &n);
83 
84  MPZ_rational operator-(MPZ_rational const &n) const;
85  void opp(MPZ_rational *&_c) const;
86  MPZ_rational &operator-=(MPZ_rational const &n);
87 
88  MPZ_rational operator*(MPZ_rational const &n) const;
89  MPZ_rational &operator*=(MPZ_rational const &n);
90 
91  MPZ_rational operator/(MPZ_rational const &n) const;
92  MPZ_rational &operator/=(MPZ_rational const &n);
93 
94  void print(ostream &) const;
95 
96  string to_string() const;
97 };
98 
99 ostream &operator<<(ostream &, MPZ_rational const &);
100 // BigInteger gcd(const BigInteger &, const BigInteger &);
101 
102 #endif
Definition: mpz_rational.h:49
mpz_class a
Definition: mpz_rational.h:51
mpz_class b
Definition: mpz_rational.h:52
Definition: number_template.h:37
bool operator==(const Graph &g1, const Graph &g2)
Definition: graph.cpp:991
ostream & operator<<(ostream &, MPZ_rational const &)
Definition: mpz_rational.cpp:224
Permet d'avoir un type générique (regroupant Number_rational, ...)