SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of Münster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
MatrixSize.cpp
1 /*****************************************************************************
2  * Copyright (c) 2011-2012 The SkelCL Team as listed in CREDITS.txt *
3  * http://skelcl.uni-muenster.de *
4  * *
5  * This file is part of SkelCL. *
6  * SkelCL is available under multiple licenses. *
7  * The different licenses are subject to terms and condition as provided *
8  * in the files specifying the license. See "LICENSE.txt" for details *
9  * *
10  *****************************************************************************
11  * *
12  * SkelCL is free software: you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation, either version 3 of the License, or *
15  * (at your option) any later version. See "LICENSE-gpl.txt" for details. *
16  * *
17  * SkelCL is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  *****************************************************************************
23  * *
24  * For non-commercial academic use see the license specified in the file *
25  * "LICENSE-academic.txt". *
26  * *
27  *****************************************************************************
28  * *
29  * If you are interested in other licensing models, including a commercial- *
30  * license, please contact the author at michel.steuwer@uni-muenster.de *
31  * *
32  *****************************************************************************/
33 
39 
40 #include "SkelCL/Matrix.h"
41 
42 namespace skelcl {
43 
44 // MatrixSize
45 
46 MatrixSize::MatrixSize(size_type rowCount, size_type columnCount)
47 : _rowCount(rowCount), _columnCount(columnCount)
48 {
49 }
50 
51 MatrixSize::size_type MatrixSize::elemCount() const
52 {
53  return (_rowCount *_columnCount);
54 }
55 
56 MatrixSize::size_type MatrixSize::rowCount() const
57 {
58  return _rowCount;
59 }
60 
61 MatrixSize::size_type MatrixSize::columnCount() const
62 {
63  return _columnCount;
64 }
65 
66 bool MatrixSize::operator==(const MatrixSize& rhs) const
67 {
68  return ( (_rowCount == rhs._rowCount)
69  && (_columnCount == rhs._columnCount) );
70 }
71 
72 bool MatrixSize::operator!=(const MatrixSize& rhs) const
73 {
74  return !this->operator==(rhs);
75 }
76 
77 bool MatrixSize::operator>(const MatrixSize& rhs) const
78 {
79  if (_columnCount == rhs._columnCount) {
80  if (_rowCount > rhs._rowCount)
81  return true;
82  } else if (_columnCount > rhs._columnCount) {
83  if (_rowCount >= rhs._rowCount)
84  return true;
85  }
86 
87  return false;
88 }
89 
90 bool MatrixSize::operator<(const MatrixSize& rhs) const
91 {
92  if (_columnCount == rhs._columnCount) {
93  if (_rowCount < rhs._rowCount)
94  return true;
95  } else if (_columnCount < rhs._columnCount) {
96  if (_rowCount <= rhs._rowCount)
97  return true;
98  }
99 
100  return false;
101 }
102 
103 bool MatrixSize::operator>=(const MatrixSize& rhs) const
104 {
105  if (_columnCount == rhs._columnCount) {
106  if (_rowCount >= rhs._rowCount)
107  return true;
108  } else if (_columnCount > rhs._columnCount) {
109  if (_rowCount >= rhs._rowCount)
110  return true;
111  }
112 
113  return false;
114 }
115 
116 bool MatrixSize::operator<=(const MatrixSize& rhs) const
117 {
118  if (_columnCount == rhs._columnCount) {
119  if (_rowCount <= rhs._rowCount)
120  return true;
121  } else if (_columnCount < rhs._columnCount) {
122  if (_rowCount <= rhs._rowCount)
123  return true;
124  }
125 
126  return false;
127 }
128 
129 } // namespace skelcl
size_type elemCount() const
Returns the total number of elements. I.e. rowCount() * columnCount().
Definition: MatrixSize.cpp:51
bool operator<=(const MatrixSize &rhs) const
Compares if this is less than rhs.
Definition: MatrixSize.cpp:116
bool operator>=(const MatrixSize &rhs) const
Compares if this is greater than rhs.
Definition: MatrixSize.cpp:103
This class defines a two dimensional size for a Matrix.
Definition: Matrix.h:67
size_type rowCount() const
Returns the number of rows.
Definition: MatrixSize.cpp:56
bool operator>(const MatrixSize &rhs) const
Compares if this is greater than rhs.
Definition: MatrixSize.cpp:77
MatrixSize(size_type rowCount, size_type columnCount)
Create a new MatrixSize object with the given number of rows and number of columns.
Definition: MatrixSize.cpp:46
size_type columnCount() const
Returns the number of columns.
Definition: MatrixSize.cpp:61
bool operator==(const MatrixSize &rhs) const
Compares two MatrixSizes for equality.
Definition: MatrixSize.cpp:66
bool operator!=(const MatrixSize &rhs) const
Compares two MatrixSizes for inequality.
Definition: MatrixSize.cpp:72
bool operator<(const MatrixSize &rhs) const
Compares if this is less than rhs.
Definition: MatrixSize.cpp:90