public void addTerm(term t) { int i; frac zero = new frac(0); if ((i = canJoin(ref t)) >= 0) { terms[i].c += t.c; if (terms[i].c == zero) { delTerm(i); } } else if (count < terms.Length) { terms[count] = new term(t); count++; if (terms[count - 1].c == zero) { delTerm(count - 1); } } else { throw new Exception("poly is full!"); } }
public term integralX() { term temp = new term(this); temp.xp++; temp.c /= new frac(temp.xp); return(temp); }
public poly(poly p) { count = p.count; for (int i = 0; i < count; i++) { terms[i] = new term(p.terms[i]); } }
public static poly operator -(poly p1, poly p2) { poly a = new poly(); term neg = new term(-1); a.extend(p1); a.extend(neg * p2); return(a); }
public int canJoin(ref term t) { for (int i = 0; i < count; i++) { if (t.xp == terms[i].xp && t.yp == terms[i].yp) { return(i); } } return(-1); }
public term(term t) { c = t.c; xp = t.xp; yp = t.yp; }
public poly(term t) { addTerm(t); }
static poly pol(term t) { return(new poly(t)); }