next up previous contents
Next: The Inner Product: Up: Implementation: The Complex_POLY_CELL Class: Previous: Arithmetic Operators:

Integration:

    // ***************************************** //
    //             Integration Function          //
    // ***************************************** //
Complex_POLY Complex_POLY::integral()
{  
  Complex_POLY_CELL *temp,*before;
  if(head==NULL){
    //the current polynomial is degenerate 
    Complex_POLY INTEGRAL;
    return(INTEGRAL);
    }
  else{
    //this is non NULL
    Complex_POLY INTEGRAL = *this;
    temp = INTEGRAL.head;
    temp->power += 1;
    temp->element /= (Complex)(temp->power);
    before = temp;
    temp = temp->next;
    //
    while(temp!=NULL){
      temp->power += 1;
      temp->element /= (Complex)(temp->power);
      before = temp;
      temp = temp->next;
      }
    //at end of list; head holds highest power
    //so add a constant to tail
    before->next = new Complex_POLY_CELL(1.0,0);
    return(INTEGRAL);
    }
}

    // ***************************************** //
    //   Definite Integral Function              //
    // ***************************************** //
Complex Complex_POLY::definite_integral(Complex a,Complex b)
{
  Complex value;
  if(head==NULL){
    //the incoming polynomial is degenerate
    //cout << "The incoming polynomial is degenerate" << endl;
    value = 0;
    return(value);
    }
  else{
    //P is non NULL
    Complex_POLY P = integral();
    value = P(b) - P(a);
    return(value);
    }
}



Jim Peterson
1999-04-22