Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
BPASEuclideanDomain.hpp
1 
2 #ifndef _BPAS_EUCLIDEAN_DOMAIN_H_
3 #define _BPAS_EUCLIDEAN_DOMAIN_H_
4 
5 #include "BPASGCDDomain.hpp"
6 #include "../Utils/TemplateHelpers.hpp"
7 
8 class Integer;
9 
10 /**
11  * An abstract class defining the interface of a Euclidean domain.
12  */
13 template <class Derived>
14 class BPASEuclideanDomain : public virtual BPASGCDDomain<Derived> {
15 
16 public:
17 
18  /**
19  * Get the euclidean size of *this.
20  */
21  virtual Integer euclideanSize() const = 0;
22 
23  /**
24  * Perform the eucldiean division of *this and b. Returns the
25  * remainder. If q is not NULL, then returns the quotient in q.
26  *
27  * @param b: the divisor.
28  * @param[out] q: a pointer to store the quotient in.
29  *
30  * @return the remainder.
31  */
32  virtual Derived euclideanDivision(const Derived& b, Derived* q = NULL) const = 0;
33 
34  /**
35  * Perform the extended euclidean division on *this and b.
36  * Returns the GCD. If s and t are not NULL, returns the bezout coefficients in them.
37  * @param b: the divisor.
38  * @param[out] s: the bezout coefficient of this.
39  * @param[out] t: the bezout coefficient of b.
40  * @return the remainder.
41  */
42  virtual Derived extendedEuclidean(const Derived& b, Derived* s = NULL, Derived* t = NULL) const = 0;
43 
44  /**
45  * Get the quotient of *this and b.
46  *
47  * @param b: the divisor
48  * @return the quotient
49  */
50  virtual Derived quotient(const Derived& b) const = 0;
51 
52  /**
53  * Get the remainder of *this and b.
54  * @param b: the divisor
55  * @return the remainder
56  */
57  virtual Derived remainder(const Derived& b) const = 0;
58 
59  /**
60  * Get the remainder of *this and b;
61  * @param b: the divisor
62  * @return the remainder
63  */
64  virtual Derived operator%(const Derived& b) const = 0;
65 
66  /**
67  * Assign *this to be the remainder of *this and b.
68  * @param b: the divisor
69  * @return this after assignment.
70  */
71  virtual Derived& operator%=(const Derived& b) = 0;
72 
73 
74 };
75 
76 #endif
An abstract class defining the interface of a GCD domain.
Definition: BPASGCDDomain.hpp:14
virtual Derived operator%(const Derived &b) const =0
Get the remainder of *this and b;.
virtual Derived & operator%=(const Derived &b)=0
Assign *this to be the remainder of *this and b.
virtual Derived extendedEuclidean(const Derived &b, Derived *s=NULL, Derived *t=NULL) const =0
Perform the extended euclidean division on *this and b.
virtual Integer euclideanSize() const =0
Get the euclidean size of *this.
virtual Derived remainder(const Derived &b) const =0
Get the remainder of *this and b.
An arbitrary-precision Integer.
Definition: Integer.hpp:22
An abstract class defining the interface of a Euclidean domain.
Definition: BPASEuclideanDomain.hpp:14
virtual Derived quotient(const Derived &b) const =0
Get the quotient of *this and b.
virtual Derived euclideanDivision(const Derived &b, Derived *q=NULL) const =0
Perform the eucldiean division of *this and b.