S
S
Silence2019-04-24 19:20:09
OOP
Silence, 2019-04-24 19:20:09

How to correctly implement the exponentiation of a polynomial?

Good evening.
The problem arose such, I can not understand how to correctly raise a polynomial to a power.
This is how the polynomial is stored:

class Polynom  {
  private: 
    int deg; //степень полинома
    double *koef; //указатель на массив коэффициентов полинома

There is an overloaded multiplication operator (*) between objects, but it does not keep track of powers, i.e.
When multiplying a polynomial by a polynomial, the resulting polynomial must be initialized as
Polynom "имя объекта"(степень первого полинома умножаемого + степень второго умножаемого);

Thus, the constructor will be called to allocate memory for the required number of elements.
Constructor:
Polynom::Polynom(int count)
{
        deg=count;
        koef=new double[deg+1];
}

But I don’t understand how to implement adequate exponentiation while initializing the resulting polynomial to the required degree.
Maybe it will be possible to implement this in the exponentiation function itself.
Tell me, please, who is not difficult and understands.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-04-24
@Adrikk

If a polynomial of degree m is raised to a degree n, then the resulting polynomial will have degree m*n.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question