Source: tests/utility/sortperm.cpp 
 
 
   15 #include <tests/myratest.h>    20 ADD_TEST(
"sortperm",
"[utility]")
    24   std::vector<float> v1;
    25   for (
int v = 0; v < V; ++v)
    26     v1.push_back( random<float>() );
    27   myra::out() << 
"v1 = " << v1 << std::endl;
    29   std::vector<int> perm = 
sortperm(v1.begin(), v1.end(), std::less<float>());
    30   myra::out() << 
"perm = " << perm << std::endl;
    32   std::vector<float> v2;
    33   for (
int v = 0; v < V; ++v)
    34     v2.push_back( v1[perm[v]] );
    35   myra::out() << 
"v2 = " << v2 << std::endl;
    38   for (
int v = 0; v < V-1; ++v)
 std::vector< int > sortperm(Iterator begin, Iterator end, const Comparator &cmp)
Given a range, returns the permutation that will place it in sorted order according to cmp()...
Definition: sortperm.h:50
Given a range, returns the permutation that will place it in sorted order. 
Definition: stlprint.h:32
Routines for printing the contents of various std::container's to a std::ostream using operator <<...
Simplistic random number functions. 
 
 Results:  [PASS] 
 
 
v1 = [ 0.753231 0.612978 0.773258 -0.568787 0.0041765 -0.0856677 0.346901 0.450497 0.232718 -0.556931 ] (10)
perm = [ 3 9 5 4 8 6 7 1 0 2 ] (10)
v2 = [ -0.568787 -0.556931 -0.0856677 0.0041765 0.232718 0.346901 0.450497 0.612978 0.753231 0.773258 ] (10)
 
 Go back to Summary of /test programs.