1#ifndef STAN_MATH_REV_FUN_TANH_HPP
2#define STAN_MATH_REV_FUN_TANH_HPP
44 const auto a_cosh = std::cosh(a.val());
45 a.adj() += vi.adj_ / (a_cosh * a_cosh);
56template <
typename VarMat, require_var_matrix_t<VarMat>* =
nullptr>
57inline auto tanh(
const VarMat& a) {
59 a.val().array().tanh().matrix(), [a](
const auto& vi)
mutable {
60 a.adj().array() += vi.adj_.array() / (a.val().array().cosh().square());
70inline std::complex<var>
tanh(
const std::complex<var>& z) {
std::complex< V > complex_tanh(const std::complex< V > &z)
Return the hyperbolic tangent of the complex argument.
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 > tanh(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...