$\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }$

Specifications

Implementation
// suppress conversion warnings before other includes
//

// list of possible options
# include <map>
extern std::map<std::string, bool> global_option;

size_t                           size     ,
size_t                           repeat   ,
{
// speed test global option values
if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] )
return false;
// The correctness check for this test is failing, so abort (for now).
return false;

// -----------------------------------------------------
// setup

// object for computing determinant

size_t j;                // temporary index
size_t m = 1;            // number of dependent variables
size_t n = size * size;  // number of independent variables
ADVector   X(n);         // AD domain space vector
ADVector   Y(n);         // Store product matrix
ADVector   Z(m);         // AD range space vector

// ------------------------------------------------------
while(repeat--)
{     // get the next matrix

// set independent variable values
for(j = 0; j < n; j++)
X[j] = x[j];

// do the computation
mat_sum_sq(size, X, Y, Z);

// create function object f : X -> Z
Z[0].diff(0, m);  // index 0 of m dependent variables

// evaluate and return gradient using reverse mode
for(j = 0; j < n; j++)
dz[j] = X[j].d(0); // partial Z[0] w.r.t X[j]
}
// return function value
z[0] = Z[0].x();

// ---------------------------------------------------------
return true;
}