Add(ComplexPolynomial lhs, ComplexPolynomial rhs)
        {
            int order = lhs.Degree;

            if (order < rhs.Degree)
            {
                order = rhs.Degree;
            }

            var rv = new WWComplex[order + 1];

            for (int i = 0; i <= order; ++i)
            {
                WWComplex ck = WWComplex.Zero();
                if (i <= lhs.Degree)
                {
                    ck = WWComplex.Add(ck, lhs.C(i));
                }
                if (i <= rhs.Degree)
                {
                    ck = WWComplex.Add(ck, rhs.C(i));
                }
                rv[i] = ck;
            }

            // 最高次の項が0のとき削除して次数を減らす。
            return(new ComplexPolynomial(rv).ReduceDegree());
        }
        MultiplyC(ComplexPolynomial p, WWComplex c)
        {
            var rv = new WWComplex[p.Degree + 1];

            for (int i = 0; i <= p.Degree; ++i)
            {
                rv[i] = WWComplex.Mul(p.C(i), c);
            }
            return(new ComplexPolynomial(rv));
        }
        MultiplyX(ComplexPolynomial p)
        {
            var rv = new WWComplex [p.Degree + 2];

            rv[0] = WWComplex.Zero();
            for (int i = 0; i <= p.Degree; ++i)
            {
                rv[i + 1] = p.C(i);
            }
            return(new ComplexPolynomial(rv));
        }
        TrimPolynomialOrder(ComplexPolynomial p, int n)
        {
            int newOrder = n;

            if (p.Degree < newOrder)
            {
                newOrder = p.Degree;
            }
            var rv = new WWComplex[newOrder + 1];

            for (int i = 0; i <= newOrder; ++i)
            {
                rv[i] = p.C(i);
            }

            //強制的に次数を減らした結果最高位の係数が0になったとき次数を減らす処理。
            return(new ComplexPolynomial(rv).ReduceDegree());
        }