Template Class Matrix

Class Documentation

template<class T, int M, int N = M>
class Matrix

Matrix class to represent small matrices.

Template Parameters:
  • TMatrix value type.

  • M – Number of rows.

  • N – Number of columns. Default is M.

Public Types

using Type = T

Public Functions

inline constexpr __host__ __device__ void load (const T *inFlattenMatrix)

Load values from a flatten array into this matrix.

Parameters:

inFlattenMatrix[in] Input flatten matrix to load values from.

inline constexpr __host__ __device__ void store (T *outFlattenMatrix) const

Store values to a flatten array from this matrix.

Parameters:

outFlattenMatrix[out] Output flatten matrix to store values to.

inline constexpr __host__ __device__ int rows () const

Get number of rows of this matrix.

Returns:

Number of rows.

inline constexpr __host__ __device__ int cols () const

Get number of columns of this matrix.

Returns:

Number of columns.

inline constexpr const __host__ __device__ Vector< T, N > & operator[] (int i) const

Subscript operator for read-only access.

Parameters:

i[in] Row of the matrix to access.

Returns:

Vector (constant reference) of the corresponding row.

inline constexpr __host__ __device__ Vector< T, N > & operator[] (int i)

Subscript operator for read-and-write access.

Parameters:

i[in] Row of the matrix to access.

Returns:

Vector (reference) of the corresponding row.

inline constexpr const __host__ __device__ T & operator[] (int2 c) const

Subscript operator for read-only access of matrix elements.

Parameters:

c[in] Coordinates (y row and x column) of the matrix element to access.

Returns:

Element (constant reference) of the corresponding row and column.

inline constexpr __host__ __device__ T & operator[] (int2 c)

Subscript operator for read-and-write access of matrix elements.

Parameters:

c[in] Coordinates (y row and x column) of the matrix element to access.

Returns:

Element (reference) of the corresponding row and column.

inline constexpr __host__ __device__ Vector< T, M > col (int j) const

Get column j of this matrix.

Parameters:

j[in] Index of column to get.

Returns:

Column j (copied) as a vector.

inline constexpr __host__ __device__ void set_col (int j, const Vector< T, M > &c)

Set column j of this matrix.

Parameters:
  • j[in] Index of column to set.

  • c[in] Vector to place in matrix column.

inline constexpr __host__ __device__ void set_col (int j, const T *c)
inline constexpr __host__ __device__ Matrix< T, M - 1, N - 1 > subm (int skip_i, int skip_j) const

Get a sub-matrix of this matrix.

Parameters:
  • skip_i[in] Row to skip when getting values from this matrix.

  • skip_j[in] Column to skip when getting values from this matrix.

Returns:

Matrix with one less row and one less column.

Public Members

Vector<T, N> m_data[M]