Automatic Differentiation
 
Loading...
Searching...
No Matches
to_int.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_TO_INT_HPP
2#define STAN_MATH_PRIM_FUN_TO_INT_HPP
3
6
7namespace stan {
8namespace math {
9
18template <typename T, require_integral_t<T>* = nullptr>
19inline T to_int(T x) {
20 return std::forward<T>(x);
21}
22
41template <typename T, require_floating_point_t<T>* = nullptr>
42inline int to_int(T x) {
43 static constexpr const char* function = "to_int";
44 check_bounded(function, "x", x, std::numeric_limits<int>::min(),
45 std::numeric_limits<int>::max());
46 return static_cast<int>(x);
47}
48
57struct to_int_fun {
58 template <typename T>
59 static inline auto fun(const T& x) {
60 return to_int(x);
61 }
62};
63
72template <typename Container,
74inline auto to_int(const Container& x) {
76}
77
78} // namespace math
79} // namespace stan
80
81#endif
require_t< container_type_check_base< is_std_vector, scalar_type_t, TypeCheck, Check... > > require_std_vector_st
Require type satisfies is_std_vector.
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
T to_int(T x)
Returns the input scalar as an integer type.
Definition to_int.hpp:19
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 auto fun(const T &x)
Definition to_int.hpp:59
Return elementwise integer value of the specified real-valued container.
Definition to_int.hpp:57