NAG Library Routine Document
E02DDF
1 Purpose
E02DDF computes a bicubic spline approximation to a set of scattered data. The knots of the spline are located automatically, but a single parameter must be specified to control the tradeoff between closeness of fit and smoothness of fit.
2 Specification
SUBROUTINE E02DDF ( 
START, M, X, Y, F, W, S, NXEST, NYEST, NX, LAMDA, NY, MU, C, FP, RANK, WRK, LWRK, IWRK, LIWRK, IFAIL) 
INTEGER 
M, NXEST, NYEST, NX, NY, RANK, LWRK, IWRK(LIWRK), LIWRK, IFAIL 
REAL (KIND=nag_wp) 
X(M), Y(M), F(M), W(M), S, LAMDA(NXEST), MU(NYEST), C((NXEST4)*(NYEST4)), FP, WRK(LWRK) 
CHARACTER(1) 
START 

3 Description
E02DDF determines a smooth bicubic spline approximation $s\left(x,y\right)$ to the set of data points $\left({x}_{\mathit{r}},{y}_{\mathit{r}},{f}_{\mathit{r}}\right)$ with weights ${\mathit{w}}_{\mathit{r}}$, for $\mathit{r}=1,2,\dots ,m$.
The approximation domain is considered to be the rectangle $\left[{x}_{\mathrm{min}},{x}_{\mathrm{max}}\right]\times \left[{y}_{\mathrm{min}},{y}_{\mathrm{max}}\right]$, where ${x}_{\mathrm{min}}\left({y}_{\mathrm{min}}\right)$ and ${x}_{\mathrm{max}}\left({y}_{\mathrm{max}}\right)$ denote the lowest and highest data values of $x\left(y\right)$.
The spline is given in the Bspline representation
where
${M}_{i}\left(x\right)$ and
${N}_{j}\left(y\right)$ denote normalized cubic Bsplines, the former defined on the knots
${\lambda}_{i}$ to
${\lambda}_{i+4}$ and the latter on the knots
${\mu}_{j}$ to
${\mu}_{j+4}$. For further details, see
Hayes and Halliday (1974) for bicubic splines and
de Boor (1972) for normalized Bsplines.
The total numbers
${n}_{x}$ and
${n}_{y}$ of these knots and their values
${\lambda}_{1},\dots ,{\lambda}_{{n}_{x}}$ and
${\mu}_{1},\dots ,{\mu}_{{n}_{y}}$ are chosen automatically by the routine. The knots
${\lambda}_{5},\dots ,{\lambda}_{{n}_{x}4}$ and
${\mu}_{5},\dots ,{\mu}_{{n}_{y}4}$ are the interior knots; they divide the approximation domain
$\left[{x}_{\mathrm{min}},{x}_{\mathrm{max}}\right]\times \left[{y}_{\mathrm{min}},{y}_{\mathrm{max}}\right]$ into
$\left({n}_{x}7\right)\times \left({n}_{y}7\right)$ subpanels
$\left[{\lambda}_{\mathit{i}},{\lambda}_{\mathit{i}+1}\right]\times \left[{\mu}_{\mathit{j}},{\mu}_{\mathit{j}+1}\right]$, for
$\mathit{i}=4,5,\dots ,{n}_{x}4$ and
$\mathit{j}=4,5,\dots ,{n}_{y}4$. Then, much as in the curve case (see
E02BEF), the coefficients
${c}_{ij}$ are determined as the solution of the following constrained minimization problem:
minimize
subject to the constraint
where: 
$\eta $ 
is a measure of the (lack of) smoothness of $s\left(x,y\right)$. Its value depends on the discontinuity jumps in $s\left(x,y\right)$ across the boundaries of the subpanels. It is zero only when there are no discontinuities and is positive otherwise, increasing with the size of the jumps (see Dierckx (1981b) for details). 

${\epsilon}_{r}$ 
denotes the weighted residual
${\mathit{w}}_{r}\left({f}_{r}s\left({x}_{r},{y}_{r}\right)\right)$, 
and 
${\mathbf{S}}$ 
is a nonnegative number to be specified by you. 
By means of the parameter
${\mathbf{S}}$, ‘the smoothing factor’, you will then control the balance between smoothness and closeness of fit, as measured by the sum of squares of residuals in
(3). If
${\mathbf{S}}$ is too large, the spline will be too smooth and signal will be lost (underfit); if
${\mathbf{S}}$ is too small, the spline will pick up too much noise (overfit). In the extreme cases the method would return an interpolating spline
$\left(\theta =0\right)$ if
${\mathbf{S}}$ were set to zero, and returns the least squares bicubic polynomial
$\left(\eta =0\right)$ if
${\mathbf{S}}$ is set very large. Experimenting with
${\mathbf{S}}$values between these two extremes should result in a good compromise. (See
Section 8.2 for advice on choice of
${\mathbf{S}}$.) Note however, that this routine, unlike
E02BEF and
E02DCF, does not allow
${\mathbf{S}}$ to be set exactly to zero: to compute an interpolant to scattered data,
E01SAF or
E01SGF should be used.
The method employed is outlined in
Section 8.5 and fully described in
Dierckx (1981a) and
Dierckx (1981b). It involves an adaptive strategy for locating the knots of the bicubic spline (depending on the function underlying the data and on the value of
${\mathbf{S}}$), and an iterative method for solving the constrained minimization problem once the knots have been determined.
Values and derivatives of the computed spline can subsequently be computed by calling
E02DEF,
E02DFF or
E02DHF as described in
Section 8.6.
4 References
de Boor C (1972) On calculating with Bsplines J. Approx. Theory 6 50–62
Dierckx P (1981a) An improved algorithm for curve fitting with spline functions Report TW54 Department of Computer Science, Katholieke Univerciteit Leuven
Dierckx P (1981b) An algorithm for surface fitting with spline functions IMA J. Numer. Anal. 1 267–283
Hayes J G and Halliday J (1974) The leastsquares fitting of cubic spline surfaces to general data sets J. Inst. Math. Appl. 14 89–103
Peters G and Wilkinson J H (1970) The leastsquares problem and pseudoinverses Comput. J. 13 309–316
Reinsch C H (1967) Smoothing by spline functions Numer. Math. 10 177–183
5 Parameters
 1: START – CHARACTER(1)Input
On entry: determines whether calculations are to be performed afresh (Cold Start) or whether knots found in previous calls are to be used as an initial estimate of knot placement (Warm Start).
 ${\mathbf{START}}=\text{'C'}$
 The routine will build up the knot set starting with no interior knots. No values need be assigned to the parameters NX, NY, LAMDA, MU or WRK.
 ${\mathbf{START}}=\text{'W'}$
 The routine will restart the knotplacing strategy using the knots found in a previous call of the routine. In this case, the parameters NX, NY, LAMDA, MU and WRK must be unchanged from that previous call. This warm start can save much time in determining a satisfactory set of knots for the given value of S. This is particularly useful when different smoothing factors are used for the same dataset.
Constraint:
${\mathbf{START}}=\text{'C'}$ or $\text{'W'}$.
 2: M – INTEGERInput
On entry:
$m$, the number of data points.
The number of data points with nonzero weight (see
W) must be at least
$16$.
 3: X(M) – REAL (KIND=nag_wp) arrayInput
 4: Y(M) – REAL (KIND=nag_wp) arrayInput
 5: F(M) – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{X}}\left(\mathit{r}\right)$, ${\mathbf{Y}}\left(\mathit{r}\right)$, ${\mathbf{F}}\left(\mathit{r}\right)$ must be set to the coordinates of $\left({x}_{\mathit{r}},{y}_{\mathit{r}},{f}_{\mathit{r}}\right)$, the $\mathit{r}$th data point, for $\mathit{r}=1,2,\dots ,m$. The order of the data points is immaterial.
 6: W(M) – REAL (KIND=nag_wp) arrayInput
On entry:
${\mathbf{W}}\left(\mathit{r}\right)$ must be set to
${\mathit{w}}_{\mathit{r}}$, the
$\mathit{r}$th value in the set of weights, for
$\mathit{r}=1,2,\dots ,m$. Zero weights are permitted and the corresponding points are ignored, except when determining
${x}_{\mathrm{min}}$,
${x}_{\mathrm{max}}$,
${y}_{\mathrm{min}}$ and
${y}_{\mathrm{max}}$ (see
Section 8.4). For advice on the choice of weights, see
Section 2.1.2 in the E02 Chapter Introduction.
Constraint:
the number of data points with nonzero weight must be at least $16$.
 7: S – REAL (KIND=nag_wp)Input
On entry: the smoothing factor,
S.
For advice on the choice of
S, see
Sections 3 and
8.2.
Constraint:
${\mathbf{S}}>0.0$.
 8: NXEST – INTEGERInput
 9: NYEST – INTEGERInput
On entry: an upper bound for the number of knots
${n}_{x}$ and
${n}_{y}$ required in the
$x$ and
$y$directions respectively.
In most practical situations,
${\mathbf{NXEST}}={\mathbf{NYEST}}=4+\sqrt{m/2}$ is sufficient. See also
Section 8.3.
Constraint:
${\mathbf{NXEST}}\ge 8$ and ${\mathbf{NYEST}}\ge 8$.
 10: NX – INTEGERInput/Output
On entry: if the warm start option is used, the value of
NX must be left unchanged from the previous call.
On exit: the total number of knots, ${n}_{x}$, of the computed spline with respect to the $x$ variable.
 11: LAMDA(NXEST) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if the warm start option is used, the values ${\mathbf{LAMDA}}\left(1\right),{\mathbf{LAMDA}}\left(2\right),\dots ,{\mathbf{LAMDA}}\left({\mathbf{NX}}\right)$ must be left unchanged from the previous call.
On exit: contains the complete set of knots
${\lambda}_{i}$ associated with the
$x$ variable, i.e., the interior knots
${\mathbf{LAMDA}}\left(5\right),{\mathbf{LAMDA}}\left(6\right),\dots ,{\mathbf{LAMDA}}\left({\mathbf{NX}}4\right)$ as well as the additional knots
and
needed for the Bspline representation (where
${x}_{\mathrm{min}}$ and
${x}_{\mathrm{max}}$ are as described in
Section 3).
 12: NY – INTEGERInput/Output
On entry: if the warm start option is used, the value of
NY must be left unchanged from the previous call.
On exit: the total number of knots, ${n}_{y}$, of the computed spline with respect to the $y$ variable.
 13: MU(NYEST) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if the warm start option is used, the values ${\mathbf{MU}}\left(1\right),{\mathbf{MU}}\left(2\right),\dots ,{\mathbf{MU}}\left({\mathbf{NY}}\right)$ must be left unchanged from the previous call.
On exit: contains the complete set of knots
${\mu}_{i}$ associated with the
$y$ variable, i.e., the interior knots
${\mathbf{MU}}\left(5\right),{\mathbf{MU}}\left(6\right),\dots ,{\mathbf{MU}}\left({\mathbf{NY}}4\right)$ as well as the additional knots
and
needed for the Bspline representation (where
${y}_{\mathrm{min}}$ and
${y}_{\mathrm{max}}$ are as described in
Section 3).
 14: C($\left({\mathbf{NXEST}}4\right)\times \left({\mathbf{NYEST}}4\right)$) – REAL (KIND=nag_wp) arrayOutput
On exit: the coefficients of the spline approximation.
${\mathbf{C}}\left(\left({n}_{y}4\right)\times \left(i1\right)+j\right)$ is the coefficient
${c}_{ij}$ defined in
Section 3.
 15: FP – REAL (KIND=nag_wp)Output
On exit: the weighted sum of squared residuals,
$\theta $, of the computed spline approximation.
FP should equal
S within a relative tolerance of
$0.001$ unless
${\mathbf{NX}}={\mathbf{NY}}=8$, when the spline has no interior knots and so is simply a bicubic polynomial. For knots to be inserted,
S must be set to a value below the value of
FP produced in this case.
 16: RANK – INTEGEROutput
On exit: gives the rank of the system of equations used to compute the final spline (as determined by a suitable machinedependent threshold). When
${\mathbf{RANK}}=\left({\mathbf{NX}}4\right)\times \left({\mathbf{NY}}4\right)$, the solution is unique; otherwise the system is rankdeficient and the minimumnorm solution is computed. The latter case may be caused by too small a value of
S.
 17: WRK(LWRK) – REAL (KIND=nag_wp) arrayCommunication Array
If the warm start option is used, on entry, the value of ${\mathbf{WRK}}\left(1\right)$ must be left unchanged from the previous call.
This array is used as workspace.
 18: LWRK – INTEGERInput
On entry: the dimension of the array
WRK as declared in the (sub)program from which E02DDF is called.
Constraint:
${\mathbf{LWRK}}\ge \left(7\times \mathit{u}\times \mathit{v}+25\times \mathit{w}\right)\times \left(\mathit{w}+1\right)+2\times \left(\mathit{u}+\mathit{v}+4\times {\mathbf{M}}\right)+23\times \mathit{w}+56$,
where
$\mathit{u}={\mathbf{NXEST}}4$,
$\mathit{v}={\mathbf{NYEST}}4$ and
$\mathit{w}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\mathit{u},\mathit{v}\right)$..
For some problems, the routine may need to compute the minimal least squares solution of a rankdeficient system of linear equations (see
Section 3). The amount of workspace required to solve such problems will be larger than specified by the value given above, which must be increased by an amount,
lwrk2 say. An upper bound for
lwrk2 is given by
$4\times \mathit{u}\times \mathit{v}\times \mathit{w}+2\times \mathit{u}\times \mathit{v}+4\times \mathit{w}$, where
$\mathit{u}$,
$\mathit{v}$ and
$\mathit{w}$ are as above. However, if there are enough data points, scattered uniformly over the approximation domain, and if the smoothing factor
S is not too small, there is a good chance that this extra workspace is not needed. A lot of memory might therefore be saved by assuming that no additional workspace is required (
$\mathit{lwrk2}=0$).
 19: IWRK(LIWRK) – INTEGER arrayWorkspace
 20: LIWRK – INTEGERInput
On entry: the dimension of the array
IWRK as declared in the (sub)program from which E02DDF is called.
Constraint:
${\mathbf{LIWRK}}\ge {\mathbf{M}}+2\times \left({\mathbf{NXEST}}7\right)\times \left({\mathbf{NYEST}}7\right)$.
 21: IFAIL – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit:
${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{1}}}$, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
 ${\mathbf{IFAIL}}=1$
On entry,  ${\mathbf{START}}\ne \text{'C'}$ or $\text{'W'}$, 
or  the number of data points with nonzero weight $\text{}<16$, 
or  ${\mathbf{S}}\le 0.0$, 
or  ${\mathbf{NXEST}}<8$, 
or  ${\mathbf{NYEST}}<8$, 
or  ${\mathbf{LWRK}}<\left(7\times \mathit{u}\times \mathit{v}+25\times \mathit{w}\right)\times \left(\mathit{w}+1\right)+2\times \left(\mathit{u}+\mathit{v}+4\times {\mathbf{M}}\right)+23\times \mathit{w}+56$, where $\mathit{u}={\mathbf{NXEST}}4$, $\mathit{v}={\mathbf{NYEST}}4$ and $\mathit{w}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\mathit{u},\mathit{v}\right)$, 
or  ${\mathbf{LIWRK}}<{\mathbf{M}}+2\times \left({\mathbf{NXEST}}7\right)\times \left({\mathbf{NYEST}}7\right)$. 
 ${\mathbf{IFAIL}}=2$
On entry, either all the ${\mathbf{X}}\left(\mathit{r}\right)$, for $\mathit{r}=1,2,\dots ,{\mathbf{M}}$, are equal, or all the ${\mathbf{Y}}\left(\mathit{r}\right)$, for $\mathit{r}=1,2,\dots ,{\mathbf{M}}$, are equal.
 ${\mathbf{IFAIL}}=3$
The number of knots required is greater than allowed by
NXEST and
NYEST. Try increasing
NXEST and/or
NYEST and, if necessary, supplying larger arrays for the parameters
LAMDA,
MU,
C,
WRK and
IWRK. However, if
NXEST and
NYEST are already large, say
NXEST,
${\mathbf{NYEST}}>4+\sqrt{{\mathbf{M}}/2}$, then this error exit may indicate that
S is too small.
 ${\mathbf{IFAIL}}=4$
No more knots can be added because the number of Bspline coefficients
$\left({\mathbf{NX}}4\right)\times \left({\mathbf{NY}}4\right)$ already exceeds the number of data points
M. This error exit may occur if either of
S or
M is too small.
 ${\mathbf{IFAIL}}=5$
No more knots can be added because the additional knot would (quasi) coincide with an old one. This error exit may occur if too large a weight has been given to an inaccurate data point, or if
S is too small.
 ${\mathbf{IFAIL}}=6$

The iterative process used to compute the coefficients of the approximating spline has failed to converge. This error exit may occur if
S has been set very small. If the error persists with increased
S, contact
NAG.
 ${\mathbf{IFAIL}}=7$
LWRK is too small; the routine needs to compute the minimal least squares solution of a rankdeficient system of linear equations, but there is not enough workspace. There is no approximation returned but, having saved the information contained in
NX,
LAMDA,
NY,
MU and
WRK, and having adjusted the value of
LWRK and the dimension of array
WRK accordingly, you can continue at the point the program was left by calling E02DDF with
${\mathbf{START}}=\text{'W'}$. Note that the requested value for
LWRK is only large enough for the current phase of the algorithm. If the routine is restarted with
LWRK set to the minimum value requested, a larger request may be made at a later stage of the computation. See
Section 5 for the upper bound on
LWRK. On soft failure, the minimum requested value for
LWRK is returned in
${\mathbf{IWRK}}\left(1\right)$ and the safe value for
LWRK is returned in
${\mathbf{IWRK}}\left(2\right)$.
If
${\mathbf{IFAIL}}={\mathbf{3}}$,
${\mathbf{4}}$,
${\mathbf{5}}$ or
${\mathbf{6}}$, a spline approximation is returned, but it fails to satisfy the fitting criterion (see
(2) and
(3) in
Section 3 – perhaps only by a small amount, however.
7 Accuracy
On successful exit, the approximation returned is such that its weighted sum of squared residuals
FP is equal to the smoothing factor
${\mathbf{S}}$, up to a specified relative tolerance of
$0.001$ – except that if
${n}_{x}=8$ and
${n}_{y}=8$,
FP may be significantly less than
${\mathbf{S}}$: in this case the computed spline is simply the least squares bicubic polynomial approximation of degree
$3$, i.e., a spline with no interior knots.
The time taken for a call of E02DDF depends on the complexity of the shape of the data, the value of the smoothing factor ${\mathbf{S}}$, and the number of data points. If E02DDF is to be called for different values of ${\mathbf{S}}$, much time can be saved by setting ${\mathbf{START}}=\text{'W'}$ after the first call.
It should be noted that choosing ${\mathbf{S}}$ very small considerably increases computation time.
If the weights have been correctly chosen (see
Section 2.1.2 in the E02 Chapter Introduction), the standard deviation of
${\mathit{w}}_{r}{f}_{r}$ would be the same for all
$r$, equal to
$\sigma $, say. In this case, choosing the smoothing factor
${\mathbf{S}}$ in the range
${\sigma}^{2}\left(m\pm \sqrt{2m}\right)$, as suggested by
Reinsch (1967), is likely to give a good start in the search for a satisfactory value. Otherwise, experimenting with different values of
${\mathbf{S}}$ will be required from the start.
In that case, in view of computation time and memory requirements, it is recommended to start with a very large value for
${\mathbf{S}}$ and so determine the least squares bicubic polynomial; the value returned for
FP, call it
${{\mathbf{FP}}}_{0}$, gives an upper bound for
${\mathbf{S}}$. Then progressively decrease the value of
${\mathbf{S}}$ to obtain closer fits – say by a factor of
$10$ in the beginning, i.e.,
${\mathbf{S}}={{\mathbf{FP}}}_{0}/10$,
${\mathbf{S}}={{\mathbf{FP}}}_{0}/100$, and so on, and more carefully as the approximation shows more details.
To choose
${\mathbf{S}}$ very small is strongly discouraged. This considerably increases computation time and memory requirements. It may also cause rankdeficiency (as indicated by the parameter
RANK) and endanger numerical stability.
The number of knots of the spline returned, and their location, generally depend on the value of ${\mathbf{S}}$ and on the behaviour of the function underlying the data. However, if E02DDF is called with ${\mathbf{START}}=\text{'W'}$, the knots returned may also depend on the smoothing factors of the previous calls. Therefore if, after a number of trials with different values of ${\mathbf{S}}$ and ${\mathbf{START}}=\text{'W'}$, a fit can finally be accepted as satisfactory, it may be worthwhile to call E02DDF once more with the selected value for ${\mathbf{S}}$ but now using ${\mathbf{START}}=\text{'C'}$. Often, E02DDF then returns an approximation with the same quality of fit but with fewer knots, which is therefore better if data reduction is also important.
The number of knots may also depend on the upper bounds
NXEST and
NYEST. Indeed, if at a certain stage in E02DDF the number of knots in one direction (say
${n}_{x}$) has reached the value of its upper bound (
NXEST), then from that moment on all subsequent knots are added in the other
$\left(y\right)$ direction. This may indicate that the value of
NXEST is too small. On the other hand, it gives you the option of limiting the number of knots the routine locates in any direction. For example, by setting
${\mathbf{NXEST}}=8$ (the lowest allowable value for
NXEST), you can indicate that you want an approximation which is a simple cubic polynomial in the variable
$x$.
The fit obtained is not defined outside the rectangle $\left[{\lambda}_{4},{\lambda}_{{n}_{x}3}\right]\times \left[{\mu}_{4},{\mu}_{{n}_{y}3}\right]$. The reason for taking the extreme data values of $x$ and $y$ for these four knots is that, as is usual in data fitting, the fit cannot be expected to give satisfactory values outside the data region. If, nevertheless, you require values over a larger rectangle, this can be achieved by augmenting the data with two artificial data points $\left(a,c,0\right)$ and $\left(b,d,0\right)$ with zero weight, where $\left[a,b\right]\times \left[c,d\right]$ denotes the enlarged rectangle.
First suitable knot sets are built up in stages (starting with no interior knots in the case of a cold start but with the knot set found in a previous call if a warm start is chosen). At each stage, a bicubic spline is fitted to the data by least squares and
$\theta $, the sum of squares of residuals, is computed. If
$\theta >{\mathbf{S}}$, a new knot is added to one knot set or the other so as to reduce
$\theta $ at the next stage. The new knot is located in an interval where the fit is particularly poor. Sooner or later, we find that
$\theta \le {\mathbf{S}}$ and at that point the knot sets are accepted. The routine then goes on to compute a spline which has these knot sets and which satisfies the full fitting criterion specified by
(2) and
(3). The theoretical solution has
$\theta ={\mathbf{S}}$. The routine computes the spline by an iterative scheme which is ended when
$\theta ={\mathbf{S}}$ within a relative tolerance of
$0.001$. The main part of each iteration consists of a linear least squares computation of special form, done in a similarly stable and efficient manner as in
E02DAF. As there also, the minimal least squares solution is computed wherever the linear system is found to be rankdeficient.
An exception occurs when the routine finds at the start that, even with no interior knots ($\mathrm{N}=8$), the least squares spline already has its sum of squares of residuals $\text{}\le {\mathbf{S}}$. In this case, since this spline (which is simply a bicubic polynomial) also has an optimal value for the smoothness measure $\eta $, namely zero, it is returned at once as the (trivial) solution. It will usually mean that ${\mathbf{S}}$ has been chosen too large.
For further details of the algorithm and its use see
Dierckx (1981b).
The values of the computed spline at the points
$\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for
$\mathit{r}=1,2,\dots ,n$, may be obtained in the real array
FF (see
E02DEF), of length at least
$n$, by the following call:
IFAIL = 0
CALL E02DEF(N,NX,NY,X,Y,LAMDA,MU,C,FF,WRK,IWRK,IFAIL)
where
$\mathtt{N}=n$ and the coordinates
${x}_{r}$,
${y}_{r}$ are stored in
$\mathtt{X}\left(k\right)$,
$\mathtt{Y}\left(k\right)$.
PX and
PY have the same values as
NX and
NY as output from E02DDF, and
LAMDA,
MU and
C have the same values as
LAMDA,
MU and
C output from E02DDF.
WRK is a real workspace array of length at least
$\mathtt{PY}4$, and
IWRK is an integer workspace array of length at least
$\mathtt{PY}4$.
To evaluate the computed spline on a
${k}_{x}$ by
${k}_{y}$ rectangular grid of points in the
$x$
$y$ plane, which is defined by the
$x$ coordinates stored in
$\mathtt{X}\left(\mathit{q}\right)$, for
$\mathit{q}=1,2,\dots ,{k}_{x}$, and the
$y$ coordinates stored in
$\mathtt{Y}\left(\mathit{r}\right)$, for
$\mathit{r}=1,2,\dots ,{k}_{y}$, returning the results in the real array
FF (see
E02DFF) which is of length at least
${\mathbf{MX}}\times {\mathbf{MY}}$, the following call may be used:
IFAIL = 0
CALL E02DFF(KX,KY,NX,NY,TX,TY,LAMDA,MU,C,FG,WRK,LWRK,
* IWRK,LIWRK,IFAIL)
where
$\mathtt{KX}={k}_{x}$,
$\mathtt{KY}={k}_{y}$.
NX,
NY,
LAMDA,
MU and
C have the same values as
NX,
NY,
LAMDA,
MU and
C output from E02DDF.
WRK is a real workspace array of length at least
$\mathtt{LWRK}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(\mathit{nwrk1},\mathit{nwrk2}\right)$, where
$\mathit{nwrk1}=\mathtt{KX}\times 4+\mathtt{PX}$ and
$\mathit{nwrk2}=\mathtt{KY}\times 4+\mathtt{PY}$.
IWRK is an integer workspace array of length at least
$\mathtt{LIWRK}=\mathtt{KY}+\mathtt{PY}4$ if
$\mathit{nwrk1}\ge \mathit{nwrk2}$, or
$\mathtt{KX}+\mathtt{PX}4$ otherwise.
The result of the spline evaluated at grid point $\left(q,r\right)$ is returned in element $\left(\mathtt{KY}\times \left(q1\right)+r\right)$ of the array FG.
9 Example
This example reads in a value of
M, followed by a set of
M data points
$\left({x}_{r},{y}_{r},{f}_{r}\right)$ and their weights
${\mathit{w}}_{r}$. It then calls E02DDF to compute a bicubic spline approximation for one specified value of
S, and prints the values of the computed knots and Bspline coefficients. Finally it evaluates the spline at a small sample of points on a rectangular grid.
9.1 Program Text
Program Text (e02ddfe.f90)
9.2 Program Data
Program Data (e02ddfe.d)
9.3 Program Results
Program Results (e02ddfe.r)