$\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["atomic"] )
return false;
if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
return false;
// -----------------------------------------------------
// setup

// object for computing determinant

size_t i;                // temporary index
size_t m = 1;            // number of dependent variables
size_t n = size * size;  // number of independent variables

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

// set independent variable values
for(i = 0; i < n; i++)
A[i] = matrix[i];

// compute the determinant
detA = Det(A);

// create function object f : A -> detA
detA.diff(0, m);  // index 0 of m dependent variables

// evaluate and return gradient using reverse mode
for(i =0; i < n; i++)
gradient[i] = A[i].d(0); // partial detA w.r.t A[i]
}
// ---------------------------------------------------------
return true;
}