jsci.maths.polynomials
Class PolynomialMath
- java.lang.Object
-
- jsci.maths.AbstractMath
-
- jsci.maths.polynomials.PolynomialMath
-
public final class PolynomialMath extends AbstractMath
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static ComplexevalPolynomial(ComplexPolynomial p, Complex t)Evaluates a polynomial by Horner's scheme.static doubleevalPolynomial(RealPolynomial p, double t)Evaluates a polynomial by Horner's scheme.static Complex[]findRoots(RealPolynomial p)Calculates the roots of a given polynomial by solving the eigenvalue problem for the companion matrix.static ComplexPolynomialinterpolateLagrange(Complex[][] samplingPoints)Interpolates a polynomial.static RealPolynomialinterpolateLagrange(double[][] samplingPoints)Interpolates a polynomial.static intmaxDegree(Polynomial p1, Polynomial p2)Get the maximum degree of two polynomialsstatic intminDegree(Polynomial p1, Polynomial p2)Get the minimal degree of two polynomialsstatic ComplexPolynomialnormalize(ComplexPolynomial p)Normalizes a given complex polynomial, i.e.static RealPolynomialnormalize(RealPolynomial p)Normalizes a given real polynomial, i.e.static AbstractComplexSquareMatrixtoCompanionMatrix(ComplexPolynomial p)static AbstractDoubleSquareMatrixtoCompanionMatrix(RealPolynomial p)Returns the companion matrix of a given polynomial.static ComplexPolynomialtoComplex(Polynomial p)Try to cast a Polynomial to a complex polynomial
-
-
-
Method Detail
-
toCompanionMatrix
public static AbstractDoubleSquareMatrix toCompanionMatrix(RealPolynomial p)
Returns the companion matrix of a given polynomial. The eigenvalues of the companion matrix are the roots of the polynomial.- Parameters:
p- the polynomial- Returns:
- the companion matrix
-
toCompanionMatrix
public static AbstractComplexSquareMatrix toCompanionMatrix(ComplexPolynomial p)
-
findRoots
public static Complex[] findRoots(RealPolynomial p)
Calculates the roots of a given polynomial by solving the eigenvalue problem for the companion matrix. This is not yet implemented (depends on a QR- decomposition)- Parameters:
p- the polynomial- Returns:
- (unordered) list of roots.
-
maxDegree
public static int maxDegree(Polynomial p1, Polynomial p2)
Get the maximum degree of two polynomials- Parameters:
p1-p2-
-
minDegree
public static int minDegree(Polynomial p1, Polynomial p2)
Get the minimal degree of two polynomials- Parameters:
p1-p2-
-
evalPolynomial
public static double evalPolynomial(RealPolynomial p, double t)
Evaluates a polynomial by Horner's scheme.- Parameters:
p-t-
-
evalPolynomial
public static Complex evalPolynomial(ComplexPolynomial p, Complex t)
Evaluates a polynomial by Horner's scheme.- Parameters:
p-t-
-
interpolateLagrange
public static RealPolynomial interpolateLagrange(double[][] samplingPoints)
Interpolates a polynomial. Caveat: this method is brute-force, slow and not very stable. It shouldn't be used for more than approx. 10 points. Remember the strong variations of higher degree polynomials.- Parameters:
samplingPoints- an array[2][n] where array[0] denotes x-values, array[1] y-values
-
interpolateLagrange
public static ComplexPolynomial interpolateLagrange(Complex[][] samplingPoints)
Interpolates a polynomial. Caveat: this method is brute-force, slow and not very stable. It shouldn't be used for more than approx. 10 points. Remember the strong variations of higher degree polynomials.- Parameters:
samplingPoints- an array[2][n] where array[0] denotes x-values, array[1] y-values
-
normalize
public static RealPolynomial normalize(RealPolynomial p)
Normalizes a given real polynomial, i.e. divide by the leading coefficient.- Parameters:
p-
-
normalize
public static ComplexPolynomial normalize(ComplexPolynomial p)
Normalizes a given complex polynomial, i.e. divide by the leading coefficient.- Parameters:
p-
-
toComplex
public static ComplexPolynomial toComplex(Polynomial p)
Try to cast a Polynomial to a complex polynomial
-
-
DMelt 3.0 © DataMelt by jWork.ORG