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

Function PyArray_OverflowMultiplyList

numpy/core/src/multiarray/multiarraymodule.c:196–213  ·  view source on GitHub ↗

NUMPY_API * Multiply a List of Non-negative numbers with over-flow detection. */

Source from the content-addressed store, hash-verified

194 * Multiply a List of Non-negative numbers with over-flow detection.
195 */
196NPY_NO_EXPORT npy_intp
197PyArray_OverflowMultiplyList(npy_intp const *l1, int n)
198{
199 npy_intp prod = 1;
200 int i;
201
202 for (i = 0; i < n; i++) {
203 npy_intp dim = l1[i];
204
205 if (dim == 0) {
206 return 0;
207 }
208 if (npy_mul_sizes_with_overflow(&prod, prod, dim)) {
209 return -1;
210 }
211 }
212 return prod;
213}
214
215/*NUMPY_API
216 * Produce a pointer into array

Callers 4

_convert_from_tupleFunction · 0.85
PyArray_BroadcastFunction · 0.85
arr_unravel_indexFunction · 0.85
PyArray_MapIterNewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected