Automatic Differentiation
 
Loading...
Searching...
No Matches
atan.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_ATAN_HPP
2#define STAN_MATH_REV_FUN_ATAN_HPP
3
18#include <cmath>
19#include <complex>
20
21namespace stan {
22namespace math {
23
54inline var atan(const var& x) {
55 return make_callback_var(std::atan(x.val()), [x](const auto& vi) mutable {
56 x.adj() += vi.adj() / (1.0 + (x.val() * x.val()));
57 });
58}
59
69template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
70inline auto atan(const VarMat& x) {
71 return make_callback_var(
72 x.val().array().atan().matrix(), [x](const auto& vi) mutable {
73 x.adj().array()
74 += vi.adj().array() / (1.0 + (x.val().array().square()));
75 });
76}
83inline std::complex<var> atan(const std::complex<var>& z) {
85}
86
87} // namespace math
88} // namespace stan
89#endif
std::complex< V > complex_atan(const std::complex< V > &z)
Return the arc tangent of the complex argument.
Definition atan.hpp:73
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 > atan(const fvar< T > &x)
Definition atan.hpp:15
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...