| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 #ifdef _MSC_VER
10 #include <boost/math/special_functions/acosh.hpp>
11 using boost::math::acosh;
12 #endif
13
14 namespace stan {
15 namespace math {
16
17 namespace {
18 class acosh_vari : public op_v_vari {
19 public:
20 acosh_vari(double val, vari* avi) :
21 op_v_vari(val, avi) {
22 }
23 void chain() {
24 avi_->adj_ += adj_ / std::sqrt(avi_->val_ * avi_->val_ - 1.0);
25 }
26 };
27 }
28
68 inline var acosh(const var& a) {
69 if (boost::math::isinf(a.val()) && a > 0.0)
70 return var(new acosh_vari(a.val(), a.vi_));
71 return var(new acosh_vari(::acosh(a.val()), a.vi_));
72 }
73
74 }
75 }
76 #endif
core.hpp
stan::math::sqrt
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
boost::math::isinf
bool isinf(const stan::math::var &v)
Checks if the given number is infinite.
Definition: boost_isinf.hpp:22
stan::math::acosh
var acosh(const var &a)
The inverse hyperbolic cosine function for variables (C99).
Definition: acosh.hpp:68
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
stan::math::var::val
double val() const
Return the value of this variable.
Definition: var.hpp:233
stan::math::acosh
fvar< T > acosh(const fvar< T > &x)
Definition: acosh.hpp:14

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