MCKL
Monte Carlo Kernel Library
Classes | Public Types | Public Member Functions | List of all members
mckl::StateMatrix< Layout, T, Dim > Class Template Reference

Particle::state_type subtype. More...

#include <mckl/core/state_matrix.hpp>

Inherits mckl::Matrix< T, Layout >.

Inherited by mckl::PMCMCStateMatrix< Param, Layout, T, Dim >.

Classes

class  particle_index_type
 ParticleIndex base class. More...
 

Public Types

using difference_type = typename matrix_type::difference_type
 
using matrix_type = Matrix< T, Layout >
 
using pointer = typename matrix_type::pointer
 
using reference = typename matrix_type::reference
 
using size_type = typename matrix_type::size_type
 
using value_type = typename matrix_type::value_type
 
- Public Types inherited from mckl::Matrix< T, Layout >
using allocator_type = Allocator< T >
 
using col_iterator = std::conditional_t< Layout==ColMajor, pointer, StepIterator< pointer > >
 
using col_range = Range< col_iterator >
 
using const_col_iterator = std::conditional_t< Layout==ColMajor, const_pointer, StepIterator< const_pointer > >
 
using const_col_range = Range< const_col_iterator >
 
using const_iterator = const_pointer
 
using const_pointer = const value_type *
 
using const_reference = const value_type &
 
using const_reverse_col_iterator = std::reverse_iterator< const_col_iterator >
 
using const_reverse_col_range = Range< const_reverse_col_iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using const_reverse_row_iterator = std::reverse_iterator< const_row_iterator >
 
using const_reverse_row_range = Range< const_reverse_row_iterator >
 
using const_row_iterator = std::conditional_t< Layout==RowMajor, const_pointer, StepIterator< const_pointer > >
 
using const_row_range = Range< const_row_iterator >
 
using difference_type = std::ptrdiff_t
 
using iterator = pointer
 
using pointer = value_type *
 
using reference = value_type &
 
using reverse_col_iterator = std::reverse_iterator< col_iterator >
 
using reverse_col_range = Range< reverse_col_iterator >
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using reverse_row_iterator = std::reverse_iterator< row_iterator >
 
using reverse_row_range = Range< reverse_row_iterator >
 
using row_iterator = std::conditional_t< Layout==RowMajor, pointer, StepIterator< pointer > >
 
using row_range = Range< row_iterator >
 
using size_type = std::size_t
 
using transpose_type = Matrix< T, Layout==RowMajor ? ColMajor :RowMajor, Allocator< T > >
 
using value_type = T
 

Public Member Functions

 StateMatrix (size_type N=0)
 Matrix::Matrix(N, Dim) More...
 
 StateMatrix (size_type N, size_type dim)
 Matrix::Matrix(N, dim) More...
 
size_type dim () const
 Matrix::ncol() More...
 
void duplicate (size_type src, size_type dst)
 Duplicate a sample. More...
 
void reserve (size_type N)
 Matrix::reserve(N, dim()) More...
 
void resize (size_type N)
 Matrix::resize(N, dim()) More...
 
template<typename InputIter >
void select (size_type n, InputIter index)
 Select samples in-place. More...
 
size_type size () const
 Matrix::nrow() More...
 
- Public Member Functions inherited from mckl::Matrix< T, Layout >
 Matrix () noexcept(std::is_nothrow_default_constructible< Vector< T, Allocator< T > >>::value)
 Construct an empty matrix. More...
 
 Matrix (size_type nrow, size_type ncol)
 Construct an nrow by ncol matrix. More...
 
 Matrix (const Matrix &)=default
 Copy constructor. More...
 
 Matrix (Matrix &&other) noexcept(std::is_nothrow_move_constructible< Vector< T, Allocator< T > >>::value)
 Move constructor. More...
 
reference at (size_type i, size_type j)
 Access an element in the matrix with bound checking. More...
 
const_reference at (size_type i, size_type j) const
 Access an element in the matrix with bound checking. More...
 
iterator begin ()
 Iterator to the upper left corner of the matrix. More...
 
const_iterator begin () const
 Iterator to the upper left corner of the matrix. More...
 
const_iterator cbegin () const
 Iterator to the upper left corner of the matrix. More...
 
const_col_range ccol (size_type i) const
 Range of a column. More...
 
const_iterator cend () const
 Iterator to one pass the lower right corner of the matrix. More...
 
void clear ()
 Clear the matrix of all elements. More...
 
col_range col (size_type i)
 Range of a column. More...
 
const_col_range col (size_type i) const
 Range of a column. More...
 
col_iterator col_begin (size_type i)
 Iterator to the beginning of a column. More...
 
const_col_iterator col_begin (size_type j) const
 Iterator to the beginning of a column. More...
 
const_col_iterator col_cbegin (size_type j) const
 Iterator to the beginning of a column. More...
 
const_col_iterator col_cend (size_type j) const
 Iterator to one pass the end of a column. More...
 
const_reverse_col_iterator col_crbegin (size_type j) const
 Iterator to the end of a column. More...
 
const_reverse_col_iterator col_crend (size_type j) const
 Iterator to one before the beginning of a column. More...
 
pointer col_data (size_type j)
 Pointer to the beginning of a column. More...
 
const_pointer col_data (size_type j) const
 Pointer to the beginning of a column. More...
 
col_iterator col_end (size_type j)
 Iterator to one pass the end of a column. More...
 
const_col_iterator col_end (size_type j) const
 Iterator to one pass the end of a column. More...
 
reverse_col_iterator col_rbegin (size_type j)
 Iterator to the end of a column. More...
 
const_reverse_col_iterator col_rbegin (size_type j) const
 Iterator to the end of a column. More...
 
reverse_col_iterator col_rend (size_type j)
 Iterator to one before the beginning of a column. More...
 
const_reverse_col_iterator col_rend (size_type j) const
 Iterator to one before the beginning of a column. More...
 
size_type col_stride () const
 The stride size of column-wise access through col_data() More...
 
const_reverse_iterator crbegin () const
 Iterator to the lower right corner of the matrix. More...
 
const_reverse_col_range crcol (size_type i) const
 Range of a column in reverse order. More...
 
const_reverse_iterator crend () const
 Iterator one before the upper left corner of the matrix. More...
 
const_row_range crow (size_type i) const
 Range of a row. More...
 
const_reverse_row_range crrow (size_type i) const
 Range of a row in reverse order. More...
 
pointer data ()
 Pointer to the upper left corner of the matrix. More...
 
const_pointer data () const
 Pointer to the upper left corner of the matrix. More...
 
bool empty () const
 If the matrix is empty, i.e., nrow() * ncol() == 0 More...
 
iterator end ()
 Iterator to one pass the lower right corner of the matrix. More...
 
const_iterator end () const
 Iterator to one pass the lower right corner of the matrix. More...
 
allocator_type get_allocator () const
 Return the associated allocator. More...
 
size_type ldim () const
 The number of elements in the leading dimension. More...
 
size_type ncol () const
 The number of columns. More...
 
size_type nrow () const
 The number of rows. More...
 
 operator transpose_type () const
 Convert to a matrix with a different storage layout. More...
 
reference operator() (size_type i, size_type j)
 Access an element in the matrix. More...
 
const_reference operator() (size_type i, size_type j) const
 Access an element in the matrix. More...
 
Matrixoperator= (const Matrix &)=default
 Copy assignment operator. More...
 
Matrixoperator= (Matrix &&other) noexcept(noexcept(data_.swap(other.data_)))
 Move assignment operator. More...
 
void push_back_col (InputIter first)
 Insert a new coloumn at the right. More...
 
void push_back_row (InputIter first)
 Insert a new row at the bottom. More...
 
reverse_iterator rbegin ()
 Iterator to the lower right corner of the matrix. More...
 
const_reverse_iterator rbegin () const
 Iterator to the lower right corner of the matrix. More...
 
reverse_col_range rcol (size_type i)
 Range of a column in reverse order. More...
 
const_reverse_col_range rcol (size_type i) const
 Range of a column in reverse order. More...
 
reverse_iterator rend ()
 Iterator one before the upper left corner of the matrix. More...
 
const_reverse_iterator rend () const
 Iterator one before the upper left corner of the matrix. More...
 
void reserve (size_type n, size_type m)
 Reserve storage space for the matrix. More...
 
void resize (size_type nrow, size_type ncol)
 Resize the matrix. More...
 
row_range row (size_type i)
 Range of a row. More...
 
const_row_range row (size_type i) const
 Range of a row. More...
 
row_iterator row_begin (size_type i)
 Iterator to the beginning of a row. More...
 
const_row_iterator row_begin (size_type i) const
 Iterator to the beginning of a row. More...
 
const_row_iterator row_cbegin (size_type i) const
 Iterator to the beginning of a row. More...
 
const_row_iterator row_cend (size_type i) const
 Iterator to one pass the end of a row. More...
 
const_reverse_row_iterator row_crbegin (size_type i) const
 Iterator to the end of a row. More...
 
const_reverse_row_iterator row_crend (size_type i) const
 Iterator to one before the beginning of a row. More...
 
pointer row_data (size_type i)
 Pointer to the first element of a row. More...
 
const_pointer row_data (size_type i) const
 Pointer to the first element of a row. More...
 
row_iterator row_end (size_type i)
 Iterator to one pass the end of a row. More...
 
const_row_iterator row_end (size_type i) const
 Iterator to one pass the end of a row. More...
 
reverse_row_iterator row_rbegin (size_type i)
 Iterator to the end of a row. More...
 
const_reverse_row_iterator row_rbegin (size_type i) const
 Iterator to the end of a row. More...
 
reverse_row_iterator row_rend (size_type i)
 Iterator to one before the beginning of a row. More...
 
const_reverse_row_iterator row_rend (size_type i) const
 Iterator to one before the beginning of a row. More...
 
size_type row_stride () const
 The stride of row-wise access through row_data() More...
 
reverse_row_range rrow (size_type i)
 Range of a row in reverse order. More...
 
const_reverse_row_range rrow (size_type i) const
 Range of a row in reverse order. More...
 
void shrink_to_fit ()
 Release memory no longer needed. More...
 
size_type size () const
 The total number of elements. More...
 
void swap (Matrix &other) noexcept(noexcept(data_.swap(other.data_)))
 Swap two matrices. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from mckl::Matrix< T, Layout >
static constexpr MatrixLayout layout ()
 The layout of the matrix. More...
 

Detailed Description

template<MatrixLayout Layout, typename T, std::size_t Dim = 0>
class mckl::StateMatrix< Layout, T, Dim >

Particle::state_type subtype.

Template Parameters
LayoutThe storage layout, either RowMajor or ColMajor
DimThe initial dimension of the samples
TThe value type of the samples

Let \(X\) be \(D\)-vector of samples of type T. A collection of \(N\) samples is stored as an \(N\) by \(D\) matrix. The value of the template parameter Dim only specifies the initial value of \(D\).

Definition at line 53 of file state_matrix.hpp.

Member Typedef Documentation

◆ difference_type

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::difference_type = typename matrix_type::difference_type

Definition at line 63 of file state_matrix.hpp.

◆ matrix_type

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::matrix_type = Matrix<T, Layout>

Definition at line 60 of file state_matrix.hpp.

◆ pointer

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::pointer = typename matrix_type::pointer

Definition at line 65 of file state_matrix.hpp.

◆ reference

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::reference = typename matrix_type::reference

Definition at line 64 of file state_matrix.hpp.

◆ size_type

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::size_type = typename matrix_type::size_type

Definition at line 62 of file state_matrix.hpp.

◆ value_type

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
using mckl::StateMatrix< Layout, T, Dim >::value_type = typename matrix_type::value_type

Definition at line 61 of file state_matrix.hpp.

Constructor & Destructor Documentation

◆ StateMatrix() [1/2]

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
mckl::StateMatrix< Layout, T, Dim >::StateMatrix ( size_type  N = 0)
inlineexplicit

Matrix::Matrix(N, Dim)

Definition at line 154 of file state_matrix.hpp.

◆ StateMatrix() [2/2]

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
mckl::StateMatrix< Layout, T, Dim >::StateMatrix ( size_type  N,
size_type  dim 
)
inline

Matrix::Matrix(N, dim)

Definition at line 157 of file state_matrix.hpp.

Member Function Documentation

◆ dim()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
size_type mckl::StateMatrix< Layout, T, Dim >::dim ( ) const
inline

Matrix::ncol()

Definition at line 168 of file state_matrix.hpp.

◆ duplicate()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
void mckl::StateMatrix< Layout, T, Dim >::duplicate ( size_type  src,
size_type  dst 
)
inline

Duplicate a sample.

Parameters
srcThe index of sample to be duplicated
dstThe index of sample to be eliminated
Postcondition
Let \(i\) and \(j\) be the values of src and dst, respectivley, then \(X_j = X_i\), where \(X_i\) is the \(i\)-th row of the matrix

Definition at line 207 of file state_matrix.hpp.

◆ reserve()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
void mckl::StateMatrix< Layout, T, Dim >::reserve ( size_type  N)
inline

Matrix::reserve(N, dim())

Definition at line 173 of file state_matrix.hpp.

◆ resize()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
void mckl::StateMatrix< Layout, T, Dim >::resize ( size_type  N)
inline

Matrix::resize(N, dim())

Definition at line 178 of file state_matrix.hpp.

◆ select()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
template<typename InputIter >
void mckl::StateMatrix< Layout, T, Dim >::select ( size_type  n,
InputIter  index 
)
inline

Select samples in-place.

Parameters
nThe new sample size
indexN-vector of parent index
Precondition
Let \(a_i\) denote the value of index[i], and \(r_i = \sum_{j=1}^N \mathbb{I}_{\{i\}}(a_j)\). Then it is required that \(a_i = i\) for all \(r_i > 0\).
Postcondition
size() == N
For \(i = 1,\dots,N\), \(Y_i = X_{a_i}\), where \(Y_i\) is the \(i\)-th row of the new matrix and \(X_j\) is the \(j\)-th row of the original matrix

Definition at line 194 of file state_matrix.hpp.

◆ size()

template<MatrixLayout Layout, typename T , std::size_t Dim = 0>
size_type mckl::StateMatrix< Layout, T, Dim >::size ( ) const
inline

Matrix::nrow()

Definition at line 165 of file state_matrix.hpp.