Storage bytes [first, last) the spec addresses, from storage start.
89{
91 if (!count)
92 return std::nullopt;
93 if (*count == 0)
95
96 if (
dtype.is_sub_byte()) {
97 const auto bytes =
dtype.storage_bytes(*count);
98 if (!bytes || *bytes > std::numeric_limits<uint64_t>::max() -
byte_offset)
99 return std::nullopt;
101 }
102
104 uint64_t low = 0;
105 uint64_t high = 0;
106 for (
size_t i = 0; i <
shape.size(); ++i) {
108 continue;
109 const int64_t stride = resolved[i];
110 const uint64_t magnitude = stride < 0 ? static_cast<uint64_t>(-(stride + 1)) + 1 : static_cast<uint64_t>(stride);
111 uint64_t reach = 0;
112 if (!magnitude_times(
shape[i] - 1, magnitude, reach))
113 return std::nullopt;
114 uint64_t& side = stride < 0 ? low : high;
115 if (reach > max_signed - side)
116 return std::nullopt;
117 side += reach;
118 }
119
120 const uint64_t element =
dtype.element_bytes();
121 uint64_t low_bytes = 0;
122 uint64_t high_bytes = 0;
123 if (!magnitude_times(low, element, low_bytes) || !magnitude_times(high, element, high_bytes))
124 return std::nullopt;
126 return std::nullopt;
127
129 const uint64_t extent = high_bytes + low_bytes + element;
130 if (extent < element || extent > std::numeric_limits<uint64_t>::max() - first)
131 return std::nullopt;
132 return std::pair<uint64_t, uint64_t> { first, first + extent };
133}
std::vector< double > count(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Sample count per window (as double for pipeline uniformity).
std::optional< uint64_t > element_count() const noexcept
Product of the shape, or std::nullopt on overflow.
std::vector< uint64_t > shape
std::vector< int64_t > resolved_strides() const
Element strides, with C order filled in when none are stored.