uk.org.ogsadai.activity.files
Class Lagrange

java.lang.Object
  |
  +--uk.org.ogsadai.activity.files.Lagrange

public class Lagrange
extends java.lang.Object

A class which generates Lagrange interpolating polynomials interpolating the co-ordinates (pn, n), given an array of integers {pn}.

The generated polynomial is defined to be of degree n-1 if there are n co-ordinates.

Author:
The OGSA-DAI Project Team

Constructor Summary
Lagrange(int[] vals)
          Generate a new polynomial based on the given "seed integers" {pn}.
 
Method Summary
 double p(int x)
          The function representing the Lagrange interpolating polynomial.
 double p(int j, int x)
          The function representing one part of the Lagrange interpolating polynomial, used by the function P(int x).
 java.lang.String toString()
          Return a textual representation of the array of seed integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Lagrange

public Lagrange(int[] vals)
Generate a new polynomial based on the given "seed integers" {pn}.

Parameters:
vals - the seed integers
Method Detail

toString

public java.lang.String toString()
Return a textual representation of the array of seed integers. For debugging purposes only.

Overrides:
toString in class java.lang.Object
Returns:
the textual representation

p

public double p(int x)
The function representing the Lagrange interpolating polynomial.
P(x) =def Sum of (Pj(x)), for j = 1 to n.

Parameters:
x - the abscissa
Returns:
the ordinate

p

public double p(int j,
                int x)
The function representing one part of the Lagrange interpolating polynomial, used by the function P(int x).
Pj(x) =def yj * Product of ((x - xk) / (xj - xk)), for k = 1 to n and k != j.

Parameters:
j - the index j of the function Pj
x - the abscissa
Returns:
the ordinate