Beatmup
Beatmup::Array< datatype, numdim > Class Template Reference

Multidimensional array container with data access facilities The number of dimensions is compile time-known. More...

#include <array.h>

Public Member Functions

 Array (size_t length)
 
 Array (size_t width, size_t height)
 
 Array (size_t width, size_t height, size_t depth)
 
 Array (size_t channels, size_t width, size_t height, size_t depth)
 
datatype * data ()
 
size_t size () const
 
datatype & operator() (size_t i)
 
datatype & operator() (size_t x, size_t y)
 
datatype & operator() (size_t x, size_t y, size_t z)
 
datatype & operator() (size_t c, size_t x, size_t y, size_t z)
 
const datatype & operator() (size_t c, size_t x, size_t y, size_t z) const
 

Private Attributes

std::vector< datatype > storage
 
size_t dims [numdim]
 

Detailed Description

template<typename datatype, size_t numdim>
class Beatmup::Array< datatype, numdim >

Multidimensional array container with data access facilities The number of dimensions is compile time-known.

Definition at line 27 of file array.h.

Constructor & Destructor Documentation

◆ Array() [1/4]

template<typename datatype , size_t numdim>
Beatmup::Array< datatype, numdim >::Array ( size_t  length)
inline

Definition at line 32 of file array.h.

32  :
33  storage(length)
34  {
35  static_assert(numdim == 1, "Dimensions mismatch");
36  dims[0] = length;
37  }
std::vector< datatype > storage
Definition: array.h:29
size_t dims[numdim]
Definition: array.h:30

◆ Array() [2/4]

template<typename datatype , size_t numdim>
Beatmup::Array< datatype, numdim >::Array ( size_t  width,
size_t  height 
)
inline

Definition at line 39 of file array.h.

39  :
41  {
42  static_assert(numdim == 2, "Dimensions mismatch");
43  dims[0] = width;
44  dims[1] = height;
45  }
jlong jint width
jlong jint jint height

◆ Array() [3/4]

template<typename datatype , size_t numdim>
Beatmup::Array< datatype, numdim >::Array ( size_t  width,
size_t  height,
size_t  depth 
)
inline

Definition at line 47 of file array.h.

47  :
48  storage(width * height * depth)
49  {
50  static_assert(numdim == 3, "Dimensions mismatch");
51  dims[0] = width;
52  dims[1] = height;
53  dims[2] = depth;
54  }

◆ Array() [4/4]

template<typename datatype , size_t numdim>
Beatmup::Array< datatype, numdim >::Array ( size_t  channels,
size_t  width,
size_t  height,
size_t  depth 
)
inline

Definition at line 56 of file array.h.

56  :
57  storage(channels * width * height * depth)
58  {
59  static_assert(numdim == 4, "Dimensions mismatch");
60  dims[0] = channels;
61  dims[1] = width;
62  dims[2] = height;
63  dims[3] = depth;
64  }
JNIEnv jobject jint jint jint channels

Member Function Documentation

◆ data()

template<typename datatype , size_t numdim>
datatype* Beatmup::Array< datatype, numdim >::data ( )
inline

Definition at line 66 of file array.h.

66 { return storage.data(); }

◆ size()

template<typename datatype , size_t numdim>
size_t Beatmup::Array< datatype, numdim >::size ( ) const
inline

Definition at line 67 of file array.h.

67 { return storage.size(); }

◆ operator()() [1/5]

template<typename datatype , size_t numdim>
datatype& Beatmup::Array< datatype, numdim >::operator() ( size_t  i)
inline

Definition at line 69 of file array.h.

69  {
70  static_assert(numdim == 1, "Dimensions mismatch");
71  return storage[i];
72  }

◆ operator()() [2/5]

template<typename datatype , size_t numdim>
datatype& Beatmup::Array< datatype, numdim >::operator() ( size_t  x,
size_t  y 
)
inline

Definition at line 74 of file array.h.

74  {
75  static_assert(numdim == 2, "Dimensions mismatch");
76  return storage[y * dims[0] + x];
77  }
jobject jlong jint jint y
jobject jlong jint x

◆ operator()() [3/5]

template<typename datatype , size_t numdim>
datatype& Beatmup::Array< datatype, numdim >::operator() ( size_t  x,
size_t  y,
size_t  z 
)
inline

Definition at line 79 of file array.h.

79  {
80  static_assert(numdim == 3, "Dimensions mismatch");
81  return storage[(z * dims[1] + y) * dims[0] + x];
82  }
jlong jstring jint jint jint z

◆ operator()() [4/5]

template<typename datatype , size_t numdim>
datatype& Beatmup::Array< datatype, numdim >::operator() ( size_t  c,
size_t  x,
size_t  y,
size_t  z 
)
inline

Definition at line 84 of file array.h.

84  {
85  static_assert(numdim == 4, "Dimensions mismatch");
86  return storage[((z * dims[2] + y) * dims[1] + x) * dims[0] + c];
87  }

◆ operator()() [5/5]

template<typename datatype , size_t numdim>
const datatype& Beatmup::Array< datatype, numdim >::operator() ( size_t  c,
size_t  x,
size_t  y,
size_t  z 
) const
inline

Definition at line 89 of file array.h.

89  {
90  static_assert(numdim == 4, "Dimensions mismatch");
91  return storage[((z * dims[2] + y) * dims[1] + x) * dims[0] + c];
92  }

Member Data Documentation

◆ storage

template<typename datatype , size_t numdim>
std::vector<datatype> Beatmup::Array< datatype, numdim >::storage
private

Definition at line 29 of file array.h.

◆ dims

template<typename datatype , size_t numdim>
size_t Beatmup::Array< datatype, numdim >::dims[numdim]
private

Definition at line 30 of file array.h.


The documentation for this class was generated from the following file: