public class Spline2DLeastSquares extends Spline2D
The Spline2DLeastSquares class computes a tensorproduct spline leastsquares
approximation to weighted tensorproduct data. The input consists of data
vectors to specify the tensorproduct grid for the data, two vectors with
the weights, the values of the surface on the grid, and the specification
for the tensorproduct spline. The grid is specified by the two vectors
x = xData
and y = yData
of length
n = xData.length
and m = yData.length
,
respectively. A twodimensional array f = fData
contains
the data values which are to be fit. The two vectors =
xWeights
and = yWeights
contain the
weights for the weighted leastsquares problem. The information for the
approximating tensorproduct spline can be provided using the
setXOrder
, setYOrder
, setXKnots
and
setYKnots
methods. This information is contained in
= xOrder
, =
xKnots
, and N = xSplineSpaceDim
for the
spline in the first variable, and in =
yOrder
, = yKnots
and
M = ySplineSpaceDim
for the spline in the second variable.
This class computes coefficients for the tensorproduct spline by solving
the normal equations in tensorproduct form as discussed in de Boor (1978,
Chapter 17). The interested reader might also want to study the paper by
Grosse (1980).
As the computation proceeds, we obtain coefficients c minimizing
where the function is the tensorproduct of two Bsplines of order and . Specifically, we have The spline and its partial derivatives can be evaluated using thevalue
method.
Constructor and Description 

Spline2DLeastSquares(double[] xData,
double[] yData,
double[][] fData,
int xSplineSpaceDim,
int ySplineSpaceDim)
Constructor for
Spline2DLeastSquares . 
Modifier and Type  Method and Description 

void 
compute()
Computes a twodimensional, tensorproduct spline approximant using
least squares.

double 
getErrorSumOfSquares()
Returns the weighted error sum of squares.

int 
getXOrder()
Returns the order of the spline in the xdirection.

double[] 
getXWeights()
Returns the weights for the leastsquares fit in the xdirection.

int 
getYOrder()
Returns the order of the spline in the ydirection.

double[] 
getYWeights()
Returns the weights for the leastsquares fit in the ydirection.

void 
setXKnots(double[] xKnots)
Sets the knot sequences of the spline in the xdirection.

void 
setXOrder(int xOrder)
Sets the order of the spline in the xdirection.

void 
setXWeights(double[] xWeights)
Sets the weights for the leastsquares fit in the xdirection.

void 
setYKnots(double[] yKnots)
Sets the knot sequences of the spline in the ydirection.

void 
setYOrder(int yOrder)
Sets the order of the spline in the ydirection.

void 
setYWeights(double[] yWeights)
Sets the weights for the leastsquares fit in the ydirection.

derivative, derivative, getCoefficients, getXKnots, getYKnots, integral, value, value
public Spline2DLeastSquares(double[] xData, double[] yData, double[][] fData, int xSplineSpaceDim, int ySplineSpaceDim)
Spline2DLeastSquares
.xData
 a double
array containing the data points
in the xdirection.yData
 a double
array containing the data points
in the ydirection.fData
 a double
matrix of size
xData.length
by yData.length
containing the values to be approximated.xSplineSpaceDim
 an int
scalar value specifying the
linear dimension of the spline subspace for the x
variable. It should be smaller than xData.length
and greater than or equal to xOrder
(whose default value is 4).ySplineSpaceDim
 an int
scalar value specifying the
linear dimension of the spline subspace for the y
variable. It should be smaller than yData.length
and greater than or equal to yOrder
(whose default value is 4).public void compute()
public double getErrorSumOfSquares()
double
scalar containing the weighted error sum
of squares.public int getXOrder()
int
scalar containing the order
of the spline in the xdirection.public double[] getXWeights()
double
array containing the weights for the
leastsquares fit in the xdirection.public int getYOrder()
int
scalar containing the order
of the spline in the ydirection.public double[] getYWeights()
double
array containing the weights for the
leastsquares fit in the ydirection.public void setXKnots(double[] xKnots)
xKnots
 a double
array of size
xSplineSpaceDim + xOrder
specifying the knot
sequences of the spline in the xdirection. Default knot
sequences are selected by the class.public void setXOrder(int xOrder)
xOrder
 an int
scalar value specifying the order
of the spline in the xdirection. xOrder
must
be at least 1. Default: xOrder
= 4,
implying a tensorproduct cubic spline.public void setXWeights(double[] xWeights)
xWeights
 a double
array of size
xData.length
specifying the weights for the
leastsquares fit in the xdirection. Default:
all weights are equal to 1.public void setYKnots(double[] yKnots)
yKnots
 a double
array of size
ySplineSpaceDim + yOrder
specifying the knot
sequences of the spline in the ydirection. Default knot
sequences are selected by the class.public void setYOrder(int yOrder)
yOrder
 an int
scalar value specifying the order
of the spline in the ydirection. yOrder
must
be at least 1. Default: yOrder
= 4,
implying a tensorproduct cubic spline.public void setYWeights(double[] yWeights)
yWeights
 a double
array of size
yData.length
specifying the weights for the
leastsquares fit in the ydirection. Default:
all weights are equal to 1.Copyright © 19702015 Rogue Wave Software
Built October 13 2015.