class to define the function for diff
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
logical, | private | :: | stop | = | .false. | ||
procedure(func), | private, | pointer | :: | f | => | null() |
This procedure attempts to estimate the level of rounding errors in
the calculated function values near the point x0+h0
by fitting a
least-squares straight-line approximation to the function at the
six points x0+h0-j*h1
, (j = 0,1,3,5,7,9
), and then setting facc
to
twice the largest deviation of the function values from this line.
hi
is adjusted if necessary so that it is approximately 8 times the
smallest spacing at which the function values are unequal near x0+h0
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(diff_func), | intent(inout) | :: | me | |||
real(kind=wp), | intent(inout) | :: | h0 | |||
real(kind=wp), | intent(inout) | :: | h1 | |||
real(kind=wp), | intent(out) | :: | facc | |||
real(kind=wp), | intent(in) | :: | x0 | |||
real(kind=wp), | intent(in) | :: | twoinf | |||
real(kind=wp), | intent(in) | :: | f0 | |||
real(kind=wp), | intent(in) | :: | f1 | |||
integer, | intent(out) | :: | ifail |
0 if no error, -1 if user termination. |
Set the function in a diff_func. Must be called before diff.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(diff_func), | intent(inout) | :: | me | |||
procedure(func) | :: | f |
the procedure diff
calculates the first, second or
third order derivative of a function by using neville's process to
extrapolate from a sequence of simple polynomial approximations based on
interpolating points distributed symmetrically about x0
(or lying only on
one side of x0
should this be necessary). if the specified tolerance is
non-zero then the procedure attempts to satisfy this absolute or relative
accuracy requirement, while if it is unsuccessful or if the tolerance is
set to zero then the result having the minimum achievable estimated error
is returned instead.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(diff_func), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | iord |
1, 2 or 3 specifies that the first, second or third order derivative,respectively, is required. |
||
real(kind=wp), | intent(in) | :: | x0 |
the point at which the derivative of the function is to be calculated. |
||
real(kind=wp), | intent(in) | :: | xmin |
|
||
real(kind=wp), | intent(in) | :: | xmax |
|
||
real(kind=wp), | intent(in) | :: | eps |
denotes the tolerance, either absolute or relative. |
||
real(kind=wp), | intent(in) | :: | accr |
denotes that the absolute ( |
||
real(kind=wp), | intent(out) | :: | deriv |
the calculated value of the derivative |
||
real(kind=wp), | intent(out) | :: | error |
an estimated upper bound on the magnitude of the absolute error in the calculated result. it should always be examined, since in extreme case may indicate that there are no correct significant digits in the value returned for derivative. |
||
integer, | intent(out) | :: | ifail |
will have one of the following values on exit:
0 the procedure was successful.
1 the estimated error in the result exceeds the (non-zero) requested
error, but the most accurate result possible has been returned.
2 input data incorrect (derivative and error will be undefined).
3 the interval [ |
type,public :: diff_func !! class to define the function for [[diff]] private logical :: stop = .false. procedure(func),pointer :: f => null() contains private procedure :: faccur procedure,public :: set_function procedure,public :: compute_derivative => diff procedure,public :: terminate end type diff_func