Automatic Differentiation
 
Loading...
Searching...
No Matches
sort_asc.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SORT_ASC_HPP
2#define STAN_MATH_PRIM_FUN_SORT_ASC_HPP
3
7#include <algorithm>
8#include <vector>
9
10namespace stan {
11namespace math {
12
21template <typename T>
22inline std::vector<T> sort_asc(std::vector<T> xs) {
23 check_not_nan("sort_asc", "container argument", xs);
24 std::sort(xs.begin(), xs.end());
25 return xs;
26}
27
37template <typename EigVec, require_eigen_vector_t<EigVec>* = nullptr>
38inline plain_type_t<EigVec> sort_asc(EigVec&& xs) {
39 plain_type_t<EigVec> x = std::forward<EigVec>(xs);
40 check_not_nan("sort_asc", "container argument", x);
41 std::sort(x.data(), x.data() + x.size());
42 return x;
43}
44
45} // namespace math
46} // namespace stan
47
48#endif
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
auto sort_asc(T &&input)
Sort the (row)vector in ascending order.
Definition sort_asc.hpp:21
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...