Compute Library
 20.08
Size2D.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 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)
45  : width(w), height(h)
46  {
47  }
48  /** The area of the image or rectangle calculated as (width * height)
49  *
50  * @return Area (width * height)
51  *
52  */
53  size_t area() const
54  {
55  return (width * height);
56  }
57 
58  bool operator==(const Size2D &other) const
59  {
60  return (width == other.width) && (height == other.height);
61  }
62 
63  bool operator!=(const Size2D &other) const
64  {
65  return !(*this == other);
66  }
67 
68  std::string to_string() const;
69 
70  /** Semantic accessor for width as x.
71  *
72  * @return x.
73  */
74  size_t x() const
75  {
76  return width;
77  }
78 
79  /** Semantic accessor for height as y.
80  *
81  * @return y.
82  */
83  size_t y() const
84  {
85  return height;
86  }
87 
88 public:
89  size_t width = {}; /**< Width of the image region or rectangle */
90  size_t height = {}; /**< Height of the image region or rectangle */
91 };
92 }
93 #endif /*ARM_COMPUTE_SIZE2D_H */
SimpleTensor< float > w
Definition: DFT.cpp:156
Size2D()=default
Default constructor.
size_t x() const
Semantic accessor for width as x.
Definition: Size2D.h:74
bool operator!=(const Size2D &other) const
Definition: Size2D.h:63
Copyright (c) 2017-2020 Arm Limited.
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:90
size_t y() const
Semantic accessor for height as y.
Definition: Size2D.h:83
Size2D(size_t w, size_t h)
Constructor.
Definition: Size2D.h:44
bool operator==(const Size2D &other) const
Definition: Size2D.h:58
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:89
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
size_t area() const
The area of the image or rectangle calculated as (width * height)
Definition: Size2D.h:53
std::string to_string() const
Definition: Size2D.cpp:29