Automatic Differentiation
 
Loading...
Searching...
No Matches
cosh.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_COSH_HPP
2#define STAN_MATH_REV_FUN_COSH_HPP
3
11#include <cmath>
12#include <complex>
13
14namespace stan {
15namespace math {
16
44inline var cosh(const var& a) {
45 return make_callback_var(std::cosh(a.val()), [a](const auto& vi) mutable {
46 a.adj() += vi.adj() * std::sinh(a.val());
47 });
48}
49
57template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
58inline auto cosh(const VarMat& a) {
59 return make_callback_var(
60 a.val().array().cosh().matrix(), [a](const auto& vi) mutable {
61 a.adj() += vi.adj().cwiseProduct(a.val().array().sinh().matrix());
62 });
63}
64
71inline std::complex<var> cosh(const std::complex<var>& z) {
73}
74
75} // namespace math
76} // namespace stan
77#endif
std::complex< V > complex_cosh(const std::complex< V > &z)
Return the hyperbolic cosine of the complex argument.
Definition cosh.hpp:71
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
fvar< T > cosh(const fvar< T > &x)
Definition cosh.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...