XXX-GRAD-TEST:  Test the correctness of the energy gradient computations.

There is a version of this program for each 'mc' application (eg,
net-grad-test).  These programs are used to check the energy gradient
computed by the application-specific 'mc' module against that found by
taking differences using the straight energy computation procedure of
the same module.

If there is a GPU version of the xxx-mc program, there will also be a
GPU version of xxx-grad-test, so that gradient computations on the GPU
can be tested.

These programs are meant for debugging, not for ordinary use.

Usage:

    xxx-grad-test log-file index delta [ pix ]

or:

    xxx-grad-test log-file index [ "-" ]
 
Here 'xxx' is a prefix identifying the particular incarnation of this
program.  The energy and gradient computations are tested at the point
stored with the specified index in the log file.  

For the first form, with delta specified, the computed gradient is
compared to the gradient found using finite differences of the energy
evaluated at the point plus or minus delta/2 for each coordinate.  If
a parameter index 'pix' (from 0) is given as the optional final
argument, only the component of the gradient with that index is
checked.  (This is much faster that checking the full gradient for
high-dimensional problems.)

For the second form, only the computed gradient is printed, with no
check against the value from finite differences.  If "-" is given, no
gradient is displayed, only the energy.

The results for the energy and (if asked for) the gradient are written
to standard output.

            Copyright (c) 1995-2021 by Radford M. Neal