org.ddogleg.solver
Class PolynomialOps
- java.lang.Object
-
- org.ddogleg.solver.PolynomialOps
-
public class PolynomialOps extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description PolynomialOps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Polynomialadd(Polynomial a, Polynomial b, Polynomial results)Adds two polynomials together.static intcountRealRoots(Polynomial poly)static PolynomialRootscreateRootFinder(int maxCoefficients, RootFinderType which)Creates different polynomial root finders.static doublecubicRealRoot(double c0, double c1, double c2, double c3)Returns a real root to the cubic polynomial: 0 = c0 + c1*x + c2*x^2 + c3*c^3.static Polynomialderivative(Polynomial poly, Polynomial deriv)static voiddivide(Polynomial numerator, Polynomial denominator, Polynomial quotient, Polynomial remainder)Polynomial division.static Polynomialmultiply(Polynomial a, Polynomial b, Polynomial result)Multiplies the two polynomials together.static doublequadraticVertex(double a, double b)Given the coefficients compute the vertex (minimum/maximum) of the quadratic.static doublerefineRoot(Polynomial poly, double root, int maxIterations)
-
-
-
Method Detail
-
quadraticVertex
public static double quadraticVertex(double a, double b)Given the coefficients compute the vertex (minimum/maximum) of the quadratic. y = a*x2 + b*x + c- Parameters:
a- quadratic coefficient.b- quadratic coefficient.- Returns:
- The quadratic's vertex.
-
derivative
public static Polynomial derivative(Polynomial poly, Polynomial deriv)
-
refineRoot
public static double refineRoot(Polynomial poly, double root, int maxIterations)
-
divide
public static void divide(Polynomial numerator, Polynomial denominator, Polynomial quotient, Polynomial remainder)
Polynomial division. Computes both the quotient and the remainder.
quotient = numerator/denominator
remainder = numerator % denominator- Parameters:
numerator- Numerator in the division. Not modified.denominator- Denominator in the division. Not modified.quotient- Output quotient, Modified.remainder- Output remainder. Modified.
-
multiply
public static Polynomial multiply(Polynomial a, Polynomial b, Polynomial result)
Multiplies the two polynomials together.- Parameters:
a- Polynomialb- Polynomialresult- Optional storage parameter for the results. Must be have enough coefficients to store the results. If null a new instance is declared.- Returns:
- Results of the multiplication
-
add
public static Polynomial add(Polynomial a, Polynomial b, Polynomial results)
Adds two polynomials together. The lengths of the polynomials do not need to be the zero, but the 'missing' coefficients are assumed to be zero.- Parameters:
a- Polynomialb- Polynomialresults- Optional storage for resulting polynomial. If null a new instance is declared. If not null its length must be the same as the largest polynomial 'a' or 'b'.- Returns:
- Polynomial 'a' and 'b' added together.
-
countRealRoots
public static int countRealRoots(Polynomial poly)
-
createRootFinder
public static PolynomialRoots createRootFinder(int maxCoefficients, RootFinderType which)
Creates different polynomial root finders.- Parameters:
maxCoefficients- The maximum number of coefficients that will be processed. This is the order + 1which- 0 = Sturm and 1 = companion matrix.- Returns:
- PolynomialRoots
-
cubicRealRoot
public static double cubicRealRoot(double c0, double c1, double c2, double c3)Returns a real root to the cubic polynomial: 0 = c0 + c1*x + c2*x^2 + c3*c^3. There can be other real roots. WARNING: This technique is much less stable than using one of the RootFinder algorithms- Parameters:
c0- Polynomial coefficient for power 0c1- Polynomial coefficient for power 1c2- Polynomial coefficient for power 2c3- Polynomial coefficient for power 3- Returns:
- A real root of the polynomial
-
-
DataMelt 3.0 © DataMelt by jWork.ORG