Package pulse.math
Class LegendrePoly
- java.lang.Object
-
- pulse.math.LegendrePoly
-
- All Implemented Interfaces:
Serializable
public class LegendrePoly extends Object implements Serializable
A utility class represents the Legendre polynomial of a given order.May be useful in some applications, particularly, for calculating the ordinate sets in the discrete ordinates method. Allows calculating its coefficients, the value of the polynomial and its derivative at a given point, and the roots of the polynomial (with the help of a
LaguerreSolver.- See Also:
LaguerreSolver, Wiki page, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LegendrePoly(int n)Creates a Legendre polynomial of the ordern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longbinomial(int m, int k)Fast calculation of binomial coefficient Cmk = m!/(k!(m-k)!)voidcoefficients()This will generate the coefficients for the Legendre polynomial, arranged in order of significance (from x0 to xn).doublederivative(double x)Calculates the derivative of this Legendre polynomial.static doublegeneralisedBinomial(double alpha, int k)Calculates the generalised binomial coefficient.intgetOrder()doublepoly(double x)Calculates the value of this Legendre polynomial atxdouble[]roots()Uses aLaguerreSolverto calculate the roots of this polynomial.
-
-
-
Method Detail
-
binomial
public static long binomial(int m, int k)Fast calculation of binomial coefficient Cmk = m!/(k!(m-k)!)- Parameters:
m- integer.k- integer, k ≤ m.- Returns:
- binomial coefficient Cmk.
-
generalisedBinomial
public static double generalisedBinomial(double alpha, int k)Calculates the generalised binomial coefficient.- Parameters:
k- integer.alpha- a double value- Returns:
- the generalised binomial coefficient Cαk.
-
coefficients
public void coefficients()
This will generate the coefficients for the Legendre polynomial, arranged in order of significance (from x0 to xn). The coeffients will then be stored in a double array for further use.
-
derivative
public double derivative(double x)
Calculates the derivative of this Legendre polynomial. The coefficients are assumed to be known.- Parameters:
x- a real value.- Returns:
- the derivative at
x.
-
getOrder
public int getOrder()
- Returns:
- the order of this polynomial.
-
poly
public double poly(double x)
Calculates the value of this Legendre polynomial atx- Parameters:
x- a real value.- Returns:
- the value of the Legendre polynomial at
x.
-
roots
public double[] roots()
Uses aLaguerreSolverto calculate the roots of this polynomial. All coefficients are assumed to be known.- Returns:
- the real roots of the Legendre polynomial.
-
-