Question: I need help with this. Please help! #ifndef POLYNOMIAL _ ( H ) #define POLYNOMIAL _ ( H ) #include #include #include #include term.h
I need help with this. Please help! #ifndef POLYNOMIALH #define POLYNOMIALH #include #include #include #include "term.h class Polynomial public: Create a badinvalid polynomial of degree Arithmetic operations are not permitted on this bad value and may cause a program to crash. Nonetheless, this value is useful as a way of signalling invalid results. Polynomial; Create a polynomial representing a linear or constant formula ax b Polynomial int b int a ; Create a polynomial containing a collections of terms. @param terms a set of terms Polynomial std::initializerlist terms; Create a polynomial with the given coefficients. Eg double c; Polynomial p c; creates a polynomial p representing: x x @param nCoeff number of coefficients in the input array @param coeff the coefficients of the new polynomial, starting with power Polynomial int nCoeff, int coeff; Get the coefficient of the term with the indicated power. @param power the power of a term @return the corresponding coefficient, or zero if power or if power getDegree int getCoeffint power const; The degree of a polynomial is the largest exponent of x with a nonzero coefficient. Eg xx has degree has degree x is a special case and is regarded as degree @return the degree of this polynomial int getDegree const; Add a polynomial to this one, returning their sum. @param p another polynomial @return the sum of the two polynomials Polynomial operatorconst Polynomial& p const; Multiply this polynomial by a scalar. @param scale the value by which to multiply each term in this polynomial @return the polynomial resulting from this multiplication Polynomial operatorint scale const; Multiply this polynomial by a Term. @param Term the value by which to multiply each term in this polynomial @return the polynomial resulting from this multiplication Polynomial operatorTerm term const; Multiply this polynomial by a scalar, altering this polynomial. @param scale the value by which to multiply each term in this polynomial void operatorint scale; Divide one polynomial by another, if possible. @param p the demoninator, the polynomial being divided into this one @return the polynomial resulting from this division or the bad value Polynomial if p cannot be divided into this polynomial to get a quotient polynomial with integer coefficients and no remainder. Polynomial operatorconst Polynomial& p const; Compare this polynomial for equality against another. @param p another polynomial @return true iff the polynomials have the same degree and their corresponding coefficients are equal. bool operatorconst Polynomial& p const; private: @brief The degree of the polynomial. This is the largest power of x having a nonzero coefficient, or zero if the polynomial has all zero coefficients. Note that adding polynomials together or scaling polynomials multiplying by a constant could reduce the degree of the result. int degree; ddd List of terms, in ascending order of power. Terms with zero coefficients are dropped. An empty list of degree is the polynomial: std::list terms; For example, the polynomial xx would have: degree: terms: Term Term Term The polynomial x would have: degree: terms: Term Term The polynomial would have: degree: terms: Term The polynomial would have: degree: terms: A special "bad" value used to signal an unsuccessful operations is degree: terms: A utility function to scan the current polynomial, putting it into "normal form". In this case, the normal form will drop all terms with zero coefficients, adjusting the degree as necessary. Polynomials should be kept in normal form at all times outside of the actual member function bodies of this class. void normalize; A "friend" declaration
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
