Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
min.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__MIN_HPP
2 #define STAN__MATH__MATRIX__MIN_HPP
3 
4 #include <stdexcept>
5 #include <vector>
7 
8 namespace stan {
9  namespace math {
10 
18  inline int min(const std::vector<int>& x) {
19  if (x.size() == 0)
20  throw std::domain_error("error: cannot take min of empty int vector");
21  int min = x[0];
22  for (size_t i = 1; i < x.size(); ++i)
23  if (x[i] < min)
24  min = x[i];
25  return min;
26  }
27 
35  template <typename T>
36  inline T min(const std::vector<T>& x) {
37  if (x.size() == 0)
38  return std::numeric_limits<T>::infinity();
39  T min = x[0];
40  for (size_t i = 1; i < x.size(); ++i)
41  if (x[i] < min)
42  min = x[i];
43  return min;
44  }
45 
52  template <typename T, int R, int C>
53  inline T min(const Eigen::Matrix<T,R,C>& m) {
54  if (m.size() == 0)
55  return std::numeric_limits<double>::infinity();
56  return m.minCoeff();
57  }
58 
59  }
60 }
61 #endif
double min(const double a, const double b)
Definition: min.hpp:7

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