Class Polynom

java.lang.Object
ch.nolix.base.math.algebra.Polynom

public final class Polynom extends Object
A Polynom is not mutable. A Polynom stores its coefficients in an array from the highest to the lowest coefficient. -degree: n -array: [a_n,... ,a_0]
Author:
Silvan Wyss
  • Field Details

  • Method Details

    • withCoefficients

      public static Polynom withCoefficients(double... coefficients)
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • getCoefficientForDegree

      public double getCoefficientForDegree(int degree)
      Parameters:
      degree -
      Returns:
      the coefficient for the given degree from the current Polynom.
      Throws:
      RuntimeException - if the given degree is not between 0 and the degree of the current Polynom.
    • getDerived

      public Polynom getDerived()
      Returns:
      a new Polynom that is derived from the current Polynom.
    • getDerived

      public Polynom getDerived(int deriveCount)
      Parameters:
      deriveCount -
      Returns:
      a new Polynom that is derived from the current Polynom as many times as the given deriveCount says.
      Throws:
      RuntimeException - if the given deriveCount is negative.
    • getDegree

      public int getDegree()
      Returns:
      the degree of the current Polynom.
    • getIntegrated

      public Polynom getIntegrated()
      Returns:
      a new Polynom that is the integration of the current Polynom.
    • getIntegrated

      public Polynom getIntegrated(int integrationCount)
      Parameters:
      integrationCount -
      Returns:
      a new Polynom that is the integration from the current Polynom as many times as the given integrationCount says.
      Throws:
      RuntimeException - if the given integrationCount is negative.
    • getSlopeAt

      public double getSlopeAt(double x)
      Parameters:
      x -
      Returns:
      the slope of the current Polynom at the given x.
    • getValueAt

      public double getValueAt(double x)
      This method implements the Horner scheme to calculate the value.
      Parameters:
      x -
      Returns:
      the value of the current Polynom at the given x.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • hasSameDegreeAs

      public boolean hasSameDegreeAs(Polynom polynom)
      Parameters:
      polynom -
      Returns:
      true if the current Polynom has the same degree as the given polynom, false otherwise.
    • isZeroPolynom

      public boolean isZeroPolynom()
      A Polynom is a zero Polynom if all its coefficients are 0.0.
      Returns:
      true if the current Polynom is a zero Polynom, false otherwise.
    • toArray

      public double[] toArray()
      Returns:
      a new array with the coefficients of the current Polynom.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(String parameterSymbol)
      Parameters:
      parameterSymbol -
      Returns:
      a String representation of the current Polynom with the given parameterSymbol
      Throws:
      RuntimeException - if the given parameterSymbol is null.
    • toVector

      public Vector toVector()
      Returns:
      a new Vector with the coefficients of the current Polynom.