32 #ifndef MCKL_CORE_STATE_MATRIX_HPP 33 #define MCKL_CORE_STATE_MATRIX_HPP 52 template <MatrixLayout Layout,
typename T, std::
size_t Dim = 0>
55 using layout_dispatch = std::integral_constant<MatrixLayout, Layout>;
56 using row_major = std::integral_constant<MatrixLayout, RowMajor>;
57 using col_major = std::integral_constant<MatrixLayout, ColMajor>;
92 return this->
state().row_cbegin(this->
i());
101 return this->
state().row_cend(this->
i());
107 return this->
state().row_rbegin(this->
i());
113 return this->
state().row_crbegin(this->
i());
119 return this->
state().row_rend(this->
i());
125 return this->
state().row_crend(this->
i());
131 return this->
state().at(this->
i(), j);
137 return this->
state()(this->
i(), j);
159 static_assert(Dim == 0,
160 "**StateMatrix::StateMatrix** used with an object with fixed " 193 template <
typename InputIter>
196 select_dispatch(n, index, layout_dispatch());
213 duplicate_dispatch(src, dst, layout_dispatch(),
214 std::integral_constant<
bool, (Dim == 0 || 8 < Dim)>());
218 template <
typename InputIter>
219 void select_dispatch(
size_type n, InputIter index, row_major)
230 for (
size_type dst = 0; dst != n; ++dst, ++index) {
231 duplicate(static_cast<size_type>(*index), dst);
239 template <
typename InputIter>
240 void select_dispatch(
size_type n, InputIter index, col_major)
247 InputIter idx = index;
271 void duplicate_dispatch(
277 void duplicate_dispatch(
281 std::integral_constant<bool, 0 < Dim>());
284 template <std::
size_t>
290 template <std::
size_t D>
295 duplicate_j<D + 1>(src, dst, row_major(),
296 std::integral_constant<bool, D + 1 < Dim>());
299 void duplicate_dispatch(
307 void duplicate_dispatch(
311 std::integral_constant<bool, 0 < Dim>());
314 template <std::
size_t>
320 template <std::
size_t D>
326 src, dst, std::integral_constant<bool, D + 1 < Dim>());
332 #endif // MCKL_CORE_STATE_MATRIX_HPP iterator end() const
this->state().row_end(this->i())
particle_index_type()=default
std::conditional_t< Layout==RowMajor, const_pointer, StepIterator< const_pointer > > const_row_iterator
void resize(size_type N)
Matrix::resize(N, dim())
std::reverse_iterator< const_row_iterator > const_reverse_row_iterator
const_reverse_iterator crbegin() const
this->state().row_crbegin(this->i())
StateMatrix(size_type N=0)
Matrix::Matrix(N, Dim)
size_type ncol() const
The number of columns.
Particle< S >::size_type i() const
void resize(size_type nrow, size_type ncol)
Resize the matrix.
bool empty() const
this->state().empty()
void select(size_type n, InputIter index)
Select samples in-place.
void duplicate(size_type src, size_type dst)
Duplicate a sample.
iterator begin() const
this->state().row_begin(this->i())
const_reverse_iterator crend() const
this->state().row_crend(this->i())
reference at(size_type j) const
this->state().at(this->i(), j)
void reserve(size_type N)
Matrix::reserve(N, dim())
typename matrix_type::reverse_row_iterator reverse_iterator
typename matrix_type::reference reference
std::reverse_iterator< row_iterator > reverse_row_iterator
pointer row_data(size_type i)
Pointer to the first element of a row.
pointer col_data(size_type j)
Pointer to the beginning of a column.
ParticleIndex base class.
size_type size() const
Matrix::nrow()
const_iterator cend() const
this->state().row_cend(this->i())
bool is_nullptr(T ptr, std::true_type)
typename matrix_type::const_reverse_row_iterator const_reverse_iterator
typename matrix_type::row_iterator iterator
typename matrix_type::size_type size_type
particle_index_type(typename Particle< S >::size_type i, Particle< S > *pptr)
size_type dim() const
this->state().dim()
const_iterator cbegin() const
this->state().row_cbegin(this->i())
reference operator()(size_type j) const
this->state()(this->i(), j)
reverse_iterator rend() const
this->state().row_rend(this->i())
size_type stride() const
this->state().row_stride()
Particle::state_type subtype.
typename matrix_type::pointer pointer
typename matrix_type::const_row_iterator const_iterator
pointer data() const
this->state().row_data(this->i())
size_type dim() const
Matrix::ncol()
StateMatrix(size_type N, size_type dim)
Matrix::Matrix(N, dim)
void reserve(size_type n, size_type m)
Reserve storage space for the matrix.
size_type nrow() const
The number of rows.
reverse_iterator rbegin() const
this->state().row_rbegin(this->i())
std::ptrdiff_t difference_type
std::conditional_t< Layout==RowMajor, pointer, StepIterator< pointer > > row_iterator
Matrix & operator=(const Matrix &)=default
Copy assignment operator.
A thin wrapper over a complete Particle.
typename matrix_type::difference_type difference_type
typename matrix_type::value_type value_type