doc: update voting theory reference
[barvinok.git] / bernstein / src / polynomial.cpp
blob777b700d629690534154c934e73810c454c1e250
1 /*
2 * Bernstein Expansion
4 * - polynomial class
5 */
7 #include "polynomial.h"
9 using namespace GiNaC;
11 polynomial::polynomial(void)
15 polynomial::polynomial(ex &e)
17 *this += e;
20 polynomial::polynomial(const ex &e)
22 *this += e;
26 polynomial& polynomial::operator=(ex &e)
28 *this = polynomial::polynomial(e);
30 return *this;
34 // term i of the polynomial
35 ex polynomial::term(unsigned int i)
37 ex e = *this;
38 if(!is_a<add>(e)) {
39 return e;
41 if(this->nops() == 0) {
42 return e;
44 return this->op(i);
48 // number of terms in the polynomial
49 unsigned int polynomial::nbTerms(void)
51 ex e = *this;
52 if(!is_a<add>(e)) {
53 return 1;
56 if(this->nops() == 0) {
57 return 1;
60 return this->nops();