Compute Library
 23.08
Size2D.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_SIZE2D_H
25 #define ARM_COMPUTE_SIZE2D_H
26 
27 #include <cstddef>
28 #include <string>
29 #include <utility>
30 
31 namespace arm_compute
32 {
33 /** Class for specifying the size of an image or rectangle */
34 class Size2D
35 {
36 public:
37  /** Default constructor */
38  Size2D() = default;
39  /** Constructor. Initializes "width" and "height" respectively with "w" and "h"
40  *
41  * @param[in] w Width of the image or rectangle
42  * @param[in] h Height of the image or rectangle
43  */
44  Size2D(size_t w, size_t h) noexcept
45  : width(w),
46  height(h)
47  {
48  }
49  /** The area of the image or rectangle calculated as (width * height)
50  *
51  * @return Area (width * height)
52  *
53  */
54  size_t area() const
55  {
56  return (width * height);
57  }
58 
59  bool operator==(const Size2D &other) const
60  {
61  return (width == other.width) && (height == other.height);
62  }
63 
64  bool operator!=(const Size2D &other) const
65  {
66  return !(*this == other);
67  }
68 
69  std::string to_string() const;
70 
71  /** Semantic accessor for width as x.
72  *
73  * @return x.
74  */
75  size_t x() const
76  {
77  return width;
78  }
79 
80  /** Semantic accessor for height as y.
81  *
82  * @return y.
83  */
84  size_t y() const
85  {
86  return height;
87  }
88 
89 public:
90  size_t width = {}; /**< Width of the image region or rectangle */
91  size_t height = {}; /**< Height of the image region or rectangle */
92 };
93 }
94 #endif /*ARM_COMPUTE_SIZE2D_H */
arm_compute::Size2D::operator!=
bool operator!=(const Size2D &other) const
Definition: Size2D.h:64
arm_compute::Size2D::Size2D
Size2D(size_t w, size_t h) noexcept
Constructor.
Definition: Size2D.h:44
arm_compute::Size2D::y
size_t y() const
Semantic accessor for height as y.
Definition: Size2D.h:84
arm_compute::Size2D
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
arm_compute::Size2D::height
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:91
arm_compute::Size2D::to_string
std::string to_string() const
Definition: Size2D.cpp:29
arm_compute::Size2D::area
size_t area() const
The area of the image or rectangle calculated as (width * height)
Definition: Size2D.h:54
arm_compute::Size2D::width
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:90
arm_compute::test::validation::w
SimpleTensor< float > w
Definition: DFT.cpp:156
arm_compute::Size2D::x
size_t x() const
Semantic accessor for width as x.
Definition: Size2D.h:75
arm_compute::Size2D::Size2D
Size2D()=default
Default constructor.
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::Size2D::operator==
bool operator==(const Size2D &other) const
Definition: Size2D.h:59