Esempio n. 1
0
        /// <summary>
        /// The method returns product of polynominal addition
        /// </summary>
        /// <param name="poly">Polynominal coefficients (vector starting with free term)</param>
        /// <returns>Polynominal</returns>
        public Polynominal Add(Polynominal poly)
        {
            int         M        = this.Degree();
            int         N        = poly.Degree();
            int         K        = Math.Max(M, N);
            Polynominal Poly1Ext = new Polynominal(K);
            Polynominal Poly2Ext = new Polynominal(K);
            Polynominal Add      = new Polynominal(K);

            for (int m = 0; m < M + 1; m++)
            {
                Poly1Ext.SetElement(m, this.Element(m));
            }

            for (int n = 0; n < N + 1; n++)
            {
                Poly2Ext.SetElement(n, poly.Element(n));
            }

            for (int k = 0; k < K + 1; k++)
            {
                Add.SetElement(k, Poly1Ext.Element(k) + Poly2Ext.Element(k));
            }

            return(Add);
        }
Esempio n. 2
0
        /// <summary>
        /// The method returns product of polynominal multiplication by scalar
        /// </summary>
        /// <param name="Value">Complex value</param>
        /// <returns>Polynominal</returns>
        public Polynominal Scale(Complex Value)
        {
            Polynominal scale = new Polynominal(this.Degree());

            for (int i = 0; i < this.Degree() + 1; i++)
            {
                scale.SetElement(i, this.Element(i) * Value);
            }

            return(scale);
        }
Esempio n. 3
0
        /// <summary>
        /// The method calculates polynominal derivative
        /// </summary>
        /// <returns>Polynominal</returns>
        public Polynominal Derivative()
        {
            int         Degree     = this.Degree();
            int         NumCoefs   = Degree + 1;
            Polynominal Derivative = new Polynominal(this.Degree() - 1);

            if (Degree > 0)
            {
                for (int i = 1; i < NumCoefs; i++)
                {
                    Derivative.SetElement(i - 1, i * this.Element(i));
                }
            }
            else
            {
                return(new Polynominal(new Double[1] {
                    0
                }));
            }

            return(Derivative);
        }