vSMC  v3.0.0
Scalable Monte Carlo
Public Types | Public Member Functions | List of all members
vsmc::Weight Class Reference

Weight class. More...

#include <vsmc/core/weight.hpp>

Public Types

using size_type = std::size_t
 

Public Member Functions

 Weight (size_type N=0)
 
template<typename InputIter >
void add_log (InputIter first)
 Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\). More...
 
void add_log (const double *first)
 Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\). More...
 
void add_log (double *first)
 Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\). More...
 
template<typename RandomIter >
void add_log (RandomIter first, int stride)
 Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\). More...
 
const double * data () const
 Pointer to data of the normalized weight. More...
 
template<typename RNGType >
size_type draw (RNGType &rng) const
 Draw integer index in the range \([0, N)\) according to the weights. More...
 
double ess () const
 Return the ESS of the particle system. More...
 
template<typename InputIter >
void mul (InputIter first)
 Set \(W_i \propto W_i w_i\). More...
 
void mul (const double *first)
 Set \(W_i \propto W_i w_i\). More...
 
void mul (double *first)
 Set \(W_i \propto W_i w_i\). More...
 
template<typename RandomIter >
void mul (RandomIter first, int stride)
 Set \(W_i \propto W_i w_i\). More...
 
template<typename OutputIter >
OutputIter read_weight (OutputIter first) const
 Read all normalized weights to an output iterator. More...
 
template<typename RandomIter >
RandomIter read_weight (RandomIter first, int stride) const
 Read all normalized weights to a random access iterator. More...
 
void reserve (size_type N)
 Reserve space. More...
 
void resize (size_type N)
 Resize the Weight object. More...
 
template<typename InputIter >
void set (InputIter first)
 Set \(W_i \propto w_i\). More...
 
template<typename RandomIter >
void set (RandomIter first, int stride)
 Set \(W_i \propto w_i\). More...
 
void set_equal ()
 Set \(W_i = 1/N\). More...
 
template<typename InputIter >
void set_log (InputIter first)
 Set \(\log W_i = v_i + \mathrm{const.}\). More...
 
template<typename RandomIter >
void set_log (RandomIter first, int stride)
 Set \(\log W_i = v_i + \mathrm{const.}\). More...
 
void shrink_to_fit ()
 Shrink to fit. More...
 
size_type size () const
 Size of this Weight object. More...
 

Detailed Description

Weight class.

Definition at line 43 of file weight.hpp.

Member Typedef Documentation

using vsmc::Weight::size_type = std::size_t

Definition at line 46 of file weight.hpp.

Constructor & Destructor Documentation

vsmc::Weight::Weight ( size_type  N = 0)
inlineexplicit

Definition at line 48 of file weight.hpp.

Member Function Documentation

template<typename InputIter >
void vsmc::Weight::add_log ( InputIter  first)
inline

Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\).

Definition at line 181 of file weight.hpp.

void vsmc::Weight::add_log ( const double *  first)
inline

Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\).

Definition at line 190 of file weight.hpp.

void vsmc::Weight::add_log ( double *  first)
inline

Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\).

Definition at line 198 of file weight.hpp.

template<typename RandomIter >
void vsmc::Weight::add_log ( RandomIter  first,
int  stride 
)
inline

Set \(\log W_i = \log W_i + v_i + \mathrm{const.}\).

Definition at line 202 of file weight.hpp.

const double* vsmc::Weight::data ( ) const
inline

Pointer to data of the normalized weight.

Definition at line 76 of file weight.hpp.

template<typename RNGType >
size_type vsmc::Weight::draw ( RNGType &  rng) const
inline

Draw integer index in the range \([0, N)\) according to the weights.

Definition at line 218 of file weight.hpp.

double vsmc::Weight::ess ( ) const
inline

Return the ESS of the particle system.

Definition at line 73 of file weight.hpp.

template<typename InputIter >
void vsmc::Weight::mul ( InputIter  first)
inline

Set \(W_i \propto W_i w_i\).

Definition at line 126 of file weight.hpp.

void vsmc::Weight::mul ( const double *  first)
inline

Set \(W_i \propto W_i w_i\).

Definition at line 134 of file weight.hpp.

void vsmc::Weight::mul ( double *  first)
inline

Set \(W_i \propto W_i w_i\).

Definition at line 141 of file weight.hpp.

template<typename RandomIter >
void vsmc::Weight::mul ( RandomIter  first,
int  stride 
)
inline

Set \(W_i \propto W_i w_i\).

Definition at line 145 of file weight.hpp.

template<typename OutputIter >
OutputIter vsmc::Weight::read_weight ( OutputIter  first) const
inline

Read all normalized weights to an output iterator.

Definition at line 80 of file weight.hpp.

template<typename RandomIter >
RandomIter vsmc::Weight::read_weight ( RandomIter  first,
int  stride 
) const
inline

Read all normalized weights to a random access iterator.

Definition at line 87 of file weight.hpp.

void vsmc::Weight::reserve ( size_type  N)
inline

Reserve space.

Definition at line 67 of file weight.hpp.

void vsmc::Weight::resize ( size_type  N)
inline

Resize the Weight object.

After resizing, if the size changed, equal weights are set

Definition at line 57 of file weight.hpp.

template<typename InputIter >
void vsmc::Weight::set ( InputIter  first)
inline

Set \(W_i \propto w_i\).

Definition at line 104 of file weight.hpp.

template<typename RandomIter >
void vsmc::Weight::set ( RandomIter  first,
int  stride 
)
inline

Set \(W_i \propto w_i\).

Definition at line 112 of file weight.hpp.

void vsmc::Weight::set_equal ( )
inline

Set \(W_i = 1/N\).

Definition at line 96 of file weight.hpp.

template<typename InputIter >
void vsmc::Weight::set_log ( InputIter  first)
inline

Set \(\log W_i = v_i + \mathrm{const.}\).

Definition at line 159 of file weight.hpp.

template<typename RandomIter >
void vsmc::Weight::set_log ( RandomIter  first,
int  stride 
)
inline

Set \(\log W_i = v_i + \mathrm{const.}\).

Definition at line 167 of file weight.hpp.

void vsmc::Weight::shrink_to_fit ( )
inline

Shrink to fit.

Definition at line 70 of file weight.hpp.

size_type vsmc::Weight::size ( ) const
inline

Size of this Weight object.

Definition at line 51 of file weight.hpp.