Stan Math Library  2.20.0
reverse mode automatic differentiation
print_stack.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_CORE_PRINT_STACK_HPP
2 #define STAN_MATH_REV_CORE_PRINT_STACK_HPP
3 
6 #include <ostream>
7 
8 namespace stan {
9 namespace math {
10 
20 inline void print_stack(std::ostream& o) {
21  o << "STACK, size=" << ChainableStack::instance_->var_stack_.size()
22  << std::endl;
23  // TODO(carpenter): this shouldn't need to be cast any more
24  for (size_t i = 0; i < ChainableStack::instance_->var_stack_.size(); ++i)
25  o << i << " " << ChainableStack::instance_->var_stack_[i] << " "
26  << (static_cast<vari*>(ChainableStack::instance_->var_stack_[i]))->val_
27  << " : "
28  << (static_cast<vari*>(ChainableStack::instance_->var_stack_[i]))->adj_
29  << std::endl;
30 }
31 
32 } // namespace math
33 } // namespace stan
34 #endif
static STAN_THREADS_DEF AutodiffStackStorage * instance_
void print_stack(std::ostream &o)
Prints the auto-dif variable stack.
Definition: print_stack.hpp:20

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