Automatic Differentiation
 
Loading...
Searching...
No Matches
is_odd.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_IS_ODD_HPP
2#define STAN_MATH_PRIM_FUN_IS_ODD_HPP
3
6
7namespace stan {
8namespace math {
9
17template <typename T, require_integral_t<T>* = nullptr>
18inline int is_odd(T n) {
19 return n % 2 != 0 ? 1 : 0;
20}
21
25struct is_odd_fun {
26 template <typename T>
27 static inline int fun(const T& x) {
28 return is_odd(static_cast<int>(x));
29 }
30};
31
39template <typename T, require_container_t<T>* = nullptr>
40inline auto is_odd(T&& x) {
41 return apply_scalar_unary<is_odd_fun, T>::apply(std::forward<T>(x));
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
int is_odd(T n)
Return 1 if the integer is odd and 0 otherwise.
Definition is_odd.hpp:18
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static int fun(const T &x)
Definition is_odd.hpp:27
Vectorization wrapper for is_odd.
Definition is_odd.hpp:25