1 #ifndef _DUNIPOLYNOMIAL_H_ 2 #define _DUNIPOLYNOMIAL_H_ 5 #include "../Polynomial/BPASUnivarPolynomial.hpp" 7 #include "../DyadicRationalNumber/Multiplication/multiplication.h" 9 #include "../FFT/src/dft_general.h" 10 #include "../FFT/src/dft16.h" 11 #include "../FFT/src/dft_general_fermat.h" 13 #include "../Utils/TemplateHelpers.hpp" 19 template <
class Field>
22 private Derived_from<Field, BPASField<Field>>
31 for (
int i = 0; i < n; ++i)
35 if (curd && q.curd && (name != q.name))
39 for (
int i = 0; i <= curd; ++i) {
40 if (coef[i] != q.coef[i])
49 for (
int i = curd, j = b.curd; j > -1; --i, --j) {
50 Field elem = t * b.coef[j];
56 for (
int i = curd, j = b.curd; i > -1; --i, --j) {
57 Field elem = coef[i] * c;
59 elem += t * b.coef[j];
66 inline void resetDegree() {
67 for (
int i = curd; i > 0; --i) {
87 Field lc = b.coef[b.curd];
95 return a / a.coef[a.curd];
100 mpz_class characteristic;
103 static mpz_class p1, p2, p3, p4, p5, p6, p7;
113 characteristic = coef[0].getCharacteristic();
121 if (s < 1) { s = 1; }
128 characteristic = coef[0].getCharacteristic();
135 characteristic = e.getCharacteristic();
145 std::copy(b.coef, b.coef+n, coef);
174 inline Field trailingCoefficient()
const {
175 for (
size_t i = 0; i <= curd; ++i) {
183 inline Integer numberOfTerms()
const {
185 for (
size_t i = 0; i <= curd; ++i) {
201 std::cout <<
"BPAS: warning, try to access a non-exist coefficient " << k <<
" from DUFP(" << n <<
")." << std::endl;
222 if (k >= n || k < 0) {
223 std::cout <<
"BPAS: error, DUFP(" << n <<
") but trying to access " << k <<
"." << std::endl;
228 if (k > curd && value != 0){
257 if (n) {
delete [] coef; n = 0; }
262 std::copy(b.coef, b.coef+n, coef);
278 return !(isEqual(b));
296 return (coef[0] == 0);
316 return (coef[0].
isOne());
327 for (
int i = 1; i < n; ++i)
347 coef[0].negativeOne();
348 for (
int i = 1; i < n; ++i)
357 if (curd) {
return 0; }
358 else if (!coef[0].
isZero()) {
return 1; }
364 Field leadInv = lead.inverse();
382 return Field((
int)!
isZero());
386 std::cerr <<
"DenseUnivariatePolynomial<Field>::primitivePart() NOT YET IMPLEMENTED" << std::endl;
402 unsigned long int q = e / 2, r = e % 2;
404 for (
int i = 0; i < q; ++i)
406 if (r) { res *= *
this; }
426 int s = curd + k + 1;
431 r.coef =
new Field[s];
432 for (
int i = 0; i < k; ++i)
434 for (
int i = k; i < s; ++i)
435 r.coef[i] = coef[i-k];
458 int s = curd - k + 1;
463 r.coef =
new Field[s];
464 for (
int i = 0; i < s; ++i)
465 r.coef[i] = coef[i+k];
487 if (!curd) {
return (b + coef[0]); }
489 return (*
this + b.coef[0]);
491 if (name != b.name) {
492 std::cout <<
"BPAS: error, trying to add between Q[" << name <<
"] and Q[" << b.name <<
"]." << std::endl;
496 int size = (curd > b.curd)? curd+1 : b.curd+1;
501 res.coef =
new Field[size];
502 for (
int i = 0; i < size; ++i) {
533 for (
int i = curd; i >= 0; --i) {
535 coef[i] += b.coef[i];
570 if (!curd) {
return (coef[0] - b); }
571 if (!b.curd) {
return (*
this - b.coef[0]); }
572 if (name != b.name) {
573 std::cout <<
"BPAS: error, trying to subtract between Field[" << name <<
"] and Field[" << b.name <<
"]." << std::endl;
578 int size = (curd > b.curd)? curd+1 : b.curd+1;
583 res.coef =
new Field[size];
584 for (
int i = 0; i < size; ++i) {
616 for (
int i = 0; i <= curd; ++i)
617 res.coef[i] = -coef[i];
626 for (
int i = curd; i >= 0; --i) {
628 coef[i] -= b.coef[i];
665 else if(cmp(p, p2)==0)
667 else if(cmp(p, p3)==0)
669 else if(cmp(p, p4)==0)
671 else if(cmp(p, p5)==0)
673 else if(cmp(p, p6)==0)
675 else if(cmp(p, p7)==0)
687 return (b * coef[0]);
690 return (*
this * b.coef[0]);
692 if (name != b.name) {
693 std::cout <<
"BPAS: error, trying to multiply between Field[" << name <<
"] and Field[" << b.name <<
"]." << std::endl;
710 res.coef =
new Field[size];
712 if(res.coef[0].getCharacteristic() == 0){
750 for(
int i=0; i<d; i++){
751 for(
int j=0; j<m; j++){
752 res.coef[i+j] += coef[i] * b.coef[j];
875 for(
int i=0; i<d; i++){
876 for(
int j=0; j<m; j++){
877 res.coef[i+j] += coef[i] * b.coef[j];
888 DFT_general(field, K, e, omega);
893 DFT_general(field, K, e, omega);
897 std::cout <<
" i called generalized FFT " << std::endl;
898 dft_general_fermat(field, K, e, omega);
915 inverse_DFT(field, K, e, omega);
930 inverse_DFT(field, K, e, omega);
945 inverse_fermat_DFT(field, K, e, omega);
974 if (e != 0 && e != 1) {
975 for (
int i = 0; i <= curd; ++i)
978 else if (e == 0) {
zero(); }
1004 std::cout <<
"BPAS: error, dividend is zero from DUFP." << std::endl;
1008 return (*
this /= b.coef[0]);
1014 if (name != b.name) {
1015 std::cout <<
"BPAS: error,rem trying to exact divide between Field[" << name <<
"] and Field[" << b.name <<
"]." << std::endl;
1021 while (rem.curd >= b.curd) {
1022 Field lc = rem.coef[rem.curd] / b.coef[b.curd];
1023 int diff = rem.curd - b.curd;
1024 rem.pomopo(1, -lc, b);
1028 if (!rem.isZero()) {
1029 std::cout <<
"BPAS: error, not exact division from DUFP." << std::endl;
1052 std::cout <<
"BPAS: error, dividend is zero from DUFP." << std::endl;
1056 for (
int i = 0; i <= curd; ++i)
1065 std::cout <<
"BPAS: error, dividend is zero from DUFP." << std::endl;
1073 q.coef =
new Field[1];
1076 q.coef[0] = c / p.coef[0];
1090 std::cout <<
"BPAS: error, dividend is zero from DUFP." << std::endl;
1093 else if (b.coef[b.curd] != 1) {
1094 std::cout <<
"BPAS: error, leading coefficient is not one in monicDivide() from DUFP." << std::endl;
1107 if (name != b.name) {
1108 std::cout <<
"BPAS: error, trying to monic divide between [" << name <<
"] and Q[" << b.name <<
"]." << std::endl;
1112 int size = curd - b.curd + 1;
1114 quo.curd = size - 1;
1116 while (curd >= b.curd) {
1117 Field lc = coef[curd];
1118 int diff = curd - b.curd;
1120 quo.coef[diff] = lc;
1134 return rem->monicDivide(b);
1149 int da = curd, db = b.curd;
1150 if (b.isZero() || !db) {
1151 std::cout <<
"BPAS: error, dividend is zero or constant." << std::endl;
1160 if (name != b.name) {
1161 std::cout <<
"BPAS: error, trying to pseudo divide between Field[" << name <<
"] and Field[" << b.name <<
"]." << std::endl;
1171 int size = curd - b.curd + 1;
1173 quo.curd = size - 1;
1175 int e = 0, diff = da - db;
1176 Field blc = b.coef[b.curd];
1177 while (curd >= b.curd) {
1178 Field lc = coef[curd];
1179 int k = curd - b.curd;
1182 pomopo(blc, -coef[curd], b);
1186 for (
int i = e; i <= diff; ++i)
1203 return rem->lazyPseudoDivide(b, c, d);
1258 while (!b.isZero()) {
1260 q.name = r.name = name;
1261 Field e = b.coef[b.curd];
1266 q = g->monicDivide(b, &r);
1282 a1 /= g->coef[g->curd];
1283 *g /= g->coef[g->curd];
1298 *s = a.halfExtendedEuclidean(b, &g);
1299 if (g.coef[g.curd] != 1) {
1300 f /= g.coef[g.curd];
1301 g /= g.coef[g.curd];
1303 q = f.monicDivide(g, &r);
1305 std::cout <<
"BPAS: error, " << *
this <<
" is not in the ideal (" << a <<
", " << b <<
") from DUQP." << std::endl;
1310 Field e = b.coef[b.curd];
1311 if (e != 1) { b /= e; }
1312 if (s->curd >= b.curd) {
1314 s->monicDivide(b, &r);
1320 if (e != 1) { g /= e; }
1321 *t = g.monicDivide(b);
1339 if (k <= 0) {
return *
this; }
1340 for (
int i = k; i <= ret.curd; ++i) {
1341 ret.coef[i-k] = ret.coef[i];
1342 for (
int j = 0; j < k; ++j)
1343 ret.coef[i-k] *= (i - j);
1363 b.coef =
new Field[b.n];
1365 for (
int i = 0; i <= curd; ++i)
1366 b.coef[i+1] = coef[i] / (i + 1);
1377 Field px = coef[curd];
1378 for (
int i = curd-1; i > -1; --i)
1379 px = px * x + coef[i];
1391 return (coef[0] == 0);
1399 if (
isZero()) {
return q; }
1400 if (q.isZero()) {
return *
this; }
1401 if (!curd || !q.curd) {
1408 if (name != q.name) {
1409 std::cout <<
"BPAS: error, remtrying to compute GCD between Q[" << name <<
"] and Q[" << q.name <<
"]." << std::endl;
1415 r = euclideanGCD(q);
1434 std::vector<DenseUnivariatePolynomial<Field> > sf;
1436 sf.push_back(*
this);
1438 else if (curd == 1) {
1441 t.coef[0] = coef[curd];
1443 t = *
this / t.coef[0];
1456 while (!z.isZero()) {
1469 for (
int i = 0; i < sf.size(); ++i) {
1470 e *= sf[i].coef[sf[i].curd];
1471 sf[i] /= sf[i].coef[sf[i].curd];
1476 sf.insert(sf.begin(), t);
1480 f.setRingElement(sf[0]);
1481 for (
int i = 1; i < sf.size(); ++i) {
1482 f.addFactor(sf[i], i);
1496 for (
int i = 0; i <= curd; ++i)
1497 coef[i] = coef[i+1];
1514 for (
int i = 0; i < (curd+1)/2; ++i) {
1515 Field elem = coef[i];
1516 coef[i] = coef[curd-i];
1517 coef[curd-i] = elem;
1527 for (
int i = 0; i <= curd; ++i)
1528 coef[i] <<= (curd - i) * k;
1536 for (
int i = 0; i <= curd; ++i)
1545 for (
int i = 0; i <= curd; ++i) {
1557 for (
int i = 0; i <= curd; ++i)
1568 inline void print(std::ostream& out)
const {
1571 for (
int i = 0; i <= this->curd; ++i) {
1572 if (!this->coef[i].
isZero()) {
1576 if (!this->coef[i].
isOne())
1577 out << this->coef[i] <<
"*";
1582 else { out << this->coef[i]; }
1586 if (isFirst) { out <<
"0"; }
1590 std::cerr <<
"DenseUnivariatePolynomial<Field>::convertToExpressionTree() NOT YET IMPLEMENTED" << std::endl;
1604 Field lc = b.leadingCoefficient();
1613 return rem.monicDivide(b);
1618 std::cerr <<
"DenseUnivariatePolynomial::extendedEuclidean NOT YET IMPLEMENTED" << std::endl;
1652 y.setVariableName(this->name);
1653 for(
int i = this->
degree(); i >=0; i--){
1671 int r = ceil(log2(l));
1672 for(
int i=0; i<r; i++){
1673 g = (g*two) - ((*
this)*(g*g));
1674 int deg = g.degree();
1675 int it = pow(2, i+1);
1677 temp.setVariableName(this->name);
1679 for(
int j=0; j<it; j++){
1680 temp.setCoefficient(j, g.coefficient(j));
1702 int m = this->
degree() - b.degree();
1706 tempQuot = this->
Reverse() * bb.NewtonIterationInversion(l);
1708 tempModQuot.setVariableName(this->name);
1709 for(
int j=0; j<m+1; j++){
1710 tempModQuot.setCoefficient(j, tempQuot.coefficient(j));
1712 q = tempModQuot.Reverse();
1713 r = (*this) - (b*q);
1717 template <
class Field>
1719 template <
class Field>
1721 template <
class Field>
1722 mpz_class
DenseUnivariatePolynomial<Field>::p3(
"52374250506775412587080182017685909013279339260195121351951847958786555732255090462694066661827009813312276859354987266719224819790981416185422168457217",10);
1723 template <
class Field>
1724 mpz_class
DenseUnivariatePolynomial<Field>::p4(
"41855814947416230160905824077102044107723669195743478941314613188961602997492974631771080284897031989884853955219823218284507222180203198418365663867454557929637857661786690253443410218509127538830031125593957763469901695303351030684228602570766096943274989297544663448958866408079360000000000000001",10);
1725 template <
class Field>
1726 mpz_class
DenseUnivariatePolynomial<Field>::p5(
"2877263539710446421731156102715413817501924683780203686146470704479400367915116616138891969740546502029403969510010797456265193559830952776697283528940113468571280365197702193026548850188074400758303550622614323711553963509499617917475399195332219370635307438240127286098723642161848281710791141158514433179269730389996820841870847439976376347222063201890220935378395463717774388387120384211168483542746311978533439751087743189685602954995966307828869222780207146437854468321622285523442498620491234986821135672225672571988303097617848628157952640424574080207395225600000000000000000000000000000001",10);
1727 template <
class Field>
1728 mpz_class
DenseUnivariatePolynomial<Field>::p6(
"56616002759896959989415322854958727265928518265558894081721915112338478642152987382081777901106335963367885845155763417916565153797308803666707803977539356324269844089304564587076354736376986405278272779897162317130287620982152662704148023386047880191229049189096093126016047741788639253285397227699187048459276900664828446151952389379779872483448827148216422038130194295758324036868739847281348652718382706086985165783151098320403070769834562613385987477083199297963686734355937454052502472824036058010003416215471582444408483889852282411679533336856925440851946178882063994444491916045719853726844950223273102469496195879587497097269220475494120869128671848644970662426110042888649905237795797441676015340881806045138767954343337713455178248747715202796137422620937669272350685622178511493534367574328398416598592863781482592003147323049228191952409766232800103525201364901470397364906237602845461804081111668634216071070833972247292545003189326173445338852542217465888156430817411944210832836729444740015333742919095761005296073941774939988656174783310275846314511363344139168277105168250508129957477572900470266117913389691465601936338974995950792881631257549184987642764414960873189711746068672863213585432577",10);
1729 template <
class Field>
1730 mpz_class
DenseUnivariatePolynomial<Field>::p7(
"1090748133587739207496133104623209685652043340944525583769922043686052876979141040038395373676653597591795495926807366279537470195844376816521507523618991686398153905679787781478759328905566212525054647896231628355359135635798293361069723097331736557050988577986243892532466698313135887886138444662377632073755381143950221100025346676696096637756641164069467382471667320021238955178621076923370794798694345041333296701870548156651489758101607968522281523969635189200754728978386730361168951561126882965293650334538609649761122401061010853886509602124698406378631272561442673369233937827268652039439967721278901678024095092864613759484683254583736063704358175932953266749684554868685618312267884858266625457439986285293580091133149878361352074448701717504456518088365128951751801324867934946295450111407936849396611409550525348661741918663903030770894532253322458469943425510889282843922868145807907363320595378693696835191869459437314830716877183603950247193579548207267489507689973156425200759112179070584550934920498931256877825412489146370885286547409945479643242694187863206290671548410690203340958006276613646712414730669667136223216464966782734564195802691203036768257805594494102413460722901406746958482564038382712381753485759119365977102301962480617202907182258596705133279208778898957530866346338095658945650199559035759233831660684522622662629611826038362788351572091930801750440291059713981728995722747793865224424707283629868761313993150399745881815938602359160601744218529135375895347494668407421931150844787149547879919791239585278863789643049041266244553112251574272797287440972746560481170921474633126611400596027422225750981318016619477921226148845565965761129968247215480526365772473453996471123113518375556705346341505539769221542741170266489368211724332244794506899906126995079451869450859316306542657546308047179341725779510114986968935109860258498110066067846826136020542550539706591317400144521343503647697440441721640835065587388170041690014385725998766494102073306124651052994491828044263831344641288860621253508151934136220329913691383260972274841983306863608939116025856836931995877644594086124860302354708294645851839410316355926145110650494378186764629875649766904746646788333914098179144689393484186874701417787934689792155194373081952167714271117559720776224173158712008495626957577178627392043052139387289600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",10);
void scaleTransform(int k)
Scale transform operation.
Definition: dupolynomial.h:1535
DenseUnivariatePolynomial< Field > Reverse() const
Reverse a polynomial (based on Modern Computer Algebra , Newton Iteration Chapter 9) ...
Definition: dupolynomial.h:1650
DenseUnivariatePolynomial< Field > operator-() const
Overload operator -, negate.
Definition: dupolynomial.h:612
DenseUnivariatePolynomial< Field > NewtonIterationInversion(int l)
Does Newton Iteration to compute the Reverse Inverse of a polynomial (based on Modern Computer Algebr...
Definition: dupolynomial.h:1665
DenseUnivariatePolynomial< Field > & operator>>=(int k)
Overload operator >>= replace by dividing x^k, and return the quotient.
Definition: dupolynomial.h:476
bool operator==(const DenseUnivariatePolynomial< Field > &b) const
Overload operator ==.
Definition: dupolynomial.h:285
A univariate polynomial with arbitrary BPASField coefficients represented densely.
Definition: dupolynomial.h:20
void differentiate()
Differentiate this polynomial, setting itself to its derivative.
Definition: dupolynomial.h:1333
void zero()
Zero polynomial.
Definition: dupolynomial.h:304
DenseUnivariatePolynomial< Field > operator%(const DenseUnivariatePolynomial< Field > &b) const
Get the remainder of *this and b;.
Definition: dupolynomial.h:1633
bool isConstantTermZero() const
Is the least signficant coefficient zero.
Definition: dupolynomial.h:1390
bool isZero() const
Is zero polynomial.
Definition: dupolynomial.h:294
void diophantinEquationSolve(const DenseUnivariatePolynomial< Field > &a, const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *s, DenseUnivariatePolynomial< Field > *t)
s*a + t*b = c, where c in the ideal (a,b)
Definition: dupolynomial.h:1296
DenseUnivariatePolynomial< Field > operator/(const DenseUnivariatePolynomial< Field > &b) const
Overload operator / ExactDivision.
Definition: dupolynomial.h:992
DenseUnivariatePolynomial< Field > operator*(const DenseUnivariatePolynomial< Field > &b) const
Multiply to another polynomial.
Definition: dupolynomial.h:685
DenseUnivariatePolynomial< Field > & operator<<=(int k)
Overload operator <<= replace by muplitying x^k.
Definition: dupolynomial.h:444
DenseUnivariatePolynomial< Field > extendedEuclidean(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *s=NULL, DenseUnivariatePolynomial< Field > *t=NULL) const
Perform the extended euclidean division on *this and b.
Definition: dupolynomial.h:1617
An ExpressionTree encompasses various forms of data that can be expressed generically as a binary tre...
Definition: ExpressionTree.hpp:17
void subtract(const DenseUnivariatePolynomial< Field > &b)
Subtract another polynomial from itself.
Definition: dupolynomial.h:625
Field evaluate(const Field &x) const
Evaluate f(x)
Definition: dupolynomial.h:1375
void negativeVariable()
Compute f(-x)
Definition: dupolynomial.h:1544
A finite field whose prime should be a generalized fermat number.
Definition: GeneralizedFermatPrimeField.hpp:36
bool isOne() const
Is polynomial a constatn 1.
Definition: dupolynomial.h:314
DenseUnivariatePolynomial< Field > operator^(long long int e) const
Overload operator ^ replace xor operation by exponentiation.
Definition: dupolynomial.h:398
Factors< DenseUnivariatePolynomial< Field > > squareFree() const
Square free.
Definition: dupolynomial.h:1433
bool SRGFNcmp(mpz_class &p)
Helper function to compare a given prime number with manually computed Generalized Fermat Numbers...
Definition: dupolynomial.h:662
Field leadingCoefficient() const
Get the leading coefficient.
Definition: dupolynomial.h:170
DenseUnivariatePolynomial< Field > derivative(int k) const
Obtain the kth derivative of this polynomial.
Definition: dupolynomial.h:1337
A prime field whose prime is 32 bits or less.
Definition: SmallPrimeField.hpp:450
void negativeOne()
Set polynomial to -1.
Definition: dupolynomial.h:345
DenseUnivariatePolynomial< Field > gcd(const DenseUnivariatePolynomial< Field > &q, int type) const
GCD(p, q)
Definition: dupolynomial.h:1398
DenseUnivariatePolynomial< Field > derivative() const
Obtain the derivative of this polynomial.
Definition: dupolynomial.h:1350
bool operator!=(const DenseUnivariatePolynomial< Field > &b) const
Overload operator !=.
Definition: dupolynomial.h:277
void print(std::ostream &out) const
Overload stream operator <<.
Definition: dupolynomial.h:1568
DenseUnivariatePolynomial< Field > & operator-=(const DenseUnivariatePolynomial< Field > &b)
Overload operator -=.
Definition: dupolynomial.h:600
DenseUnivariatePolynomial< Field > & operator^=(long long int e)
Overload operator ^= replace xor operation by exponentiation.
Definition: dupolynomial.h:415
DenseUnivariatePolynomial< Field > monicDivide(const DenseUnivariatePolynomial< Field > &b)
Monic division Return quotient and itself become the remainder.
Definition: dupolynomial.h:1088
DenseUnivariatePolynomial< Field > pseudoDivide(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *rem, Field *d) const
Pseudo dividsion Return the quotient.
Definition: dupolynomial.h:1234
A prime field whose prime can be arbitrarily large.
Definition: BigPrimeField.hpp:27
int isConstant() const
Is a constant.
Definition: dupolynomial.h:356
DenseUnivariatePolynomial< Field > & operator=(const DenseUnivariatePolynomial< Field > &b)
Overload operator =.
Definition: dupolynomial.h:255
void reciprocal()
Number of coefficient sign variation.
Definition: dupolynomial.h:1513
DenseUnivariatePolynomial< Field > pseudoDivide(const DenseUnivariatePolynomial< Field > &b, Field *d=NULL)
Pseudo dividsion Return the quotient and itself becomes remainder.
Definition: dupolynomial.h:1214
A simple data structure for encapsulating a collection of Factor elements.
Definition: Factors.hpp:95
bool divideByVariableIfCan()
Divide by variable if it is zero.
Definition: dupolynomial.h:1491
DenseUnivariatePolynomial< Field > operator+(const DenseUnivariatePolynomial< Field > &b) const
Overload operator +.
Definition: dupolynomial.h:486
void setCoefficient(int k, const Field &value)
Set a coefficient of the polynomial.
Definition: dupolynomial.h:221
void one()
Set polynomial to 1.
Definition: dupolynomial.h:324
void add(const DenseUnivariatePolynomial< Field > &b)
Add another polynomial to itself.
Definition: dupolynomial.h:532
DenseUnivariatePolynomial< Field > quotient(const DenseUnivariatePolynomial< Field > &b) const
Get the quotient of *this and b.
Definition: dupolynomial.h:1623
DenseUnivariatePolynomial< Field > lazyPseudoDivide(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *rem, Field *c, Field *d) const
Lazy pseudo dividsion Return the quotient e is the exact number of division steps.
Definition: dupolynomial.h:1201
void homothetic(int k)
Homothetic operation.
Definition: dupolynomial.h:1526
An arbitrary-precision Integer.
Definition: Integer.hpp:22
bool isNegativeOne() const
Is polynomial a constatn -1.
Definition: dupolynomial.h:335
DenseUnivariatePolynomial< Field > unitCanonical(DenseUnivariatePolynomial< Field > *u, DenseUnivariatePolynomial< Field > *v) const
Obtain the unit normal (a.k.a canonical associate) of an element.
Definition: dupolynomial.h:362
An abstract class defining the interface of a univariate polynomial over an arbitrary BPASRing...
Definition: BPASUnivarPolynomial.hpp:22
DenseUnivariatePolynomial< Field > halfExtendedEuclidean(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *g)
s * a g (mod b), where g = gcd(a, b)
Definition: dupolynomial.h:1249
Integer euclideanSize() const
Euclidean domain methods.
Definition: dupolynomial.h:1599
DenseUnivariatePolynomial< Field > euclideanDivision(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *q=NULL) const
Perform the eucldiean division of *this and b.
Definition: dupolynomial.h:1603
An abstract class defining the interface of a Euclidean domain.
Definition: BPASEuclideanDomain.hpp:14
DenseUnivariatePolynomial< Field > remainder(const DenseUnivariatePolynomial< Field > &b) const
Get the remainder of *this and b.
Definition: dupolynomial.h:1629
Field * coefficients(int k=0)
Get coefficients of the polynomial, given start offset.
Definition: dupolynomial.h:198
Symbol variable() const
Get variable's name.
Definition: dupolynomial.h:239
An encapsulation of a mathematical symbol.
Definition: Symbol.hpp:23
DenseUnivariatePolynomial< Field > & operator/=(const DenseUnivariatePolynomial< Field > &b)
Overload operator /= ExactDivision.
Definition: dupolynomial.h:1002
DenseUnivariatePolynomial< Field > monicDivide(const DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > *rem) const
Monic division Return quotient.
Definition: dupolynomial.h:1132
void negate()
Compute -f(x)
Definition: dupolynomial.h:1556
DenseUnivariatePolynomial< Field > gcd(const DenseUnivariatePolynomial< Field > &q) const
Get GCD of *this and other.
Definition: dupolynomial.h:1424
DenseUnivariatePolynomial< Field > & operator*=(const DenseUnivariatePolynomial< Field > &b)
Overload operator *=.
Definition: dupolynomial.h:954
DenseUnivariatePolynomial< Field > & operator+=(const DenseUnivariatePolynomial< Field > &b)
Overload Operator +=.
Definition: dupolynomial.h:519
DenseUnivariatePolynomial< Field > operator>>(int k) const
Overload operator >> replace by dividing x^k, and return the quotient.
Definition: dupolynomial.h:455
Field coefficient(int k) const
Get a coefficient of the polynomial.
Definition: dupolynomial.h:210
DenseUnivariatePolynomial< Field > operator<<(int k) const
Overload operator << replace by muplitying x^k.
Definition: dupolynomial.h:425
Integer degree() const
Get degree of the polynomial.
Definition: dupolynomial.h:161
DenseUnivariatePolynomial< Field > & operator%=(const DenseUnivariatePolynomial< Field > &b)
Assign *this to be the remainder of *this and b.
Definition: dupolynomial.h:1639
void differentiate(int k)
Compute k-th differentiate.
Definition: dupolynomial.h:1329
Field content() const
Content of the polynomial.
Definition: dupolynomial.h:381
ExpressionTree convertToExpressionTree() const
Convert this to an expression tree.
Definition: dupolynomial.h:1589
void NewtonDivisionQuotient(DenseUnivariatePolynomial< Field > &b, DenseUnivariatePolynomial< Field > &q, DenseUnivariatePolynomial< Field > &r, int l)
Fast Division (based on Modern Computer Algebra , Newton Iteration Chapter 9)
Definition: dupolynomial.h:1698
DenseUnivariatePolynomial< Field > lazyPseudoDivide(const DenseUnivariatePolynomial< Field > &b, Field *c, Field *d)
Lazy pseudo dividsion Return the quotient and itself becomes remainder e is the exact number of divis...
Definition: dupolynomial.h:1146
void setVariableName(const Symbol &x)
Set variable's name.
Definition: dupolynomial.h:247
DenseUnivariatePolynomial< Field > integrate() const
Compute the integral with constant of integration 0.
Definition: dupolynomial.h:1359