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

Function strides_to_terms

numpy/core/src/common/mem_overlap.c:713–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711
712
713static int
714strides_to_terms(PyArrayObject *arr, diophantine_term_t *terms,
715 unsigned int *nterms, int skip_empty)
716{
717 int i;
718
719 for (i = 0; i < PyArray_NDIM(arr); ++i) {
720 if (skip_empty) {
721 if (PyArray_DIM(arr, i) <= 1 || PyArray_STRIDE(arr, i) == 0) {
722 continue;
723 }
724 }
725
726 terms[*nterms].a = PyArray_STRIDE(arr, i);
727
728 if (terms[*nterms].a < 0) {
729 terms[*nterms].a = -terms[*nterms].a;
730 }
731
732 if (terms[*nterms].a < 0) {
733 /* integer overflow */
734 return 1;
735 }
736
737 terms[*nterms].ub = PyArray_DIM(arr, i) - 1;
738 ++*nterms;
739 }
740
741 return 0;
742}
743
744
745/**

Callers 2

solve_may_share_memoryFunction · 0.85

Calls 3

PyArray_NDIMFunction · 0.85
PyArray_DIMFunction · 0.85
PyArray_STRIDEFunction · 0.85

Tested by

no test coverage detected