CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
model_c_source_gen_loops_hess_r2.hpp
1#ifndef CPPAD_CG_MODEL_C_SOURCE_GEN_LOOPS_HESS_R2_INCLUDED
2#define CPPAD_CG_MODEL_C_SOURCE_GEN_LOOPS_HESS_R2_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
18namespace CppAD {
19namespace cg {
20
21template<class Base>
22void ModelCSourceGen<Base>::generateSparseHessianWithLoopsSourceFromRev2(const std::map<size_t, CompressedVectorInfo>& hessInfo,
23 size_t maxCompressedSize) {
24 using namespace std;
25 using namespace CppAD::cg::loops;
26
27 startingJob("'sparse Hessian'", JobTimer::SOURCE_GENERATION);
28
32 LanguageC<Base> langC(_baseTypeName);
33 string argsDcl = langC.generateDefaultFunctionArgumentsDcl();
34
35 string model_function = _name + "_" + FUNCTION_SPARSE_HESSIAN;
36 string functionRev2 = _name + "_" + FUNCTION_SPARSE_REVERSE_TWO;
37 string suffix = "indep";
38 string nlRev2Suffix = "noloop_" + suffix;
39
40 _cache.str("");
41 _cache << "#include <stdlib.h>\n"
43 generateFunctionDeclarationSource(_cache, functionRev2, nlRev2Suffix, _nonLoopRev2Elements, argsDcl);
44 generateFunctionDeclarationSourceLoopForRev(_cache, langC, _name, "jrow", _loopRev2Groups, generateFunctionNameLoopRev2);
45
46 _cache << "\n";
47
48 printForRevUsageFunction(_cache, _baseTypeName, _name,
49 model_function, 3,
50 functionRev2, suffix,
51 "jrow", "it", "hess",
52 _loopRev2Groups,
53 _nonLoopRev2Elements,
54 hessInfo,
55 generateFunctionNameLoopRev2,
56 _hessSparsity.rows.size(), maxCompressedSize);
57
58 finishedJob();
59
60 _sources[model_function + ".c"] = _cache.str();
61 _cache.str("");
62}
63
64} // END cg namespace
65} // END CppAD namespace
66
67#endif
virtual void generateSparseHessianWithLoopsSourceFromRev2(const std::map< size_t, CompressedVectorInfo > &hessInfo, size_t maxCompressedSize)