Prev Next speed_main

Speed Testing Main Program

Syntax
speed/package/package option seed

Purpose
A version of this program runs the correctness tests or the speed tests for one AD package identified by package.

package

AD Package
The value package can specify one of the following AD packages: adolc , cppad , fadbad , sacado .

double
The value package can be double in which case the function values (instead of derivatives) are computed using double precision operations. This enables one to compare the speed of computing function values in double to the speed of the derivative computations. (It is often useful to divide the speed of the derivative computation by the speed of the function evaluation in double.)

profile
In the special case where package is profile, the CppAD package is compiled and run with profiling to aid in determining where it is spending most of its time.

option
It the argument option specifies which test to run and has the following possible values: correct , speed , det_minor , det_lu , poly .

correct
If option is equal to correct, all of the correctness tests are run.

speed
If option is equal to speed, all of the speed tests are run.

Return Values
Each of the option values specified below corresponds to a particular test. The function call corresponding to each test has a bool return value. If a particular package supports a test, it should return true when the corresponding function is called. Otherwise (if the return value is false), the test is skipped whenever the corresponding package and option are specified.

seed
The random number simulator uniform_01 is initialized with the call
     uniform_01(
seed)
before any of the testing routines (listed above) are called.

Correctness Results
An output line is generated for each correctness test stating of the test passed or failed.

Speed Results
For each speed test, corresponds to three lines of output. The name of the package and test are printed on the first line, the vector of problem sizes are printed on the next line, and the rates corresponding to the different problem sizes are printed on the third line. The rate is the number of times per second that the calculation was repeated.

det_lu
If option is equal to det_lu, the correctness and speed test for the gradient of the determinant using LU factorization tests are run. Each package defines a version of this test with the following prototype:
     extern bool compute_det_lu(
          size_t                     size      , 
          size_t                     repeat    , 
          CppAD::vector<double>      &matrix   ,
          CppAD::vector<double>      &gradient 
     );

size
The argument size is the number of rows and columns in the matrix.

repeat
The argument repeat is the number of different matrices that the gradient is computed for.

matrix
The argument matrix is a vector with size*size elements. The input value of its elements does not matter. The output value of its elements is the last matrix that the gradient is computed for.

gradient
The argument gradient is a vector with size*size elements. The input value of its elements does not matter. The output value of its elements is the gradient of the determinant of matrix with respect to its elements. gradient is computed for. (If package is double, only the first element of gradient is used and it is actually the determinant value instead of the gradient value.)

det_minor
If option is equal to det_minor, the correctness and speed test for the gradient of the determinant using expansion by minors are run. Each package defines a version of this test with the following prototype:
     extern bool compute_det_minor(
          size_t                     size      , 
          size_t                     repeat    , 
          CppAD::vector<double>      &matrix   ,
          CppAD::vector<double>      &gradient 
     );

size
The argument size is the number of rows and columns in the matrix.

repeat
The argument repeat is the number of different matrices that the gradient is computed for.

matrix
The argument matrix is a vector with size*size elements. The input value of its elements does not matter. The output value of its elements is the last matrix that the gradient is computed for.

gradient
The argument gradient is a vector with size*size elements. The input value of its elements does not matter. The output value of its elements is the gradient of the determinant of matrix with respect to its elements. gradient is computed for. (If package is double, only the first element of gradient is used and it is actually the determinant value instead of the gradient value.)

poly
If option is equal to poly, the correctness and speed test for the derivative of a polynomial are run. Each package defines a version of this test with the following prototype:
     extern bool compute_poly(
          size_t                     size     , 
          size_t                     repeat   , 
          CppAD::vector<double>      &a       ,
          CppAD::vector<double>      &z       ,
          CppAD::vector<double>      &ddp      
     );

size
The argument size is the order of the polynomial (the number of coefficients in the polynomial).

repeat
The argument repeat is the number of different argument values that the polynomial will be differentiated at.

a
The argument a is a vector with size*size elements. The input value of its elements does not matter. The output value of its is the coefficients of the last polynomial that is differentiated (i-th element is coefficient of order  i ).

z
The argument z is a vector with one element. The input value of the element does not matter. The output its value is the polynomial argument value were the derivative was computed.

ddp
The argument ddp is a vector with one element. The input value of the element does not matter. The output its value is the second derivative of the polynomial value with respect to it's argument value. (If package is double, only the first element of ddp is used and it is actually the polynomial value instead of the gradient value.)

sparse_hessian
If option is equal to sparse_hessian, the correctness and speed test for computing a sparse Hessian matrix are run. Each package defines a version of this test with the following prototype:
     extern bool compute_sparse_hessian(
          size_t                     size       , 
          size_t                     repeat     ,
          size_t                      ell       ,
          CppAD::vector<size_t>      &i         ,
          CppAD::vector<size_t>      &j         , 
          CppAD::vector<double>      &hessian
     );

f
The function  f : \R^n \rightarrow \R  is defined by  \[
     f(x) = \sum_{k=1}^\ell x_{i[k]} x_{j[k]}
\] 
Note that different vectors  i and  j correspond to different functions  f(x) .

size
The argument size is the dimension of the argument space for the function  f ; i.e. size is equal to  n .

repeat
The argument repeat is the number of different functions  f(x) that the Hessian is computed for.

ell
The argument ell has prototype
        size_t 
ell
and is the number of terms in the summation that defines  f(x) ; i.e.,  \ell .

i
The argument i is a vector of size ell. The input value of its elements does not matter. On output, it has been set the first index vector for the last function  f(x) (each element of the repeat loop corresponds to a different choice of  i and  j ). All the elements of i must be between zero and size-1.

j
The argument j is a vector of size ell. The input value of its elements does not matter. On output, it has been set the second index vector for the last function  f(x) . All the elements of j must be between zero and size-1.

hessian
The argument hessian is a vector with n*n elements. The input value of its elements does not matter. The output value of its elements is the Hessian of the function  f(x) corresponding to output values of i and j. To be more specific,  k = 0 , \ldots , n-1 ,  m = 0 , \ldots , n-1 ,  \[
     \DD{f}{x[k]}{x[m]} = hessian [ k * n + m ]
\] 
(If package is double, only the first element of hessian is used and it is actually  f(x) value instead of  f^{(2)} (x) .)
Input File: speed/main.cpp