Stan Math Library  2.14.0
reverse mode automatic differentiation
erfc.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_ERFC_HPP
2 #define STAN_MATH_REV_SCAL_FUN_ERFC_HPP
3 
6 #include <stan/math/rev/core.hpp>
7 #include <cmath>
8 
9 namespace stan {
10  namespace math {
11 
12  namespace {
13  class erfc_vari : public op_v_vari {
14  public:
15  explicit erfc_vari(vari* avi) :
16  op_v_vari(erfc(avi->val_), avi) {
17  }
18  void chain() {
19  avi_->adj_ += adj_ * NEG_TWO_OVER_SQRT_PI
20  * std::exp(- avi_->val_ * avi_->val_);
21  }
22  };
23  }
24 
60  inline var erfc(const var& a) {
61  return var(new erfc_vari(a.vi_));
62  }
63 
64  }
65 }
66 #endif
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
const double NEG_TWO_OVER_SQRT_PI
Definition: constants.hpp:161
fvar< T > erfc(const fvar< T > &x)
Definition: erfc.hpp:14

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