Basic Polynomial Algebra Subprograms (BPAS)  v. 1.791
uzpolynomial.h
1 #ifndef _UZPOLYNOMIAL_H_
2 #define _UZPOLYNOMIAL_H_
3 
4 
5 #include "../Polynomial/BPASUnivarPolynomial.hpp"
6 #include "modpoly.h"
7 #include "../ring.h"
8 
9 /**
10  * A univariate polynomial with Integer coefficients using a dense representation.
11  * This representation stores all possible coefficients, up to a maximum degree,
12  * even if they are zero.
13  */
14 class DenseUnivariateIntegerPolynomial : public BPASUnivariatePolynomial<Integer,DenseUnivariateIntegerPolynomial> {
15  private:
16  Symbol name; // Variable name
17  int curd; // Current degree
18  int n; // Maximum size of the polynomial
19  mpz_class* coef; // Coefficients
20 
21  inline void zeros() {
22  for (int i = 0; i < n; ++i)
23  coef[i] = 0;
24  }
25 
26  bool isEqual(const DenseUnivariateIntegerPolynomial& q) const;
27  void pomopo(const mpz_class c, const mpz_class t, const DenseUnivariateIntegerPolynomial& b);
28  void resetDegree();
31  ;
33 
34  public:
35  static mpz_class characteristic;
36  // static bool isPrimeField;
37  // static bool isSmallPrimeField;
38  // static bool isComplexField;
39  /**
40  * Construct a polynomial
41  *
42  * @param d
43  **/
44  DenseUnivariateIntegerPolynomial () : curd(0), n(1), name("%") {
45  coef = new mpz_class[1];
46  coef[0] = 0;
47  }
48  /**
49  * Construct a polynomial with degree
50  *
51  * @param d: Size of the polynomial
52  **/
54  if (s < 1) { s = 1; }
55  n = s;
56  coef = new mpz_class[n];
57  curd = 0;
58  //coef[0] = 0;
59  zeros();
60  name = "%";
61  }
62 
63  /**
64  * Construct a polynomial with a coeffient
65  * @param e: The coefficient
66  **/
67  DenseUnivariateIntegerPolynomial (const Integer& e) : curd(0), n(1), name("%") {
68  coef = new mpz_class[1];
69  coef[0] = e.get_mpz();
70  }
71  DenseUnivariateIntegerPolynomial (const RationalNumber& e) : curd(0), n(1), name("%") {
72  if (e.get_den() == 1) {
73  coef = new mpz_class[1];
74  coef[0] = e.get_num().get_mpz();
75  }
76  else {
77  std::cout << "BPAS error, try to construct a rational number in DUZP." << std::endl;
78  exit(1);
79  }
80  }
81  /**
82  * Copy constructor
83  *
84  * @param b: A densed univariate rationl polynomial
85  **/
86  DenseUnivariateIntegerPolynomial(const DenseUnivariateIntegerPolynomial& b) : curd(b.curd), name(b.name) {
87  n = curd + 1;
88  coef = new mpz_class[n];
89  std::copy(b.coef, b.coef+n, coef);
90  }
91  /**
92  * Destroy the polynomial
93  *
94  * @param
95  **/
97  delete [] coef;
98  }
99 
100  /**
101  * Get degree of the polynomial
102  *
103  * @param
104  **/
105  inline Integer degree() const {
106  return curd;
107  }
108 
109  /**
110  * Get the leading coefficient
111  *
112  * @param
113  **/
114  inline Integer leadingCoefficient() const {
115  return coef[curd];
116  }
117 
118  inline Integer trailingCoefficient() const {
119  for(int i = 0; i <= curd; ++i) {
120  if (coef[i] != 0) {
121  return coef[i];
122  }
123  }
124  return 0;
125  }
126 
127  inline Integer numberOfTerms() const {
128  size_t c = 0;
129  for (size_t i = 0; i <= curd; ++i) {
130  ++c;
131  }
132  return c;
133  }
134 
135  /**
136  * Get coefficients of the polynomial, given start offset
137  *
138  * @param k: Offset
139  **/
140  inline mpz_class* coefficients(int k=0) const {
141 #ifdef BPASDEBUG
142  if (k < 0 || k >= n)
143  std::cout << "BPAS: warning, try to access a non-exist coefficient " << k << " from DUZP(" << n << ")." << std::endl;
144 #endif
145  return &coef[k];
146  }
147  /**
148  * Get a coefficient of the polynomial
149  *
150  * @param k: Offset
151  **/
152  inline Integer coefficient(int k) const {
153  if (k < 0 || k >= n) {
154  mpz_class z(0);
155  return Integer(z);
156  }
157  return Integer(coef[k]);
158  }
159  /**
160  * Set a coefficient of the polynomial
161  *
162  * @param k: Offset
163  * @param val: Coefficient
164  **/
165  inline void setCoefficient(int k, const mpz_class value) {
166  if (k >= n || k < 0) {
167  std::cout << "BPAS: error, DUZP(" << n << ") but trying to access " << k << "." << std::endl;
168  exit(1);
169  }
170  coef[k] = value;
171  if (k > curd && value != 0)
172  curd = k;
173  resetDegree();
174  }
175  inline void setCoefficient(int k, const Integer& value) {
176  setCoefficient(k, value.get_mpz());
177  }
178  inline void setCoefficient(int k, const int value) {
179  setCoefficient(k, mpz_class(value));
180  }
181 
182 
183  /**
184  * Set a coefficient of the polynomial
185  *
186  * @param k: Degree of the term of which you are setting the coefficient
187  * @param val: Coefficient value
188  **/
189  inline void setCoefficient(Integer k, const Integer& value);
190 
191  /**
192  * Get variable's name
193  *
194  * @param
195  **/
196  inline Symbol variable() const {
197  return name;
198  }
199  /**
200  * Set variable's name
201  *
202  * @param x: Varable's name
203  **/
204  inline void setVariableName (const Symbol& x) {
205  name = x;
206  }
207  /**
208  * Overload operator =
209  *
210  * @param b: A univariate integer polynoial
211  **/
213  if (this != &b) {
214  if (n) { delete [] coef; n = 0; }
215  name = b.name;
216  curd = b.curd;
217  n = curd + 1;
218  coef = new mpz_class[n];
219  std::copy(b.coef, b.coef+n, coef);
220  }
221  return *this;
222  }
223 
226  return *this;
227  }
228 
229  /**
230  * Overload operator !=
231  *
232  * @param b: A univariate integer polynoial
233  **/
234  inline bool operator!= (const DenseUnivariateIntegerPolynomial& b) const {
235  return !(isEqual(b));
236  }
237 
238  /**
239  * Overload operator ==
240  *
241  * @param b: A univariate integer polynoial
242  **/
243  inline bool operator== (const DenseUnivariateIntegerPolynomial& b) const {
244  return isEqual(b);
245  }
246 
247  /**
248  * Is zero polynomial
249  *
250  * @param
251  **/
252  inline bool isZero () const {
253  if (!curd)
254  return (coef[0] == 0);
255  return 0;
256  }
257 
258  /**
259  * Zero polynomial
260  *
261  * @param
262  **/
263  inline void zero() {
264  curd = 0;
265  zeros();
266  }
267 
268  /**
269  * Is polynomial a constatn 1
270  *
271  * @param
272  **/
273  inline bool isOne() const {
274  if (!curd)
275  return (coef[0] == 1);
276  return 0;
277  }
278 
279  /**
280  * Set polynomial to 1
281  *
282  * @param
283  **/
284  inline void one() {
285  curd = 0;
286  coef[0] = 1;
287  for (int i = 1; i < n; ++i)
288  coef[i] = 0;
289  }
290 
291  /**
292  * Is polynomial a constatn -1
293  *
294  * @param
295  **/
296  inline bool isNegativeOne() const {
297  if (!curd)
298  return (coef[0] == -1);
299  return 0;
300  }
301 
302  /**
303  * Set polynomial to -1
304  *
305  * @param
306  **/
307  inline void negativeOne() {
308  curd = 0;
309  coef[0] = -1;
310  for (int i = 1; i < n; ++i)
311  coef[i] = 0;
312  }
313 
314  /**
315  * Is a constant
316  *
317  * @param
318  **/
319  inline int isConstant() const {
320  if (curd) { return 0; }
321  else if (coef[0] >= 0) { return 1; }
322  else { return -1; }
323  }
324 
325  /**
326  * Obtain the unit normal (a.k.a canonical associate) of an element.
327  * If either parameters u, v, are non-NULL then the units are returned such that
328  * b = ua, v = u^-1. Where b is the unit normal of a, and is the returned value.
329  */
331  Integer lead = leadingCoefficient();
332  Integer unit, uInv;
333  lead.unitCanonical(&unit, &uInv);
334  if (unit != 1) {
335  if (u != NULL) {
336  *u = unit;
337  }
338  if (v != NULL) {
339  *v = uInv;
340  }
341 
342  return *this * unit;
343 
344  }
345 
346  if (u != NULL) {
347  *u = Integer(1);
348  }
349  if (v != NULL) {
350  *v = Integer(1);
351  }
352  return *this;
353  }
354 
355 
356 
357  /**
358  * Content of the polynomial
359  *
360  * @param
361  **/
362  inline Integer content() const {
363  mpz_class c = coef[0];
364  for (int i = 1; i <= curd; ++i) {
365  if (coef[i] != 0) {
366  mpz_gcd(c.get_mpz_t(), c.get_mpz_t(), coef[i].get_mpz_t());
367  if (c == 1)
368  break;
369  }
370  }
371  return Integer(c);
372  }
373 
374  inline DenseUnivariateIntegerPolynomial primitivePart() const {
375  //TODO
376  std::cerr << "BPAS ERROR: DUZP::primitivePart NOT YET IMPLEMENTED" << std::endl;
377  return *this;
378  }
379 
380  /**
381  * Is the least signficant coefficient zero
382  *
383  * @param
384  **/
385  inline bool isConstantTermZero() const {
386  return (coef[0] == 0);
387  }
388 
389  /**
390  * Overload operator ^
391  * replace xor operation by exponentiation
392  *
393  * @param e: The exponentiation, e > 0
394  **/
395  DenseUnivariateIntegerPolynomial operator^ (long long int e) const;
396 
397  /**
398  * Overload operator ^=
399  * replace xor operation by exponentiation
400  *
401  * @param e: The exponentiation, e > 0
402  **/
404  *this = *this ^ e;
405  return *this;
406  }
407 
408  /**
409  * Overload operator <<
410  * replace by muplitying x^k
411  *
412  * @param k: The exponent of variable, k > 0
413  **/
415 
416  /**
417  * Overload operator <<
418  * replace by muplitying x^k
419  *
420  * @param k: The exponent of variable, k > 0
421  **/
423  *this = *this << k;
424  return *this;
425  }
426 
427  /**
428  * Overload operator >>
429  * replace by dividing x^k, and
430  * return the quotient
431  *
432  * @param k: The exponent of variable, k > 0
433  **/
435 
436  /**
437  * Overload operator >>=
438  * replace by dividing x^k, and
439  * return the quotient
440  *
441  * @param k: The exponent of variable, k > 0
442  **/
444  *this = *this >> k;
445  return *this;
446  }
447 
448  /**
449  * Overload operator +
450  *
451  * @param b: A univariate integer polynomial
452  **/
454 
455  /**
456  * Overload Operator +=
457  *
458  * @param b: A univariate integer polynomial
459  **/
461  if (curd >= b.curd)
462  add(b);
463  else
464  *this = *this + b;
465  return *this;
466  }
467 
468  /**
469  * Add another polynomial to itself
470  *
471  * @param b: A univariate integer polynomial
472  **/
473  void add(const DenseUnivariateIntegerPolynomial& b);
474 
475  /**
476  * Overload Operator +
477  *
478  * @param c: An integer
479  **/
482  return (r += c);
483  }
484 
485  inline DenseUnivariateIntegerPolynomial operator+ (const mpz_class& c) const {
487  return (r += c);
488  }
489 
490  inline DenseUnivariateIntegerPolynomial operator+ (int c) const {
492  return (r += c);
493  }
494 
495  /**
496  * Overload Operator +=
497  *
498  * @param c: An integer
499  **/
501  coef[0] += c.get_mpz();
502  return *this;
503  }
504 
505  inline DenseUnivariateIntegerPolynomial& operator+= (const mpz_class& c) {
506  coef[0] += c;
507  return *this;
508  }
509 
511  coef[0] += c;
512  return *this;
513  }
514 
515  inline friend DenseUnivariateIntegerPolynomial operator+ (const mpz_class& c, const DenseUnivariateIntegerPolynomial& p) {
516  return (p + c);
517  }
518 
520  return (p + c);
521  }
522 
523  /**
524  * Subtract another polynomial
525  *
526  * @param b: A univariate integer polynomial
527  */
529 
530  /**
531  * Overload operator -=
532  *
533  * @param b: A univariate integer polynomial
534  **/
536  if (curd >= b.curd)
537  subtract(b);
538  else
539  *this = *this - b;
540  return *this;
541  }
542 
543  /**
544  * Overload operator -, negate
545  *
546  * @param
547  **/
549 
550  /**
551  * Compute -f(x)
552  *
553  * @param
554  **/
555  inline void negate() {
556  for (int i = 0; i <= curd; ++i) {
557  coef[i] = -coef[i];
558  }
559  }
560 
561  /**
562  * Subtract another polynomial from itself
563  *
564  * @param b: A univariate integer polynomial
565  **/
567 
568  /**
569  * Overload operator -
570  *
571  * @param c: An integer
572  **/
575  return (r -= c);
576  }
577 
578  inline DenseUnivariateIntegerPolynomial operator- (const mpz_class& c) const {
580  return (r -= c);
581  }
582 
583  inline DenseUnivariateIntegerPolynomial operator- (int c) const {
585  return (r -= c);
586  }
587 
588  /**
589  * Overload operator -=
590  *
591  * @param c: An integer
592  **/
594  coef[0] -= c.get_mpz();
595  return *this;
596  }
597 
598  inline DenseUnivariateIntegerPolynomial& operator-= (const mpz_class& c) {
599  coef[0] -= c;
600  return *this;
601  }
602 
604  coef[0] -= c;
605  return *this;
606  }
607 
608  inline friend DenseUnivariateIntegerPolynomial operator- (const mpz_class& c, const DenseUnivariateIntegerPolynomial& p) {
609  return (-p + c);
610  }
611 
613  return (-p + c);
614  }
615 
616  /**
617  * Multiply to another polynomial
618  *
619  * @param b: A univariate integer polynomial
620  **/
622 
623  /**
624  * Overload operator *=
625  *
626  * @param b: A univariate integer polynomial
627  **/
629  *this = *this * b;
630  return *this;
631  }
632 
633  /**
634  * Overload operator *
635  *
636  * @param e: An integer
637  **/
640  return (r *= e);
641  }
642 
643  inline DenseUnivariateIntegerPolynomial operator* (const mpz_class& e) const {
645  return (r *= e);
646  }
647 
648  inline DenseUnivariateIntegerPolynomial operator* (int e) const {
650  return (r *= e);
651  }
652 
653  /**
654  * Overload operator *=
655  *
656  * @param e: An integer
657  **/
659  mpz_class c = e.get_mpz();
660  *this *= c;
661  return *this;
662  }
663 
664  inline DenseUnivariateIntegerPolynomial& operator*= (const mpz_class& e) {
665  if (e != 0 && e != 1) {
666  for (int i = 0; i <= curd; ++i)
667  coef[i] *= e;
668  }
669  else if (e == 0) { zero(); }
670  return *this;
671  }
672 
673  /**
674  * Overload operator *=
675  *
676  * @param e: A constant
677  **/
679  if (e != 0 && e != 1) {
680  for (int i = 0; i <= curd; ++i)
681  coef[i] *= e;
682  }
683  else if (e == 0) { zero(); }
684  return *this;
685  }
686 
687  inline friend DenseUnivariateIntegerPolynomial operator* (const mpz_class& e, const DenseUnivariateIntegerPolynomial& p) {
688  return (p * e);
689  }
690 
692  return (p * e);
693  }
694 
695  /**
696  * Overload operator /
697  * ExactDivision
698  *
699  * @param b: A univariate integer polynomial
700  **/
703  return (rem /= b);
704  }
705 
706  /**
707  * Overload operator /=
708  * ExactDivision
709  *
710  * @param b: A univariate integer polynomial
711  **/
713 
714  /**
715  * Overload operator /
716  *
717  * @param e: An integer
718  **/
721  return (r /= e);
722  }
723 
724  inline DenseUnivariateIntegerPolynomial operator/ (const mpz_class& e) const {
726  return (r /= e);
727  }
728 
729  inline DenseUnivariateIntegerPolynomial operator/ (int e) const {
731  return (r /= e);
732  }
733 
734  /**
735  * Overload operator /=
736  *
737  * @param e: An integer
738  **/
740  mpz_class c = e.get_mpz();
741  return (*this /= c);
742  }
743 
744  DenseUnivariateIntegerPolynomial& operator/= (const mpz_class& e);
745 
747  return (*this /= mpz_class(e));
748  }
749 
751 
752  /**
753  * Monic division
754  * Return quotient and itself become the remainder
755  *
756  * @param b: The dividend polynomial
757  **/
759 
760  /**
761  * Monic division
762  * Return quotient
763  *
764  * @param b: The dividend polynomial
765  * @param rem: The remainder polynomial
766  **/
768  *rem = *this;
769  return rem->monicDivide(b);
770  }
771 
772  /**
773  * Lazy pseudo dividsion
774  * Return the quotient and itself becomes remainder
775  * e is the exact number of division steps
776  *
777  * @param b: The dividend polynomial
778  * @param c: The leading coefficient of b to the power e
779  * @param d: That to the power deg(a) - deg(b) + 1 - e
780  **/
782 
783  /**
784  * Lazy pseudo dividsion
785  * Return the quotient
786  * e is the exact number of division steps
787  *
788  * @param b: The divident polynomial
789  * @param rem: The remainder polynomial
790  * @param c: The leading coefficient of b to the power e
791  * @param d: That to the power deg(a) - deg(b) + 1 - e
792  **/
794  *rem = *this;
795  return rem->lazyPseudoDivide(b, c, d);
796  }
797 
798  /**
799  * Pseudo dividsion
800  * Return the quotient and itself becomes remainder
801  *
802  * @param b: The divident polynomial
803  * @param d: The leading coefficient of b
804  * to the power deg(a) - deg(b) + 1
805  **/
807 
808  /**
809  * Pseudo dividsion
810  * Return the quotient
811  *
812  * @param b: The divident polynomial
813  * @param rem: The remainder polynomial
814  * @param d: The leading coefficient of b
815  * to the power deg(a) - deg(b) + 1
816  **/
818 
819  /**
820  * GCD(p, q)
821  *
822  * @param q: The other polynomial
823  **/
825 
827  return gcd(q, 0);
828  }
829 
830  /**
831  * Convert current object to its k-th derivative
832  *
833  * @param k: Order of the derivative, k > 0
834  **/
835  void differentiate(int k);
836 
837  /**
838  * Convert current object to its derivative
839  *
840  **/
841  inline void differentiate() {
842  this->differentiate(1);
843  }
844 
845  /**
846  * Return k-th derivative
847  *
848  * @param k: Order of the k-th derivative, k > 0
849  **/
852  a.differentiate(k);
853  return a;
854  }
855 
856  /**
857  * Compute derivative
858  *
859  **/
861  return this->derivative(1);
862  }
863 
864  /**
865  * Convert current object to its integral with constant of integration 0
866  *
867  **/
868  void integrate();
869 
870  /**
871  * Compute integral with constant of integration 0
872  *
873  **/
876  a.integrate();
877  return a;
878  }
879 
880  /**
881  /**
882  * Evaluate f(x)
883  *
884  * @param x: Evaluation point
885  **/
886  // THIS FUNCTION IS DEPRECATED
887  // mpz_class evaluate(const mpz_class& x) const;
888 
889  /**
890  * Evaluate f(x)
891  *
892  * @param x: Evaluation point
893  **/
894  Integer evaluate(const Integer& x) const;
895 
896  /**
897  * Square free
898  *
899  * @param
900  **/
901  Factors<DenseUnivariateIntegerPolynomial> squareFree() const;
902 
903  /**
904  * Overload stream operator <<
905  *
906  * @param out: Stream object
907  * @param b: A univariate Integer polynoial
908  **/
909  void print(std::ostream &out) const;
910 
911  /**
912  * Convert this DUZP into an expression tree.
913  */
914  ExpressionTree convertToExpressionTree() const;
915 };
916 
917 #endif
DenseUnivariateIntegerPolynomial gcd(const DenseUnivariateIntegerPolynomial &q, int type) const
GCD(p, q)
DenseUnivariateIntegerPolynomial & operator+=(const DenseUnivariateIntegerPolynomial &b)
Overload Operator +=.
Definition: uzpolynomial.h:460
DenseUnivariateIntegerPolynomial operator*(const DenseUnivariateIntegerPolynomial &b) const
Multiply to another polynomial.
DenseUnivariateIntegerPolynomial(const Integer &e)
Construct a polynomial with a coeffient.
Definition: uzpolynomial.h:67
void integrate()
Convert current object to its integral with constant of integration 0.
DenseUnivariateIntegerPolynomial & operator=(const DenseUnivariateIntegerPolynomial &b)
Overload operator =.
Definition: uzpolynomial.h:212
DenseUnivariateIntegerPolynomial & operator>>=(int k)
Overload operator >>= replace by dividing x^k, and return the quotient.
Definition: uzpolynomial.h:443
DenseUnivariateIntegerPolynomial operator^(long long int e) const
Overload operator ^ replace xor operation by exponentiation.
DenseUnivariateIntegerPolynomial & operator*=(const DenseUnivariateIntegerPolynomial &b)
Overload operator *=.
Definition: uzpolynomial.h:628
DenseUnivariateIntegerPolynomial & operator^=(long long int e)
Overload operator ^= replace xor operation by exponentiation.
Definition: uzpolynomial.h:403
DenseUnivariateIntegerPolynomial unitCanonical(DenseUnivariateIntegerPolynomial *u=NULL, DenseUnivariateIntegerPolynomial *v=NULL) const
Obtain the unit normal (a.k.a canonical associate) of an element.
Definition: uzpolynomial.h:330
mpz_class * coefficients(int k=0) const
Get coefficients of the polynomial, given start offset.
Definition: uzpolynomial.h:140
void differentiate()
Convert current object to its derivative.
Definition: uzpolynomial.h:841
DenseUnivariateIntegerPolynomial operator+(const DenseUnivariateIntegerPolynomial &b) const
Overload operator +.
DenseUnivariateIntegerPolynomial()
Construct a polynomial.
Definition: uzpolynomial.h:44
DenseUnivariateIntegerPolynomial(int s)
Construct a polynomial with degree.
Definition: uzpolynomial.h:53
Integer unitCanonical(Integer *u=NULL, Integer *v=NULL) const
Obtain the unit normal (a.k.a canonical associate) of an element.
DenseUnivariateIntegerPolynomial monicDivide(const DenseUnivariateIntegerPolynomial &b, DenseUnivariateIntegerPolynomial *rem) const
Monic division Return quotient.
Definition: uzpolynomial.h:767
DenseUnivariateIntegerPolynomial lazyPseudoDivide(const DenseUnivariateIntegerPolynomial &b, DenseUnivariateIntegerPolynomial *rem, Integer *c, Integer *d) const
Lazy pseudo dividsion Return the quotient e is the exact number of division steps.
Definition: uzpolynomial.h:793
A univariate polynomial with Integer coefficients using a dense representation.
Definition: uzpolynomial.h:14
Symbol variable() const
Get variable&#39;s name.
Definition: uzpolynomial.h:196
void setCoefficient(int k, const mpz_class value)
Set a coefficient of the polynomial.
Definition: uzpolynomial.h:165
Integer leadingCoefficient() const
Get the leading coefficient.
Definition: uzpolynomial.h:114
void one()
Set polynomial to 1.
Definition: uzpolynomial.h:284
DenseUnivariateIntegerPolynomial lazyPseudoDivide(const DenseUnivariateIntegerPolynomial &b, Integer *c, Integer *d=NULL)
Lazy pseudo dividsion Return the quotient and itself becomes remainder e is the exact number of divis...
DenseUnivariateIntegerPolynomial derivative() const
Compute derivative.
Definition: uzpolynomial.h:860
Integer coefficient(int k) const
Get a coefficient of the polynomial.
Definition: uzpolynomial.h:152
Integer content() const
Content of the polynomial.
Definition: uzpolynomial.h:362
DenseUnivariateIntegerPolynomial derivative(int k) const
Return k-th derivative.
Definition: uzpolynomial.h:850
bool isConstantTermZero() const
Is the least signficant coefficient zero.
Definition: uzpolynomial.h:385
int isConstant() const
Is a constant.
Definition: uzpolynomial.h:319
void zero()
Zero polynomial.
Definition: uzpolynomial.h:263
DenseUnivariateIntegerPolynomial & operator<<=(int k)
Overload operator << replace by muplitying x^k.
Definition: uzpolynomial.h:422
void subtract(const DenseUnivariateIntegerPolynomial &b)
Subtract another polynomial from itself.
DenseUnivariateIntegerPolynomial integral()
Compute integral with constant of integration 0.
Definition: uzpolynomial.h:874
void negate()
Compute -f(x)
Definition: uzpolynomial.h:555
DenseUnivariateIntegerPolynomial(const DenseUnivariateIntegerPolynomial &b)
Copy constructor.
Definition: uzpolynomial.h:86
An arbitrary-precision Integer.
Definition: Integer.hpp:22
An abstract class defining the interface of a univariate polynomial over an arbitrary BPASRing...
Definition: BPASUnivarPolynomial.hpp:22
void differentiate(int k)
Convert current object to its k-th derivative.
DenseUnivariateIntegerPolynomial & operator-=(const DenseUnivariateIntegerPolynomial &b)
Overload operator -=.
Definition: uzpolynomial.h:535
bool operator==(const DenseUnivariateIntegerPolynomial &b) const
Overload operator ==.
Definition: uzpolynomial.h:243
void add(const DenseUnivariateIntegerPolynomial &b)
Add another polynomial to itself.
bool isZero() const
Is zero polynomial.
Definition: uzpolynomial.h:252
bool operator!=(const DenseUnivariateIntegerPolynomial &b) const
Overload operator !=.
Definition: uzpolynomial.h:234
bool isOne() const
Is polynomial a constatn 1.
Definition: uzpolynomial.h:273
DenseUnivariateIntegerPolynomial operator>>(int k) const
Overload operator >> replace by dividing x^k, and return the quotient.
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
bool isNegativeOne() const
Is polynomial a constatn -1.
Definition: uzpolynomial.h:296
An arbitrary-precision rational number.
Definition: RationalNumber.hpp:24
DenseUnivariateIntegerPolynomial & operator/=(const DenseUnivariateIntegerPolynomial &b)
Overload operator /= ExactDivision.
DenseUnivariateIntegerPolynomial operator-() const
Overload operator -, negate.
DenseUnivariateIntegerPolynomial operator/(const DenseUnivariateIntegerPolynomial &b) const
Overload operator / ExactDivision.
Definition: uzpolynomial.h:701
DenseUnivariateIntegerPolynomial pseudoDivide(const DenseUnivariateIntegerPolynomial &b, Integer *d=NULL)
Pseudo dividsion Return the quotient and itself becomes remainder.
void negativeOne()
Set polynomial to -1.
Definition: uzpolynomial.h:307
DenseUnivariateIntegerPolynomial monicDivide(const DenseUnivariateIntegerPolynomial &b)
Monic division Return quotient and itself become the remainder.
void setCoefficient(int k, const Integer &value)
Set the coefficient of the monomial with degree d to be the Ring element r.
Definition: uzpolynomial.h:175
DenseUnivariateIntegerPolynomial operator<<(int k) const
Overload operator << replace by muplitying x^k.
Integer degree() const
Get degree of the polynomial.
Definition: uzpolynomial.h:105
~DenseUnivariateIntegerPolynomial()
Destroy the polynomial.
Definition: uzpolynomial.h:96
void setVariableName(const Symbol &x)
Set variable&#39;s name.
Definition: uzpolynomial.h:204