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

Function c_strides

include/pybind11/buffer_info.h:19–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18// Default, C-style strides
19inline std::vector<ssize_t> c_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {
20 auto ndim = shape.size();
21 std::vector<ssize_t> strides(ndim, itemsize);
22 if (ndim > 0) {
23 for (size_t i = ndim - 1; i > 0; --i) {
24 strides[i - 1] = strides[i] * shape[i];
25 }
26 }
27 return strides;
28}
29
30// F-style strides; default when constructing an array_t with `ExtraFlags & f_style`
31inline std::vector<ssize_t> f_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {

Callers 3

buffer_infoMethod · 0.85
arrayMethod · 0.85
array_tFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected