dims.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 
9 #pragma once
10 
11 #include <iostream>
12 #include "defines.h"
13 
14 namespace af {
16 class AFAPI dim4
17 {
18  public:
19  dim4();
21  dim4(unsigned x, unsigned y=1, unsigned z=1, unsigned w=1);
22  // \p dims is assumed to be owned by caller and values are copied into an internal array
23  dim4(unsigned ndims, const unsigned *dims);
24  dim4(const dim4&);
25 
34  unsigned elements() const;
35 
44  unsigned rest(unsigned i) const;
45 
46 
55  unsigned numdims() const;
56 
66  const unsigned *dims() const;
67 
77  bool isempty() const { return elements() == 0; }
78 
88  bool isscalar() const { return elements() == 1; }
89 
99  bool isvector() const { return numdims() == 2 && (m_dims[0] == 1 || m_dims[1] == 1); }
108  bool iscolumn() const { return numdims() == 2 && m_dims[1] == 1; }
109 
118  bool isrow() const { return numdims() == 2 && m_dims[0] == 1; }
119 
128  unsigned& operator[](unsigned);
129 
138  unsigned operator[](unsigned) const;
139 
147  bool operator==(const dim4&) const;
148 
156  bool operator!=(const dim4&) const;
157 
169  dim4& operator=(const dim4&);
170 
180  AFAPI friend std::ostream& operator<<(std::ostream&, const dim4&);
181 
182  private:
185  unsigned m_dims[4];
186 };
187 };
bool iscolumn() const
Is column vector?
Definition: dims.h:108
bool isempty() const
Is empty array?
Definition: dims.h:77
#define AFAPI
Definition: defines.h:45
bool isvector() const
Is array vector (row or column or scalar)?
Definition: dims.h:99
bool isscalar() const
Is scalar array (one element)?
Definition: dims.h:88
const cfloat i
representation for imaginary unit 0+1i
array dimensions descriptor
Definition: dims.h:16
bool isrow() const
Is row vector?
Definition: dims.h:118