CppAD: A C++ Algorithmic Differentiation Package  20130102
link_det_lu.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_lu$$
00015 $spell
00016      det_lu
00017      bool
00018      CppAD
00019 $$
00020 
00021 $index link_det_lu$$
00022 $index det_lu, speed test$$
00023 $index speed, test det_lu$$
00024 $index test, det_lu speed$$
00025 
00026 $section Speed Testing Gradient of Determinant Using Lu Factorization$$
00027 
00028 $head Prototype$$
00029 $codei%extern bool link_det_lu(
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 routine $cref det_by_lu$$ is used 
00045 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_lu$$ 
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 $icode%size%*%size%$$ elements.
00063 The input value of its elements does not matter. 
00064 The output value of its elements is the last matrix that the
00065 gradient (or determinant) is computed for.
00066 
00067 $head gradient$$
00068 The argument $icode gradient$$ is a vector with $icode%size%*%size%$$ elements.
00069 The input value of its elements does not matter. 
00070 The output value of its elements is the gradient of the
00071 determinant of $icode matrix$$ with respect to its elements.
00072 
00073 $subhead double$$
00074 In the case where $icode package$$ is $code double$$, 
00075 only the first element of $icode gradient$$ is used and it is actually 
00076 the determinant value (the gradient value is not computed).
00077 
00078 $end 
00079 -----------------------------------------------------------------------------
00080 */
00081 
00082 # include <cppad/vector.hpp>
00083 # include <cppad/speed/det_grad_33.hpp>
00084 # include <cppad/speed/det_33.hpp>
00085 
00086 extern bool link_det_lu(
00087      size_t                     size      , 
00088      size_t                     repeat    , 
00089      CppAD::vector<double>      &matrix   ,
00090      CppAD::vector<double>      &gradient 
00091 );
00092 
00093 
00094 bool available_det_lu(void)
00095 {    size_t size   = 3;
00096      size_t repeat = 1;
00097      CppAD::vector<double> matrix(size * size);
00098      CppAD::vector<double> gradient(size * size);
00099 
00100      return link_det_lu(size, repeat, matrix, gradient);
00101 }
00102 bool correct_det_lu(bool is_package_double)
00103 {    size_t size   = 3;
00104      size_t repeat = 1;
00105      CppAD::vector<double> matrix(size * size);
00106      CppAD::vector<double> gradient(size * size);
00107 
00108      link_det_lu(size, repeat, matrix, gradient);
00109      bool ok;
00110      if( is_package_double )
00111           ok = CppAD::det_33(matrix, gradient);
00112      else ok = CppAD::det_grad_33(matrix, gradient);
00113      return ok;
00114 }
00115 void speed_det_lu(size_t size, size_t repeat)
00116 {    CppAD::vector<double> matrix(size * size);
00117      CppAD::vector<double> gradient(size * size);
00118 
00119      link_det_lu(size, repeat, matrix, gradient);
00120      return;
00121 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines