NUMPY_API * Gets the broadcast shape if a multi-index is being tracked by the iterator, * otherwise gets the shape of the iteration as Fortran-order * (fastest-changing index first). * * The reason Fortran-order is returned when a multi-index * is not enabled is that this is providing a direct view into how * the iterator traverses the n-dimensional space. The iterator organizes * its memo
| 978 | * Returns NPY_SUCCEED or NPY_FAIL. |
| 979 | */ |
| 980 | NPY_NO_EXPORT int |
| 981 | NpyIter_GetShape(NpyIter *iter, npy_intp *outshape) |
| 982 | { |
| 983 | npy_uint32 itflags = NIT_ITFLAGS(iter); |
| 984 | int ndim = NIT_NDIM(iter); |
| 985 | int nop = NIT_NOP(iter); |
| 986 | |
| 987 | int idim, sizeof_axisdata; |
| 988 | NpyIter_AxisData *axisdata; |
| 989 | npy_int8 *perm; |
| 990 | |
| 991 | axisdata = NIT_AXISDATA(iter); |
| 992 | sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); |
| 993 | |
| 994 | if (itflags&NPY_ITFLAG_HASMULTIINDEX) { |
| 995 | perm = NIT_PERM(iter); |
| 996 | for(idim = 0; idim < ndim; ++idim) { |
| 997 | int axis = npyiter_undo_iter_axis_perm(idim, ndim, perm, NULL); |
| 998 | outshape[axis] = NAD_SHAPE(axisdata); |
| 999 | |
| 1000 | NIT_ADVANCE_AXISDATA(axisdata, 1); |
| 1001 | } |
| 1002 | } |
| 1003 | else { |
| 1004 | for(idim = 0; idim < ndim; ++idim) { |
| 1005 | outshape[idim] = NAD_SHAPE(axisdata); |
| 1006 | NIT_ADVANCE_AXISDATA(axisdata, 1); |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | return NPY_SUCCEED; |
| 1011 | } |
| 1012 | |
| 1013 | /*NUMPY_API |
| 1014 | * Builds a set of strides which are the same as the strides of an |
no test coverage detected