Class NevilleTable
java.lang.Object
dev.nm.analysis.function.rn2r1.AbstractRealScalarFunction
dev.nm.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction
dev.nm.analysis.curvefit.interpolation.NevilleTable
- All Implemented Interfaces:
OnlineInterpolator
,Function<Vector,
,Double> RealScalarFunction
,UnivariateRealFunction
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.nm.analysis.function.Function
Function.EvaluationException
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty Neville table.NevilleTable
(int n, OrderedPairs f) Construct a Neville table of size n, initialized with data {(x, y)}.Construct a Neville table of size n, initialized with data {(x, y)}. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 dev.nm.analysis.function.rn2r1.univariate.AbstractUnivariateRealFunction
evaluate
Methods inherited from class dev.nm.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 dev.nm.analysis.function.Function
dimensionOfDomain, dimensionOfRange
-
Constructor Details
-
NevilleTable
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 pointsf
- the points to be interpolated
-
NevilleTable
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 Details
-
addData
Description copied from interface:OnlineInterpolator
Add more points for interpolation.- Specified by:
addData
in interfaceOnlineInterpolator
- 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 0j
- 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 interfaceUnivariateRealFunction
- Parameters:
x
- x- Returns:
- f(x)
-