| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

atanh.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_ATANH_HPP
2 #define STAN_MATH_REV_SCAL_FUN_ATANH_HPP
3
4 #include <math.h>
5 #include <stan/math/rev/core.hpp>
6 #include <cmath>
7 #include <limits>
8
9 #ifdef _MSC_VER
10 #include <boost/math/special_functions/atanh.hpp>
11 using boost::math::atanh;
12 #endif
13
14 namespace stan {
15 namespace math {
16
17 namespace {
18 class atanh_vari : public op_v_vari {
19 public:
20 atanh_vari(double val, vari* avi) :
21 op_v_vari(val, avi) {
22 }
23 void chain() {
24 avi_->adj_ += adj_ / (1.0 - avi_->val_ * avi_->val_);
25 }
26 };
27 }
28
69 inline var atanh(const var& a) {
70 if (a == 1.0)
71 return var(new atanh_vari(std::numeric_limits<double>::infinity(),
72 a.vi_));
73 if (a == -1.0)
74 return var(new atanh_vari(-std::numeric_limits<double>::infinity(),
75 a.vi_));
76 return var(new atanh_vari(::atanh(a.val()), a.vi_));
77 }
78
79 }
80 }
81 #endif
core.hpp
stan::math::atanh
fvar< T > atanh(const fvar< T > &x)
Definition: atanh.hpp:13
stan
Definition: log_sum_exp.hpp:8
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
stan::math::atanh
var atanh(const var &a)
The inverse hyperbolic tangent function for variables (C99).
Definition: atanh.hpp:69
stan::math::var::val
double val() const
Return the value of this variable.
Definition: var.hpp:229

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