AlVin  1.0
A C++ implementation of the Vinberg's algorithm for Q, Q( sqrt(d) ) and Q( cos(2 pi / 7) )
rationalinteger.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2014, 2015, 2016
3 Rafael Guglielmetti, rafael.guglielmetti@unifr.ch
4 */
5 
6 /*
7 This file is part of AlVin.
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 AlVin. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
31 #ifndef RATIONALINTEGER_H
32 #define RATIONALINTEGER_H
33 
34 #include "algebraicinteger.h"
35 
36 class RationalInteger : public AlgebraicInteger // TODO: tout passer en long
37 {
38  public:
39  long int iVal; // TODO: version avec gmp?
40 
41  public:
43  RationalInteger( long int iVal );
44  RationalInteger( const RationalInteger& ri );
45  virtual ~RationalInteger();
46 
47  AlgebraicInteger* copy() const;
48  AlgebraicInteger* aiCopyToInteger( const int& n ) const;
49  virtual void set( const int& n );
50  virtual void set( AlgebraicInteger* ai );
51 
52  virtual void removeSquareFactors();
53 
54  virtual bool bIsInvertible() const;
55  virtual bool bIsSquareOfIvertible() const;
56 
57  virtual void gcd( const AlgebraicInteger* ai );
58  virtual bool bIsDivisbleBy( const AlgebraicInteger* ) const;
59  virtual bool divideByIfDivisible( const AlgebraicInteger* ai );
60  virtual void divideBy( const AlgebraicInteger *ai );
61  virtual void multiplyBy( const int& n );
62  virtual void multiplyBy( const AlgebraicInteger *ai );
63  virtual void add( const AlgebraicInteger *ai );
64  virtual void substract( const AlgebraicInteger *ai );
65  virtual void opp();
66 
67  virtual bool bIsLessThan( const int& n ) const;
68  virtual bool bIsLessThan( const AlgebraicInteger& ai ) const;
69  virtual bool bIsLessOEThan( const AlgebraicInteger& ai ) const;
70  virtual bool bIsGreaterThan( const int& n ) const;
71  virtual bool bIsGreaterOEThan( const int& n ) const;
72  virtual bool bIsEqualTo( const AlgebraicInteger& ai ) const;
73  virtual bool bIsEqualTo( const int& n ) const;
74 
75  ostream& print( ostream& ) const;
76  virtual string to_string( const string& strFormat = "generic", const bool& bProtect = false ) const;
77  virtual double to_double() const;
78  virtual string get_classname() const;
79 
80  long int get_iValue() const;
81 
82  // --------------------------------------------
83  // Operators
84  RationalInteger& operator=( const RationalInteger& );
85  RationalInteger& operator/=( RationalInteger const &ri );
86  RationalInteger& operator*=( RationalInteger const &ri );
87  RationalInteger operator-() const;
88 
89  RationalInteger operator+( const RationalInteger& ) const;
90  RationalInteger operator*( const RationalInteger& ) const;
91  RationalInteger operator-( const RationalInteger& ) const;
92 
93  bool operator==(const RationalInteger& ) const;
94  bool operator==(const long int& ) const;
95  bool operator>(const RationalInteger& ) const;
96  bool operator<(const RationalInteger& ) const;
97 };
98 
99 #endif // RATIONALINTEGER_H
virtual void gcd(const AlgebraicInteger *ai)
*this becomes the gcd of *this and the parameter
Definition: rationalinteger.cpp:53
virtual void divideBy(const AlgebraicInteger *ai)
Performs the division of *this by the parameter Remark: we do not check that the *this is divisible b...
Definition: rationalinteger.cpp:171
virtual void multiplyBy(const int &n)
Performs the multiplication of *this by the parameter.
Definition: rationalinteger.cpp:181
virtual void add(const AlgebraicInteger *ai)
Performs the addition of *this by the parameter.
Definition: rationalinteger.cpp:176
ostream & print(ostream &) const
Print the number.
Definition: rationalinteger.cpp:201
AlgebraicInteger * copy() const
Create a copy of an algebraic integer.
Definition: rationalinteger.cpp:27
virtual bool bIsLessOEThan(const AlgebraicInteger &ai) const
Check whether *this <= ai.
Definition: rationalinteger.cpp:123
AlgebraicInteger * aiCopyToInteger(const int &n) const
Create an algebraic integer from an integer.
Definition: rationalinteger.cpp:22
virtual double to_double() const
Convert to double (approximation)
Definition: rationalinteger.cpp:213
virtual bool bIsDivisbleBy(const AlgebraicInteger *) const
Check whether *this is divisible by the parameter.
Definition: rationalinteger.cpp:154
virtual void substract(const AlgebraicInteger *ai)
Substracts the parameter from *this.
Definition: rationalinteger.cpp:191
virtual bool bIsGreaterThan(const int &n) const
Check whether *this > n.
Definition: rationalinteger.cpp:134
virtual void removeSquareFactors()
Remove all the square factors of the algebraic integer.
Definition: rationalinteger.cpp:74
Parent class for rational, quadratic and rc7 integers.
Definition: algebraicinteger.h:43
virtual bool bIsInvertible() const
Check whether the number is invertible.
Definition: rationalinteger.cpp:43
virtual bool bIsLessThan(const int &n) const
Check whether *this < n.
Definition: rationalinteger.cpp:129
virtual string get_classname() const
Return the type (string)
Definition: rationalinteger.cpp:218
virtual bool bIsSquareOfIvertible() const
Check whether the number is the square of an invertible element.
Definition: rationalinteger.cpp:48
virtual string to_string(const string &strFormat="generic", const bool &bProtect=false) const
Convert to string.
Definition: rationalinteger.cpp:208
Rational integers.
Definition: rationalinteger.h:36
virtual void opp()
Computes the opp.
Definition: rationalinteger.cpp:196
virtual bool bIsEqualTo(const AlgebraicInteger &ai) const
Check whether *this == ai.
Definition: rationalinteger.cpp:144
virtual bool bIsGreaterOEThan(const int &n) const
Check whether *this >= n.
Definition: rationalinteger.cpp:139