3 * poly.h -- routines for manipulation of polynomials in one var
5 * (c) 1993, 1996,1999 Han-Wen Nienhuys
12 #include "arithmetic-operator.hh"
15 /// structure for a polynomial in one var.
18 /// degree of polynomial
30 Real eval(Real) const ;
31 void print_sols(Array<Real>) const ;
32 void check_sols(Array<Real>) const ;
33 void check_sol(Real x) const;
34 static Polynomial multiply(const Polynomial & p1, const Polynomial & p2);
35 static Polynomial power(int exponent, const Polynomial & src);
37 /// chop low coefficients
40 /// eliminate #x# close to zero
42 static Polynomial add(const Polynomial & p1, const Polynomial & p2);
43 void scalarmultiply(Real fact);
44 void operator *= (Real f) { scalarmultiply(f); }
45 void operator /= (Real f) { scalarmultiply(1/f); }
46 void operator += (Polynomial const &p2);
47 void operator *= (Polynomial const &p2);
48 void operator -= (Polynomial const &p2);
49 Polynomial (Real a, Real b =0.0);
51 static Polynomial subtract(const Polynomial & p1, const Polynomial & p2);
52 void set_negate(const Polynomial & src);
54 /// take the derivative
56 int set_mod(const Polynomial &u, const Polynomial &v);
60 Array<Real> solve_quadric()const;
61 Array<Real> solve_cubic()const;
62 Array<Real> solve_linear()const;
64 Array<Real> solve () const;
68 IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, - );
69 IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, + );
70 IMPLEMENT_ARITHMETIC_OPERATOR(Polynomial, * );
73 operator * (Polynomial p, Real a)
79 operator * (Real a,Polynomial p)