CppAD: A C++ Algorithmic Differentiation Package  20130102
link_det_minor.cpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 /* --------------------------------------------------------------------------
00003 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
00004 
00005 CppAD is distributed under multiple licenses. This distribution is under
00006 the terms of the 
00007                     Eclipse Public License Version 1.0.
00008 
00009 A copy of this license is included in the COPYING file of this distribution.
00010 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
00011 -------------------------------------------------------------------------- */
00012 
00013 /*
00014 $begin link_det_minor$$
00015 $spell
00016      det
00017      bool
00018      CppAD
00019 $$
00020 
00021 $index link_det_minor$$
00022 $index det_minor, speed test$$
00023 $index speed, test det_minor$$
00024 $index test, det_minor speed$$
00025 
00026 $section Speed Testing Gradient of Determinant by Minor Expansion$$
00027 
00028 $head Prototype$$
00029 $codei%extern bool link_det_minor(
00030      size_t                 %size%      , 
00031      size_t                 %repeat%    , 
00032      CppAD::vector<double> &%matrix%    ,
00033      CppAD::vector<double> &%gradient% 
00034 );
00035 %$$
00036 
00037 $head Purpose$$
00038 Each $cref/package/speed_main/package/$$
00039 must define a version of this routine as specified below.
00040 This is used by the $cref speed_main$$ program 
00041 to run the corresponding speed and correctness tests.
00042 
00043 $head Method$$
00044 The same template class $cref det_by_minor$$
00045 is used by the different AD packages.
00046 
00047 $head Return Value$$
00048 If this speed test is not yet
00049 supported by a particular $icode package$$,
00050 the corresponding return value for $code link_det_minor$$ 
00051 should be $code false$$.
00052 
00053 $head size$$
00054 The argument $icode size$$
00055 is the number of rows and columns in the matrix.
00056 
00057 $head repeat$$
00058 The argument $icode repeat$$ is the number of different matrices
00059 that the gradient (or determinant) is computed for.
00060 
00061 $head matrix$$
00062 The argument $icode matrix$$ is a vector with 
00063 $icode%size%*%size%$$ elements.
00064 The input value of its elements does not matter. 
00065 The output value of its elements is the last matrix that the
00066 gradient (or determinant) is computed for.
00067 
00068 $head gradient$$
00069 The argument $icode gradient$$ is a vector with 
00070 $icode%size%*%size%$$ elements.
00071 The input value of its elements does not matter. 
00072 The output value of its elements is the gradient of the
00073 determinant of $icode matrix$$ with respect to its elements.
00074 
00075 $subhead double$$
00076 In the case where $icode package$$ is $code double$$, 
00077 only the first element of $icode gradient$$ is used and it is actually 
00078 the determinant value (the gradient value is not computed).
00079 
00080 $end 
00081 -----------------------------------------------------------------------------
00082 */
00083 
00084 # include <cppad/vector.hpp>
00085 # include <cppad/speed/det_grad_33.hpp>
00086 # include <cppad/speed/det_33.hpp>
00087 
00088 extern bool link_det_minor(
00089      size_t                     size      , 
00090      size_t                     repeat    , 
00091      CppAD::vector<double>      &matrix   ,
00092      CppAD::vector<double>      &gradient 
00093 );
00094 
00095 bool available_det_minor(void)
00096 {    size_t size   = 3;
00097      size_t repeat = 1;
00098      CppAD::vector<double> matrix(size * size);
00099      CppAD::vector<double> gradient(size * size);
00100 
00101      return link_det_minor(size, repeat, matrix, gradient);
00102 }
00103 bool correct_det_minor(bool is_package_double)
00104 {    size_t size   = 3;
00105      size_t repeat = 1;
00106      CppAD::vector<double> matrix(size * size);
00107      CppAD::vector<double> gradient(size * size);
00108 
00109      link_det_minor(size, repeat, matrix, gradient);
00110      bool ok = CppAD::det_grad_33(matrix, gradient);
00111      if( is_package_double )
00112           ok = CppAD::det_33(matrix, gradient);
00113      else ok = CppAD::det_grad_33(matrix, gradient);
00114      return ok;
00115 }
00116 void speed_det_minor(size_t size, size_t repeat)
00117 {    CppAD::vector<double> matrix(size * size);
00118      CppAD::vector<double> gradient(size * size);
00119 
00120      link_det_minor(size, repeat, matrix, gradient);
00121      return;
00122 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines