Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
acosh.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__ACOSH_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__ACOSH_HPP
3 
4 #include <math.h>
5 #include <stan/agrad/rev/var.hpp>
7 #include <boost/math/special_functions/fpclassify.hpp>
12 
13 namespace stan {
14  namespace agrad {
15 
16  namespace {
17  class acosh_vari : public op_v_vari {
18  public:
19  acosh_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 
67  inline var acosh(const stan::agrad::var& a) {
68  if (boost::math::isinf(a.val()) && a > 0.0)
69  return var(new acosh_vari(a.val(),a.vi_));
70  return var(new acosh_vari(::acosh(a.val()),a.vi_));
71  }
72 
73  }
74 }
75 
76 #endif
fvar< T > acosh(const fvar< T > &x)
Definition: acosh.hpp:17
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
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27

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