Automatic Differentiation
 
Loading...
Searching...
No Matches
min.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_MIN_HPP
2#define STAN_MATH_PRIM_FUN_MIN_HPP
3
7#include <algorithm>
8#include <vector>
9
10namespace stan {
11namespace math {
12
23template <typename T1, typename T2, require_all_arithmetic_t<T1, T2>* = nullptr>
24auto min(T1 x, T2 y) {
25 return std::min(x, y);
26}
27
40template <typename T, require_container_t<T>* = nullptr>
41inline value_type_t<T> min(const T& m) {
42 if (std::is_integral<value_type_t<T>>::value) {
43 check_nonzero_size("min", "int vector", m);
44 } else if (m.size() == 0) {
45 return INFTY;
46 }
48 m, [](const auto& x) { return x.minCoeff(); });
49}
50
51} // namespace math
52} // namespace stan
53
54#endif
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto min(T1 x, T2 y)
Returns the minimum coefficient of the two specified scalar arguments.
Definition min.hpp:24
void check_nonzero_size(const char *function, const char *name, const T_y &y)
Check if the specified matrix/vector is of non-zero size.
static constexpr double INFTY
Positive infinity.
Definition constants.hpp:46
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...