-
Notifications
You must be signed in to change notification settings - Fork 3
/
rationalinteger.h
100 lines (80 loc) · 3.19 KB
/
rationalinteger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Copyright (C) 2014, 2015, 2016
Rafael Guglielmetti, [email protected]
*/
/*
This file is part of AlVin.
CoxIter is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
CoxIter is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AlVin. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file rationalinteger.h
* \author Rafael Guglielmetti
*
* \class RationalInteger
* \brief Rational integers
*/
#ifndef RATIONALINTEGER_H
#define RATIONALINTEGER_H
#include "algebraicinteger.h"
class RationalInteger : public AlgebraicInteger // TODO: tout passer en long
{
public:
long int iVal; // TODO: version avec gmp?
public:
RationalInteger();
RationalInteger(long int iVal);
RationalInteger(const RationalInteger &ri);
virtual ~RationalInteger();
AlgebraicInteger *copy() const;
AlgebraicInteger *aiCopyToInteger(const int &n) const;
virtual void set(const int &n);
virtual void set(AlgebraicInteger *ai);
virtual void removeSquareFactors();
virtual bool isInvertible() const;
virtual bool isSquareOfIvertible() const;
virtual void gcd(const AlgebraicInteger *ai);
virtual bool isDivisibleBy(const AlgebraicInteger *) const;
virtual bool divideByIfDivisible(const AlgebraicInteger *ai);
virtual void divideBy(const AlgebraicInteger *ai);
virtual void multiplyBy(const int &n);
virtual void multiplyBy(const AlgebraicInteger *ai);
virtual void add(const AlgebraicInteger *ai);
virtual void substract(const AlgebraicInteger *ai);
virtual void opp();
virtual bool isLessThan(const int &n) const;
virtual bool isLessThan(const AlgebraicInteger &ai) const;
virtual bool isLessOEThan(const AlgebraicInteger &ai) const;
virtual bool isGreaterThan(const int &n) const;
virtual bool isGreaterOEThan(const int &n) const;
virtual bool isEqualTo(const AlgebraicInteger &ai) const;
virtual bool isEqualTo(const int &n) const;
ostream &print(ostream &) const;
virtual string to_string(const string &strFormat = "generic",
const bool &bProtect = false) const;
virtual double to_double() const;
virtual string get_classname() const;
long int get_iValue() const;
// --------------------------------------------
// Operators
RationalInteger &operator=(const RationalInteger &);
RationalInteger &operator/=(RationalInteger const &ri);
RationalInteger &operator*=(RationalInteger const &ri);
RationalInteger operator-() const;
RationalInteger operator+(const RationalInteger &) const;
RationalInteger operator*(const RationalInteger &)const;
RationalInteger operator-(const RationalInteger &) const;
bool operator==(const RationalInteger &) const;
bool operator==(const long int &) const;
bool operator>(const RationalInteger &) const;
bool operator<(const RationalInteger &) const;
};
#endif // RATIONALINTEGER_H