polynomial odd and even powers separation
This commit is contained in:
parent
59f3bb9eea
commit
4c420b1e9b
@ -144,6 +144,8 @@ public:
|
|||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Polynomial even_powers() const {int d=degree()/2; Polynomial r(d); for(int i=0; i<=degree(); i+=2) r[i/2] = (*this)[i]; return r;};
|
||||||
|
Polynomial odd_powers() const {int d=(degree()-1)/2; Polynomial r(d); if(degree()==0) {r[0]=0; return r;} for(int i=1; i<=degree(); i+=2) r[(i-1)/2] = (*this)[i]; return r;};
|
||||||
void polydiv(const Polynomial &rhs, Polynomial &q, Polynomial &r) const;
|
void polydiv(const Polynomial &rhs, Polynomial &q, Polynomial &r) const;
|
||||||
Polynomial operator/(const Polynomial &rhs) const {Polynomial q,r; polydiv(rhs,q,r); return q;};
|
Polynomial operator/(const Polynomial &rhs) const {Polynomial q,r; polydiv(rhs,q,r); return q;};
|
||||||
Polynomial operator%(const Polynomial &rhs) const {Polynomial q,r; polydiv(rhs,q,r); return r;};
|
Polynomial operator%(const Polynomial &rhs) const {Polynomial q,r; polydiv(rhs,q,r); return r;};
|
||||||
|
Loading…
Reference in New Issue
Block a user