code: public static double[] applyIndices (double[] vector, int[] indices) {
          // Initialize the return array:
          final double[] retval = new double[indices.length];
  
          // Iterate over indices and populate:
          for (int i = 0; i < retval.length; i++) {
              retval[i] = vector[indices[i]];
          }
  
          // Done, return the return value:
          return retval;
      }
docs: Consumes an array and desired respective indices in an array and return a new array with values from the desired indices.
  
  @param vector Values.
  @param indices Desired indices for order.
  @return A new array.