![]() |
Prev | Next |
ok = FunCheck(
f,
g,
x,
r,
a)
See Also
CompareChange
F : B^n \rightarrow B^m
to denote the
AD function
corresponding to f.
We use
G : B^n \rightarrow B^m
to denote the
function corresponding to the C++ function object g.
This routine check if
\[
F(x) = G(x)
\]
If
F(x) \neq G(x)
, the
operation sequence
corresponding to f does not represents the algorithm used
by g to calculate values for
G
(see Discussion
below).
FunCheck
argument f has prototype
ADFun<
Base>
f
Note that the ADFun
object f is not const
(see Forward
below).
FunCheck
argument g has prototype
Fun &
g
(Fun is defined the properties of g).
The C++ function object g supports the syntax
y =
g(
x)
which computes
y = G(x)
.
const
Vector &
x
(see Vector
below)
and its size
must be equal to n, the dimension of the
domain
space for f.
Vector
y
and its value is
G(x)
.
The size of y
is equal to m, the dimension of the
range
space for f.
FunCheck
argument x has prototype
const
Vector &
x
and its size
must be equal to n, the dimension of the
domain
space for f.
This specifies that point at which to compare the values
calculated by f and G.
FunCheck
argument r has prototype
const
Base &
r
It specifies the relative error the element by element
comparison of the value of
F(x)
and
G(x)
.
FunCheck
argument a has prototype
const
Base &
a
It specifies the absolute error the element by element
comparison of the value of
F(x)
and
G(x)
.
FunCheck
result ok has prototype
bool
ok
It is true, if for
i = 0 , \ldots , m-1
either the relative error bound is satisfied
\[
| F_i (x) - G_i (x) |
\leq
r ( | F_i (x) | + | G_i (x) | )
\]
or the absolute error bound is satisfied
\[
| F_i (x) - G_i (x) | \leq a
\]
It is false if for some
(i, j)
neither
of these bounds is satisfied.
FunCheck
,
the previous calls to Forward
are undefined.
if(
x >= 0 )
y = exp(
x)
else
y = exp(-
x)
where x and y are AD<double>
objects.
It follows that the
AD of double
operation sequence
depends on the value of x.
If the sequence of operations stored in f corresponds to
g with
x \geq 0
,
the function values computed using f when
x < 0
will not agree with the function values computed by
g
.
This is because the operation sequence corresponding to g changed
(and hence the object f does not represent the function
G
for this value of x).
In this case, you probably want to re-tape the calculations
performed by g with the
independent variables
equal to the values in x
(so AD operation sequence properly represents the algorithm
for this value of independent variables).