Do more. Code less. Free software for GPU computing.
<scroll to top>

dims.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------//
00002 //   Copyright (c) AccelerEyes LLC. All rights reserved.                 //
00003 //   See http://www.accelereyes.com/eula for details.                    //
00004 //   This software is distributed WITHOUT ANY WARRANTY; without even     //
00005 //   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
00006 //   PURPOSE.  See the above copyright notices for more information.     //
00007 //-----------------------------------------------------------------------//
00008 
00009 #pragma once
00010 
00011 #include <iostream>
00012 #include "defines.h"
00013 
00014 namespace af {
00015 class AFAPI dim4
00016 {
00017     public:
00018         dim4();
00020         dim4(unsigned x, unsigned y=1, unsigned z=1, unsigned w=1);
00021         // \p dims is assumed to be owned by caller and values are copied into an internal array
00022         dim4(unsigned ndims, const unsigned *dims);
00023         dim4(const dim4&);
00024 
00025         unsigned elements() const;         
00026         unsigned rest(unsigned i) const;   
00027         unsigned ndims() const;            
00028 
00029         bool isempty()   const  { return elements() == 0; }
00031         bool isscalar()  const  { return elements() == 1; }
00033         bool isvector()  const  { return ndims() == 2 && (m_dims[0] == 1 || m_dims[1] == 1); }
00035         bool iscolumn()  const  { return ndims() == 2 && m_dims[1] == 1; }
00037         bool isrow()     const  { return ndims() == 2 && m_dims[0] == 1; }
00038 
00040         unsigned& operator[](unsigned);
00041         unsigned operator[](unsigned) const;
00042 
00043         bool operator==(const dim4&) const;
00044         bool operator!=(const dim4&) const;
00045 
00046         dim4& operator=(const dim4&);
00047 
00048         AFAPI friend std::ostream& operator<<(std::ostream&, const dim4&);
00049 
00050     private:
00051         unsigned m_dims[4];
00052 };
00053 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines