List of utility methods to do Array Permute
double[][] | permuteCols(double[][] ary, int[] idx) permute Cols if (ary == null) return null; assert ary[0].length == idx.length : "Number of columns must match permutation vector length: Got " + ary[0].length + " != " + idx.length; double[][] res = new double[ary.length][ary[0].length]; for (int j = 0; j < ary[0].length; j++) { for (int i = 0; i < ary.length; i++) res[i][j] = ary[i][idx[j]]; ... |
List | permuteList(List permute List List<String> result = new ArrayList<String>(); Random rand = new Random(System.currentTimeMillis()); int count = 0; int currIndex = inList.size() - 1; for (; count < inList.size(); count++) { int randPosition = rand.nextInt(currIndex + 1); String currLine = inList.get(randPosition); result.add(currLine); ... |
double[][] | permuteRows(double[][] ary, int[] idx) permute Rows if (ary == null) return null; assert ary.length == idx.length : "Number of rows must match permutation vector length: Got " + ary.length + " != " + idx.length; double[][] res = new double[ary.length][ary[0].length]; for (int i = 0; i < ary.length; i++) res[i] = permute(ary[i], idx); return res; ... |
float[] | permuteVector(float[] indexVector, int rotation) permute Vector if (Math.abs(rotation) > indexVector.length) { rotation = rotation % indexVector.length; float[] permutedVector = new float[indexVector.length]; int max = indexVector.length; for (int x = 0; x < max; x++) { int newIndex = x + rotation; if (newIndex >= max) { ... |