22 #include <tensor/tensor.h>
26 bool operator<(
const cdouble &a,
const cdouble &b)
28 return (real(a) < real(b));
32 sort(
const CTensor &v,
bool reverse)
36 std::sort(output.begin(), output.end(), std::greater<double>());
38 std::sort(output.begin(), output.end(), std::less<double>());
43 template<
typename elt_t>
47 Compare(
const elt_t *newp) : p(newp) {};
48 int operator()(
size_t i1,
size_t i2) {
49 return p[i1] < p [i2];
53 template<
typename elt_t>
57 CompareInv(
const elt_t *newp) : p(newp) {};
58 int operator()(
size_t i1,
size_t i2) {
64 sort_indices(
const CTensor &v,
bool reverse)
67 Indices output = iota(0,v.size()-1);
69 CompareInv<double> c(v.begin());
70 std::sort(output.begin(), output.end(), c);
72 Compare<double> c(v.begin());
73 std::sort(output.begin(), output.end(), c);