CoxIter  1.2
CoxIter - Computing invariants of hyperbolic Coxeter groups
mpz_rational.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2013, 2014
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 "number_template.h"
39 #include "../string.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 
50 {
51  public:
52  mpz_class a;
53  mpz_class b;
54 
55  private:
59  void update( );
60 
61  public:
62  MPZ_rational( );
63 
64  MPZ_rational( mpz_class a, mpz_class b );
65  MPZ_rational( mpz_class a );
66 
67  MPZ_rational( const int& i );
68  #ifndef _COMPILE_WITHOUT_REGEXP_
69  MPZ_rational( string szRational );
70  #endif
71  bool isInteger( ) const;
72  bool isCOInteger( ) const;
73 
74  bool operator>=( int const& ) const;
75  bool operator==( int const& ) const;
76  bool operator==( MPZ_rational const& ) const;
77  bool operator==( mpz_class const& ) const;
78  bool operator!=( MPZ_rational const& ) const;
79 
80  MPZ_rational& operator=( long int );
81 
82  MPZ_rational operator+( MPZ_rational const &n ) const;
83  MPZ_rational& operator+=( MPZ_rational const &n );
84 
85  MPZ_rational operator-( MPZ_rational const &n ) const;
86  void opp( MPZ_rational* &_c ) const;
87  MPZ_rational& operator-=( MPZ_rational const &n );
88 
89  MPZ_rational operator*( MPZ_rational const &n ) const;
90  MPZ_rational& operator*=( MPZ_rational const &n );
91 
92  MPZ_rational operator/( MPZ_rational const &n ) const;
93  MPZ_rational& operator/=( MPZ_rational const &n );
94 
95  void print( ostream & ) const;
96 
97  string to_string( ) const;
98 };
99 
100 ostream& operator<<( ostream& , MPZ_rational const & );
101 //BigInteger gcd( const BigInteger &, const BigInteger & );
102 
103 #endif
Definition: number_template.h:37
Permet d&#39;avoir un type générique (regroupant Number_rational, ...)
mpz_class a
Definition: mpz_rational.h:52
Definition: mpz_rational.h:49
bool operator==(const Graph &g1, const Graph &g2)
Definition: graph.cpp:918
ostream & operator<<(ostream &, MPZ_rational const &)
Definition: mpz_rational.cpp:269
mpz_class b
Definition: mpz_rational.h:53