Stan Math Library  2.20.0
reverse mode automatic differentiation
sort_desc.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_SORT_DESC_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_SORT_DESC_HPP
3 
6 #include <algorithm>
7 #include <functional>
8 #include <vector>
9 
10 namespace stan {
11 namespace math {
12 
21 template <typename T>
22 inline std::vector<T> sort_desc(std::vector<T> xs) {
23  check_not_nan("sort_asc", "container argument", xs);
24  std::sort(xs.begin(), xs.end(), std::greater<T>());
25  return xs;
26 }
27 
28 } // namespace math
29 } // namespace stan
30 #endif
std::vector< T > sort_desc(std::vector< T > xs)
Return the specified standard vector in descending order.
Definition: sort_desc.hpp:22
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.

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