12#ifndef RTCTK_COMPONENTFRAMEWORK_MATRIXBUFFER_HPP
13#define RTCTK_COMPONENTFRAMEWORK_MATRIXBUFFER_HPP
26template <
typename T,
typename A = std::allocator<T>>
29 using typename std::vector<T, A>::size_type;
30 using typename std::vector<T, A>::value_type;
31 using typename std::vector<T, A>::reference;
32 using typename std::vector<T, A>::const_reference;
43 std::allocator_traits<A>::propagate_on_container_move_assignment::value or
44 std::allocator_traits<A>::is_always_equal::value) {
45 m_nrows = other.m_nrows;
46 m_ncols = other.m_ncols;
47 std::vector<T, A>::operator=(std::move(other));
51 constexpr MatrixBuffer(size_type n, size_type m,
const std::vector<T, A>& data)
52 :
std::vector<T, A>(data), m_nrows(n), m_ncols(m) {
53 assert(n * m == data.size());
59 constexpr void resize(size_type n, size_type m) {
60 std::vector<T, A>::resize(n * m);
66 constexpr void resize(size_type n, size_type m,
const value_type& value) {
67 std::vector<T, A>::resize(n * m, value);
72 constexpr reference
operator()(size_type n, size_type m) {
73 assert(0 <= n and n < m_nrows);
74 assert(0 <= m and m < m_ncols);
75 return std::vector<T, A>::operator[](n * m_ncols + m);
78 constexpr const_reference
operator()(size_type n, size_type m)
const {
79 assert(0 <= n and n < m_nrows);
80 assert(0 <= m and m < m_ncols);
81 return std::vector<T, A>::operator[](n * m_ncols + m);
93 return row * m_ncols + col;
105template <
typename T,
typename A>
107 return lhs.GetNrows() == rhs.GetNrows() and lhs.GetNcols() == rhs.GetNcols() and
108 static_cast<std::vector<T, A>
>(lhs) ==
static_cast<std::vector<T, A>
>(rhs);
115template <
typename T,
typename A>
117 return lhs.GetNrows() != rhs.GetNrows() or lhs.GetNcols() != rhs.GetNcols() or
118 static_cast<std::vector<T, A>
>(lhs) !=
static_cast<std::vector<T, A>
>(rhs);
129template <
typename T,
typename A>
131 if (lhs.size() < rhs.size()) {
133 }
else if (lhs.size() == rhs.size()) {
134 if (lhs.GetNrows() < rhs.GetNrows()) {
136 }
else if (lhs.GetNrows() > rhs.GetNrows()) {
140 return static_cast<std::vector<T, A>
>(lhs) <
static_cast<std::vector<T, A>
>(rhs);
147template <
typename T,
typename A>
149 if (lhs.size() < rhs.size()) {
151 }
else if (lhs.size() == rhs.size()) {
152 if (lhs.GetNrows() < rhs.GetNrows()) {
154 }
else if (lhs.GetNrows() > rhs.GetNrows()) {
158 return static_cast<std::vector<T, A>
>(lhs) <=
static_cast<std::vector<T, A>
>(rhs);
169template <
typename T,
typename A>
171 if (lhs.size() > rhs.size()) {
173 }
else if (lhs.size() == rhs.size()) {
174 if (lhs.GetNrows() > rhs.GetNrows()) {
176 }
else if (lhs.GetNrows() < rhs.GetNrows()) {
180 return static_cast<std::vector<T, A>
>(lhs) >
static_cast<std::vector<T, A>
>(rhs);
187template <
typename T,
typename A>
189 if (lhs.size() > rhs.size()) {
191 }
else if (lhs.size() == rhs.size()) {
192 if (lhs.GetNrows() > rhs.GetNrows()) {
194 }
else if (lhs.GetNrows() < rhs.GetNrows()) {
198 return static_cast<std::vector<T, A>
>(lhs) >=
static_cast<std::vector<T, A>
>(rhs);
constexpr MatrixBuffer() noexcept(noexcept(A()))=default
A buffer class representing 2D matrix data.
Definition matrixBuffer.hpp:27
constexpr reference operator()(size_type n, size_type m)
Definition matrixBuffer.hpp:72
constexpr void resize(size_type n, size_type m, const value_type &value)
Definition matrixBuffer.hpp:66
constexpr MatrixBuffer(size_type n, size_type m, const std::vector< T, A > &data)
Definition matrixBuffer.hpp:51
size_type GetNcols() const
Definition matrixBuffer.hpp:88
constexpr MatrixBuffer() noexcept(noexcept(A()))=default
size_type GetNrows() const
Definition matrixBuffer.hpp:84
constexpr const_reference operator()(size_type n, size_type m) const
Definition matrixBuffer.hpp:78
constexpr void resize(size_type n, size_type m)
Definition matrixBuffer.hpp:59
size_t GetElementIndex(size_t row, size_t col)
Definition matrixBuffer.hpp:92
Definition commandReplier.cpp:21
bool operator<=(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:375
bool operator>(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:379
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:367
bool operator>=(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:383
constexpr bool operator!=(const MatrixBuffer< T, A > &lhs, const MatrixBuffer< T, A > &rhs) noexcept
Compares two MatrixBuffer objects and returns true if they do not have the same shape or the elements...
Definition matrixBuffer.hpp:116
bool operator<(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:371
Definition ddsSub.hpp:155