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

Function _bad_strides

numpy/core/src/common/cblasfuncs.c:187–208  ·  view source on GitHub ↗

* This also makes sure that the data segment is aligned with * an itemsize address as well by returning one if not true. */

Source from the content-addressed store, hash-verified

185 * an itemsize address as well by returning one if not true.
186 */
187NPY_NO_EXPORT int
188_bad_strides(PyArrayObject *ap)
189{
190 int itemsize = PyArray_ITEMSIZE(ap);
191 int i, N=PyArray_NDIM(ap);
192 npy_intp *strides = PyArray_STRIDES(ap);
193 npy_intp *dims = PyArray_DIMS(ap);
194
195 if (((npy_intp)(PyArray_DATA(ap)) % itemsize) != 0) {
196 return 1;
197 }
198 for (i = 0; i < N; i++) {
199 if ((strides[i] < 0) || (strides[i] % itemsize) != 0) {
200 return 1;
201 }
202 if ((strides[i] == 0 && dims[i] > 1)) {
203 return 1;
204 }
205 }
206
207 return 0;
208}
209
210/*
211 * dot(a,b)

Callers 1

cblas_matrixproductFunction · 0.85

Calls 5

PyArray_ITEMSIZEFunction · 0.85
PyArray_NDIMFunction · 0.85
PyArray_STRIDESFunction · 0.85
PyArray_DIMSFunction · 0.85
PyArray_DATAFunction · 0.85

Tested by

no test coverage detected