| 332 | // in each dimension. |
| 333 | template <typename T> |
| 334 | static std::unique_ptr<Array2D<T>> Slice2D(const Array2D<T>& input, |
| 335 | std::array<int64, 2> starts, |
| 336 | std::array<int64, 2> limits, |
| 337 | std::array<int64, 2> strides) { |
| 338 | CHECK_LE(starts[0], input.n1()); |
| 339 | CHECK_LE(starts[1], input.n2()); |
| 340 | CHECK_LE(limits[0], input.n1()); |
| 341 | CHECK_LE(limits[1], input.n2()); |
| 342 | CHECK_GE(strides[0], 1); |
| 343 | CHECK_GE(strides[1], 1); |
| 344 | auto result = absl::make_unique<Array2D<T>>( |
| 345 | CeilOfRatio(limits[0] - starts[0], strides[0]), |
| 346 | CeilOfRatio(limits[1] - starts[1], strides[1])); |
| 347 | for (int64 i0 = 0; i0 < result->n1(); ++i0) { |
| 348 | for (int64 i1 = 0; i1 < result->n2(); ++i1) { |
| 349 | (*result)(i0, i1) = |
| 350 | input(starts[0] + i0 * strides[0], starts[1] + i1 * strides[1]); |
| 351 | } |
| 352 | } |
| 353 | return result; |
| 354 | } |
| 355 | |
| 356 | template <typename T> |
| 357 | static std::unique_ptr<Array3D<T>> Slice3D(const Array3D<T>& input, |
nothing calls this directly
no test coverage detected