22 #include <tensor/tensor.h>
27 sort(
const RTensor &v,
bool reverse)
31 std::sort(output.begin(), output.end(), std::greater<double>());
33 std::sort(output.begin(), output.end(), std::less<double>());
38 template<
typename elt_t>
42 Compare(
const elt_t *newp) : p(newp) {};
43 int operator()(
size_t i1,
size_t i2) {
44 return p[i1] < p [i2];
48 template<
typename elt_t>
52 CompareInv(
const elt_t *newp) : p(newp) {};
53 int operator()(
size_t i1,
size_t i2) {
59 sort_indices(
const RTensor &v,
bool reverse)
62 Indices output = iota(0,v.size()-1);
64 CompareInv<double> c(v.begin());
65 std::sort(output.begin(), output.end(), c);
67 Compare<double> c(v.begin());
68 std::sort(output.begin(), output.end(), c);