32 #ifndef VSMC_CORE_PARTICLE_HPP    33 #define VSMC_CORE_PARTICLE_HPP    42 #define VSMC_RUNTIME_ASSERT_CORE_PARTICLE_RESIZE_BY_RANGE                     \    43     VSMC_RUNTIME_ASSERT(                                                      \    44         (!internal::is_negative(first) && first < last && last <= size_),     \    45         "**Particle::resize_by_range** INDICES OUT OF RANGE")    58         : pptr_(pptr), begin_(begin), end_(end)
    90     using rng_type = 
typename rng_set_type::rng_type;
    94     Particle() : size_(0), state_(0), weight_(0), rng_set_(0)
    99     template <
typename... Args>
   102         , state_(N, 
std::forward<Args>(args)...)
   113         particle.rng_set_.seed();
   126     template <
typename InputIter>
   130             N, index, std::is_convertible<InputIter, const size_type *>());
   141     template <
typename ResampleType>
   146         op(static_cast<std::size_t>(size_), static_cast<std::size_t>(N), rng_,
   147             weight_.data(), rep.data());
   149             static_cast<std::size_t>(N), rep.data(), idx.data());
   150         resize(N, idx.data());
   188         return rng_set_[
static_cast<std::size_t
>(id)];
   194         return rng_set_[
static_cast<std::size_t
>(id)];
   233         state_.select(N, idx);
   238     template <
typename InputIter>
   239     void resize_by_index(
size_type N, InputIter index, std::true_type)
   241         resize(N, static_cast<const size_type *>(index));
   244     template <
typename InputIter>
   245     void resize_by_index(
size_type N, InputIter index, std::false_type)
   248         std::copy_n(index, N, idx.data());
   249         resize(N, idx.data());
   252     template <
typename InputIter, 
typename OutputIter>
   253     void resize_copy_index(
   254         std::size_t N, std::size_t M, InputIter src, OutputIter dst)
   257             dst = std::copy_n(src, M, dst);
   260         std::copy_n(src, N, dst);
   266 #endif // VSMC_CORE_PARTICLE_HPP 
std::vector< T, Alloc > Vector
std::vector with Allocator as default allocator 
ResampleAlgorithm< U01SequenceSorted, false > ResampleMultinomial
Multinomial resampling. 
range_type range(size_type begin, size_type end)
Get a ParticleRange<T> object. 
static SeedGenerator< ID, ResultType > & instance()
Particle class representing the whole particle set. 
sp_type sp(size_type id)
Get a SingleParticle<T> object. 
typename rng_set_type::rng_type rng_type
typename RNGSetTypeTrait< T >::type RNGSetType
const rng_type & rng(size_type id) const 
Get an (parallel) RNG stream for a given particle. 
state_type & state()
Read and write access to the state collection object. 
OutputIter resample_trans_rep_index(std::size_t N, std::size_t M, InputIter replication, OutputIter index)
Transform replication numbers into parent indices. 
range_type range()
Get a ParticleRange<T> object with begin == 0, end == size() 
sp_type end()
Get a SingleParticle<T> object for the first particle. 
void resize_by_index(size_type N, InputIter index)
Resize by selecting according to user supplied index vector. 
const rng_type & rng() const 
Get the (sequential) RNG used stream for resampling. 
weight_type & weight()
Read and write access to the weight collection object. 
const weight_type & weight() const 
Read only access to the weight collection object. 
ParticleRange(typename Particle< T >::size_type begin, typename Particle< T >::size_type end, Particle< T > *pptr)
Particle< T > * particle_ptr() const 
void resize_by_resample(size_type N, ResampleType &&op)
Resize by resampling. 
Particle< T > clone() const 
Clone the Particle except the RNG engines. 
const state_type & state() const 
Read only access to the state collection object. 
Particle< T >::rng_type & rng() const 
Particle(size_type N, Args &&...args)
rng_type & rng(size_type id)
Get an (parallel) RNG stream for a given particle. 
Particle< T >::size_type size() const 
rng_set_type & rng_set()
Read and write access to the RNG collection object. 
typename SizeTypeTrait< T >::type SizeType
typename WeightTypeTrait< T >::type WeightType
size_type size() const 
Number of particles. 
void resize_by_uniform(size_type N)
Resize by uniformly selecting from all particles. 
Particle< T > & particle() const 
Particle< T >::size_type begin() const 
sp_type begin()
Get a SingleParticle<T> object for the first particle. 
A thin wrapper over a complete Particle. 
rng_type & rng()
Get the (sequential) RNG used stream for resampling. 
typename ResampleTypeTrait< Scheme >::type ResampleType
Type of resample class corresponding to ResampleScheme parameter. 
Particle< T >::size_type end() const 
const rng_set_type & rng_set() const 
Read only access to the RNG collection object.