public void argSortIndexes(VoidPtr ip, npy_intp m, VoidPtr sortData, npy_intp startingIndex, NPY_SORTKIND kind, int DivSize, int IntpDivSize) { if (kind == NPY_SORTKIND.NPY_MERGESORT) { argMergeSortIndexes(ip, m, sortData, startingIndex, DivSize, IntpDivSize); return; } if (kind == NPY_SORTKIND.NPY_QUICKSORT) { // use merge sort until we can get a faster quick sort. argMergeSortIndexes(ip, m, sortData, startingIndex, DivSize, IntpDivSize); //argQuickSortIndexes(ip, m, sortData, startingIndex, DivSize, IntpDivSize); return; } if (kind == NPY_SORTKIND.NPY_HEAPSORT) { throw new Exception("HEAPSORT not supported"); } throw new Exception("Unrecognized sort type"); }
internal static int NpyArray_ArgSortFunc(object o1, VoidPtr indices, npy_intp m, NpyArray a, NPY_SORTKIND kind) { VoidPtr sortData = o1 as VoidPtr; if (kind == NPY_SORTKIND.NPY_MERGESORT) { ArgSortIndexes(indices, m, new VoidPtr(sortData), 0, kind); } else { ArgSortIndexes(indices, m, new VoidPtr(sortData), 0, kind); } return(0); }
public void argSortIndexes(VoidPtr ip, npy_intp m, VoidPtr sortData, npy_intp startingIndex, NPY_SORTKIND kind, int DivSize, int IntpDivSize) { var data = sortData.datap as System.Object[]; var argSortDouble = new ArgSortData_OBJECT[m]; var adjustedIndex = startingIndex + (sortData.data_offset >> DivSize); for (int i = 0; i < m; i++) { argSortDouble[i] = new ArgSortData_OBJECT(i, data[i + adjustedIndex]); } //Array.Sort(argSortDouble); argSortDouble = argSortDouble.AsParallel().OrderBy(t => t).ToArray(); npy_intp[] _ip = (npy_intp[])ip.datap; for (int i = 0; i < m; i++) { _ip[i + (ip.data_offset >> IntpDivSize)] = argSortDouble[i].index - startingIndex; } }
internal static int NpyArray_SortFunc(object o1, npy_intp length, NpyArray NOTUSED, NPY_SORTKIND kind) { VoidPtr arr = o1 as VoidPtr; return(NpyArray_SortFuncTypeNum(arr, (int)(arr.data_offset / GetTypeSize(arr.type_num)), (int)length)); }
public static ndarray ArgSort(this ndarray a, int?axis = -1, NPY_SORTKIND kind = NPY_SORTKIND.NPY_QUICKSORT) { return(np.argsort(a, axis, kind)); }
public static ndarray Sort(this ndarray a, int?axis = -1, NPY_SORTKIND sortkind = NPY_SORTKIND.NPY_QUICKSORT) { return(np.sort(a, axis, sortkind, null)); }
internal static NpyArray NpyArray_ArgSort(NpyArray op, int axis, NPY_SORTKIND which) { return(numpyinternal.NpyArray_ArgSort(op, axis, which)); }
public static int NpyArray_Sort(NpyArray op, int axis, NPY_SORTKIND which) { return(numpyinternal.NpyArray_Sort(op, axis, which)); }