Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
erf.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__ERF_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__ERF_HPP
3 
4 #include <valarray>
5 #include <math.h>
6 #include <stan/agrad/rev/var.hpp>
9 
10 namespace stan {
11  namespace agrad {
12 
13  namespace {
14  class erf_vari : public op_v_vari {
15  public:
16  erf_vari(vari* avi) :
17  op_v_vari(::erf(avi->val_),avi) {
18  }
19  void chain() {
20  avi_->adj_ += adj_ * stan::math::TWO_OVER_SQRT_PI
21  * ::exp(- avi_->val_ * avi_->val_);
22  }
23  };
24  }
25 
63  inline var erf(const stan::agrad::var& a) {
64  return var(new erf_vari(a.vi_));
65  }
66 
67  }
68 }
69 #endif
fvar< T > erf(const fvar< T > &x)
Definition: erf.hpp:17
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
const double TWO_OVER_SQRT_PI
Definition: constants.hpp:146
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:16

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