Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
asinh.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__ASINH_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__ASINH_HPP
3 
4 #include <valarray>
5 #include <stan/agrad/rev/var.hpp>
7 #include <boost/math/special_functions/fpclassify.hpp>
11 #include <math.h>
12 
13 namespace stan {
14  namespace agrad {
15 
16  namespace {
17  class asinh_vari : public op_v_vari {
18  public:
19  asinh_vari(double val, vari* avi) :
20  op_v_vari(val,avi) {
21  }
22  void chain() {
23  avi_->adj_ += adj_ / std::sqrt(avi_->val_ * avi_->val_ + 1.0);
24  }
25  };
26  }
27 
65  inline var asinh(const stan::agrad::var& a) {
66  if (boost::math::isinf(a.val()))
67  return var(new asinh_vari(a.val(), a.vi_));
68  return var(new asinh_vari(::asinh(a.val()),a.vi_));
69  }
70 
71  }
72 }
73 #endif
double val() const
Return the value of this variable.
Definition: var.hpp:209
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
bool isinf(const stan::agrad::var &v)
Checks if the given number is infinite.
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
fvar< T > asinh(const fvar< T > &x)
Definition: asinh.hpp:16
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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