예제 #1
0
        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");
        }
예제 #2
0
        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);
        }
예제 #3
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;
            }
        }
예제 #4
0
        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));
        }
예제 #5
0
 public static ndarray ArgSort(this ndarray a, int?axis = -1, NPY_SORTKIND kind = NPY_SORTKIND.NPY_QUICKSORT)
 {
     return(np.argsort(a, axis, kind));
 }
예제 #6
0
 public static ndarray Sort(this ndarray a, int?axis = -1, NPY_SORTKIND sortkind = NPY_SORTKIND.NPY_QUICKSORT)
 {
     return(np.sort(a, axis, sortkind, null));
 }
예제 #7
0
 internal static NpyArray NpyArray_ArgSort(NpyArray op, int axis, NPY_SORTKIND which)
 {
     return(numpyinternal.NpyArray_ArgSort(op, axis, which));
 }
예제 #8
0
 public static int NpyArray_Sort(NpyArray op, int axis, NPY_SORTKIND which)
 {
     return(numpyinternal.NpyArray_Sort(op, axis, which));
 }