Here you can find the source of permuteCols(double[][] ary, int[] idx)
public static double[][] permuteCols(double[][] ary, int[] idx)
//package com.java2s; //License from project: Apache License public class Main { public static double[][] permuteCols(double[][] ary, int[] idx) { 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]]; }/* www . j a v a 2 s . c o m*/ return res; } }