Template Class Matrix

Class Documentation

template<typename T, size_t Dimensions, typename Container = std::vector<T>>
class Matrix

A template container for holding a multi-dimensional array of items.

This class is a work-in-progress.

Template Parameters
  • T – The type of value contained by this matrix.

  • Dimensions – The number of dimensions of this matrix type.

  • Container – The std::vector-like container used for this matrix.

Public Types

using size_type = int
using shape_type = std::array<size_type, Dimensions>
using index_type = std::array<size_type, Dimensions>
using reference = typename Container::reference
using const_reference = typename Container::const_reference

Public Functions

constexpr Matrix() = default

Default constructor.

inline explicit constexpr Matrix(const shape_type &shape)

Create a matrix of the given shape.

inline constexpr Matrix(const shape_type &shape, const T &fill_value)

Create a matrix of the given shape filled with a default value.

inline constexpr auto begin() noexcept

Return the iterator beginning.

inline constexpr auto begin() const noexcept

Return the iterator beginning.

inline constexpr auto end() noexcept

Return the iterator end.

inline constexpr auto end() const noexcept

Return the iterator end.

inline constexpr reference operator[](const index_type &index) noexcept

Get the item at index.

inline constexpr const_reference operator[](const index_type &index) const noexcept

Get the const item at index.

inline constexpr reference at(const index_type &index)

Get the item at index, checking bounds.

inline constexpr const_reference at(const index_type &index) const

Get the const item at index, checking bounds.

inline constexpr const shape_type &get_shape() const noexcept

Return the shape of this matrix.

inline constexpr bool in_bounds(const index_type &index) const noexcept

Return true if index is within the bounds of this matrix.

inline constexpr operator MatrixView<T, Dimensions>() noexcept

Implicit cast to a view of this matrix.

inline constexpr operator MatrixView<const T, Dimensions>() const noexcept

Implicit cast to a const view of this matrix.

inline constexpr Container &get_container() noexcept

Get the flat container for this matrix.

inline constexpr const Container &get_container() const noexcept

Get the const flat container for this matrix.

template<class Archive>
inline void serialize(Archive &archive)