Documentation of 'org.ddogleg.solver.Polynomial' Java class
Polynomial
org.ddogleg.solver

Class Polynomial



  • public class Polynomial
    extends java.lang.Object
    Data structure for storing polynomials. Internally the coefficients are stored in an array from lowest degree to highest:
    f(x) = c[0] + c[1]*x + ... + c[n]*xn-1
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      double[] c 
      int size 
    • Constructor Summary

      Constructors 
      Constructor and Description
      Polynomial(int maxCoefficients)
      Creates a polynomial which can hold the specified number of coefficients.
      Polynomial(Polynomial original) 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int computeDegree()
      Finds the power of the largest non-zero coefficient in the polynomial.
      double evaluate(double variable)
      Computes the polynomials output given the variable value Can handle infinite numbers
      double get(int i) 
      double[] getCoefficients() 
      boolean isIdentical(Polynomial p, double tol)
      Checks to see if the coefficients of two polynomials are identical to within tolerance.
      void print() 
      void resize(int size)
      Change the maximum number of coefficients which can be stored inside this polynomial
      void setTo(double[] coefficients, int size) 
      void setTo(Polynomial source) 
      int size() 
      java.lang.String toString() 
      void truncateZeros(double tol)
      Prunes zero coefficients from the end of a sequence.
      static Polynomial wrap(double... coefficients)
      Wraps the polynomial around the array:
      f(x) = c[0] + c[1]*x + ...
      void zero() 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • c

        public double[] c
      • size

        public int size
    • Constructor Detail

      • Polynomial

        public Polynomial(int maxCoefficients)
        Creates a polynomial which can hold the specified number of coefficients. Note this is the polynomial's degree+1.
        Parameters:
        maxCoefficients - The largest number of coefficients which can be stored. Also the initial size of the polynomial.
      • Polynomial

        public Polynomial(Polynomial original)
    • Method Detail

      • wrap

        public static Polynomial wrap(double... coefficients)
        Wraps the polynomial around the array:
        f(x) = c[0] + c[1]*x + ... + c[n]*xn-1
        Parameters:
        coefficients - Polynomial coefficients
        Returns:
        new instance of a polyonimial which is identical to the input array
      • evaluate

        public double evaluate(double variable)
        Computes the polynomials output given the variable value Can handle infinite numbers
        Returns:
        Output
      • setTo

        public void setTo(double[] coefficients,
                          int size)
      • resize

        public void resize(int size)
        Change the maximum number of coefficients which can be stored inside this polynomial
        Parameters:
        size - New maximum number of coefficients.
      • zero

        public void zero()
      • computeDegree

        public int computeDegree()
        Finds the power of the largest non-zero coefficient in the polynomial. If all the coefficients are zero or if there is only the constant term, zero is returned.
        Returns:
        Degree of the polynomial
      • isIdentical

        public boolean isIdentical(Polynomial p,
                                   double tol)
        Checks to see if the coefficients of two polynomials are identical to within tolerance. If the lengths of the polynomials are not the same then the extra coefficients in the longer polynomial must be within tolerance of zero.
        Parameters:
        p - Polynomial that this polynomial is being compared against.
        tol - Similarity tolerance. Try 1e-15 for high confidence
        Returns:
        true if the two polynomials are identical to within tolerance.
      • truncateZeros

        public void truncateZeros(double tol)
        Prunes zero coefficients from the end of a sequence. A coefficient is zero if its absolute value is less than or equal to tolerance.
        Parameters:
        tol - Tolerance for zero. Try 1e-15
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • print

        public void print()
      • getCoefficients

        public double[] getCoefficients()
      • size

        public int size()
      • get

        public double get(int i)

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.