Logo Search packages:      
Sourcecode: jblas version File versions  Download package

int [] org::jblas::la::FloatMatrix::sortingPermutation (  )  [inline]

Get the sorting permutation.

Returns:
an int[] array such that which indexes the elements in sorted order.

Definition at line 1878 of file FloatMatrix.java.

References data.

Referenced by columnSortingPermutations(), and rowSortingPermutations().

                                      {
        Integer[] indices = new Integer[length];

        for (int i = 0; i < length; i++) {
            indices[i] = i;
        }

        final float[] array = data;

        Arrays.sort(indices, new Comparator() {

            public int compare(Object o1, Object o2) {
                int i = (Integer) o1;
                int j = (Integer) o2;
                if (array[i] < array[j]) {
                    return -1;
                } else if (array[i] == array[j]) {
                    return 0;
                } else {
                    return 1;
                }
            }
        });

        int[] result = new int[length];

        for (int i = 0; i < length; i++) {
            result[i] = indices[i];
        }

        return result;
    }


Generated by  Doxygen 1.6.0   Back to index