13#ifndef RTCTK_COMPONENTFRAMEWORK_MATRIXSPAN_HPP
14#define RTCTK_COMPONENTFRAMEWORK_MATRIXSPAN_HPP
37 using typename gsl::span<T>::element_type;
38 using typename gsl::span<T>::value_type;
39 using typename gsl::span<T>::size_type;
40 using typename gsl::span<T>::pointer;
42 using typename gsl::span<T>::reference;
44 using typename gsl::span<T>::iterator;
45 using typename gsl::span<T>::reverse_iterator;
47 constexpr MatrixSpan() noexcept : gsl::span<T>(), m_nrows(0), m_ncols(0) {
51 : gsl::span<T>(other), m_nrows(other.m_nrows), m_ncols(other.m_ncols) {
55 gsl::span<T>::operator=(other);
56 m_nrows = other.m_nrows;
57 m_ncols = other.m_ncols;
62 : gsl::span<T>(std::forward<MatrixSpan>(other))
63 , m_nrows(std::move(other.m_nrows))
64 , m_ncols(std::move(other.m_ncols)) {
68 gsl::span<T>::operator=(std::forward<MatrixSpan>(other));
69 m_nrows = std::move(other.m_nrows);
70 m_ncols = std::move(other.m_ncols);
74 constexpr explicit MatrixSpan(size_type n, size_type m,
const gsl::span<T>& data)
75 : gsl::span<T>(data), m_nrows(n), m_ncols(m) {
76 assert(n * m == data.size());
80 constexpr explicit MatrixSpan(size_type n, size_type m, I first, size_type count)
81 : gsl::span<T>(first, count), m_nrows(n), m_ncols(m) {
82 assert(n * m == count);
86 constexpr explicit MatrixSpan(size_type n, size_type m, I first, I last)
87 : gsl::span<T>(first, last), m_nrows(n), m_ncols(m) {
88 assert(n * m == std::distance(first, last));
91 template <std::
size_t N>
92 constexpr explicit MatrixSpan(size_type n, size_type m, element_type (&array)[N]) noexcept
93 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
97 template <std::
size_t N>
98 constexpr explicit MatrixSpan(size_type n, size_type m, std::array<T, N>& array) noexcept
99 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
103 template <std::
size_t N>
104 constexpr explicit MatrixSpan(size_type n, size_type m,
const std::array<T, N>& array) noexcept
105 : gsl::span<T>(array), m_nrows(n), m_ncols(m) {
109 template <
typename R>
110 constexpr explicit MatrixSpan(size_type n, size_type m, R&& range) noexcept
111 : gsl::span<T>(std::forward<R>(range)), m_nrows(n), m_ncols(m) {
112 assert(n * m == range.size());
115 template <
typename A>
117 : gsl::span<T>(buffer.data(), buffer.size())
118 , m_nrows(buffer.GetNrows())
119 , m_ncols(buffer.GetNcols()) {
124 assert(0 <= n and n < m_nrows);
126 assert(0 <= m and m < m_ncols);
127 return gsl::span<T>::operator[](n* m_ncols + m);
132 assert(0 <= n and n < m_nrows);
134 assert(0 <= m and m < m_ncols);
135 return gsl::span<T>::operator[](n* m_ncols + m);
A buffer class representing 2D matrix data.
Definition: matrixBuffer.hpp:28
A span referencing a 2D matrix buffer.
Definition: matrixSpan.hpp:35
const T & const_reference
Definition: matrixSpan.hpp:43
constexpr MatrixSpan(size_type n, size_type m, R &&range) noexcept
Definition: matrixSpan.hpp:110
constexpr MatrixSpan(size_type n, size_type m, I first, I last)
Definition: matrixSpan.hpp:86
size_type GetNrows() const
Definition: matrixSpan.hpp:138
constexpr MatrixSpan(size_type n, size_type m, const gsl::span< T > &data)
Definition: matrixSpan.hpp:74
constexpr MatrixSpan(const MatrixSpan &other)
Definition: matrixSpan.hpp:50
constexpr MatrixSpan(MatrixBuffer< T, A > &buffer) noexcept
Definition: matrixSpan.hpp:116
constexpr MatrixSpan & operator=(const MatrixSpan &other)
Definition: matrixSpan.hpp:54
constexpr MatrixSpan(size_type n, size_type m, I first, size_type count)
Definition: matrixSpan.hpp:80
constexpr reference operator()(size_type n, size_type m)
Definition: matrixSpan.hpp:122
size_type GetNcols() const
Definition: matrixSpan.hpp:142
constexpr MatrixSpan(size_type n, size_type m, element_type(&array)[N]) noexcept
Definition: matrixSpan.hpp:92
constexpr MatrixSpan() noexcept
Definition: matrixSpan.hpp:47
constexpr MatrixSpan(size_type n, size_type m, std::array< T, N > &array) noexcept
Definition: matrixSpan.hpp:98
constexpr const_reference operator()(size_type n, size_type m) const
Definition: matrixSpan.hpp:130
constexpr MatrixSpan(MatrixSpan &&other) noexcept
Definition: matrixSpan.hpp:61
constexpr MatrixSpan & operator=(MatrixSpan &&other) noexcept
Definition: matrixSpan.hpp:67
const T * const_pointer
Definition: matrixSpan.hpp:41
constexpr MatrixSpan(size_type n, size_type m, const std::array< T, N > &array) noexcept
Definition: matrixSpan.hpp:104
Declaration of the MatrixBuffer template class used in APIs.
Definition: commandReplier.cpp:22