Example usage for org.apache.commons.math3.analysis.polynomials PolynomialsUtils createJacobiPolynomial

List of usage examples for org.apache.commons.math3.analysis.polynomials PolynomialsUtils createJacobiPolynomial

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis.polynomials PolynomialsUtils createJacobiPolynomial.

Prototype

public static PolynomialFunction createJacobiPolynomial(final int degree, final int v, final int w) 

Source Link

Document

Create a Jacobi polynomial.

Usage

From source file:org.orekit.propagation.semianalytical.dsst.utilities.JacobiPolynomials.java

/** Returns the value and derivatives of the Jacobi polynomial P<sub>l</sub><sup>v,w</sup> evaluated at .
 * <p>//ww  w  .  j  a  v a2 s.c  o m
 * This method is guaranteed to be thread-safe
 * </p>
 * @param l degree of the polynomial
 * @param v v value
 * @param w w value
 * @param gamma  value
 * @return value and derivatives of the Jacobi polynomial P<sub>l</sub><sup>v,w</sup>()
 */
public static DerivativeStructure getValue(final int l, final int v, final int w,
        final DerivativeStructure gamma) {

    final List<PolynomialFunction> polyList;
    synchronized (MAP) {

        final JacobiKey key = new JacobiKey(v, w);

        // Check the existence of the corresponding key in the map.
        if (!MAP.containsKey(key)) {
            MAP.put(key, new ArrayList<PolynomialFunction>());
        }

        polyList = MAP.get(key);

    }

    final PolynomialFunction polynomial;
    synchronized (polyList) {
        // If the l-th degree polynomial has not been computed yet, the polynomials
        // up to this degree are computed.
        for (int degree = polyList.size(); degree <= l; degree++) {
            polyList.add(degree, PolynomialsUtils.createJacobiPolynomial(degree, v, w));
        }
        polynomial = polyList.get(l);
    }

    // compute value and derivative
    return polynomial.value(gamma);

}