matrix_2d.hpp#

Typedefs

using shape_t = pair<size_t>#
template<typename T>
class Matrix2D#

Public Functions

inline Matrix2D(size_t n = 0, size_t m = 0)#

Default constructor

Parameters
  • n – size on the first axis

  • m – size on the second axis

Matrix2D &operator=(const Matrix2D&&) = delete#
inline Matrix2D(Matrix2D &other)#

Copy constructor; put copied flag

inline Matrix2D(Matrix2D &&other)#

Move constructor; this allows the matrix to be passed as a return value from a function swapping the pointers and keeping the allocated data on the heap.

inline ~Matrix2D()#

Construct in host for device from Matrix2D

Parameters
  • other – matrix2D to construct from Copy to host from device

  • other – matrix2D to construct from Desctructor; dealocate heap and set pointer to null

inline void reshape(size_t n, size_t m)#

Change shape of matrix droping previous data

Parameters
  • n – size on the first axis

  • m – size on the second axis

inline shape_t shape() const#

Get shape of the matrix

Returns

shape

inline T &operator()(size_t i, size_t j)#

Write access to matrix (host)

Parameters
  • i – index on the first axis

  • j – index on the second axis

Returns

M(i, j)

inline const T &operator()(size_t i, size_t j) const#

Read-only access to matrix (host)

Parameters
  • i – index on the first axis

  • j – index on the second axis

Returns

M(i, j)

Private Members

T *_arr#
shape_t _shape#
bool _copied#