Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
BPASMultivarPolynomial.hpp
1 
2 #ifndef _BPAS_MULTIVAR_POLYNOMIAL_H_
3 #define _BPAS_MULTIVAR_POLYNOMIAL_H_
4 
5 
6 #include "BPASPolynomial.hpp"
7 #include <vector>
8 
9 
10 /**
11  * An abstract class defining the interface of a multivariate polynomial over an arbitrary BPASRing.
12  *
13  * This class is automatically determined to be an integral domain, GCD domain, etc.
14  * depending on the template specialization of Ring.
15  */
16 template <class Ring, class Derived>
17 class BPASMultivariatePolynomial : public virtual BPASPolynomial<Ring, Derived>
18 {
19  // Monomials are the abelian free monoid generated by Symbols
20  public:
21  // virtual void setPolynomialRing(const std::vector<Symbol>& v) = 0;
22  // virtual std::vector<Symbol> polynomialRing() = 0;
23 
24 
25  /**
26  * Differentiate this polynomial, with respect to a particular
27  * variable, setting itself to its derivative.
28  *
29  * @param var: the variable to derive with respect to.
30  */
31  virtual void differentiate(const Symbol& var) = 0;
32 
33  /**
34  * Differentiate this polynomial k times, with respect to a particular
35  * variable, setting itself to its derivative.
36  *
37  * @param var: the variable to derive with respect to.
38  * @param k: the number of times to differentiate.
39  */
40  virtual void differentiate(const Symbol& var, int k) = 0;
41 
42  /**
43  * Differentiate this polynomial, with respect to a particular
44  * variable, setting itself to its derivative.
45  *
46  * @param var: the variable to derive with respect to.
47  *
48  * @return the derivative.
49  */
50  virtual Derived derivative(const Symbol&) const = 0;
51 
52  /**
53  * Differentiate this polynomial k times, with respect to a particular
54  * variable, setting itself to its derivative.
55  *
56  * @param var: the variable to derive with respect to.
57  * @param k: the number of times to differentiate.
58  *
59  * @return the derivative.
60  */
61  virtual Derived derivative(const Symbol&, int) const = 0;
62 
63  // TODO
64  // virtual void integrate(const Symbol&) = 0;
65  // virtual void integrate(const Symbol&, int) = 0;
66  // virtual Derived integral(const Symbol&) const = 0;
67  // virtual Derived integral(const Symbol&, int) const = 0;
68 
69  /**
70  * Evaluate this polynomial by substituting the input ring
71  * elements elems for the variables vars, such that
72  * vars[i] = elems[i].
73  *
74  * @param n: the size of the vars and elems arrays.
75  * @param vars: the variables to evaluate.
76  * @param elems: the ring elements to substitute for the varibales.
77  * @return the evaluation of this polynomial for the variables in vars.
78  */
79  virtual Derived evaluate(int n, const Symbol* vars, const Ring* elems) const = 0;
80 
81  /**
82  * Evaluate this polynomial by substituting the input ring
83  * elements elems for the variables vars, such that
84  * vars[i] = elems[i].
85  *
86  * @param vars: the variables to evaluate.
87  * @param elems: the ring elements to substitute for the varibales.
88  * @return the evaluation of this polynomial for the variables in vars.
89  */
90  virtual Derived evaluate(const std::vector<Symbol>& vars, const std::vector<Ring>& elems) const = 0;
91 
92  /**
93  * Get the number of variables in this multivariate polynomial
94  * which have positive degree.
95  *
96  * @return the number of variables.
97  */
98  virtual int numberOfVariables() const = 0;
99 
100  /**
101  * Get the number of variables defined for the poylnomial ring of this
102  * polynomial, that is, in the ambient space of this polynomial.
103  *
104  * @return the number variables in the polynomial ring of this polynomial.
105  */
106  virtual int numberOfRingVariables() const = 0;
107 
108  /**
109  * Get the partial degree of this polynomial with respect to
110  * the variable v.
111  *
112  * @return the partial degree w.r.t to variable v.
113  */
114  virtual Integer degree(const Symbol& v) const = 0;
115 
116  // virtual unsigned int degree(const Symbol& v) const = 0;
117 
118  /**
119  * Get the coefficient of this polynomial with respect to the
120  * monomial defined by exponent vector exps of size n.
121  * The exponent vector should be defined over all variables in the
122  * polynomial ring.
123  *
124  * @param n: the size of the exponent vector
125  * @param exps: the exponent vector
126  */
127  virtual Ring coefficient(int n, const int* exps) const = 0;
128 
129  /**
130  * Get the coefficient of this polynomial with respect to the
131  * monomial defined by exponent vector exps.
132  * The exponent vector should be defined over all variables in the
133  * polynomial ring.
134  *
135  * @param exps: the exponent vector
136  */
137  virtual Ring coefficient(const std::vector<int>& exps) const = 0;
138 
139 
140  /**
141  * Set the coefficient of this polynomial for the
142  * monomial defined by exponent vector exps, of size n, to r.
143  * The exponent vector should be defined over all variables in the
144  * polynomial ring.
145  *
146  * @param n: the size of the exponent vector
147  * @param exps: the exponent vector
148  * @param r: the ring element to set as coefficient.
149  */
150  virtual void setCoefficient(int n, const int*, const Ring& r) = 0;
151 
152  /**
153  * Set the coefficient of this polynomial for the
154  * monomial defined by exponent vector exps to r.
155  * The exponent vector should be defined over all variables in the
156  * polynomial ring.
157  *
158  * @param exps: the exponent vector
159  * @param r: the ring element to set as coefficient.
160  */
161  virtual void setCoefficient(const std::vector<int>& v, const Ring& r) = 0;
162 
163  /**
164  * Set the variables in the polynomial ring to xs.
165  * This can change be used to change the symbols of the variables
166  * as well as to increase or decrease the dimension of this polynomial ring.
167  * On a decrease, this polynomial may be invalidated if it has
168  * positive degree in a variable being removed.
169  *
170  * @param xs: the vector of new symbols for the polynomial ring.
171  */
172  virtual void setRingVariables (const std::vector<Symbol>& xs) = 0;
173 
174 
175  /**
176  * Get all the variables in the polynomial ring.
177  *
178  * @return a vector of all the variables in this polynomial's ring.
179  */
180  virtual std::vector<Symbol> ringVariables() const = 0;
181 
182  /**
183  * Get all the variables in this polynomial with positive degree.
184  *
185  * @return a vector of all the variables in this polynomial with positive degree.
186  */
187  virtual std::vector<Symbol> variables() const = 0;
188 
189  // virtual Derived content(const std::vector<Symbol>& v) const = 0;
190  // virtual Derived primitivePart(const std::vector<Symbol>& v) const = 0;
191  // virtual Derived primitivePart(const std::vector<Symbol>& v, Derived& content) const = 0;
192 };
193 
194 
195 
196 
197 #endif
virtual Ring coefficient(int n, const int *exps) const =0
Get the coefficient of this polynomial with respect to the monomial defined by exponent vector exps o...
virtual Integer degree(const Symbol &v) const =0
Get the partial degree of this polynomial with respect to the variable v.
virtual void setRingVariables(const std::vector< Symbol > &xs)=0
Set the variables in the polynomial ring to xs.
virtual int numberOfVariables() const =0
Get the number of variables in this multivariate polynomial which have positive degree.
virtual Derived evaluate(int n, const Symbol *vars, const Ring *elems) const =0
Evaluate this polynomial by substituting the input ring elements elems for the variables vars...
virtual int numberOfRingVariables() const =0
Get the number of variables defined for the poylnomial ring of this polynomial, that is...
virtual void setCoefficient(int n, const int *, const Ring &r)=0
Set the coefficient of this polynomial for the monomial defined by exponent vector exps...
virtual Derived derivative(const Symbol &) const =0
Differentiate this polynomial, with respect to a particular variable, setting itself to its derivativ...
An abstract class defining the interface of a polynomial over an arbitrary BPASRing.
Definition: BPASPolynomial.hpp:32
An abstract class defining the interface of a multivariate polynomial over an arbitrary BPASRing...
Definition: BPASMultivarPolynomial.hpp:17
An arbitrary-precision Integer.
Definition: Integer.hpp:22
virtual std::vector< Symbol > ringVariables() const =0
Get all the variables in the polynomial ring.
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
virtual std::vector< Symbol > variables() const =0
Get all the variables in this polynomial with positive degree.
virtual void differentiate(const Symbol &var)=0
Differentiate this polynomial, with respect to a particular variable, setting itself to its derivativ...