numpy
2.0.0
|
#include <Python.h>
#include "structmember.h"
#include "numpy/arrayobject.h"
#include "numpy/arrayscalars.h"
#include "numpy/npy_math.h"
#include "npy_config.h"
#include "npy_pycompat.h"
#include "common.h"
#include "arrayobject.h"
#include "ctors.h"
#include "lowlevel_strided_loops.h"
#include "item_selection.h"
#include "npy_sort.h"
#define _MULTIARRAYMODULE |
#define NPY_NO_DEPRECATED_API NPY_API_VERSION |
#define PY_SSIZE_T_CLEAN |
#define SWAPAXES | ( | op, | |
ap | |||
) |
{ \ orign = PyArray_NDIM(ap)-1; \ if (axis != orign) { \ (op) = (PyArrayObject *)PyArray_SwapAxes((ap), axis, orign); \ Py_DECREF((ap)); \ if ((op) == NULL) return NULL; \ } \ else (op) = (ap); \ }
#define SWAPAXES2 | ( | ap | ) |
{ \ orign = PyArray_NDIM(ap)-1; \ if (axis != orign) { \ SWAPINTP(PyArray_DIMS(ap)[axis], PyArray_DIMS(ap)[orign]); \ SWAPINTP(PyArray_STRIDES(ap)[axis], PyArray_STRIDES(ap)[orign]); \ PyArray_UpdateFlags(ap, NPY_ARRAY_C_CONTIGUOUS | \ NPY_ARRAY_F_CONTIGUOUS); \ } \ }
#define SWAPBACK | ( | op, | |
ap | |||
) |
{ \ if (axis != orign) { \ (op) = (PyArrayObject *)PyArray_SwapAxes((ap), axis, orign); \ Py_DECREF((ap)); \ if ((op) == NULL) return NULL; \ } \ else (op) = (ap); \ }
#define SWAPBACK2 | ( | ap | ) |
{ \ if (axis != orign) { \ SWAPINTP(PyArray_DIMS(ap)[axis], PyArray_DIMS(ap)[orign]); \ SWAPINTP(PyArray_STRIDES(ap)[axis], PyArray_STRIDES(ap)[orign]); \ PyArray_UpdateFlags(ap, NPY_ARRAY_C_CONTIGUOUS | \ NPY_ARRAY_F_CONTIGUOUS); \ } \ }
static PyObject* _new_argsort | ( | PyArrayObject * | op, |
int | axis, | ||
NPY_SORTKIND | which | ||
) | [static] |
Referenced by argsort_static_compare().
static int _new_sort | ( | PyArrayObject * | op, |
int | axis, | ||
NPY_SORTKIND | which | ||
) | [static] |
References _strided_byte_swap(), _unaligned_strided_byte_copy(), PyArrayIterObject_tag::dataptr, PyArray_ITER_NEXT, PyDataMem_FREE(), and PyDataMem_NEW().
static int argsort_static_compare | ( | const void * | ip1, |
const void * | ip2 | ||
) | [static] |
References _new_argsort().
NPY_NO_EXPORT npy_intp count_boolean_trues | ( | int | ndim, |
char * | data, | ||
npy_intp * | ashape, | ||
npy_intp * | astrides | ||
) |
static int local_argsearch_left | ( | PyArrayObject * | arr, |
PyArrayObject * | key, | ||
PyArrayObject * | sorter, | ||
PyArrayObject * | ret | ||
) | [static] |
static int local_argsearch_right | ( | PyArrayObject * | arr, |
PyArrayObject * | key, | ||
PyArrayObject * | sorter, | ||
PyArrayObject * | ret | ||
) | [static] |
References NPY_ARRAY_DEFAULT, NPY_ARRAY_NOTSWAPPED, NPY_BEGIN_THREADS_DEF, NPY_INTP, Py_TYPE, PyArray_CheckFromAny(), PyArray_DESCR, PyArray_DescrFromObject(), PyArray_DescrFromType(), PyArray_DIMS, PyArray_FromArray(), PyArray_ISINTEGER, PyArray_NDIM, PyArray_New(), and PyArray_SIZE.
static void local_search_left | ( | PyArrayObject * | arr, |
PyArrayObject * | key, | ||
PyArrayObject * | ret | ||
) | [static] |
Referenced by PyArray_SearchSorted().
static void local_search_right | ( | PyArrayObject * | arr, |
PyArrayObject * | key, | ||
PyArrayObject * | ret | ||
) | [static] |
Referenced by PyArray_SearchSorted().
NPY_NO_EXPORT PyObject* PyArray_ArgSort | ( | PyArrayObject * | op, |
int | axis, | ||
NPY_SORTKIND | which | ||
) |
References NPY_HEAPSORT, npy_heapsort(), NPY_MERGESORT, npy_mergesort(), NPY_QUICKSORT, and npy_quicksort().
NPY_NO_EXPORT PyObject* PyArray_Choose | ( | PyArrayObject * | ip, |
PyObject * | op, | ||
PyArrayObject * | out, | ||
NPY_CLIPMODE | clipmode | ||
) |
NPY_NO_EXPORT PyObject* PyArray_Compress | ( | PyArrayObject * | self, |
PyObject * | condition, | ||
int | axis, | ||
PyArrayObject * | out | ||
) |
NPY_NO_EXPORT PyObject* PyArray_Diagonal | ( | PyArrayObject * | self, |
int | offset, | ||
int | axis1, | ||
int | axis2 | ||
) |
NPY_NO_EXPORT PyObject* PyArray_LexSort | ( | PyObject * | sort_keys, |
int | axis | ||
) |
NPY_NO_EXPORT PyObject* PyArray_MultiIndexGetItem | ( | PyArrayObject * | self, |
npy_intp * | multi_index | ||
) |
NPY_NO_EXPORT int PyArray_MultiIndexSetItem | ( | PyArrayObject * | self, |
npy_intp * | multi_index, | ||
PyObject * | obj | ||
) |
NPY_NO_EXPORT PyObject* PyArray_Nonzero | ( | PyArrayObject * | self | ) |
NPY_NO_EXPORT PyObject* PyArray_PutMask | ( | PyArrayObject * | self, |
PyObject * | values0, | ||
PyObject * | mask0 | ||
) |
<
NPY_NO_EXPORT PyObject* PyArray_PutTo | ( | PyArrayObject * | self, |
PyObject * | values0, | ||
PyObject * | indices0, | ||
NPY_CLIPMODE | clipmode | ||
) |
NPY_NO_EXPORT PyObject* PyArray_Repeat | ( | PyArrayObject * | aop, |
PyObject * | op, | ||
int | axis | ||
) |
NPY_NO_EXPORT PyObject* PyArray_SearchSorted | ( | PyArrayObject * | op1, |
PyObject * | op2, | ||
NPY_SEARCHSIDE | side, | ||
PyObject * | perm | ||
) |
result is an array of indexes, one for each element in op2, such that if the item were to be inserted in op1 just before that index the array would still be in sorted order.
Binary search is used to find the indexes.
References local_search_left(), local_search_right(), NPY_BEGIN_THREADS_DESCR, NPY_END_THREADS_DESCR, NPY_SEARCHLEFT, NPY_SEARCHRIGHT, and PyArray_DESCR.
NPY_NO_EXPORT int PyArray_Sort | ( | PyArrayObject * | op, |
int | axis, | ||
NPY_SORTKIND | which | ||
) |
<
NPY_NO_EXPORT PyObject* PyArray_TakeFrom | ( | PyArrayObject * | self0, |
PyObject * | indices0, | ||
int | axis, | ||
PyArrayObject * | out, | ||
NPY_CLIPMODE | clipmode | ||
) |
References check_and_adjust_index(), NPY_ARRAY_CARRAY, NPY_ARRAY_ENSURECOPY, NPY_ARRAY_UPDATEIFCOPY, NPY_CLIP, NPY_INTP, NPY_MAXDIMS, NPY_RAISE, NPY_WRAP, Py_TYPE, PyArray_CheckAxis(), PyArray_CompareLists(), PyArray_ContiguousFromAny, PyArray_DATA, PyArray_DESCR, PyArray_DIMS, PyArray_FromArray(), PyArray_INCREF(), PyArray_NDIM, PyArray_NewFromDescr(), and PyArray_XDECREF_ERR().
static int sortCompare | ( | const void * | a, |
const void * | b | ||
) | [static] |
char* global_data [static] |
PyArrayObject* global_obj [static] |