/usr/include/cppad/speed/det_33.hpp is in cppad 2017.00.00.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | // $Id: det_33.hpp 3804 2016-03-20 15:08:46Z bradbell $
# ifndef CPPAD_SPEED_DET_33_HPP
# define CPPAD_SPEED_DET_33_HPP
/* --------------------------------------------------------------------------
CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell
CppAD is distributed under multiple licenses. This distribution is under
the terms of the
GNU General Public License Version 3.
A copy of this license is included in the COPYING file of this distribution.
Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
-------------------------------------------------------------------------- */
/*
$begin det_33$$
$spell
cppad
CppAD
det
cppad.hpp
namespace
const
bool
$$
$section Check Determinant of 3 by 3 matrix$$
$mindex det_33 correct$$
$head Syntax$$
$codei%# include <cppad/speed/det_33.hpp>
%$$
$icode%ok% = det_33(%x%, %d%)%$$
$head Purpose$$
This routine can be used to check a method for computing
the determinant of a matrix.
$head Inclusion$$
The template function $code det_33$$ is defined in the $code CppAD$$
namespace by including
the file $code cppad/speed/det_33.hpp$$
(relative to the CppAD distribution directory).
It is only intended for example and testing purposes,
so it is not automatically included by
$cref/cppad.hpp/cppad/$$.
$head x$$
The argument $icode x$$ has prototype
$codei%
const %Vector% &%x%
%$$.
It contains the elements of the matrix $latex X$$ in row major order; i.e.,
$latex \[
X_{i,j} = x [ i * 3 + j ]
\] $$
$head d$$
The argument $icode d$$ has prototype
$codei%
const %Vector% &%d%
%$$.
It is tested to see if $icode%d%[0]%$$ it is equal to $latex \det ( X )$$.
$head Vector$$
If $icode y$$ is a $icode Vector$$ object,
it must support the syntax
$codei%
%y%[%i%]
%$$
where $icode i$$ has type $code size_t$$ with value less than 9.
This must return a $code double$$ value corresponding to the $th i$$
element of the vector $icode y$$.
This is the only requirement of the type $icode Vector$$.
(Note that only the first element of the vector $icode d$$ is used.)
$head ok$$
The return value $icode ok$$ has prototype
$codei%
bool %ok%
%$$
It is true, if the determinant $icode%d%[0]%$$
passes the test and false otherwise.
$children%
omh/det_33_hpp.omh
%$$
$head Source Code$$
The file
$cref det_33.hpp$$
contains the source code for this template function.
$end
------------------------------------------------------------------------------
*/
// BEGIN C++
# include <cppad/utility/near_equal.hpp>
namespace CppAD {
template <class Vector>
bool det_33(const Vector &x, const Vector &d)
{ bool ok = true;
// use expansion by minors to compute the determinant by hand
double check = 0.;
check += x[0] * ( x[4] * x[8] - x[5] * x[7] );
check -= x[1] * ( x[3] * x[8] - x[5] * x[6] );
check += x[2] * ( x[3] * x[7] - x[4] * x[6] );
ok &= CppAD::NearEqual(check, d[0], 1e-10, 1e-10);
return ok;
}
}
// END C++
# endif
|