Automatic Differentiation
 
Loading...
Searching...
No Matches
acos.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ACOS_HPP
2#define STAN_MATH_PRIM_FUN_ACOS_HPP
3
15#include <cmath>
16#include <complex>
17
18namespace stan {
19namespace math {
20
28template <typename T, require_arithmetic_t<T>* = nullptr>
29inline auto acos(T&& x) {
30 return std::acos(x);
31}
32
40template <typename T, require_complex_bt<std::is_arithmetic, T>* = nullptr>
41inline auto acos(T&& x) {
42 return std::acos(x);
43}
44
52struct acos_fun {
53 template <typename T>
54 static inline auto fun(T&& x) {
55 return acos(std::forward<T>(x));
56 }
57};
58
67template <typename Container, require_ad_container_t<Container>* = nullptr>
68inline auto acos(Container&& x) {
70 std::forward<Container>(x));
71}
72
81template <typename Container,
83inline auto acos(Container&& x) {
84 return apply_vector_unary<Container>::apply(
85 std::forward<Container>(x), [](auto&& v) { return v.array().acos(); });
86}
87
88namespace internal {
96template <typename V>
97inline std::complex<V> complex_acos(const std::complex<V>& x) {
98 return 0.5 * pi() - asin(x);
99}
100} // namespace internal
101
102} // namespace math
103} // namespace stan
104
105#endif
require_t< container_type_check_base< is_container, base_type_t, TypeCheck, Check... > > require_container_bt
Require type satisfies is_container.
std::complex< V > complex_acos(const std::complex< V > &x)
Return the arc cosine of the complex argument.
Definition acos.hpp:97
fvar< T > acos(const fvar< T > &x)
Definition acos.hpp:16
static constexpr double pi()
Return the value of pi.
Definition constants.hpp:36
fvar< T > asin(const fvar< T > &x)
Definition asin.hpp:16
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
static auto fun(T &&x)
Definition acos.hpp:54
Structure to wrap acos() so it can be vectorized.
Definition acos.hpp:52
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...