NAG Library Routine Document
E02JDF
Note: this routine uses optional parameters to define choices in the problem specification and in the details of the algorithm. If you wish to use default
settings for all of the optional parameters, you need only read Sections 1 to 10 of this document. If, however, you wish to reset some or all of the settings please refer to Section 11 for a detailed description of the specification of the optional parameters produced by the routine.
1 Purpose
E02JDF computes a spline approximation to a set of scattered data using a two-stage approximation method.
The computational complexity of the method grows linearly with the number of data points; hence large datasets are easily accommodated.
2 Specification
SUBROUTINE E02JDF ( |
N, X, Y, F, LSMINP, LSMAXP, NXCELS, NYCELS, LCOEFS, COEFS, IOPTS, OPTS, IFAIL) |
INTEGER |
N, LSMINP, LSMAXP, NXCELS, NYCELS, LCOEFS, IOPTS(*), IFAIL |
REAL (KIND=nag_wp) |
X(N), Y(N), F(N), COEFS(LCOEFS), OPTS(*) |
|
Before calling E02JDF,
E02ZKF must be called with
OPTSTR set to
"Initialize = E02JDF". Settings for optional algorithmic parameters may be specified by calling
E02ZKF before a call to E02JDF.
3 Description
E02JDF determines a smooth bivariate spline approximation to a set of
data points
, for
.
Here, ‘smooth’ means
or
. (You may select the degree of smoothing using the optional parameter
Global Smoothing Level.)
The approximation domain is the bounding box , where (respectively ) and (respectively ) denote the lowest and highest data values of the (respectively ).
The spline is computed by local approximations on a uniform triangulation of the bounding box. These approximations are extended to a smooth spline representation of the surface over the domain. The local approximation scheme is controlled by the optional parameter
Local Method. The schemes provided are: by least squares polynomial approximation (
Davydov and Zeilfelder (2004)); by hybrid polynomial and radial basis function (RBF) approximation (
Davydov et al. (2006)); or by pure RBF approximation (
Davydov et al. (2005)).
The two-stage approximation method employed by E02JDF is derived from
the TSFIT package of O. Davydov and F. Zeilfelder.
Values of the computed spline can subsequently be computed by calling
E02JEF or
E02JFF.
4 References
Davydov O, Morandi R and Sestini A (2006) Local hybrid approximation for scattered data fitting with bivariate splines Comput. Aided Geom. Design 23 703–721
Davydov O, Sestini A and Morandi R (2005) Local RBF approximation for scattered data fitting with bivariate splines Trends and Applications in Constructive Approximation M. G. de Bruin, D. H. Mache, and J. Szabados, Eds ISNM Vol. 151 Birkhauser 91–102
Davydov O and Zeilfelder F (2004) Scattered data fitting by direct extension of local polynomials to bivariate splines Advances in Comp. Math. 21 223–271
5 Parameters
- 1: – INTEGERInput
-
On entry: , the number of data values to be fitted.
Constraint:
.
- 2: – REAL (KIND=nag_wp) arrayInput
- 3: – REAL (KIND=nag_wp) arrayInput
- 4: – REAL (KIND=nag_wp) arrayInput
-
On entry: the data values to be fitted.
Constraint:
for some and for some ; i.e., there are at least two distinct and values.
- 5: – INTEGERInput
- 6: – INTEGERInput
-
On entry: are control parameters for the local approximations.
Each local approximation is computed on a local domain containing one of the
triangles in the discretization of the bounding box. The size of each local domain will be adaptively chosen such that if it contains fewer than
LSMINP sample points it is expanded, else if it contains greater than
LSMAXP sample points a thinning method is applied.
LSMAXP mainly controls computational cost (in that working with a thinned set of points is cheaper and may be appropriate if the input data is densely distributed), while
LSMINP allows handling of different types of scattered data.
Setting , and therefore forcing either expansion or thinning, may be useful for computing initial coarse approximations. In general smaller values for these arguments reduces cost.
A calibration procedure (experimenting with a small subset of the data to be fitted and validating the results) may be needed to choose the most appropriate values for
LSMINP and
LSMAXP.
- 7: – INTEGERInput
- 8: – INTEGERInput
-
On entry:
NXCELS (respectively
NYCELS) is the number of cells in the
(respectively
) direction that will be used to create the triangulation of the bounding box of the domain of the function to be fitted.
Greater efficiency generally comes when
NXCELS and
NYCELS are chosen to be of the same order of magnitude and are such that
N is
. Thus for a ‘square’ triangulation — when
— the quantities
and
NXCELS should be of the same order of magnitude. See also
Section 9.
- 9: – INTEGERInput
- 10: – REAL (KIND=nag_wp) arrayOutput
-
On exit: if
on exit,
COEFS contains the computed spline coefficients.
Constraints:
- if , ;
- if , .
- 11: – INTEGER arrayCommunication Array
-
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
IOPTS in the previous call to
E02ZKF.
On entry: the contents of
IOPTS must not be modified in any way either directly or indirectly, by further calls to
E02ZKF, before calling either or both of the evaluation routines
E02JEF and
E02JFF.
- 12: – REAL (KIND=nag_wp) arrayCommunication Array
-
Note: the dimension of this array is dictated by the requirements of associated functions that must have been previously called. This array
must be the same array passed as argument
OPTS in the previous call to
E02ZKF.
On entry: the contents of
OPTS must not be modified in any way either directly or indirectly, by further calls to
E02ZKF, before calling either or both of the evaluation routines
E02JEF and
E02JFF.
- 13: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint:
if ,
;
if ,
.
-
Option arrays are not initialized or are corrupted.
-
An unexpected algorithmic failure was encountered. Please contact
NAG.
-
On entry, all elements of
X or of
Y are equal.
-
The selected radial basis function cannot be used with the RBF local method.
-
The value of optional parameter
Polynomial Starting Degree was invalid.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
Local approximation by polynomials of degree
for
data points has optimal
approximation order
.
The improved approximation power of hybrid polynomial/RBF and of pure RBF approximations is shown in
Davydov et al. (2006) and
Davydov et al. (2005).
The approximation error for global smoothing is .
For smoothing the error is when and when .
Whether maximal accuracy is achieved depends on the distribution of the input data and the choices of the algorithmic parameters. The references above contain extensive numerical tests and further technical discussions of how best to configure the method.
8 Parallelism and Performance
E02JDF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
E02JDF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
-linear complexity and memory usage can be attained for sufficiently dense input data if the triangulation parameters
NXCELS and
NYCELS are chosen as recommended in their descriptions above. For sparse input data on such triangulations, if many expansion steps are required (see
LSMINP) the complexity may rise to be loglinear.
Parts of the pure RBF method used when have -quadratic memory usage.
Note that if
and an initial hybrid approximation is deemed unreliable (see the description of optional parameter
Minimum Singular Value LHA), a pure polynomial approximation will be used instead on that local domain.
10 Example
The Franke function
is widely used for testing surface-fitting methods. The example program randomly generates a number of points on this surface. From these a spline is computed and then evaluated at a vector of points and on a mesh.
10.1 Program Text
Program Text (e02jdfe.f90)
10.2 Program Data
Program Data (e02jdfe.d)
10.3 Program Results
Program Results (e02jdfe.r)
11 Optional Parameters
Several optional parameters in E02JDF control aspects of the algorithm, methodology used, logic or output. Their values are contained in the arrays
IOPTS and
OPTS; these must be initialized before calling E02JDF by first calling
E02ZKF with
OPTSTR set to
"Initialize = E02JDF".
Each optional parameter has an associated default value; to set any of them to a non-default value, or to reset any of them to the default value, use
E02ZKF. The current value of an optional parameter can be queried using
E02ZLF.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in
Section 11.1.
11.1 Description of the Optional Parameters
For each option, we give a summary line, a description of the optional parameter and details of constraints.
The summary line contains:
- the keywords;
- a parameter value,
where the letters , and denote options that take character, integer and real values respectively;
- the default value.
Keywords and character values are case insensitive.
For E02JDF the maximum length of the parameter
CVALUE used by
E02ZLF is
.
Averaged Spline | | Default |
When the bounding box is triangulated there are 8 equivalent configurations of the mesh. Setting will use the averaged value of the possible local polynomial approximations over each triangle in the mesh. This usually gives better results but at (about 8 times) higher computational cost.
Constraint: or .
Global Smoothing Level | | Default |
The smoothness level for the global spline approximation.
- Will use piecewise cubics.
- Will use piecewise sextics.
Constraint:
or .
Interpolation Only RBF | | Default |
If , each local RBF approximation is computed by interpolation.
If , each local RBF approximation is computed by a discrete least squares approach. This is likely to be more accurate and more expensive than interpolation.
If or , this option setting is ignored.
Constraint:
or .
Local Method | | Default |
The local approximation scheme to use.
- Uses least squares polynomial approximations.
- Uses hybrid polynomial and RBF approximations.
- Uses pure RBF approximations.
In general is less computationally expensive than is less computationally expensive than with the reverse ordering holding for accuracy of results.
Constraint:
, or .
Minimum Singular Value LHA | | Default |
A tolerance measure for accepting or rejecting a local hybrid approximation (LHA) as reliable.
The solution of a local least squares problem solved on each triangle subdomain is accepted as reliable if the minimum singular value of the collocation matrix (of polynomial and radial basis function terms) associated with the least squares problem satisfies .
In general the approximation power will be reduced as
Minimum Singular Value LHA is reduced. (A small
indicates that the local data has hidden redundancies which prevent it from carrying enough information for a good approximation to be made.) Setting
Minimum Singular Value LHA very large may have the detrimental effect that only approximations of low degree are deemed reliable.
A calibration procedure (experimenting with a small subset of the data to be fitted and validating the results) may be needed to choose the most appropriate value for this parameter.
If or , this option setting is ignored.
Constraint:
.
Minimum Singular Value LPA | | Default |
A tolerance measure for accepting or rejecting a local polynomial approximation (LPA) as reliable. Clearly this setting is relevant when
, but it also may be used when
(see
Section 9.)
The solution of a local least squares problem solved on each triangle subdomain is accepted as reliable if the minimum singular value of the matrix (of Bernstein polynomial values) associated with the least squares problem satisfies .
In general the approximation power will be reduced as
Minimum Singular Value LPA is reduced. (A small
indicates that the local data has hidden redundancies which prevent it from carrying enough information for a good approximation to be made.) Setting
Minimum Singular Value LPA very large may have the detrimental effect that only approximations of low degree are deemed reliable.
Minimum Singular Value LPA will have no effect if
, and it will have little effect if the input data is ‘smooth’ (e.g., from a known function).
A calibration procedure (experimenting with a small subset of the data to be fitted and validating the results) may be needed to choose the most appropriate value for this parameter.
If , this option setting is ignored.
Constraint:
.
Polynomial Starting Degree | |
Default if , Default otherwise
|
The degree to be used for the polynomial part in the initial step of each local approximation.
At this initial step the method will attempt to fit with a local approximation having polynomial part of degree
Polynomial Starting Degree. If
and the approximation is deemed unreliable (according to
Minimum Singular Value LPA), the degree will be decremented by one and a new local approximation computed, ending with a constant approximation if no other is reliable. If
and the approximation is deemed unreliable (according to
Minimum Singular Value LHA), a pure polynomial approximation of this degree will be tried instead. The method then proceeds as in the
case.
Polynomial Starting Degree is bounded from above by the maximum possible spline degree, which is
(when performing
global super-smoothing). Note that the best-case approximation error (see
Section 7) for
smoothing with
is achieved for local polynomials of degree
; that is, for this level of global smoothing no further benefit is gained by setting
.
The default value gives a good compromise between efficiency and accuracy. In general the best approximation can be obtained by setting:
- If
- if , ;
- if ;
- if , ;
- otherwise .
- If , Polynomial Starting Degree as small as possible.
If , this option setting is ignored.
Constraints:
- if ,
- if , , or , ;
- if or , ;
- if or , ;
- if , ;
- otherwise ;
- if and , ;
- otherwise .
Radial Basis Function | | Default |
Scaling Coefficient RBF | | Default |
Radial Basis Function selects the RBF to use in each local RBF approximation, while
Scaling Coefficient RBF selects the scale factor to use in its evaluation, as described below.
A calibration procedure (experimenting with a small subset of the data to be fitted and validating the results) may be needed to choose the most appropriate scale factor and RBF.
If , these option settings are ignored.
If or , the following (conditionally) positive definite functions may be chosen.
Define and .
| Gaussian |
| inverse multiquadric |
| inverse multiquadric |
| inverse multiquadric |
| inverse multiquadric |
| H. Wendland's function |
| H. Wendland's function |
| H. Wendland's function |
| M. Buhmann's function if , otherwise |
| multiquadric |
| multiquadric |
| polyharmonic spline |
| polyharmonic spline |
If
the following conditionally positive definite functions may also be chosen.
| multiquadric |
| multiquadric |
| thin plate spline |
| polyharmonic spline |
| thin plate spline |
| polyharmonic spline |
| thin plate spline |
| polyharmonic spline |
| polyharmonic spline |
Constraints:
- if , , or , and ;
- if or , and ;
- if or , and ;
- if , and ;
- .
Separation LRBFA | | Default |
A knot-separation parameter used to control the condition number of the matrix used in each local RBF approximation (LRBFA). A smaller value may mean greater numerical stability but fewer knots.
If or , this option setting is ignored.
Constraint:
.
Supersmooth C2 | | Default |
If , the spline is generated using additional smoothness constraints. This usually gives better results but at higher computational cost.
If this option setting is ignored.
Constraint:
or .