CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
independent_node_sorter.hpp
1#ifndef CPPAD_CG_INDEPENDENT_SORTER_INCLUDED
2#define CPPAD_CG_INDEPENDENT_SORTER_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
25template<class Base>
27public:
28
33 const OperationNode<Base>* node2) const {
34 CPPADCG_ASSERT_UNKNOWN(node1 == nullptr || node1->getInfo().size() == 1);
35 CPPADCG_ASSERT_UNKNOWN(node2 == nullptr || node2->getInfo().size() == 1);
36 CPPADCG_ASSERT_UNKNOWN(node1 == nullptr || node1->getOperationType() == CGOpCode::Inv);
37 CPPADCG_ASSERT_UNKNOWN(node2 == nullptr || node2->getOperationType() == CGOpCode::Inv);
38
39 // some variables are not used in all iterations
40 if (node1 == nullptr) {
41 if (node2 == nullptr) {
42 return false;
43 }
44 return true;
45 } else if (node2 == nullptr) {
46 return false;
47 }
48
49 size_t index1 = node1->getInfo()[0];
50 size_t index2 = node2->getInfo()[0];
51 if (index1 < index2)
52 return true;
53 else //if (index1 >= index2)
54 return false;
55 }
56
57};
58
59} // END cg namespace
60} // END CppAD namespace
61
62#endif
bool operator()(const OperationNode< Base > *node1, const OperationNode< Base > *node2) const
const std::vector< size_t > & getInfo() const
CGOpCode getOperationType() const