Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
exp2.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__EXP2_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__EXP2_HPP
3 
4 #include <valarray>
5 #include <stan/agrad/rev/var.hpp>
8 #include <math.h>
9 
10 namespace stan {
11  namespace agrad {
12 
13  namespace {
14  class exp2_vari : public op_v_vari {
15  public:
16  exp2_vari(vari* avi) :
17  op_v_vari(::pow(2.0,avi->val_),avi) {
18  }
19  void chain() {
20  avi_->adj_ += adj_ * val_ * stan::math::LOG_2;
21  }
22  };
23  }
24 
53  inline var exp2(const stan::agrad::var& a) {
54  return var(new exp2_vari(a.vi_));
55  }
56 
57  }
58 }
59 #endif
const double LOG_2
The natural logarithm of 2, .
Definition: constants.hpp:32
fvar< T > exp2(const fvar< T > &x)
Definition: exp2.hpp:16
fvar< T > pow(const fvar< T > &x1, const fvar< T > &x2)
Definition: pow.hpp:17
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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