MCPcopy Create free account
hub / github.com/numpy/numpy / get_item_pointer

Function get_item_pointer

numpy/core/src/multiarray/mapping.c:789–802  ·  view source on GitHub ↗

* Get pointer for an integer index. * * For a purely integer index, set ptr to the memory address. * Returns 0 on success, -1 on failure. * The caller must ensure that the index is a full integer * one. * * @param Array being indexed * @param result pointer * @param parsed index information * @param number of indices * * @return 0 on success -1 on failure */

Source from the content-addressed store, hash-verified

787 * @return 0 on success -1 on failure
788 */
789static int
790get_item_pointer(PyArrayObject *self, char **ptr,
791 npy_index_info *indices, int index_num) {
792 int i;
793 *ptr = PyArray_BYTES(self);
794 for (i=0; i < index_num; i++) {
795 if ((check_and_adjust_index(&(indices[i].value),
796 PyArray_DIMS(self)[i], i, NULL)) < 0) {
797 return -1;
798 }
799 *ptr += PyArray_STRIDE(self, i) * indices[i].value;
800 }
801 return 0;
802}
803
804
805/**

Callers 4

array_itemFunction · 0.85
array_subscriptFunction · 0.85
array_assign_itemFunction · 0.85
array_assign_subscriptFunction · 0.85

Calls 4

PyArray_BYTESFunction · 0.85
check_and_adjust_indexFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_STRIDEFunction · 0.85

Tested by

no test coverage detected