Automatic Differentiation
 
Loading...
Searching...
No Matches
acos.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_ACOS_HPP
2#define STAN_MATH_REV_FUN_ACOS_HPP
3
13#include <cmath>
14#include <complex>
15
16namespace stan {
17namespace math {
18
55inline var acos(const var& x) {
56 return make_callback_var(std::acos(x.val()), [x](const auto& vi) mutable {
57 x.adj() -= vi.adj() / std::sqrt(1.0 - (x.val() * x.val()));
58 });
59}
60
68template <typename VarMat, require_var_matrix_t<VarMat>* = nullptr>
69inline auto acos(const VarMat& x) {
70 return make_callback_var(
71 x.val().array().acos().matrix(), [x](const auto& vi) mutable {
72 x.adj().array()
73 -= vi.adj().array() / (1.0 - (x.val().array().square())).sqrt();
74 });
75}
76
83inline std::complex<var> acos(const std::complex<var>& x) {
85}
86
87} // namespace math
88} // namespace stan
89#endif
std::complex< V > complex_acos(const std::complex< V > &x)
Return the arc cosine of the complex argument.
Definition acos.hpp:77
fvar< T > acos(const fvar< T > &x)
Definition acos.hpp:15
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 ...