NUMPY_API * Adjusts previously broadcasted iterators so that the axis with * the smallest sum of iterator strides is not iterated over. * Returns dimension which is smallest in the range [0,multi->nd). * A -1 is returned if multi->nd == 0. * * don't use with PyArray_ITER_GOTO1D because factors are not adjusted */
| 342 | * don't use with PyArray_ITER_GOTO1D because factors are not adjusted |
| 343 | */ |
| 344 | NPY_NO_EXPORT int |
| 345 | PyArray_RemoveSmallest(PyArrayMultiIterObject *multi) |
| 346 | { |
| 347 | PyArrayIterObject *it; |
| 348 | int i, j; |
| 349 | int axis; |
| 350 | npy_intp smallest; |
| 351 | npy_intp sumstrides[NPY_MAXDIMS]; |
| 352 | |
| 353 | if (multi->nd == 0) { |
| 354 | return -1; |
| 355 | } |
| 356 | for (i = 0; i < multi->nd; i++) { |
| 357 | sumstrides[i] = 0; |
| 358 | for (j = 0; j < multi->numiter; j++) { |
| 359 | sumstrides[i] += multi->iters[j]->strides[i]; |
| 360 | } |
| 361 | } |
| 362 | axis = 0; |
| 363 | smallest = sumstrides[0]; |
| 364 | /* Find longest dimension */ |
| 365 | for (i = 1; i < multi->nd; i++) { |
| 366 | if (sumstrides[i] < smallest) { |
| 367 | axis = i; |
| 368 | smallest = sumstrides[i]; |
| 369 | } |
| 370 | } |
| 371 | for(i = 0; i < multi->numiter; i++) { |
| 372 | it = multi->iters[i]; |
| 373 | it->contiguous = 0; |
| 374 | if (it->size != 0) { |
| 375 | it->size /= (it->dims_m1[axis]+1); |
| 376 | } |
| 377 | it->dims_m1[axis] = 0; |
| 378 | it->backstrides[axis] = 0; |
| 379 | } |
| 380 | multi->size = multi->iters[0]->size; |
| 381 | return axis; |
| 382 | } |
| 383 | |
| 384 | /* Returns an array scalar holding the element desired */ |
| 385 |
nothing calls this directly
no outgoing calls
no test coverage detected