13#ifndef RTCTK_COMPONENTFRAMEWORK_MATRIXBUFFER_HPP
14#define RTCTK_COMPONENTFRAMEWORK_MATRIXBUFFER_HPP
27template <
typename T,
typename A = std::allocator<T>>
30 using typename std::vector<T, A>::size_type;
31 using typename std::vector<T, A>::value_type;
32 using typename std::vector<T, A>::reference;
33 using typename std::vector<T, A>::const_reference;
44 std::allocator_traits<A>::propagate_on_container_move_assignment::value or
45 std::allocator_traits<A>::is_always_equal::value) {
46 m_nrows = other.m_nrows;
47 m_ncols = other.m_ncols;
48 std::vector<T, A>::operator=(std::move(other));
52 constexpr MatrixBuffer(size_type n, size_type m,
const std::vector<T, A>& data)
53 :
std::vector<T, A>(data), m_nrows(n), m_ncols(m) {
54 assert(n * m == data.size());
60 constexpr void resize(size_type n, size_type m) {
61 std::vector<T, A>::resize(n * m);
67 constexpr void resize(size_type n, size_type m,
const value_type& value) {
68 std::vector<T, A>::resize(n * m, value);
73 constexpr reference
operator()(size_type n, size_type m) {
74 assert(0 <= n and n < m_nrows);
75 assert(0 <= m and m < m_ncols);
76 return std::vector<T, A>::operator[](n * m_ncols + m);
79 constexpr const_reference
operator()(size_type n, size_type m)
const {
80 assert(0 <= n and n < m_nrows);
81 assert(0 <= m and m < m_ncols);
82 return std::vector<T, A>::operator[](n * m_ncols + m);
94 return row * m_ncols + col;
106template <
typename T,
typename A>
108 return lhs.GetNrows() == rhs.GetNrows() and lhs.GetNcols() == rhs.GetNcols() and
109 static_cast<std::vector<T, A>
>(lhs) ==
static_cast<std::vector<T, A>
>(rhs);
116template <
typename T,
typename A>
118 return lhs.GetNrows() != rhs.GetNrows() or lhs.GetNcols() != rhs.GetNcols() or
119 static_cast<std::vector<T, A>
>(lhs) !=
static_cast<std::vector<T, A>
>(rhs);
130template <
typename T,
typename A>
132 if (lhs.size() < rhs.size()) {
134 }
else if (lhs.size() == rhs.size()) {
135 if (lhs.GetNrows() < rhs.GetNrows()) {
137 }
else if (lhs.GetNrows() > rhs.GetNrows()) {
141 return static_cast<std::vector<T, A>
>(lhs) <
static_cast<std::vector<T, A>
>(rhs);
148template <
typename T,
typename A>
150 if (lhs.size() < rhs.size()) {
152 }
else if (lhs.size() == rhs.size()) {
153 if (lhs.GetNrows() < rhs.GetNrows()) {
155 }
else if (lhs.GetNrows() > rhs.GetNrows()) {
159 return static_cast<std::vector<T, A>
>(lhs) <=
static_cast<std::vector<T, A>
>(rhs);
170template <
typename T,
typename A>
172 if (lhs.size() > rhs.size()) {
174 }
else if (lhs.size() == rhs.size()) {
175 if (lhs.GetNrows() > rhs.GetNrows()) {
177 }
else if (lhs.GetNrows() < rhs.GetNrows()) {
181 return static_cast<std::vector<T, A>
>(lhs) >
static_cast<std::vector<T, A>
>(rhs);
188template <
typename T,
typename A>
190 if (lhs.size() > rhs.size()) {
192 }
else if (lhs.size() == rhs.size()) {
193 if (lhs.GetNrows() > rhs.GetNrows()) {
195 }
else if (lhs.GetNrows() < rhs.GetNrows()) {
199 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:28
constexpr reference operator()(size_type n, size_type m)
Definition matrixBuffer.hpp:73
constexpr void resize(size_type n, size_type m, const value_type &value)
Definition matrixBuffer.hpp:67
constexpr MatrixBuffer(size_type n, size_type m, const std::vector< T, A > &data)
Definition matrixBuffer.hpp:52
size_type GetNcols() const
Definition matrixBuffer.hpp:89
constexpr MatrixBuffer() noexcept(noexcept(A()))=default
size_type GetNrows() const
Definition matrixBuffer.hpp:85
constexpr const_reference operator()(size_type n, size_type m) const
Definition matrixBuffer.hpp:79
constexpr void resize(size_type n, size_type m)
Definition matrixBuffer.hpp:60
size_t GetElementIndex(size_t row, size_t col)
Definition matrixBuffer.hpp:93
Definition commandReplier.cpp:22
bool operator<=(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:376
bool operator>(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:380
bool operator==(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:368
bool operator>=(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:384
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:117
bool operator<(const DataPointPath &lhs, const char *rhs) noexcept
Definition dataPointPath.hpp:372
Definition ddsSub.hpp:156