Stan Math Library  2.9.0
reverse mode automatic differentiation
set_zero_all_adjoints_nested.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_SET_ZERO_ALL_ADJOINTS_NESTED_HPP
2 #define STAN_MATH_REV_CORE_SET_ZERO_ALL_ADJOINTS_NESTED_HPP
3 
8 
9 namespace stan {
10  namespace math {
11 
17  if (empty_nested())
18  throw std::logic_error("empty_nested() must be false before calling"
19  " set_zero_all_adjoints_nested()");
20  size_t start1 = ChainableStack::nested_var_stack_sizes_.back();
21  for (size_t i = start1 - 1; i < ChainableStack::var_stack_.size(); ++i)
22  ChainableStack::var_stack_[i]->set_zero_adjoint();
23 
24 
26  for (size_t i = start2 - 1;
27  i < ChainableStack::var_nochain_stack_.size(); ++i)
28  ChainableStack::var_nochain_stack_[i]->set_zero_adjoint();
29  }
30 
31  }
32 }
33 #endif
static bool empty_nested()
Return true if there is no nested autodiff being executed.
static void set_zero_all_adjoints_nested()
Reset all adjoint values in the top nested portion of the stack to zero.
static std::vector< ChainableT * > var_nochain_stack_
static std::vector< size_t > nested_var_nochain_stack_sizes_
static std::vector< size_t > nested_var_stack_sizes_
static std::vector< ChainableT * > var_stack_

     [ Stan Home Page ] © 2011–2015, Stan Development Team.