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