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

Function npyiter_goto_iterindex

numpy/core/src/multiarray/nditer_api.c:1811–1889  ·  view source on GitHub ↗

* This sets the AXISDATA portion of the iterator to the specified * iterindex, updating the pointers as well. This function does * no error checking. */

Source from the content-addressed store, hash-verified

1809 * no error checking.
1810 */
1811NPY_NO_EXPORT void
1812npyiter_goto_iterindex(NpyIter *iter, npy_intp iterindex)
1813{
1814 npy_uint32 itflags = NIT_ITFLAGS(iter);
1815 int idim, ndim = NIT_NDIM(iter);
1816 int nop = NIT_NOP(iter);
1817
1818 char **dataptr;
1819 NpyIter_AxisData *axisdata;
1820 npy_intp sizeof_axisdata;
1821 npy_intp istrides, nstrides, i, shape;
1822
1823 axisdata = NIT_AXISDATA(iter);
1824 sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop);
1825 nstrides = NAD_NSTRIDES();
1826
1827 NIT_ITERINDEX(iter) = iterindex;
1828
1829 ndim = ndim ? ndim : 1;
1830
1831 if (iterindex == 0) {
1832 dataptr = NIT_RESETDATAPTR(iter);
1833
1834 for (idim = 0; idim < ndim; ++idim) {
1835 char **ptrs;
1836 NAD_INDEX(axisdata) = 0;
1837 ptrs = NAD_PTRS(axisdata);
1838 for (istrides = 0; istrides < nstrides; ++istrides) {
1839 ptrs[istrides] = dataptr[istrides];
1840 }
1841
1842 NIT_ADVANCE_AXISDATA(axisdata, 1);
1843 }
1844 }
1845 else {
1846 /*
1847 * Set the multi-index, from the fastest-changing to the
1848 * slowest-changing.
1849 */
1850 axisdata = NIT_AXISDATA(iter);
1851 shape = NAD_SHAPE(axisdata);
1852 i = iterindex;
1853 iterindex /= shape;
1854 NAD_INDEX(axisdata) = i - iterindex * shape;
1855 for (idim = 0; idim < ndim-1; ++idim) {
1856 NIT_ADVANCE_AXISDATA(axisdata, 1);
1857
1858 shape = NAD_SHAPE(axisdata);
1859 i = iterindex;
1860 iterindex /= shape;
1861 NAD_INDEX(axisdata) = i - iterindex * shape;
1862 }
1863
1864 dataptr = NIT_RESETDATAPTR(iter);
1865
1866 /*
1867 * Accumulate the successive pointers with their
1868 * offsets in the opposite order, starting from the

Callers 6

NpyIter_CopyFunction · 0.85
NpyIter_ResetFunction · 0.85
NpyIter_GotoMultiIndexFunction · 0.85
NpyIter_GotoIndexFunction · 0.85
NpyIter_GotoIterIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected