Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
BPASPolynomial.hpp
1 #ifndef _BPAS_POLYNOMIAL_H_
2 #define _BPAS_POLYNOMIAL_H_
3 
4 
5 #include "ring.h"
6 #include "BPASPolynomialTesters.hpp"
7 #include "BPASIntegralPolynomial.hpp"
8 #include "BPASGCDPolynomial.hpp"
9 #include "Utils/TemplateHelpers.hpp"
10 #include "Symbol/Symbol.hpp"
11 
12 
13 
14 /**
15  * An abstract class defining the interface of a polynomial over an arbitrary BPASRing.
16  *
17  * The actual interface of this class depends on the particular
18  * specialization of the Ring template parameter
19  * but will always follow that of BPASBasePolynomial at least.
20  * In particular, a cascade of type checks are performed on the Ring
21  * to determine if it is a GCD domain, integral domain, etc.,
22  * and from this determine the interface for this polynomial.
23  *
24  * Derived should be the conrete class being implemented, following
25  * the Curiously Recurring Template Pattern.
26  *
27  * Users should inherit from this class (or BPASUnivariatePolynomial,
28  * or BPASMultivariatePolynomil) to get this automatic build-up of
29  * the interface based on the true type of Ring,
30  */
31 template <class Ring, class Derived>
32 class BPASPolynomial : public virtual BPASGCDPolynomialTester<Ring, Derived> {};
33 
34 
35 /**
36  * An abstract class defining the interface of polynomial over an arbitrary BPASRing.
37  * This is class is the common interface for both univariate and multivariate
38  * polynomials.
39  *
40  * Depending on the true type of Ring, the interface may add some additional methods.
41  * @see BPASEuclideanPolynomial, BPASGCDPolynomial, BPASIntegralPolynomial.
42  *
43  * Since polynomials themselves form a ring, we inherit from BPASRing<Derived>,
44  * meanwhile the ground ring, Ring, must also be a valid ring.
45  **/
46 template <class Ring, class Derived>
47 class BPASBasePolynomial : public virtual BPASRing<Derived>,
48  private Derived_from<Ring, BPASRing<Ring>>
49 {
50  public:
51 
52  /**
53  * Assignment operator from the ground ring.
54  *
55  * @param r: a ground ring element to assign from.
56  * @return a reference to this polynomial.
57  */
58  virtual Derived& operator= (const Ring& r) = 0;
59 
60  /**
61  * Addition operator of a ground ring element.
62  *
63  * @param r: a ground ring element to add.
64  * @return the sum.
65  */
66  virtual Derived operator+ (const Ring& r) const = 0;
67 
68  /**
69  * Addition assignment operator of a ground ring element.
70  *
71  * @param r: a ground ring element to add.
72  * @return a reference to this polynomial, updated after addition.
73  */
74  virtual Derived& operator+= (const Ring&) = 0;
75 
76  /**
77  * Subtraction operator of a ground ring element.
78  *
79  * @param r: a ground ring element to subtract.
80  * @return the difference.
81  */
82  virtual Derived operator- (const Ring&) const = 0;
83 
84  /**
85  * Subtraction assignment operator of a ground ring element.
86  *
87  * @param r: a ground ring element to subtract.
88  * @return a reference to this polynomial, updated after subtraction.
89  */
90  virtual Derived& operator-= (const Ring&) = 0;
91 
92  /**
93  * Negation operation. Obtain the additive inverse of this polynomial.
94  *
95  * @return the negation of this polynomial.
96  */
97  virtual Derived operator- () const = 0;
98 
99  /**
100  * Multiplication operator of a ground ring element.
101  *
102  * @param r: a ground ring element to multiply.
103  * @return the product.
104  */
105  virtual Derived operator* (const Ring&) const = 0;
106 
107  /**
108  * Multiplication assignment operator of a ground ring element.
109  *
110  * @param r: a ground ring element to multiply.
111  * @return a reference to this polynomial, updated after multiplicaiton.
112  */
113  virtual Derived& operator*= (const Ring&) = 0;
114 
115  /**
116  * Return the (total) degree of polynomial.
117  *
118  * @return the degree.
119  */
120  virtual Integer degree() const = 0;
121 
122  /**
123  * Get the leading coefficient of this polynomial,
124  * the non-zero coefficient of the monomial with maximum degree.
125  *
126  * @return the leading coefficient as a Ring.
127  */
128  virtual Ring leadingCoefficient() const = 0;
129 
130  /**
131  * Get the trailing coefficient of this polynomial,
132  * the non-zero coefficient of the monomial with minimum degree.
133  *
134  * @return the trailing coefficient as a Ring.
135  */
136  virtual Ring trailingCoefficient() const = 0;
137 
138  /**
139  * Determine if the constant term of this polynomial is zero or not.
140  *
141  * @return true iff the constant term is zero.
142  */
143  virtual bool isConstantTermZero() const = 0;
144 
145  /**
146  * Determine the number of non-zero terms in this polynomial.
147  *
148  * @return the number of terms.
149  */
150  virtual Integer numberOfTerms() const = 0;
151 };
152 
153 
154 
155 
156 #endif
An abstract class defining the interface of a commutative ring.
Definition: BPASRing.hpp:19
An abstract class defining the interface of a polynomial over an arbitrary BPASRing.
Definition: BPASPolynomial.hpp:32
An arbitrary-precision Integer.
Definition: Integer.hpp:22
An abstract class defining the interface of polynomial over an arbitrary BPASRing.
Definition: BPASPolynomial.hpp:47
Via conditional inheritance, determine if the ground ring template parameter Ring is a GCD domain or ...
Definition: BPASPolynomialTesters.hpp:43