NAG FL Interface
e02cbf (dim2_cheb_eval)
1
Purpose
e02cbf evaluates a bivariate polynomial from the rectangular array of coefficients in its double Chebyshev series representation.
2
Specification
Fortran Interface
Subroutine e02cbf ( |
mfirst, mlast, k, l, x, xmin, xmax, y, ymin, ymax, ff, a, na, work, nwork, ifail) |
Integer, Intent (In) |
:: |
mfirst, mlast, k, l, na, nwork |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
x(mlast), xmin, xmax, y, ymin, ymax, a(na) |
Real (Kind=nag_wp), Intent (Out) |
:: |
ff(mlast), work(nwork) |
|
C Header Interface
#include <nag.h>
void |
e02cbf_ (const Integer *mfirst, const Integer *mlast, const Integer *k, const Integer *l, const double x[], const double *xmin, const double *xmax, const double *y, const double *ymin, const double *ymax, double ff[], const double a[], const Integer *na, double work[], const Integer *nwork, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
e02cbf_ (const Integer &mfirst, const Integer &mlast, const Integer &k, const Integer &l, const double x[], const double &xmin, const double &xmax, const double &y, const double &ymin, const double &ymax, double ff[], const double a[], const Integer &na, double work[], const Integer &nwork, Integer &ifail) |
}
|
The routine may be called by the names e02cbf or nagf_fit_dim2_cheb_eval.
3
Description
This subroutine evaluates a bivariate polynomial (represented in double Chebyshev form) of degree
in one variable,
, and degree
in the other,
. The range of both variables is
to
. However, these normalized variables will usually have been derived (as when the polynomial has been computed by
e02caf, for example) from your original variables
and
by the transformations
(Here
and
are the ends of the range of
which has been transformed to the range
to
of
.
and
are correspondingly for
. See
Section 9). For this reason, the subroutine has been designed to accept values of
and
rather than
and
, and so requires values of
, etc. to be supplied by you. In fact, for the sake of efficiency in appropriate cases, the routine evaluates the polynomial for a sequence of values of
, all associated with the same value of
.
The double Chebyshev series can be written as
where
is the Chebyshev polynomial of the first kind of degree
and argument
, and
is similarly defined. However the standard convention, followed in this subroutine, is that coefficients in the above expression which have either
or
zero are written
, instead of simply
, and the coefficient with both
and
zero is written
.
The subroutine first forms
, with
replaced by
, for each of
. The value of the double series is then obtained for each value of
, by summing
, with
replaced by
, over
. The Clenshaw three term recurrence (see
Clenshaw (1955)) with modifications due to Reinsch and
Gentleman (1969) is used to form the sums.
4
References
Clenshaw C W (1955) A note on the summation of Chebyshev series Math. Tables Aids Comput. 9 118–120
Gentleman W M (1969) An error analysis of Goertzel's (Watt's) method for computing Fourier coefficients Comput. J. 12 160–165
5
Arguments
-
1:
– Integer
Input
-
2:
– Integer
Input
-
On entry: the index of the first and last
value in the array
at which the evaluation is required respectively (see
Section 9).
Constraint:
.
-
3:
– Integer
Input
-
4:
– Integer
Input
-
On entry: the degree of and of , respectively, in the polynomial.
Constraint:
and .
-
5:
– Real (Kind=nag_wp) array
Input
-
On entry: , for , must contain the values at which the evaluation is required.
Constraint:
, for all .
-
6:
– Real (Kind=nag_wp)
Input
-
7:
– Real (Kind=nag_wp)
Input
-
On entry: the lower and upper ends,
and
, of the range of the variable
(see
Section 3).
The values of
xmin and
xmax may depend on the value of
(e.g., when the polynomial has been derived using
e02caf).
Constraint:
.
-
8:
– Real (Kind=nag_wp)
Input
-
On entry: the value of the coordinate of all the points at which the evaluation is required.
Constraint:
.
-
9:
– Real (Kind=nag_wp)
Input
-
10:
– Real (Kind=nag_wp)
Input
-
On entry: the lower and upper ends,
and
, of the range of the variable
(see
Section 3).
Constraint:
.
-
11:
– Real (Kind=nag_wp) array
Output
-
On exit: gives the value of the polynomial at the point , for .
-
12:
– Real (Kind=nag_wp) array
Input
-
On entry: the Chebyshev coefficients of the polynomial. The coefficient
defined according to the standard convention (see
Section 3) must be in
.
-
13:
– Integer
Input
-
On entry: the dimension of the array
a as declared in the (sub)program from which
e02cbf is called.
Constraint:
, the number of coefficients in a polynomial of the specified degree.
-
14:
– Real (Kind=nag_wp) array
Workspace
-
15:
– Integer
Input
-
On entry: the dimension of the array
work as declared in the (sub)program from which
e02cbf is called.
Constraint:
.
-
16:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or 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, .
Constraint: .
On entry, and .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, , and .
Constraint: .
On entry, , and .
Constraint: .
On entry, and .
Constraint: .
-
Unexpected internal failure when evaluating the polynomial.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The method is numerically stable in the sense that the computed values of the polynomial are exact for a set of coefficients which differ from those supplied by only a modest multiple of machine precision.
8
Parallelism and Performance
e02cbf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.
The time taken is approximately proportional to , where , the number of points at which the evaluation is required.
This subroutine is suitable for evaluating the polynomial surface fits produced by the subroutine
e02caf, which provides the
real
array
a in the required form. For this use, the values of
and
supplied to the present subroutine must be the same as those supplied to
e02caf. The same applies to
and
if they are independent of
. If they vary with
, their values must be consistent with those supplied to
e02caf (see
Section 9 in
e02caf).
The arguments
mfirst and
mlast are intended to permit the selection of a segment of the array
x which is to be associated with a particular value of
, when, for example, other segments of
x are associated with other values of
. Such a case arises when, after using
e02caf to fit a set of data, you wish to evaluate the resulting polynomial at all the data values. In this case, if the arguments
x,
y,
mfirst and
mlast of the present routine are set respectively (in terms of arguments of
e02caf) to
x,
,
and
, the routine will compute values of the polynomial surface at all data points which have
as their
coordinate (from which values the residuals of the fit may be derived).
10
Example
This example reads data in the following order, using the notation of the argument list above:
For each line
the polynomial is evaluated at
equispaced points between
and
inclusive.
10.1
Program Text
10.2
Program Data
10.3
Program Results