Class PolynomialFunctionNewtonForm

    • Constructor Detail

      • PolynomialFunctionNewtonForm

        public PolynomialFunctionNewtonForm​(double[] a,
                                            double[] c)
                                     throws MathIllegalArgumentException,
                                            NullArgumentException
        Construct a Newton polynomial with the given a[] and c[]. The order of centers are important in that if c[] shuffle, then values of a[] would completely change, not just a permutation of old a[].

        The constructor makes copy of the input arrays and assigns them.

        Parameters:
        a - Coefficients in Newton form formula.
        c - Centers.
        Throws:
        NullArgumentException - if any argument is null.
        MathIllegalArgumentException - if any array has zero length.
        MathIllegalArgumentException - if the size difference between a and c is not equal to 1.
    • Method Detail

      • value

        public double value​(double z)
        Calculate the function value at the given point.
        Specified by:
        value in interface UnivariateFunction
        Parameters:
        z - Point at which the function value is to be computed.
        Returns:
        the function value.
      • value

        public <T extends Derivative<T>> T value​(T t)
        Compute the value for the function.
        Specified by:
        value in interface UnivariateDifferentiableFunction
        Type Parameters:
        T - the type of the field elements
        Parameters:
        t - the point for which the function value should be computed
        Returns:
        the value
      • value

        public <T extends CalculusFieldElement<T>> T value​(T t)
        Compute the value of the function.
        Specified by:
        value in interface FieldUnivariateFunction
        Type Parameters:
        T - the type of the field elements
        Parameters:
        t - Point at which the function value should be computed.
        Returns:
        the value of the function.
      • degree

        public int degree()
        Returns the degree of the polynomial.
        Returns:
        the degree of the polynomial
      • getNewtonCoefficients

        public double[] getNewtonCoefficients()
        Returns a copy of coefficients in Newton form formula.

        Changes made to the returned copy will not affect the polynomial.

        Returns:
        a fresh copy of coefficients in Newton form formula
      • getCenters

        public double[] getCenters()
        Returns a copy of the centers array.

        Changes made to the returned copy will not affect the polynomial.

        Returns:
        a fresh copy of the centers array.
      • getCoefficients

        public double[] getCoefficients()
        Returns a copy of the coefficients array.

        Changes made to the returned copy will not affect the polynomial.

        Returns:
        a fresh copy of the coefficients array.
      • computeCoefficients

        protected void computeCoefficients()
        Calculate the normal polynomial coefficients given the Newton form. It also uses nested multiplication but takes O(N^2) time.