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

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  int mN
           
private  int[] mX
           
private  int[] mY
           
 
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
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

mX

private int[] mX

mY

private int[] mY

mN

private int mN
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