CppAD: A C++ Algorithmic Differentiation Package  20171217
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
entire_call.hpp
Go to the documentation of this file.
1 # ifndef CPPAD_LOCAL_SUBGRAPH_ENTIRE_CALL_HPP
2 # define CPPAD_LOCAL_SUBGRAPH_ENTIRE_CALL_HPP
3 /* --------------------------------------------------------------------------
4 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
5 
6 CppAD is distributed under multiple licenses. This distribution is under
7 the terms of the
8  Eclipse Public License Version 1.0.
9 
10 A copy of this license is included in the COPYING file of this distribution.
11 Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
12 -------------------------------------------------------------------------- */
13 
15 
16 // BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE
17 namespace CppAD { namespace local { namespace subgraph {
18 /*!
19 \file entire_call.hpp
20 include entire function call in a subgraph
21 */
22 // ===========================================================================
23 /*!
24 Convert from just firt UserOp to entire atomic function call in a subgraph.
25 
26 \tparam Base
27 this operation sequence was recording using AD<Base>.
28 
29 \param play
30 is the operation sequence corresponding to the ADFun<Base> function.
31 
32 \param subgraph
33 It a set of operator indices in this recording.
34 If the corresponding operator is a UserOp, it assumed to be the
35 first one in the corresponding atomic function call.
36 The other call operators are included in the subgraph.
37 */
38 template <typename Base>
40  const player<Base>* play ,
41  pod_vector<addr_t>& subgraph )
42 {
43  // add extra operators corresponding to rest of atomic function calls
44  size_t n_sub = subgraph.size();
45  for(size_t k = 0; k < n_sub; ++k)
46  { size_t i_op = subgraph[k];
47  //
48  if( play->GetOp(i_op) == UserOp )
49  { // This is the first UserOp of this atomic function call
50  while( play->GetOp(++i_op) != UserOp )
51  { switch(play->GetOp(i_op))
52  {
53  case UsravOp:
54  case UsrrvOp:
55  case UsrrpOp:
56  case UsrapOp:
57  subgraph.push_back( addr_t(i_op) );
58  break;
59 
60  default:
61  // cannot find second UserOp in this call
62  CPPAD_ASSERT_UNKNOWN(false);
63  break;
64  }
65  }
66  // THis is the second UserOp of this atomic function call
67  subgraph.push_back( addr_t(i_op) );
68  }
69  }
70 
71 }
72 
73 } } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE
74 
75 # endif
void push_back(const Type &e)
Add an element to theh back of this vector.
Definition: pod_vector.hpp:312
CPPAD_TAPE_ADDR_TYPE addr_t
Definition: declare_ad.hpp:44
Class used to store and play back an operation sequence recording.
Definition: declare_ad.hpp:27
File used to define pod_vector class.
void entire_call(const player< Base > *play, pod_vector< addr_t > &subgraph)
Convert from just firt UserOp to entire atomic function call in a subgraph.
Definition: entire_call.hpp:39
size_t size(void) const
current number of elements in this vector.
Definition: pod_vector.hpp:79
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
OpCode GetOp(size_t i) const
fetch an operator from the recording.
Definition: player.hpp:558