Automatic Differentiation
 
Loading...
Searching...
No Matches
is_even.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_IS_EVEN_HPP
2#define STAN_MATH_PRIM_FUN_IS_EVEN_HPP
3
6
7namespace stan {
8namespace math {
9
17template <typename T, require_integral_t<T>* = nullptr>
18inline int is_even(T n) {
19 return n % 2 == 0 ? 1 : 0;
20}
21
26 template <typename T>
27 static inline int fun(const T& x) {
28 return is_even(static_cast<int>(x));
29 }
30};
31
39template <typename T, require_container_t<T>* = nullptr>
40inline auto is_even(T&& x) {
41 return apply_scalar_unary<is_even_fun, T>::apply(std::forward<T>(x));
42}
43
44} // namespace math
45} // namespace stan
46
47#endif
int is_even(T n)
Return 1 if the integer is even and 0 otherwise.
Definition is_even.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_even.hpp:27
Vectorization wrapper for is_even.
Definition is_even.hpp:25