Gets a half-open range [start, end) of offsets from the data pointer */
| 657 | |
| 658 | /* Gets a half-open range [start, end) of offsets from the data pointer */ |
| 659 | NPY_VISIBILITY_HIDDEN void |
| 660 | offset_bounds_from_strides(const int itemsize, const int nd, |
| 661 | const npy_intp *dims, const npy_intp *strides, |
| 662 | npy_intp *lower_offset, npy_intp *upper_offset) |
| 663 | { |
| 664 | npy_intp max_axis_offset; |
| 665 | npy_intp lower = 0; |
| 666 | npy_intp upper = 0; |
| 667 | int i; |
| 668 | |
| 669 | for (i = 0; i < nd; i++) { |
| 670 | if (dims[i] == 0) { |
| 671 | /* If the array size is zero, return an empty range */ |
| 672 | *lower_offset = 0; |
| 673 | *upper_offset = 0; |
| 674 | return; |
| 675 | } |
| 676 | /* Expand either upwards or downwards depending on stride */ |
| 677 | max_axis_offset = strides[i] * (dims[i] - 1); |
| 678 | if (max_axis_offset > 0) { |
| 679 | upper += max_axis_offset; |
| 680 | } |
| 681 | else { |
| 682 | lower += max_axis_offset; |
| 683 | } |
| 684 | } |
| 685 | /* Return a half-open range */ |
| 686 | upper += itemsize; |
| 687 | *lower_offset = lower; |
| 688 | *upper_offset = upper; |
| 689 | } |
| 690 | |
| 691 | |
| 692 | /* Gets a half-open range [start, end) which contains the array data */ |
no outgoing calls
no test coverage detected