1#ifndef STAN_MATH_PRIM_FUN_SORT_INDICES_HPP
2#define STAN_MATH_PRIM_FUN_SORT_INDICES_HPP
21template <
bool ascending,
typename C>
44 return xs_[i - 1] <
xs_[j - 1];
46 return xs_[i - 1] >
xs_[j - 1];
63template <
bool ascending,
typename C>
66 idx_t xs_size = xs.size();
67 std::vector<int> idxs;
69 for (idx_t i = 0; i < xs_size; ++i) {
73 std::sort(idxs.begin(), idxs.end(), comparator);
index_comparator(const C &xs)
Construct an index comparator holding a reference to the specified container.
bool operator()(int i, int j) const
Return true if the value at the first index is sorted in front of the value at the second index; this...
typename index_type< T >::type index_type_t
std::vector< int > sort_indices(const C &xs)
Return an integer array of indices of the specified container sorting the values in ascending or desc...
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...