min.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_MIN_HPP
#define STAN_MATH_PRIM_MAT_FUN_MIN_HPP
#include <stan/math/prim/arr/err/check_nonzero_size.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <algorithm>
#include <limits>
#include <vector>
namespace stan {
namespace math {
inline int min(const std::vector<int>& x) {
check_nonzero_size("min", "int vector", x);
int min = x[0];
for (size_t i = 1; i < x.size(); ++i)
if (x[i] < min)
min = x[i];
return min;
}
template <typename T>
inline T min(const std::vector<T>& x) {
if (x.size() == 0)
return std::numeric_limits<T>::infinity();
T min = x[0];
for (size_t i = 1; i < x.size(); ++i)
if (x[i] < min)
min = x[i];
return min;
}
template <typename T, int R, int C>
inline T min(const Eigen::Matrix<T, R, C>& m) {
if (m.size() == 0)
return std::numeric_limits<double>::infinity();
return m.minCoeff();
}
}
}
#endif
stan::math::check_nonzero_size
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.
Definition: check_nonzero_size.hpp:27
stan::math::min
int min(const std::vector< int > &x)
Returns the minimum coefficient in the specified column vector.
Definition: min.hpp:20
stan
Definition: log_sum_exp.hpp:8
Eigen.hpp
check_nonzero_size.hpp

[ Stan Home Page ] © 2011–2016, Stan Development Team.