SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.interpolation
Class NevilleTable

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.rn2r1.UnivariateRealFunction
      extended by com.numericalmethod.suanshu.analysis.interpolation.NevilleTable
All Implemented Interfaces:
Function, RealScalarFunction, UnivariateRealInterpolator

public class NevilleTable
extends UnivariateRealFunction
implements UnivariateRealInterpolator

Neville's algorithm is an algorithm for polynomial interpolation. Given n + 1 points, there is a unique polynomial of degree ≤ n which associates with them. Neville's algorithm evaluates this polynomial for a given input x.

This implementation is based on filling out the Neville table. This table can be used in two ways.

First, it can be used as a function to compute f(x).

Second, it can be used in an incremental manner by adding a few, say one, data points at a time. The user can examine the values in the table.

See Also:
Wikipedia: Neville's algorithm

Nested Class Summary
static class NevilleTable.DuplicatedAbscissae
          RuntimeException thrown when there are duplicated abscissae.
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.Function
Function.EvaluationException
 
Constructor Summary
NevilleTable()
          Construct an empty Neville Table.
NevilleTable(double[] x, double[] y)
          Construct an instance of a Neville Table, initialized with data {(x, y)}.
NevilleTable(int n, double[] x, double[] y)
          Construct an instance of a Neville Table with size n, initialized with data {(x, y)}.
 
Method Summary
 void addData(double[] x, double[] y)
          Add more data points for interpolation.
 double evaluate(double x)
          Compute f(x).
 double get(int row, int col)
          Get the value of a table entry.
 int N()
          Get the number of data points.
 double[][] table()
          Get a copy of the Neville table.
 double[] X()
          Get a copy of the x's.
 
Methods inherited from class com.numericalmethod.suanshu.analysis.function.rn2r1.UnivariateRealFunction
dimension4Domain, dimension4Range, evaluate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NevilleTable

public NevilleTable(int n,
                    double[] x,
                    double[] y)
Construct an instance of a Neville Table with size n, initialized with data {(x, y)}.

The size n is only indicative. If there are more data points than n, the table size will increase accordingly.

Parameters:
n - indicative size; make this big for reservation to add new data points
x - the abscissae
y - the ordinates

NevilleTable

public NevilleTable(double[] x,
                    double[] y)
Construct an instance of a Neville Table, initialized with data {(x, y)}.

Parameters:
x - the abscissae
y - the ordinates

NevilleTable

public NevilleTable()
Construct an empty Neville Table.

Method Detail

addData

public void addData(double[] x,
                    double[] y)
Add more data points for interpolation.

Specified by:
addData in interface UnivariateRealInterpolator
Parameters:
x - the abscissae
y - the ordinates

N

public int N()
Get the number of data points.

Returns:
the number of data points

table

public double[][] table()
Get a copy of the Neville table.

The returned value is independent and can be modified anyhow.

Returns:
a copy of the table

X

public double[] X()
Get a copy of the x's.

The returned value is independent and can be modified anyhow.

Returns:
a copy of x's

get

public double get(int row,
                  int col)
Get the value of a table entry.

Parameters:
row - row index, counting from 0
col - column index, counting from 0
Returns:
the value of a table entry

evaluate

public double evaluate(double x)
Description copied from class: UnivariateRealFunction
Compute f(x).

Specified by:
evaluate in interface UnivariateRealInterpolator
Specified by:
evaluate in class UnivariateRealFunction
Parameters:
x - x
Returns:
f(x)

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.