70 { |
70 { |
71 return math::min(x, math::min(y, rest...)); |
71 return math::min(x, math::min(y, rest...)); |
72 } |
72 } |
73 constexpr double infinity = std::numeric_limits<double>::infinity(); |
73 constexpr double infinity = std::numeric_limits<double>::infinity(); |
74 constexpr long double pi = M_PIl; |
74 constexpr long double pi = M_PIl; |
75 |
75 // Returns the minimum value of a container |
|
76 template<typename T> |
|
77 inline auto nmin(T&& values) |
|
78 { |
|
79 auto it = std::begin(values); |
|
80 auto result_p = it; |
|
81 for (++it; it != std::end(values); ++it) |
|
82 { |
|
83 if (*it < *result_p) |
|
84 result_p = it; |
|
85 } |
|
86 return *result_p; |
|
87 } |
|
88 // Returns the maximum value of a container |
|
89 template<typename T> |
|
90 inline auto nmax(T&& values) |
|
91 { |
|
92 auto it = std::begin(values); |
|
93 auto result_p = it; |
|
94 for (++it; it != std::end(values); ++it) |
|
95 { |
|
96 if (*it > *result_p) |
|
97 result_p = it; |
|
98 } |
|
99 return *result_p; |
|
100 } |
76 /* |
101 /* |
77 * Returns the empty sum. (recursion base) |
102 * Returns the empty sum. (recursion base) |
78 */ |
103 */ |
79 template<typename T> |
104 template<typename T> |
80 constexpr T sum() |
105 constexpr T sum() |