Prev Next double_det_minor.cpp

Double Speed: Determinant Using Expansion by Minors

compute_det_minor
Routine that computes the gradient of determinant using CppAD:
# include <cppad/vector.hpp>
# include <cppad/speed/det_by_minor.hpp>
# include <cppad/speed/uniform_01.hpp>

bool compute_det_minor(
     size_t                     size     , 
     size_t                     repeat   , 
     CppAD::vector<double>     &matrix   ,
     CppAD::vector<double>     &det      )
{
     // -----------------------------------------------------
     // setup
     CppAD::det_by_minor<double>   Det(size);
     size_t n = size * size; // number of independent variables
     
     // ------------------------------------------------------
     while(repeat--)
     {    // get the next matrix
          CppAD::uniform_01(n, matrix);

          // computation of the determinant
          det[0] = Det(matrix);
     }
     return true;
}

Input File: speed/double/det_minor.cpp