code: public static void permute( int[] perm , double []input , double[]output , int N ) {
          for (int k = 0; k < N; k++) {
              output[k] = input[perm[k]];
          }
      }
docs: Permutes a vector.  output[i] = input[perm[i]]
  
  @param perm (Input) permutation vector
  @param input (Input) Vector which is to be permuted
  @param output (Output) Where the permuted vector is stored.
  @param N Number of elements in the vector.