# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.curvefit.interpolation

## Class NevilleTable

• All Implemented Interfaces:
OnlineInterpolator, Function<Vector,Double>, RealScalarFunction, UnivariateRealFunction

public class NevilleTable
extends AbstractUnivariateRealFunction
implements OnlineInterpolator
Neville's algorithm is a polynomial interpolation algorithm. 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 to compute the interpolated function f(x). Second, it can be used in an incremental manner by adding a few, say one, data points each time to allow for examination of the table values.

Wikipedia: Neville's algorithm

• ### Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.Function

Function.EvaluationException
• ### Constructor Summary

Constructors
Constructor and Description
NevilleTable()
Construct an empty Neville table.
NevilleTable(int n, OrderedPairs f)
Construct a Neville table of size n, initialized with data {(x, y)}.
NevilleTable(OrderedPairs f)
Construct a Neville table of size n, initialized with data {(x, y)}.
• ### Method Summary

All Methods
Modifier and Type Method and Description
void addData(OrderedPairs f)
Add more points for interpolation.
double evaluate(double x)
Evaluate y = f(x).
double get(int i, int j)
Get the value of a table entry.
double[][] getTable()
Get a copy of the Neville table.
int N()
Get the number of data points.
double[] x()
Get a copy of the x's.
• ### Methods inherited from class com.numericalmethod.suanshu.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction

evaluate
• ### Methods inherited from class com.numericalmethod.suanshu.analysis.function.rn2r1.AbstractRealScalarFunction

dimensionOfDomain, dimensionOfRange
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface com.numericalmethod.suanshu.analysis.function.Function

dimensionOfDomain, dimensionOfRange
• ### Constructor Detail

• #### NevilleTable

public NevilleTable(int n,
OrderedPairs f)
Construct a Neville table of size n, initialized with data {(x, y)}. The size n is only indicative. If there are more data points than n, the table size grows accordingly.
Parameters:
n - indicative size; make this big for reservation to add new data points
f - the points to be interpolated
• #### NevilleTable

public NevilleTable(OrderedPairs f)
Construct a Neville table of size n, initialized with data {(x, y)}.
Parameters:
f - the points to be interpolated
• #### NevilleTable

public NevilleTable()
Construct an empty Neville table.
• ### Method Detail

public void addData(OrderedPairs f)
Description copied from interface: OnlineInterpolator
Add more points for interpolation.
Specified by:
addData in interface OnlineInterpolator
Parameters:
f - the points to be interpolated
• #### N

public int N()
Get the number of data points.
Returns:
the number of data points
• #### getTable

public double[][] getTable()
Get a copy of the Neville table.
Returns:
a copy of the table
• #### x

public double[] x()
Get a copy of the x's.
Returns:
a copy of x's.
• #### get

public double get(int i,
int j)
Get the value of a table entry.
Parameters:
i - row index, counting from 0
j - column index, counting from 0
Returns:
the value of the table entry
• #### evaluate

public double evaluate(double x)
Description copied from interface: UnivariateRealFunction
Evaluate y = f(x).
Specified by:
evaluate in interface UnivariateRealFunction
Parameters:
x - x
Returns:
f(x)