/** * Sort an integer array using Quick Sort. * @param sortVal The integer array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sort(int[] sortVal, boolean asc) { return qSort(sortVal, asc); } /**
/** * Sort an double array using Quick Sort. * @param sortVal The double array to be sorted. * @return The sorted indexes. */ public static int[] sortDesc(final List<Double> sortVal) { return qSortDouble(sortVal, false); }
/** * Sort an long array using Quick Sort. * @param sortVal The long array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sortLong(final List<Long> sortVal, final boolean asc) { return qSortLong(sortVal, asc); }
public RankList getRanking(final short fid) { final double[] score = new double[rl.length]; for (int i = 0; i < rl.length; i++) { score[i] = rl[i].getFeatureValue(fid); } final int[] idx = Sorter.sort(score, false); return new RankList(this, idx); }
public static int[] sortString(List<String> sortVal, boolean asc) { return qSortString(sortVal, asc); } /**
public RankList getCorrectRanking() { double[] score = new double[rl.length]; for(int i=0;i<rl.length;i++) score[i] = rl[i].getLabel(); int[] idx = Sorter.sort(score, false); return new RankList(this, idx); }
public static int[] sortString(final List<String> sortVal, final boolean asc) { return qSortString(sortVal, asc); }
/** * Sort an integer array using Quick Sort. * @param sortVal The integer array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sort(List<Integer> sortVal, boolean asc) { return qSort(sortVal, asc); } public static int[] sortString(List<String> sortVal, boolean asc)
private double getIdealDCG(final int[] rel, final int topK) { final int[] idx = Sorter.sort(rel, false); double dcg = 0; for (int i = 0; i < topK; i++) { dcg += gain(rel[idx[i]]) * discount(i); } return dcg; } }
private static int[] qSortString(final List<String> l, final boolean asc) { final int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<>(); for (int i = 0; i < l.size(); i++) { idxList.add(i); } idxList = qSortString(l, idxList, asc); for (int i = 0; i < l.size(); i++) { idx[i] = idxList.get(i); } return idx; }
/** * Sort an double array using Quick Sort. * @param sortVal The double array to be sorted. * @return The sorted indexes. */ public static int[] sortDesc(List<Double> sortVal) { return qSortDouble(sortVal, false); }
/** * Sort an long array using Quick Sort. * @param sortVal The long array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sortLong(List<Long> sortVal, boolean asc) { return qSortLong(sortVal, asc); } /**
/** * Sort an integer array using Quick Sort. * @param sortVal The integer array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sort(final int[] sortVal, final boolean asc) { return qSort(sortVal, asc); }
public RankList getCorrectRanking() { final double[] score = new double[rl.length]; for (int i = 0; i < rl.length; i++) { score[i] = rl[i].getLabel(); } final int[] idx = Sorter.sort(score, false); return new RankList(this, idx); }
private static int[] qSortString(List<String> l, boolean asc) { count = 0; int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<Integer>(); for(int i=0;i<l.size();i++) idxList.add(i); System.out.print("Sorting..."); idxList = qSortString(l, idxList, asc); for(int i=0;i<l.size();i++) idx[i] = idxList.get(i); System.out.println("[Done.]"); return idx; } /**
/** * Quick sort internal * @param l The list to sort. * @param asc Ascending/Descendingly parameter. * @return The sorted indexes. */ private static int[] qSortDouble(final List<Double> l, final boolean asc) { final int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<>(); for (int i = 0; i < l.size(); i++) { idxList.add(i); } idxList = qSortDouble(l, idxList, asc); for (int i = 0; i < l.size(); i++) { idx[i] = idxList.get(i); } return idx; }
/** * Quick sort internal * @param l The list to sort. * @param asc Ascending/Descendingly parameter. * @return The sorted indexes. */ private static int[] qSortLong(final List<Long> l, final boolean asc) { final int[] idx = new int[l.size()]; List<Integer> idxList = new ArrayList<>(); for (int i = 0; i < l.size(); i++) { idxList.add(i); } idxList = qSortLong(l, idxList, asc); for (int i = 0; i < l.size(); i++) { idx[i] = idxList.get(i); } return idx; }
/** * Sort an integer array using Quick Sort. * @param sortVal The integer array to be sorted. * @param asc TRUE to sort ascendingly, FALSE to sort descendingly. * @return The sorted indexes. */ public static int[] sort(final List<Integer> sortVal, final boolean asc) { return qSort(sortVal, asc); }
private double getIdealDCG(int[] rel, int topK) { int[] idx = Sorter.sort(rel, false); double dcg = 0; for(int i=0;i<topK;i++) dcg += gain(rel[idx[i]]) * discount(i); return dcg; } }
left = qSortString(l, left, asc); right = qSortString(l, right, asc);