next up previous contents
Next: TermLists and TermNodes Up: Monomial Representation Previous: Header Files

Usage Examples

  #include "polynomial.h"
  #include "molynomial.h"

  int
  main(int argc, char** argv)
  {
    Polynomial p1 = 5;                  // Creates a poly for 5 
    Polynomial p2 = "x1";               // Creates a poly for "x1". 
    Polynomial p3 = p1 + p2;            // Adds the two to get poly x1 + 5
    Molynomial p4 = poly_to_moly(p3);   // Molynomial form. 

    /* The rest of the example shows how to create Molynomial's from
       scratch if you really have to */
    Monomial m1 = Field_element(5);     // Constant molynomial. 
    Array<int> exps = Array<int>(Polynomial::Num_vars); 
    for (int i=0;i<Polynomial::Num_vars;i++) 
      exps[i] = i;        // Create expon array of form x0^0 x1^1 x2^2 ...
    Monomial m2 = (Field_element(4),exps); 
  }

1.0



Ashu Rege
Fri May 9 17:57:21 PDT 1997