Stan Math Library  2.20.0
reverse mode automatic differentiation
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 <stan/math/rev/meta.hpp>
6 #include <stan/math/rev/core.hpp>
7 #include <cmath>
8 
9 namespace stan {
10 namespace math {
11 
12 namespace internal {
13 class acosh_vari : public op_v_vari {
14  public:
15  acosh_vari(double val, vari* avi) : op_v_vari(val, avi) {}
16  void chain() {
17  avi_->adj_ += adj_ / std::sqrt(avi_->val_ * avi_->val_ - 1.0);
18  }
19 };
20 } // namespace internal
21 
61 inline var acosh(const var& a) {
62  return var(new internal::acosh_vari(stan::math::acosh(a.val()), a.vi_));
63 }
64 
65 } // namespace math
66 } // namespace stan
67 #endif
fvar< T > sqrt(const fvar< T > &x)
Definition: sqrt.hpp:13
The variable implementation base class.
Definition: vari.hpp:30
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:33
friend class var
Definition: vari.hpp:32
const double val_
The value of this variable.
Definition: vari.hpp:38
void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
Definition: acosh.hpp:16
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:45
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
Definition: vari.hpp:44
acosh_vari(double val, vari *avi)
Definition: acosh.hpp:15
fvar< T > acosh(const fvar< T > &x)
Definition: acosh.hpp:13
double val() const
Return the value of this variable.
Definition: var.hpp:294

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