next up previous contents
Next: The Iterators: Up: The Definitions: Previous: The Complex_POLY_CORE Class:

The Complex_POLY Class:

This child contains the definition of the complex polynomial class. The polynomial is a singly linked list of these poly type cells. Note we will implement brute force polynomial multiplication as the overloaded * operator and use the more efficient FFT based multiplication through an explicit call to the method point_form().

class Complex_POLY : public Complex_POLY_CORE{
    friend class Complex_POLY_CELL;
    friend class ComplexPOLYIter;
    friend Complex_POLY operator*(Complex t,Complex_POLY& P);
    friend Complex_POLY operator*(Complex_POLY& P,Complex t);
    friend Complex_POLY& operator*=(Complex_POLY& P,Complex t);
  public:
    Complex_POLY();
    Complex_POLY(Complex x_in,unsigned int q);
    Complex_POLY(const Complex_POLY&);
    ~Complex_POLY();
    Complex_POLY&operator=(const Complex_POLY&);
    // agents
    int is_empty(){return(head==NULL);};
    void delete_power(unsigned int p);
    void search_power(unsigned int p);
    void build_list(Complex_VECTOR A);
    unsigned int get_degree();
    int insert(Complex new_element,unsigned int q);
    int insert_nosort(Complex new_element,unsigned int q);
    int operator==(const Complex_POLY&);
    int operator!=(const Complex_POLY&);   
    Complex_POLY operator+(const Complex_POLY&);
    Complex_POLY& operator+=(const Complex_POLY&);
    Complex_POLY operator-(const Complex_POLY&); 
    Complex_POLY& operator-=(const Complex_POLY&);
    Complex_POLY operator*(const Complex_POLY&);
    Complex_POLY& operator*=(const Complex_POLY&);
    Complex_POLY& conjugate();
    Complex_POLY integral();
    Complex definite_integral(Complex a,Complex b);
    Complex inner_product(Complex a,Complex b,Complex_POLY& P);
    Complex operator()(Complex x);
    Complex_POLY_CELL* split(Complex_POLY_CELL *A);
    Complex_POLY_CELL* merge(Complex_POLY_CELL *A1,Complex_POLY_CELL *A2);
    Complex_POLY_CELL* mergesort(Complex_POLY_CELL *A);
    //FFT Related Methods
    Complex_POLY point_form(const Complex_POLY&);
    unsigned int Complex_POLY::multiply_pad(const Complex_POLY& B);
    Complex_VECTOR Complex_POLY::convert2vector(unsigned int deg) const;
    Complex_VECTOR Brute_FFT(Complex_VECTOR& A, unsigned int sizeofarray, 
                       float eps, int inverseflag);
    Complex_VECTOR FFT(Complex_VECTOR& A, unsigned int deg, Complex z, float eps);
    //
    void mergesort();   
    istream& grab(istream& in);
    ostream& print(ostream& out) const;
  protected:
    Complex_POLY_CELL *head;
    Complex_POLY_CELL* get_element_address(unsigned int p);
    Complex_POLY_CELL* get_before_element_address(unsigned int p);
    Complex_POLY_CELL* get_after_element_address(unsigned int p);    
  };



Jim Peterson
1999-04-22