next up previous contents
Next: About this document Up: TermLists and TermNodes Previous: Header Files

Usage Examples

  #include "polynomial.h"

  int
  main(int argc, char** argv)
  {
    Polynomial p; 
    ...

    /* Example 1 : Get the coeff of the term of the second highest
       degree in a given polynomial. (Remember that the polynomial is
       always maintained as a sorted list.) */

    Polynomial coeff; 
    TermList t = termlist_of(p); 
    TermNode* tn = tnode_of(t); 
    if (tn != 0) tn = tn->next_of(); 
    if (tn != 0) coeff = tn->coeff_poly(); // coeff now contains the poly

    /* Example 2 : Output the degrees of every term node in the term list */
    for (tn=tnode_of(t);tn != 0; tn = tn->next_of()) {
      cout << tn->degree_of() << "\n"; 
    }

    /* For other examples see the file termlist.c which implements the
       various operators for the TermList class */ 
  }



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