Automatic Differentiation
 
Loading...
Searching...
No Matches
sinh.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_SINH_HPP
2#define STAN_MATH_REV_FUN_SINH_HPP
3
11#include <cmath>
12#include <complex>
13
14namespace stan {
15namespace math {
16
44inline var sinh(const var& a) {
45 return make_callback_var(std::sinh(a.val()), [a](const auto& vi) mutable {
46 a.adj() += vi.adj() * std::cosh(a.val());
47 });
48}
49
58template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
59inline auto sinh(const VarMat& a) {
60 return make_callback_var(
61 a.val().array().sinh().matrix(), [a](const auto& vi) mutable {
62 a.adj() += vi.adj().cwiseProduct(a.val().array().cosh().matrix());
63 });
64}
65
72inline std::complex<var> sinh(const std::complex<var>& z) {
74}
75
76} // namespace math
77} // namespace stan
78#endif
std::complex< V > complex_sinh(const std::complex< V > &z)
Return the hyperbolic sine of the complex argument.
Definition sinh.hpp:69
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 > sinh(const fvar< T > &x)
Definition sinh.hpp:13
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...