Next: E211 Cubic Splines
Up: CERNLIB
Previous: E208 Least Squares
Routine ID: E210
| Author(s): W. Mönch, B. Schorr | Library: MATHLIB
|
Submitter: W. Mönch | Submitted: 15.03.1993
|
Language: Fortran | Revised:
|
NORBAS ( NORmalized BAsis Splines) is a portable
collection of subprograms for various calculations with polynomial
splines in one dimension ( 1D) and in two dimensions ( 2D).
The polynomial splines are represented as linear combinations of
normalized basis splines (B-splines).
On computers other than CDC or Cray, only the double-precision versions
DSPKN1, etc. are available. On CDC and Cray computers, only the
single-precision versions RSPKN1, etc. are available.
The following outline provides the background material and the
notations needed for describing the subprograms
and their parameters. For further information about splines and their
applications see References, in particular Ref. 7.
Case (1D):
- k
- Degree (order -1) of the B-spline
.
- m
- Number of spline-knots
.
- i
- Index of the B-spline
.
-
- Set of m spline-knots
,
in non-decreasing order, with multiplicity
(i.e. no more than k+1 knots coincide).
-
- Interval, defined by
,
.
-
- Normalized B-spline of degree k over
with
index i. The value of
is identically zero outside the
interval
, and the normalization of
is such that
-
- Polynomial spline at
in B-spline
representation
Spline interpolation to a data set:
Given a data set
; determine
coefficients
of a polynomial interpolation
spline
in B-spline representation with degree k over a set
of m=n+k+1 knots, such that the following relations
(interpolation conditions) hold:
The existence of a solution of this interpolation problem
depends on an appropriate choice of the spline-knots (Ref. 7,
Theorem XIII.1 (Schoenberg-Whitney)).
Least squares spline approximation to a data set:
Given a data set
; determine
coefficients
of a polynomial approximation
spline
in B-spline representation with degree k over a set
of
knots, such that following least squares
problem is solved:
Variation diminishing spline approximation to a function
(Schoenberg):
For a given function
on
this spline approximation is
defined by
, with
(Ref. 7, p. 158-162)
Case (2D):
- kx
- Degree of one-dimensional B-splines in x-direction
.
- ky
- Degree of one-dimensional B-splines in y-direction
.
- mx
- Number of spline-knots in x-direction
.
- my
- Number of spline-knots in y-direction
.
- i
- Index of B-spline
in
x-direction.
- j
- Index of B-spline
in
y-direction.
-
- Set of mx spline-knots
in x-direction,
in non-decreasing order, with multiplicity
(i.e. no more than kx+1 knots coincide).
-
- Set of my spline-knots
in y-direction,
in non-decreasing order, with multiplicity
(i.e. no more than ky+1 knots coincide).
-
- Interval in x-direction,
defined by
,
.
-
- Interval in y-direction,
defined by
,
.
-
- B-spline of degree kx over
with index i.
-
- B-spline of degree ky over
with index j.
-
- Product
of
two one-dimensional B-splines.
-
- Two-dimensional polynomial spline at
in B-spline representation
Spline interpolation to a data set:
Given a data set
; determine coefficients
of a
two-dimensional polynomial interpolation spline
in B-spline
representation with degrees kx , ky over the sets
of mx=nx+kx+1 knots in x-direction and
of my=ny+ky+1
knots in y-direction, such that following relations
(interpolation conditions) hold:
The existence of a solution of this interpolation problem depends
on an appropriate choice of the spline-knots
,
in the
two-dimensional interpolation area
.
Least squares spline approximation to a data set:
Given a data set
; determine coefficients
of a
two-dimensional polynomial approximation spline
in B-spline
representation with degrees kx, ky over the sets
of
knots in x-direction and
of
knots in y-direction, such that following
least squares problem is solved:
Variation diminishing spline approximation to a function:
For a given function
on
this
two-dimensional spline approximation is defined by
on
, with
|
|
|
|
|
|
|
|
|
The package NORBAS contains FUNCTION and SUBROUTINE
subprograms for solving the following problems.
To calculate:
- (K)
-
A set
of m spline-knots
in the interval
for normalized B-splines
of
degree k, use subprogram tSPKN1 ( 1D).
The knots are in non-decreasing order and determined in such a way that
the first k+1 knots coincide with a, the last k+1 knots coincide
with b, and the remaining
knots are equidistant
in
.
Two sets
,
of spline-knots
in
and
for B-splines
of degrees kx and ky in x- and y-direction, use subprogram
tSPKN2 ( 2D).
and
, are calculated by the same formulae
in x-, and y-direction, as in case ( 1D).
- (B)
-
The function
,
the n-th derivative
,
or the integral
of a normalized B-spline
,
with fixed degree k and index i over a set
of
spline-knots, use subprogram: tSPNB1 ( 1D).
The function
,
the partial derivative
,
or the integral
of a two-dimensional B-spline
, with fixed
degrees kx, ky and indices i, j over the sets
,
of spline-knots, use subprogram tSPNB2 ( 2D).
- (P)
-
The function
,
the n-th derivative
,
or the integral
of a polynomial spline
in B-spline representation with
given coefficients
, use subprogram tSPPS1 ( 1D).
The function
,
the partial derivative
,
or the integral
of a two-dimensional polynomial spline
in B-spline representation with given coefficients
, use
subprogram tSPPS2 ( 2D).
- (I)
-
The coefficients
of a one-dimensional
polynomial interpolation spline
in B-spline
representation to a user-supplied data set
, use
subprogram tSPIN1 ( 1D).
The coefficients
of a two-dimensional
polynomial interpolation spline
in B-spline
representation to a user-supplied data set
, use subprogram
tSPIN2 ( 2D).
- (A)
-
The coefficients
of a one-dimensional
polynomial least squares approximation spline
in
B-spline representation to a user-supplied data set
,
use subprogram tSPAP1 ( 1D).
The coefficients
of a two-dimensional
polynomial least squares approximation spline
in
B-spline representation to a user-supplied data set
,
use subprogram tSPAP2 ( 2D).
- (V)
-
The coefficients
of a one-dimensional
polynomial variation diminishing spline approximation
in B-spline representation to a user-supplied function
,
use subprogram tSPVD1 ( 1D).
The coefficients
of a two-dimensional
polynomial variation diminishing spline approximation
in B-spline representation to a user-supplied function
, use subprogram tSPVD2 ( 2D).
- (D)
-
From given coefficients
of a
one-dimensional polynomial spline
in B-spline
representation, the corresponding coefficients
of its n-th
derivative
in B-spline representation,
use subprogram tSPCD1 ( 1D).
From given coefficients
of a
two-dimensional polynomial spline
in B-spline
representation, the corresponding coefficients
of its
partial derivative
in B-spline representation,
use subprogram tSPCD2 ( 2D).
Structure:
SUBROUTINE and FUNCTION subprograms
User Entry Names:
RSPKN1, | RSPKN2, | RSPNB1, | RSPNB2, | RSPPS1, | RSPPS2, | RSPIN1, | RSPIN2,
|
RSPAP1, | RSPAP2, | RSPVD1, | RSPVD2, | RSPCD1, | RSPCD2,
|
DSPKN1, | DSPKN2, | DSPNB1, | DSPNB2, | DSPPS1, | DSPPS2, | DSPIN1, | DSPIN2,
|
DSPAP1, | DSPAP2, | DSPVD1, | DSPVD2, | DSPCD1, | DSPCD2,
|
Internal Entry Names: RSPAS1, RSPAS2, RSPLKK,
DSPAS1 DSPAS2, DSPLKK
Files Referenced: Unit 6
External References:
RGBTRF, | RGBTRS, | RGESVD, | DGBTRF, | DGBTRS, | DGESVD | (F001)
|
RVSET, | RVSUM, | RVCPY, | RVMPY,
|
DVSET, | DVSUM, | DVCPY, | DVMPY | (F002)
|
RMCPY, | RMMPY, | DMCPY, | DVMPY | (F003)
|
8lMTLMTR(N002), ABEND(Z035);User supplied FUNCTIONsubprogram
|
Usage:
For
(type REAL),
(type DOUBLE PRECISION):
(K) Knots
CALL tSPKN1(K,M,A,B,T,NERR)
CALL tSPKN2(KX,KY,MX,MY,AX,BX,AY,BY,TX,TY,NERR)
(B) Normalized B-splines
tSPNB1(K,M,I,NDER,X,T,NERR)
tSPNB2(KX,KY,MX,MY,I,J,NDERX,NDERY,X,Y,TX,TY,NERR)
(P) Polynomial spline
tSPPS1(K,M,NDER,X,T,C,NERR)
tSPPS2(KX,KY,MX,MY,NDERX,NDERY,X,Y,TX,TY,C,NDIMC,W,NERR)
(I) Spline interpolation
CALL tSPIN1(K,N,XI,YI,KNOT,T,C,W,IW,NERR)
CALL tSPIN2(KX,KY,NX,NY,XI,YI,ZI,NDIMZ,KNOT,TX,TY,C,NDIMC,W,IW,NERR)
(A) Least squares spline approximation
CALL tSPAP1(K,M,N,XI,YI,KNOT,T,C,W,NW,NERR)
CALL tSPAP2(KX,KY,MX,MY,NX,NY,XI,YI,ZI,NDIMZ,KNOT,TX,TY,C,NDIMC,W,NW,NERR)
(V) Variation diminishing spline approximation
CALL tSPVD1(F,K,M,T,C,NERR)
CALL tSPVD2(F,KX,KY,MX,MY,TX,TY,C,NDIMC,NERR)
(D) Coefficients of derivatives
CALL tSPCD1(K,M,NDER,T,C,D,NERR)
CALL tSPCD2(KX,KY,MX,MY,NDERX,NDERY,TX,TY,C,NDIMC,D,NERR)
Case (1D):
- F
- Name of a user-upplied FUNCTION subprogram,
declared EXTERNAL in the calling program.
This subprogram must provide the value of the function
for variation diminishing spline approximation.
- K
- ( INTEGER) Degree of B-splines
(
for tSPVD1,
otherwise).
- M
- ( INTEGER) Number of knots (
).
- I
- ( INTEGER) Index of B-splines
(
).
- N
- ( INTEGER) Number of data points
(
for spline interpolation ( tSPIN1);
for spline approximation ( tSPAP1)).
- NDER
- ( INTEGER) Selects one out of
three cases: (i) integral, (ii) function value, or (iii) derivative.
(
for tSPNB1 and tSPPS1;
for tSPCD1).
-
-
Calculation of the integral of
( tSPNB1), or the integral of
( tSPPS1).
-
-
Calculation of the function value
( tSPNB1), or the function value
( tSPPS1).
-
-
Calculation of the NDER-th derivative of
( tSPNB1),
or the NDER-th derivative of
( tSPPS1).
- X
- (Type according to t) Independent variable x of
polynomial spline
or B-spline
.
- XI
- (Type according to t) One-dimensional array of length
. On entry,
must contain the l-th
data point
for spline interpolation ( tSPIN1) or spline
approximation ( tSPAP1). The data points must be in
ascending order.
- YI
- (Type according to t) One-dimensional array of length
. On entry,
must contain the l-th
data point
for spline interpolation ( tSPIN1) or spline
approximation ( tSPAP1).
- KNOT
- ( INTEGER) Controls the mode of supplying the knots
for spline interpolation or approximation.
-
-
The knots are computed by the subprograms tSPIN1 and tSPAP1.
At the left and right end-point of the interpolation (approximation)
interval
arise multiple knots.
The remaining knots are either equidistant (
) or are
computed by using the data points
of interpolation
(approximation) (
.
-
-
The knots must be supplied by the user.
- A,B
- (Type according to t) On entry, A and B
must contain the left (right) end-point of the interval
for
the calculation of a set of spline knots ( tSPKN1).
- T
- (Type according to t) One-dimensional array of length
.
For tSPKN1 and for tSPINT1, tSPAP1 if
On exit, T(J) contains the j-th knot.
In the other cases, on entry, T(J) must contain the j-th knot.
The knots must be in non-decreasing order with multiplicity
.
- C
- (Type according to t) One-dimensional
array of length
.
For tSPPS1 and tSPCD1: On entry, C(I) must contain
the i-th coefficient
of the polynomial spline
in B-spline
representation.
For tSPIN1, tSPAP1 and tSPVD1: On exit, C(I)
contains the i-th coefficient
of the polynomial interpolation
or approximation spline
in B-spline representation.
- D
- (Type according to t) One-dimensional
array of length
.
On exit, D(I) contains the coefficient
of the NDER-th
derivative of a polynomial spline
in B-spline representation.
- W
- (Type according to t) One-dimensional array of length
( tSPIN1), and of length
( tSPAP1); used as working space.
- NW
- ( INTEGER) Length of working array W,
(
).
- IW
- ( INTEGER) One-dimensional array
of length
, used as working space.
- NERR
- ( INTEGER) Error indicator. On exit:
-
-
No error or warning detected.
-
-
At least one of the parameters I, K, M, N,
NDER is not in range or
is not true.
-
-
The subprograms tGEQPF, tORMQR, tTRTRS in the Linear
Algebra package LAPACK (F001) were unable to solve the linear
system of equations for calculating the coefficients of the spline
interpolation to a given data set.
Case (2D):
- F
- Name of a user-upplied FUNCTION subprogram,
declared EXTERNAL in the calling program. This subprogram must
provide the value of the function
for
variation diminishing spline approximation.
- KX,KY
- ( INTEGER) Degree of one-dimensional B-splines in
x-(y-)direction (
for tSPVD2;
otherwise).
- MX,MY
- ( INTEGER) Number of knots in x-(y-)direction
(
.
- I,J
- ( INTEGER) Indices of B-splines
(
).
- NX,NY
- ( INTEGER) Number of data points
in x-(y-)direction (
for spline interpolation tSPIN2;
for spline approximation tSPAP2).
- NDERX,
- ( INTEGER) Selects one out of
three cases: (i) integral, (ii) function value, or (iii) derivative.
- NDERY
-
(
for tSPNB2 and tSPPS2;
,
for tSPCD2).
-
-
Calculation of the integral of
( tSPNB2), or the integral of
( tSPPS2).
-
-
Calculation of the function value
( tSPNB2), or the function value
( tSPPS2).
-
-
Calculation of the NDERX-th partial derivative
with respect to x and the NDERY-th partial derivative with
respect to y of
( tSPNB2),
or the calcultion of these derivatives of
( tSPPS2).
-
- Note that in the first two cases
, respectively.
- X,Y
- (Type according to t) Independent variables x,y of
polynomial spline
or B-spline
.
- XI,YI
- (Type according to t) One-dimensional arrays of
length
and
, respectively.
On entry,
and
must contain the
lx-th data point
and the ly-th data point
for spline interpolation ( tSPIN2) or spline approximation
( tSPAP2). The data points must be in ascending order.
- ZI
- (Type according to t) Two-dimensional array of dimension
. On entry,
must contain
the
-th data point
for spline interpolation
( tSPIN2) or spline approximation ( tSPAP2).
- NDIMZ
- ( INTEGER) Declared first dimension of a
two-dimensional array ZI in the calling program
(
).
- KNOT
- ( INTEGER) Controls the mode of supplying the knots
for spline interpolation or approximation.
-
-
The set of knots are computed by subprograms tSPIN2 and
tSPAP2.
At the left and right end-points of the interpolation (approximation)
intervals
arise multiple knots.
The remaining knots are either equidistant (
) or are
computed by using the data points
of
interpolation (approximation) (
).
-
-
The knots must be supplied by the user.
- AX,BX;
- (Type according to t) On entry, AX, BX;
AY, BY must contain the left (right)
end-points of the
- AY,BY
-
intervals
for the calculation of a set
of spline knots in x-(y-)direction, respectively, by tSPKN2.
- TX,TY
- (Type according to t) One-dimensional arrays of
length
and
, repectively.
For tSPKN2 and for tSPIN2, tSPAP2
if
On exit, TX(J) and TY(J) contain the
j-th knot in x-(y-)direction. In the other cases, on entry,
TX(J) and TY(J) must contain the j-th knot in
x-(y-)direction. The knots must be in non-decreasing order with
multiplicity
and
, respectively.
- C
- (Type according to t) Two-dimensional array of
dimension
.
For tSPPS2, tSPCD2: On entry, C(I,J) must contain
the
-th coefficient
of the polynomial spline
in B-spline representation.
For tSPIN2, tSPAP2, tSPVD2:
On exit, C(I,J) contains the
-th coefficient
of the polynomial interpolation or
approximation spline
in B-spline representation.
- NDIMC
- ( INTEGER) Declared first dimension of a
two-dimensional array C in the calling program
(
).
- D
- (Type according to t) Two-dimensional array of
dimension
.
On exit, D(I,J) contains the coefficient
of the
partial derivative of order
with respect to x and y
of a polynomial spline
in B-spline representation.
- W
- (Type according to t) One-dimensional array of length
( tSPPS2),
( tSPIN2),
and of length
( tSPAP2), used as
working space.
- NW
- ( INTEGER) Length of a one-dimensional array W,
used as working space
(
).
- IW
- ( INTEGER) One-dimensional array
of length
, used as working space.
- NERR
- ( INTEGER) Error indicator. On exit:
-
-
No error or warning detected.
-
-
At least one of the parameters I, J, KX, KY,
MX, MY, NX, NY, NDERX, NDERY
is not in range or at least one of the relations
,
is not true.
-
-
The routines tGEQPF, tORMQR, tTRTRS in the Linear
Algebra package LAPACK (F001) were unable to solve the linear
system of equations for calculation coefficients of spline interpolation
to a given data set.
Examples:
Calculate
-
The coefficients
of
a polynomial interpolation spline
of degree k=2 in B-spline
representation to a given data set
;
-
The corresponding coefficients
of the first derivative
;
-
The values of
and
for
.
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
DIMENSION XI(6),YI(6),T(9),C(6),D(6),W(42),IW(6)
DATA K,N,NDER,KNOT / 2,6,1,1 /
DATA XI / 0D0,0.20D0,0.40D0,0.60D0,0.80D0,1.00D0 /
DATA YI / 1D0,0.66D0,0.47D0,0.38D0,0.35D0,0.34D0 /
M=N+K+1
CALL DSPIN1(K,N,XI,YI,KNOT,T,C,W,IW,NERR)
CALL DSPCD1(K,M,NDER,T,C,D,NERR)
WRITE(6,1000) K,N,(T(I),I=1,M)
DO 20 J=0,10
X=J/1D1
SPL0=DSPPS1(K,M, 0,X,T,C,NERR)
SPL1=DSPPS1(K,M, 1,X,T,D,NERR)
SPLI=DSPPS1(K,M,-1,X,T,C,NERR)
20 WRITE(6,1010) J,X,SPL0,SPL1,SPLI
1000 FORMAT(...)
1010 FORMAT(...)
END
DEGREE OF POLYNOMIAL SPLINE: 2 NUMBER OF DATA POINTS: 6
KNOTS T : 0.00 0.00 0.00 0.25 0.50 0.75 1.00 1.00 1.00
J X S(X) DS(X) IN(X)
0 0.00 1.000000 -2.119921 0.000000
1 0.10 0.809004 -1.700000 0.090100
2 0.20 0.660000 -1.280079 0.163201
3 0.30 0.550992 -0.940017 0.223467
4 0.40 0.470000 -0.679816 0.274299
5 0.50 0.415028 -0.419615 0.318334
6 0.60 0.380000 -0.280953 0.357970
7 0.70 0.358838 -0.142290 0.394796
8 0.80 0.350000 -0.065306 0.430174
9 0.90 0.344235 -0.050000 0.464873
10 1.00 0.340000 -0.034694 0.499072
Error handling:
Error E210.1: K|KX,KYnot in range, | Error E210.5: NDER|NDERX,NDERYnot in range,
|
Error E210.2: M|MX,MYnot in range, | Error E210.6: A,B|AX,BX;AY,BYinconsistent,
|
Error E210.3: I|I,Jnot in range, | Error E210.7: NDERX|NDERYinconsistent.
|
Error E210.4: N|NX,NYnot in range,
|
In all cases, NERR is set
(see above). A message is
written on Unit 6, unless subroutine MTLSET (N002) has
been called.
References:
- J.H. Ahlberg, E.N. Nilson, J.L. Walsh, The Theory of Splines and
their Applications, Academic Press, New York, 1967.
- M.J. Marsden, An identity for spline functions with applications
to variation diminishing spline approximation,
J. Appr. Theory 3 (1970), 7-49.
- C. de Boor, On calculating with B-splines,
J. Appr. Theory 6 (1972), 50-62.
- M.G. Cox, The numerical evaluation of B-splines,
J. Inst. Maths Applics 10 (1972), 134-149.
- J.G. Hayes, J. Halliday, The least-squares fitting of cubic spline
surfaces to general data sets,
J. Inst. Maths Applics 14 (1974), 89-103.
- M.G. Cox, An algorithm for spline interpolation,
J. Inst. Maths Applics 15 (1975), 95-108.
- C. de Boor, A Practical Guide to Splines,
Springer-Verlag, Berlin (1978).
- P. Lancester, K. Salkauskas, Curve and Surface Fitting - An
Introduction, Academic Press, New York, 1986.
- J.C. Mason, M.S. Cox (Eds.), Algorithms for Approximation,
Clarendon Press, Oxford, 1987.
- J.W. Schmidt, H. Späth (Eds.), Splines in Numerical Analysis,
Akademie-Verlag, Berlin, 1989.
- H. Späth, Eindimensionale Spline-Interpolations-Algorithmen;
Zweidimensionale Spline-Interpolations-Algorithmen, (2 Bd.)
R. Oldenbourg, München 1990/1991.
E211
Next: E211 Cubic Splines
Up: CERNLIB
Previous: E208 Least Squares
Janne Saarela
Mon Apr 3 15:06:23 METDST 1995