Elffuss BraidHub

kikocis/kleidiai public

main · 1.4 KiBRawPermalink
1//
2// SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6
7#pragma once
8
9#include <cstddef>
10#include <iosfwd>
11
12namespace kai::test {
13
14/// Rectangular region of a matrix.
15///
16/// This is the absolute version of @ref MatrixPortion.
17class Rect {
18public:
19 /// Creates a new rectangular region of a matrix.
20 ///
21 /// @param[in] start_row Starting row index.
22 /// @param[in] start_col Starting column index.
23 /// @param[in] height Number of rows.
24 /// @param[in] width Number of columns.
25 Rect(size_t start_row, size_t start_col, size_t height, size_t width);
26
27 /// Gets the starting row index.
28 [[nodiscard]] size_t start_row() const;
29
30 /// Gets the starting column index.
31 [[nodiscard]] size_t start_col() const;
32
33 /// Gets the number of rows.
34 [[nodiscard]] size_t height() const;
35
36 /// Gets the number of columns.
37 [[nodiscard]] size_t width() const;
38
39 /// Gets the end (exclusive) row index.
40 [[nodiscard]] size_t end_row() const;
41
42 /// Gets the end (exclusive) column index.
43 [[nodiscard]] size_t end_col() const;
44
45 /// Check if position is within rect
46 [[nodiscard]] bool contains(size_t row, size_t col) const;
47
48private:
49 friend std::ostream& operator<<(std::ostream& os, const Rect& rect);
50
51 size_t _start_row;
52 size_t _start_col;
53 size_t _height;
54 size_t _width;
55};
56
57} // namespace kai::test