Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
BPASUnivarPolynomial.hpp
1 
2 #ifndef _BPAS_UPOLYNOMIAL_H_
3 #define _BPAS_UPOLYNOMIAL_H_
4 
5 #include "BPASPolynomial.hpp"
6 
7 #include "BPASEuclideanPolynomial.hpp"
8 #include "../Ring/BPASField.hpp"
9 
10 /**
11  * An abstract class defining the interface of a univariate polynomial over an arbitrary BPASRing.
12  *
13  * Depending on the specialization of the template Ring parameter, this class
14  * might form a Euclidean domain, and if so, fulfills the Euclidean domain
15  * interface also.
16  *
17  * Derived should be the conrete class being implemented, following
18  * the Curiously Recurring Template Pattern.
19  *
20  */
21 template <class Ring, class Derived>
22 class BPASUnivariatePolynomial : public virtual std::conditional<std::is_base_of<BPASField<Ring>, Ring>::value, BPASEuclideanPolynomial<Ring,Derived>, BPASPolynomial<Ring, Derived> >::type
23 
24 {
25  public:
26 
27  /**
28  * Differentiate this polynomial, setting itself to its derivative.
29  */
30  virtual void differentiate() = 0; // p = dp/dx
31 
32  /**
33  * Differentiate this polynomial k times,
34  * setting itself to the final derivative.
35  * @param k: the number of times to differentiate.
36  */
37  virtual void differentiate(int k) = 0;
38 
39  /**
40  * Obtain the derivative of this polynomial.
41  *
42  * @return the derivative.
43  */
44  virtual Derived derivative() const = 0;
45 
46  /**
47  * Obtain the kth derivative of this polynomial.
48  *
49  * @param k: the number of times to differentiate.
50  * @return the kth derivative.
51  */
52  virtual Derived derivative(int) const = 0;
53 
54  /**
55  * Evaluate this polynomial by substituting the input ring
56  * element r for the indeterminate.
57  *
58  * @param r the input ring element
59  * @return the evaluation of this polynomial at r.
60  */
61  virtual Ring evaluate(const Ring& r) const = 0;
62 
63  /**
64  * Divide this polynomial by the monic polynomial d,
65  * setting this polynomial to be the remainder.
66  *
67  * @param d: the monic divison.
68  * @return the quotient.
69  */
70  virtual Derived monicDivide(const Derived& d) = 0;
71 
72  /**
73  * Divide this polynomial by the monic polynomial d.
74  * The remainder is returned and the quotient returned
75  * via pointer q.
76  *
77  * @param d: the monic divisor.
78  * @param[out] q: a pointer to the quotient to return.
79  * @return the remainder.
80  */
81  virtual Derived monicDivide(const Derived& d, Derived* q = NULL) const = 0;
82 
83  /**
84  * Perform a lazy pseudo-divison, also known as sparse pseudo-division.
85  * Specifically, determine q and r, as in division, but satisfying
86  * h^e * this = q*d + r, where h is the leading coefficient of d
87  * and e is a positive integer equal to the number of division steps performed.
88  * Return the quotient and this becomes the remainder.
89  *
90  * @param d: the divisor.
91  * @param[out] h1: The leading coefficient of b to the power e
92  * @param[out] h2: h to the power deg(a) - deg(b) + 1 - e
93  * @return the quotient.
94  */
95  virtual Derived lazyPseudoDivide(const Derived& d, Ring* h1, Ring* h2) = 0;
96 
97 
98  /**
99  * Perform a lazy pseudo-divison, also known as sparse pseudo-division.
100  * Specifically, determine q and r, as in division, but satisfying
101  * h^e * this = q*d + r, where h is the leading coefficient of d
102  * and e is a positive integer equal to the number of division steps performed.
103  * Return the quotient and this becomes the remainder.
104  *
105  * @param d: the divisor.
106  * @param[out] q: a pointer to the quotient to output.
107  * @param[out] h1: The leading coefficient of b to the power e
108  * @param[out] h2: h to the power deg(this) - deg(d) + 1 - e
109  * @return the remainder.
110  */
111  virtual Derived lazyPseudoDivide(const Derived& d, Derived* q, Ring* h1, Ring* h2) const = 0;
112 
113  /**
114  * Perform a pseudo-divison, specifically,
115  * determine q and r, as in division, but satisfying
116  * h^e * this = q*d + r, where h is the leading coefficient of d
117  * and e is a positive integer equal to deg(this) - deg(d) + 1
118  * Return the quotient and this becomes the remainder.
119  *
120  * @param d: the divisor.
121  * @param[out] he: h to the power deg(this) - deg(d) + 1
122  * @return the quotient.
123  */
124  virtual Derived pseudoDivide(const Derived& d, Ring* he) = 0;
125 
126  /**
127  * Perform a pseudo-divison, specifically,
128  * determine q and r, as in division, but satisfying
129  * h^e * this = q*d + r, where h is the leading coefficient of d
130  * and e is a positive integer equal to deg(this) - deg(d) + 1
131  * Return the quotient and this becomes the remainder.
132  *
133  * @param d: the divisor.
134  * @param[out] q: a pointer to the quotient to output.
135  * @param[out] he: h to the power deg(this) - deg(d) + 1
136  * @return the remainder.
137  */
138  virtual Derived pseudoDivide(const Derived& d, Derived* q, Ring* he) const = 0;
139 
140  /**
141  * Get the coefficient of the monomial with degree d.
142  *
143  * @param d: the degree of the monomial.
144  * @return the coefficient of that monomial.
145  */
146  virtual Ring coefficient(int d) const = 0;
147 
148  /**
149  * Set the coefficient of the monomial with degree d to
150  * be the Ring element r.
151  *
152  * @param d: the degree of the monomial.
153  * @param r: the ring element
154  */
155  virtual void setCoefficient(int d, const Ring& r) = 0;
156 
157  /**
158  * Set the indeterminate of this polynomial to be the input symbol.
159  *
160  * @param sym: the new symbol for the indeterminate.
161  */
162  virtual void setVariableName (const Symbol& sym) = 0;
163 
164  /**
165  * Get the indeterminate of this polynomial.
166  *
167  * @return this polynomial's indeterminate.
168  */
169  virtual Symbol variable() const = 0;
170 
171  /**
172  * Shift this polynomial left i times, that is,
173  * multiply by x^i, where x is this polynomial's indeterminate.
174  *
175  * @return the shifted polynomial.
176  */
177  virtual Derived operator<< (int i) const = 0; // q = p * (x^i);
178 
179  /**
180  * Shift this polynomial left i times, that is,
181  * multiply by x^i, where x is this polynomial's indeterminate,
182  * and set this polynomial to the result.
183  *
184  * @return a reference to this polynomial after shifting.
185  */
186  virtual Derived& operator<<= (int i) = 0; // p = p *(x^i)
187 
188  /**
189  * Shift this polynomial right i times, that is,
190  * divide by x^i, where x is this polynomial's indeterminate,
191  *
192  * @return the shifted polynomial.
193  */
194  virtual Derived operator>> (int) const = 0; // q = p / (x^i);
195 
196  /**
197  * Shift this polynomial right i times, that is,
198  * divide by x^i, where x is this polynomial's indeterminate,
199  * and set this polynomial to the result.
200  *
201  * @return a reference to this polynomial after shifting.
202  */
203  virtual Derived& operator>>= (int) = 0;
204 };
205 
206 
207 
208 
209 #endif
virtual Derived lazyPseudoDivide(const Derived &d, Ring *h1, Ring *h2)=0
Perform a lazy pseudo-divison, also known as sparse pseudo-division.
virtual Derived derivative() const =0
Obtain the derivative of this polynomial.
virtual Symbol variable() const =0
Get the indeterminate of this polynomial.
virtual void setVariableName(const Symbol &sym)=0
Set the indeterminate of this polynomial to be the input symbol.
virtual Derived pseudoDivide(const Derived &d, Ring *he)=0
Perform a pseudo-divison, specifically, determine q and r, as in division, but satisfying h^e * this ...
virtual Derived operator>>(int) const =0
Shift this polynomial right i times, that is, divide by x^i, where x is this polynomial&#39;s indetermina...
An abstract class defining the interface of a univariate polynomial over an arbitrary BPASRing...
Definition: BPASUnivarPolynomial.hpp:22
virtual Derived monicDivide(const Derived &d)=0
Divide this polynomial by the monic polynomial d, setting this polynomial to be the remainder...
virtual Derived operator<<(int i) const =0
Shift this polynomial left i times, that is, multiply by x^i, where x is this polynomial&#39;s indetermin...
virtual Derived & operator>>=(int)=0
Shift this polynomial right i times, that is, divide by x^i, where x is this polynomial&#39;s indetermina...
virtual void setCoefficient(int d, const Ring &r)=0
Set the coefficient of the monomial with degree d to be the Ring element r.
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
virtual Ring evaluate(const Ring &r) const =0
Evaluate this polynomial by substituting the input ring element r for the indeterminate.
virtual Derived & operator<<=(int i)=0
Shift this polynomial left i times, that is, multiply by x^i, where x is this polynomial&#39;s indetermin...
virtual void differentiate()=0
Differentiate this polynomial, setting itself to its derivative.
virtual Ring coefficient(int d) const =0
Get the coefficient of the monomial with degree d.