MCKL
Monte Carlo Kernel Library
Public Types | Public Member Functions | Friends | List of all members
mckl::Weight Class Reference

Weights of samples. More...

#include <mckl/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...
 
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 OutputIter >
OutputIter read (OutputIter first) const
 Read all normalized weights to an output 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...
 
void set_equal ()
 Set \(W_i = 1/N\). More...
 
template<typename InputIter >
void set_exact (double ess, InputIter first)
 Set exact values of ESS and normalized weights. More...
 
template<typename InputIter >
void set_log (InputIter first)
 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...
 

Friends

bool is_equal (const Weight &w1, const Weight &w2)
 
bool operator!= (const Weight &w1, const Weight &w2)
 
bool operator== (const Weight &w1, const Weight &w2)
 

Detailed Description

Weights of samples.

Definition at line 44 of file weight.hpp.

Member Typedef Documentation

◆ size_type

using mckl::Weight::size_type = std::size_t

Definition at line 47 of file weight.hpp.

Constructor & Destructor Documentation

◆ Weight()

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

Definition at line 49 of file weight.hpp.

Member Function Documentation

◆ add_log() [1/3]

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

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

Definition at line 133 of file weight.hpp.

◆ add_log() [2/3]

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

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

Definition at line 143 of file weight.hpp.

◆ add_log() [3/3]

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

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

Definition at line 151 of file weight.hpp.

◆ data()

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

Pointer to data of the normalized weight.

Definition at line 67 of file weight.hpp.

◆ draw()

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

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

Definition at line 156 of file weight.hpp.

◆ ess()

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

Return the ESS of the particle system.

Definition at line 64 of file weight.hpp.

◆ mul() [1/3]

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

Set \(W_i \propto W_i w_i\).

Definition at line 105 of file weight.hpp.

◆ mul() [2/3]

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

Set \(W_i \propto W_i w_i\).

Definition at line 114 of file weight.hpp.

◆ mul() [3/3]

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

Set \(W_i \propto W_i w_i\).

Definition at line 121 of file weight.hpp.

◆ read()

template<typename OutputIter >
OutputIter mckl::Weight::read ( OutputIter  first) const
inline

Read all normalized weights to an output iterator.

Definition at line 71 of file weight.hpp.

◆ reserve()

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

Reserve space.

Definition at line 58 of file weight.hpp.

◆ resize()

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

Resize the Weight object.

Definition at line 55 of file weight.hpp.

◆ set()

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

Set \(W_i \propto w_i\).

Definition at line 85 of file weight.hpp.

◆ set_equal()

void mckl::Weight::set_equal ( )
inline

Set \(W_i = 1/N\).

Definition at line 77 of file weight.hpp.

◆ set_exact()

template<typename InputIter >
void mckl::Weight::set_exact ( double  ess,
InputIter  first 
)
inline

Set exact values of ESS and normalized weights.

This will set the internal state exactly to the input. No check of if the values are really normalized or ESS is correctly calculated

Definition at line 97 of file weight.hpp.

◆ set_log()

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

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

Definition at line 125 of file weight.hpp.

◆ shrink_to_fit()

void mckl::Weight::shrink_to_fit ( )
inline

Shrink to fit.

Definition at line 61 of file weight.hpp.

◆ size()

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

Size of this Weight object.

Definition at line 52 of file weight.hpp.

Friends And Related Function Documentation

◆ is_equal

bool is_equal ( const Weight w1,
const Weight w2 
)
friend

Definition at line 173 of file weight.hpp.

◆ operator!=

bool operator!= ( const Weight w1,
const Weight w2 
)
friend

Definition at line 168 of file weight.hpp.

◆ operator==

bool operator== ( const Weight w1,
const Weight w2 
)
friend

Definition at line 163 of file weight.hpp.