Java Array Permute permuteCols(double[][] ary, int[] idx)

Here you can find the source of permuteCols(double[][] ary, int[] idx)

Description

permute Cols

License

Apache License

Declaration

public static double[][] permuteCols(double[][] ary, int[] idx) 

Method Source Code

//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;
    }
}

Related

  1. permute(int[] p, Object[] data, boolean clone)
  2. permute(String str, int startIndex, int endIndex)
  3. permute(T[] array)
  4. permute(T[] values)
  5. permuteArray(int[] array, Integer[] permutation)
  6. permuteList(List inList)
  7. permuteRows(double[][] ary, int[] idx)
  8. permuteVector(float[] indexVector, int rotation)