Class PolynomialFunction2D

  • All Implemented Interfaces:
    java.io.Serializable, Function2D

    public class PolynomialFunction2D
    extends java.lang.Object
    implements Function2D, java.io.Serializable
    A function in the form y = a0 + a1 * x + a2 * x^2 + ... + an * x^n. Instances of this class are immutable.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double[] coefficients
      The coefficients.
    • Constructor Summary

      Constructors 
      Constructor Description
      PolynomialFunction2D​(double[] coefficients)
      Constructs a new polynomial function y = a0 + a1 * x + a2 * x^2 + ... + an * x^n
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)
      Tests this function for equality with an arbitrary object.
      double[] getCoefficients()
      Returns a copy of the coefficients array that was specified in the constructor.
      int getOrder()
      Returns the order of the polynomial.
      double getValue​(double x)
      Returns the function value.
      int hashCode()
      Returns a hash code for this instance.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • coefficients

        private double[] coefficients
        The coefficients.
    • Constructor Detail

      • PolynomialFunction2D

        public PolynomialFunction2D​(double[] coefficients)
        Constructs a new polynomial function y = a0 + a1 * x + a2 * x^2 + ... + an * x^n
        Parameters:
        coefficients - an array with the coefficients [a0, a1, ..., an] (null not permitted).
    • Method Detail

      • getCoefficients

        public double[] getCoefficients()
        Returns a copy of the coefficients array that was specified in the constructor.
        Returns:
        The coefficients array.
      • getOrder

        public int getOrder()
        Returns the order of the polynomial.
        Returns:
        The order.
      • getValue

        public double getValue​(double x)
        Returns the function value.
        Specified by:
        getValue in interface Function2D
        Parameters:
        x - the x-value.
        Returns:
        The value.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this function for equality with an arbitrary object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hash code for this instance.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        A hash code.