Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
acosh.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_ACOSH_HPP
2 #define STAN_MATH_REV_SCAL_FUN_ACOSH_HPP
3 
4 #include <math.h>
5 #include <stan/math/rev/core.hpp>
6 #include <boost/math/special_functions/fpclassify.hpp>
7 #include <cmath>
8 
9 namespace stan {
10  namespace math {
11 
12  namespace {
13  class acosh_vari : public op_v_vari {
14  public:
15  acosh_vari(double val, vari* avi) :
16  op_v_vari(val, avi) {
17  }
18  void chain() {
19  avi_->adj_ += adj_ / std::sqrt(avi_->val_ * avi_->val_ - 1.0);
20  }
21  };
22  }
23 
63  inline var acosh(const var& a) {
64  if (boost::math::isinf(a.val()) && a > 0.0)
65  return var(new acosh_vari(a.val(), a.vi_));
66  return var(new acosh_vari(::acosh(a.val()), a.vi_));
67  }
68 
69  }
70 }
71 #endif
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
bool isinf(const stan::math::var &v)
Checks if the given number is infinite.
Definition: boost_isinf.hpp:22
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
double val() const
Return the value of this variable.
Definition: var.hpp:234
fvar< T > acosh(const fvar< T > &x)
Definition: acosh.hpp:14

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