nr
Class Polynomial

java.lang.Object
  extended by nr.Polynomial

public class Polynomial
extends java.lang.Object

Polynomial evaluations, from CERN


Method Summary
static double eval(double x, double[] coef)
          Evaluates the given polynomial of degree N at x.
static double eval1(double x, double[] coef)
          Evaluates the given polynomial of degree N at x, assuming coefficient of N is 1.0.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

eval1

public static double eval1(double x,
                           double[] coef)
Evaluates the given polynomial of degree N at x, assuming coefficient of N is 1.0. Otherwise same as polevl().
y = C0 + C1x + C2x2 + … + CNxN
where CN = 1 and hence is omitted from the array.
Coefficients are stored in reverse order:
coef[0] = CN-1 , hellip, coef[N-1] = C0
Calling arguments are otherwise the same as polevl(). In the interest of speed, there are no checks for out of bounds arithmetic.

Parameters:
x - argument to the polynomial.
coef - the coefficients of the polynomial.

eval

public static double eval(double x,
                          double[] coef)
                   throws java.lang.ArithmeticException
Evaluates the given polynomial of degree N at x.
y = C0 + C1x + C2x2 + … + CNxN
Coefficients are stored in reverse order:
coef[0] = CN, …, coef[N] = C0

Parameters:
x - argument to the polynomial.
coef - the coefficients of the polynomial.
N - the degree of the polynomial.
Throws:
java.lang.ArithmeticException