MCPcopy Create free account
hub / github.com/pybind/pybind11 / init_common_iterator

Method init_common_iterator

include/pybind11/numpy.h:1941–1965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939 using common_iter = common_iterator;
1940
1941 void init_common_iterator(const buffer_info &buffer,
1942 const container_type &shape,
1943 common_iter &iterator,
1944 container_type &strides) {
1945 auto buffer_shape_iter = buffer.shape.rbegin();
1946 auto buffer_strides_iter = buffer.strides.rbegin();
1947 auto shape_iter = shape.rbegin();
1948 auto strides_iter = strides.rbegin();
1949
1950 while (buffer_shape_iter != buffer.shape.rend()) {
1951 if (*shape_iter == *buffer_shape_iter) {
1952 *strides_iter = *buffer_strides_iter;
1953 } else {
1954 *strides_iter = 0;
1955 }
1956
1957 ++buffer_shape_iter;
1958 ++buffer_strides_iter;
1959 ++shape_iter;
1960 ++strides_iter;
1961 }
1962
1963 std::fill(strides_iter, strides.rend(), 0);
1964 iterator = common_iter(buffer.ptr, strides, shape);
1965 }
1966
1967 void increment_common_iterator(size_t dim) {
1968 for (auto &iter : m_common_iterator) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected