32 #ifndef VSMC_CORE_STATE_MATRIX_HPP    33 #define VSMC_CORE_STATE_MATRIX_HPP    38 #define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_COPY_SIZE_MISMATCH              \    39     VSMC_RUNTIME_ASSERT((N == static_cast<size_type>(this->size())),          \    40         "**StateMatrix::copy** SIZE MISMATCH")    42 #define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_DIM_SIZE(dim)                   \    43     VSMC_RUNTIME_ASSERT((dim >= 1), "**StateMatrix** DIMENSION IS LESS THAN " \    46 #define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_UNPACK_SIZE(psize, dim)         \    47     VSMC_RUNTIME_ASSERT((psize >= dim),                                       \    48         "**StateMatrix::state_unpack** INPUT PACK SIZE TOO SMALL")    56 template <std::
size_t Dim>
    60     static constexpr std::size_t 
dim() { 
return Dim; }
    72     std::size_t 
dim()
 const { 
return dim_; }
    87 template <MatrixLayout Layout, std::
size_t Dim, 
typename T>
   105         std::size_t 
dim()
 const { 
return this->particle().value().dim(); }
   109             return this->particle().value().state(this->
id(), pos);
   116             "**StateMatrix** OBJECT DECLARED WITH A FIXED DIMENSION");
   120         data_.resize(size_ * dim);
   133         data_.swap(other.data_);
   136     template <
typename OutputIter>
   141         for (
size_type i = 0; i != size_; ++i, ++first)
   142             *first = sptr->state(i, pos);
   145     template <
typename OutputIterIter>
   148         for (std::size_t d = 0; d != this->
dim(); ++d, ++first)
   149             read_state(d, *first);
   152     template <MatrixLayout RLayout, 
typename OutputIter>
   155         if (RLayout == Layout) {
   156             std::copy(data_.begin(), data_.end(), first);
   162                     for (std::size_t d = 0; d != this->
dim(); ++d)
   163                         *first++ = sptr->state(i, d);
   165                 for (std::size_t d = 0; d != this->
dim(); ++d)
   167                         *first++ = sptr->state(i, d);
   172     template <
typename CharT, 
typename Traits>
   173     std::basic_ostream<CharT, Traits> &
print(
   174         std::basic_ostream<CharT, Traits> &os, 
char sepchar = 
'\t')
 const   176         if (this->
dim() == 0 || size_ == 0 || !os.good())
   182             for (std::size_t d = 0; d != this->
dim() - 1; ++d)
   183                 os << sptr->state(i, d) << sepchar;
   184             os << sptr->state(i, this->
dim() - 1) << 
'\n';
   198 template <
typename CharT, 
typename Traits, 
MatrixLayout Layout,
   199     std::size_t Dim, 
typename T>
   201     std::basic_ostream<CharT, Traits> &os,
   204     return smatrix.
print(os);
   209 template <std::
size_t Dim, 
typename T>
   222         return this->data()[
id * this->
dim() + pos];
   227         return this->data()[
id * this->
dim() + pos];
   230     using state_matrix_base_type::data;
   238         return this->data() + 
id * this->
dim();
   243         return this->data() + 
id * this->
dim();
   246     template <
typename IntType>
   252             copy_particle(index[dst], dst);
   260         copy_particle_dispatch(src, dst, std::integral_constant < 
bool,
   261             Dim == 
Dynamic || 8 < Dim > ());
   267         std::copy(row_data(
id), row_data(
id) + this->
dim(), pack.data());
   275             pack.size(), this->
dim());
   278         std::copy(ptr, ptr + this->
dim(), row_data(
id));
   284             pack.size(), this->
dim());
   287         std::move(ptr, ptr + this->
dim(), row_data(
id));
   293         std::copy(row_data(src), row_data(src) + this->
dim(), row_data(dst));
   298         copy_particle_pos<0>(row_data(src), row_data(dst),
   299             std::integral_constant<bool, 0 < Dim>());
   302     template <std::
size_t D>
   307     template <std::
size_t D>
   308     void copy_particle_pos(
   312         copy_particle_pos<D + 1>(
   313             src, dst, std::integral_constant<bool, D + 1 < Dim>());
   319 template <std::
size_t Dim, 
typename T>
   332         return this->data()[pos * this->size() + id];
   337         return this->data()[pos * this->size() + id];
   340     using state_matrix_base_type::data;
   348         return this->data() + pos * this->size();
   353         return this->data() + pos * this->size();
   356     template <
typename IntType>
   361         for (std::size_t d = 0; d != this->
dim(); ++d)
   363                 state(dst, d) = state(static_cast<size_type>(index[dst]), d);
   371         copy_particle_dispatch(src, dst, std::integral_constant < 
bool,
   372             Dim == 
Dynamic || 8 < Dim > ());
   378         for (std::size_t d = 0; d != this->
dim(); ++d)
   379             pack[d] = state(
id, d);
   387             pack.size(), this->
dim());
   389         for (std::size_t d = 0; d != this->
dim(); ++d)
   390             state(
id, d) = pack[d];
   396             pack.size(), this->
dim());
   398         for (std::size_t d = 0; d != this->
dim(); ++d)
   399             state(
id, d) = std::move(pack[d]);
   405         for (std::size_t d = 0; d != this->
dim(); ++d)
   406             state(dst, d) = state(src, d);
   411         copy_particle_pos<0>(this->data() + src, this->data() + dst,
   412             std::integral_constant<bool, 0 < Dim>());
   415     template <std::
size_t D>
   420     template <std::
size_t D>
   421     void copy_particle_pos(
   424         dst[D * this->size()] = src[D * this->size()];
   425         copy_particle_pos<D + 1>(
   426             src, dst, std::integral_constant<bool, D + 1 < Dim>());
   432 #endif // VSMC_CORE_STATE_MATRIX_HPP 
single_particle_type(typename Particle< S >::size_type id, Particle< S > *pptr)
 
T & state(size_type id, std::size_t pos)
 
Particle class representing the whole particle set. 
 
state_type & state(std::size_t pos) const 
 
state_type * row_data(size_type id)
 
void read_state_matrix(OutputIter first) const 
 
typename state_matrix_base_type::state_pack_type state_pack_type
 
Base type of StateMatrix. 
 
state_type * data(size_type id)
 
void state_unpack(size_type id, const state_pack_type &pack)
 
#define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_DIM_SIZE(dim)                                  
 
MatrixLayout
Matrix layout. 
 
const T & state(size_type id, std::size_t pos) const 
 
const T & state(size_type id, std::size_t pos) const 
 
state_type * data(size_type pos)
 
const state_type * col_data(std::size_t pos) const 
 
typename state_matrix_base_type::size_type size_type
 
const state_type * row_data(size_type id) const 
 
void copy_particle(size_type src, size_type dst)
 
void state_unpack(size_type id, state_pack_type &&pack)
 
std::basic_ostream< CharT, Traits > & print(std::basic_ostream< CharT, Traits > &os, char sepchar= '\t') const 
 
void copy_particle(size_type src, size_type dst)
 
const state_type * data() const 
 
typename state_matrix_base_type::state_pack_type state_pack_type
 
state_pack_type state_pack(size_type id) const 
 
void swap(StateMatrixBase< Layout, Dim, T > &other)
 
typename state_matrix_base_type::state_type state_type
 
void read_state(std::size_t pos, OutputIter first) const 
 
static constexpr std::size_t dim()
 
void state_unpack(size_type id, state_pack_type &&pack)
 
state_pack_type state_pack(size_type id) const 
 
void copy(size_type N, const IntType *index)
 
void resize_dim(std::size_t dim)
 
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const Sampler< T > &sampler)
 
StateMatrixBase(size_type N)
 
void swap(const MKLBase< MKLPtr, Derived > &ptr1, const MKLBase< MKLPtr, Derived > &ptr2)
Swap two MKLBase objects. 
 
void resize_dim(std::size_t dim)
 
#define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_COPY_SIZE_MISMATCH
 
const state_type * data(size_type pos) const 
 
void read_state_matrix(OutputIterIter first) const 
 
void swap(StateMatrixDim< Dim > &)
 
A thin wrapper over a complete Particle. 
 
state_type * col_data(std::size_t pos)
 
typename state_matrix_base_type::state_type state_type
 
const state_type * data(size_type id) const 
 
#define VSMC_RUNTIME_ASSERT_CORE_STATE_MATRIX_UNPACK_SIZE(psize, dim)              
 
T & state(size_type id, std::size_t pos)
 
void swap(StateMatrixDim< Dynamic > &other)
 
void state_unpack(size_type id, const state_pack_type &pack)
 
typename state_matrix_base_type::size_type size_type
 
void copy(size_type N, const IntType *index)