CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
declare_extra.hpp
1#ifndef CPPAD_CG_DECLARE_EXTRA_INCLUDED
2#define CPPAD_CG_DECLARE_EXTRA_INCLUDED
3/* --------------------------------------------------------------------------
4 * CppADCodeGen: C++ Algorithmic Differentiation with Source Code Generation:
5 * Copyright (C) 2013 Ciengis
6 *
7 * CppADCodeGen is distributed under multiple licenses:
8 *
9 * - Eclipse Public License Version 1.0 (EPL1), and
10 * - GNU General Public License Version 3 (GPL3).
11 *
12 * EPL1 terms and conditions can be found in the file "epl-v10.txt", while
13 * terms and conditions for the GPL3 can be found in the file "gpl3.txt".
14 * ----------------------------------------------------------------------------
15 * Author: Joao Leal
16 */
17
18#include <cppad/local/define.hpp>
19#include <cppad/local/cppad_assert.hpp>
20#include <cppad/local/base_cond_exp.hpp>
21
22// forward declarations
23namespace CppAD {
24namespace cg {
25
26/***********************************************************************
27 * Combined Jacobian and Hessian evaluation
28 **********************************************************************/
29
30class SparseForjacHessianWorkJac;
31class SparseForjacHessianWorkHes;
32class SparseForjacHessianWork;
33
34template<class Base, class VectorBase, class VectorSet, class VectorSize>
35size_t sparseForJacHessian(ADFun<Base>& fun,
36 const VectorBase& x,
37 const VectorBase& w,
38 VectorBase& y,
39 const VectorSet& jac_p,
40 const VectorSize& jac_row,
41 const VectorSize& jac_col,
42 VectorBase& jac,
43 const VectorSet& hes_p,
44 const VectorSize& hes_row,
45 const VectorSize& hes_col,
46 VectorBase& hes,
47 SparseForjacHessianWork& work);
48
49template<class Base, class VectorBase, class VectorVectorBase, class VectorSet, class VectorSize>
50size_t sparseForJacHessian(ADFun<Base>& fun,
51 const VectorBase& x,
52 const VectorVectorBase& w,
53 VectorBase& y,
54 const VectorSet& jac_p,
55 const VectorSize& jac_row,
56 const VectorSize& jac_col,
57 VectorBase& jac,
58 const VectorSet& hes_p,
59 const VectorSize& hes_row,
60 const VectorSize& hes_col,
61 VectorVectorBase& hes,
62 SparseForjacHessianWork& work);
63
64/***********************************************************************
65 * Sparsity evaluation
66 **********************************************************************/
67
68template<class VectorBool, class Base>
69inline VectorBool jacobianForwardSparsity(ADFun<Base>& fun);
70
71template<class VectorBool, class Base>
72inline VectorBool jacobianReverseSparsity(ADFun<Base>& fun);
73
74template<class VectorSet, class Base>
75inline VectorSet jacobianForwardSparsitySet(ADFun<Base>& fun);
76
77template<class VectorSet, class Base>
78inline VectorSet jacobianReverseSparsitySet(ADFun<Base>& fun);
79
80template<class VectorBool, class Base>
81inline VectorBool jacobianSparsity(ADFun<Base>& fun);
82
83template<class VectorSet, class Base>
84inline VectorSet jacobianSparsitySet(ADFun<Base>& fun);
85
86inline bool estimateBestJacobianADMode(const std::vector<size_t>& jacRows,
87 const std::vector<size_t>& jacCols);
88
89template<class VectorBool, class Base>
90inline VectorBool hessianSparsity(ADFun<Base>& fun,
91 bool transpose = false);
92
93template<class VectorSet, class Base>
94inline VectorSet hessianSparsitySet(ADFun<Base>& fun,
95 const std::set<size_t>& w,
96 bool transpose = false);
97
98template<class VectorSet, class Base>
99inline VectorSet hessianSparsitySet(ADFun<Base>& fun,
100 bool transpose = false);
101
102template<class VectorBool, class Base>
103inline VectorBool hessianSparsity(ADFun<Base>& fun,
104 size_t i,
105 bool transpose = false);
106
107template<class VectorSet, class Base>
108inline VectorSet hessianSparsitySet(ADFun<Base>& fun,
109 size_t i,
110 bool transpose = false);
111
112/***********************************************************************
113 * Sparsity conversion
114 **********************************************************************/
115
116template<class VectorBool, class VectorSize>
117inline void generateSparsityIndexes(const VectorBool& sparsity,
118 size_t m,
119 size_t n,
120 VectorSize& row,
121 VectorSize& col);
122
123template<class VectorSet, class VectorSize>
124inline void generateSparsityIndexes(const VectorSet& sparsity,
125 VectorSize& row,
126 VectorSize& col);
127
128template<class VectorSet, class VectorSize>
129inline void generateSparsitySet(const VectorSize& row,
130 const VectorSize& col,
131 VectorSet& sparsity);
132}
133}
134
135#endif
136