public class Spline2DInterpolate extends Spline2D
The class Spline2DInterpolate
computes a tensor-product spline
interpolant. The tensor-product spline interpolant to data
{(xi,yj,fij)}, where
0≤i≤(nx−1) and
0≤j≤(ny−1) has the form
ny−1∑m=0nx−1∑n=0cnmBn,kx,tx(x)Bm,ky,ty(y)
where kx and ky are the orders of
the splines. These numbers are defaulted to be 4, but can be set to any
positive integer using xOrder
and yOrder
in the constructor. Likewise, tx
and ty are the corresponding knot sequences (xKnots
and
yKnots
). These default values are selected by
Spline2DInterpolate
. The algorithm requires that
tx(kx−1)≤xi≤tx(nx)0≤i≤nx−1
ty(ky−1)≤yj≤ty(ny−1)0≤j≤ny−1
Tensor-product spline interpolants in two dimensions can be computed quite
efficiently by solving (repeatedly) two univariate interpolation problems.
The computation is motivated by the following observations. It is necessary
to solve the system of equations
ny−1∑m=0nx−1∑n=0cnmBn,kx,tx(xi)Bm,ky,ty(yj)=fij
Setting
hmi=nx−1∑n=0cnmBn,kx,tx(xi)
note that for each fixed i from 0 to nx−1, we
have ny linear equations in the same number of
unknowns as can be seen below:
ny−1∑m=0hmiBm,ky,ty(yj)=fij
ny−1∑m=0nx−1∑n=0cnmBn,kx,tx(xi)Bm,ky,ty(yj)=fij
Setting
hmi=nx−1∑n=0cnmBm,kx,tx(xi)
note that for each fixed i from 0 to nx−1, we
have ny−1 linear equations in the same number of
unknowns as can be seen below:
ny−1∑m=0hmiBn,ky,ty(yj)=fij
The same matrix appears in all of the equations above:
[Bm,ky,ty(yj)]0≤m,j≤ny−1
Thus, only factor this matrix once and then apply this factorization to the
nx right-hand sides. Once this is done and
hmi is computed, then solve for the coefficients
cnm using the relation
nx−1∑n=0cnmBn,kx,tx(xi)=hmi
for n from 0 to ny−1, which again involves
one factorization and ny solutions to the different
right-hand sides. The class Spline2DInterpolate
is based on the
routine SPLI2D by de Boor (1978, p. 347).
Constructor and Description |
---|
Spline2DInterpolate(double[] xData,
double[] yData,
double[][] fData)
Constructor for
Spline2DInterpolate . |
Spline2DInterpolate(double[] xData,
double[] yData,
double[][] fData,
int xOrder,
int yOrder)
Constructor for
Spline2DInterpolate . |
Spline2DInterpolate(double[] xData,
double[] yData,
double[][] fData,
int xOrder,
int yOrder,
double[] xKnots,
double[] yKnots)
Constructor for
Spline2DInterpolate . |
public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData)
Spline2DInterpolate
.xData
- a double
array containing the data points
in the x-direction.yData
- a double
array containing the data points
in the y-direction.fData
- a double
matrix of size
xData.length
by yData.length
containing the values to be interpolated.public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder)
Spline2DInterpolate
.xData
- a double
array containing the data points
in the x-direction.yData
- a double
array containing the data points
in the y-direction.fData
- a double
matrix of size
xData.length
by yData.length
containing the values to be interpolated.xOrder
- an int
scalar value specifying the order
of the spline in the x-direction. xOrder
must
be at least 1. Default: xOrder
= 4,
tensor-product cubic spline.yOrder
- an int
scalar value specifying the order
of the spline in the y-direction. yOrder
must
be at least 1. Default: yOrder
= 4,
tensor-product cubic spline.public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder, double[] xKnots, double[] yKnots)
Spline2DInterpolate
.xData
- a double
array containing the data points
in the x-direction.yData
- a double
array containing the data points
in the y-direction.fData
- a double
matrix of size
xData.length
by yData.length
containing the values to be interpolated.xOrder
- an int
scalar value specifying the order
of the spline in the x-direction. xOrder
must
be at least 1. Default: xOrder
= 4,
tensor-product cubic spline.yOrder
- an int
scalar value specifying the order
of the spline in the y-direction. yOrder
must
be at least 1. Default: yOrder
= 4,
tensor-product cubic spline.xKnots
- a double
array of size
xData.length + xOrder
specifying the knot
sequences of the spline in the x-direction. Default knot
sequences are selected by the class.yKnots
- a double
array of size
yData.length + yOrder
specifying the knot
sequences of the spline in the y-direction. Default knot
sequences are selected by the class.Copyright © 2020 Rogue Wave Software. All rights reserved.