IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution > Class Template Reference

A class for inverse transform sampling. More...

#include <InverseTransformSampling.h>

+ Collaboration diagram for ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >:

Classes

struct  fill_random
 Functor that is used for generating samples. More...
 

Public Types

using view_type = typename ippl::detail::ViewType< Vector< T, Dim >, 1 >::view_type
 
using size_type = ippl::detail::size_type
 

Public Member Functions

template<class RegionLayout >
 InverseTransformSampling (Distribution &dist_r, Vector< T, Dim > &rmax_r, Vector< T, Dim > &rmin_r, RegionLayout &rlayout_r, size_type &ntotal_r)
 Constructor for InverseTransformSampling class with domain decomposition.
 
 InverseTransformSampling (Distribution &dist_r, Vector< T, Dim > &rmax_r, Vector< T, Dim > &rmin_r, Vector< T, Dim > &locrmax_r, Vector< T, Dim > &locrmin_r, size_type &ntotal_r)
 Constructor for InverseTransformSampling class without applying domain decomposition..
 
 InverseTransformSampling (Distribution &dist_r, Vector< T, Dim > &rmax_r, Vector< T, Dim > &rmin_r, size_type &ntotal_r)
 Constructor for InverseTransformSampling class. In this method, we do not consider any domain decomposition.
 
void updateBounds (Vector< T, Dim > &rmax, Vector< T, Dim > &rmin, Vector< T, Dim > &locrmax, Vector< T, Dim > &locrmin)
 Updates the sampling bounds and reinitializes internal variables.
 
void updateBounds (Vector< T, Dim > &rmax, Vector< T, Dim > &rmin)
 Updates the sampling bounds using the CDF without any domain decomposition.
 
 ~InverseTransformSampling ()
 Deconstructor for InverseTransformSampling class.
 
KOKKOS_INLINE_FUNCTION size_type getLocalSamplesNum () const
 Get the local number of samples.
 
KOKKOS_INLINE_FUNCTION void setLocalSamplesNum (size_type nlocal)
 Set the local number of particles.
 
void generate (view_type view, Kokkos::Random_XorShift64_Pool<> rand_pool64)
 Generate random samples using inverse transform sampling.
 
void generate (view_type view, size_type startIndex, size_type endIndex, Kokkos::Random_XorShift64_Pool<> rand_pool64)
 Generate random samples using inverse transform sampling for a specific range of particles.
 

Public Attributes

Distribution dist_m
 
size_type ntotal_m
 
Vector< T, Dim > umin_m
 
Vector< T, Dim > umax_m
 

Detailed Description

template<typename T, unsigned Dim, class DeviceType, class Distribution>
class ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >

A class for inverse transform sampling.

This class performs inverse transform sampling for a given distribution.

Template Parameters
TData type.
DimDimensionality of the sample space.
DeviceTypeThe device type for Kokkos.
DistributionType of the distribution to sample from.

Constructor & Destructor Documentation

◆ InverseTransformSampling() [1/3]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
template<class RegionLayout >
ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::InverseTransformSampling ( Distribution dist_r,
Vector< T, Dim > &  rmax_r,
Vector< T, Dim > &  rmin_r,
RegionLayout &  rlayout_r,
size_type &  ntotal_r 
)
inline

Constructor for InverseTransformSampling class with domain decomposition.

Parameters
dist_rThe distribution to sample from.
rmax_rMaximum global range.
rmin_rMinimum global range.
rlayout_rThe region layout.
ntotal_rTotal number of samples to generate.

◆ InverseTransformSampling() [2/3]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::InverseTransformSampling ( Distribution dist_r,
Vector< T, Dim > &  rmax_r,
Vector< T, Dim > &  rmin_r,
Vector< T, Dim > &  locrmax_r,
Vector< T, Dim > &  locrmin_r,
size_type &  ntotal_r 
)
inline

Constructor for InverseTransformSampling class without applying domain decomposition..

Parameters
dist_rThe distribution to sample from.
rmax_rMaximum global range.
rmin_rMinimum global range.
locrmax_rMaximum local (per rank) range.
locrmin_rMinimum local (per rank) range.
ntotal_Total number of samples to generate.

◆ InverseTransformSampling() [3/3]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::InverseTransformSampling ( Distribution dist_r,
Vector< T, Dim > &  rmax_r,
Vector< T, Dim > &  rmin_r,
size_type &  ntotal_r 
)
inline

Constructor for InverseTransformSampling class. In this method, we do not consider any domain decomposition.

Parameters
dist_rThe distribution to sample from.
rmax_rMaximum global range for sampling.
rmin_rMinimum global range for sampling.
ntotal_rTotal number of samples to generate.

Member Function Documentation

◆ generate() [1/2]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
void ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::generate ( view_type  view,
Kokkos::Random_XorShift64_Pool<>  rand_pool64 
)
inline

Generate random samples using inverse transform sampling.

Parameters
viewThe view to fill with random samples.
rand_pool64The random number generator pool.

◆ generate() [2/2]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
void ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::generate ( view_type  view,
size_type  startIndex,
size_type  endIndex,
Kokkos::Random_XorShift64_Pool<>  rand_pool64 
)
inline

Generate random samples using inverse transform sampling for a specific range of particles.

Parameters
viewThe view to fill with random samples.
startIndexThe starting index of view.
endIndexThe ending index of view.
rand_pool64The random number generator pool.

◆ getLocalSamplesNum()

template<typename T , unsigned Dim, class DeviceType , class Distribution >
KOKKOS_INLINE_FUNCTION size_type ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::getLocalSamplesNum ( ) const
inline

Get the local number of samples.

Returns
The local number of samples.

◆ setLocalSamplesNum()

template<typename T , unsigned Dim, class DeviceType , class Distribution >
KOKKOS_INLINE_FUNCTION void ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::setLocalSamplesNum ( size_type  nlocal)
inline

Set the local number of particles.

Parameters
nlocalThe new number of local particles.

◆ updateBounds() [1/2]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
void ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::updateBounds ( Vector< T, Dim > &  rmax,
Vector< T, Dim > &  rmin 
)
inline

Updates the sampling bounds using the CDF without any domain decomposition.

This method allows the user to update the minimum and maximum bounds for the inverse transform sampling method. It recalculates the cumulative distribution function (CDF) values for the new bounds and updates the internal variables to reflect these changes.

Parameters
new_rmaxThe new maximum range for sampling. This vector defines the upper bounds for each dimension.
new_rminThe new minimum range for sampling. This vector defines the lower bounds for each dimension.

◆ updateBounds() [2/2]

template<typename T , unsigned Dim, class DeviceType , class Distribution >
void ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::updateBounds ( Vector< T, Dim > &  rmax,
Vector< T, Dim > &  rmin,
Vector< T, Dim > &  locrmax,
Vector< T, Dim > &  locrmin 
)
inline

Updates the sampling bounds and reinitializes internal variables.

This method allows the user to update the minimum and maximum bounds for the sampling process It recalculates the cumulative distribution function (CDF) values for the new bounds and updates the internal variables to reflect these changes.

Parameters
rmaxThe new maximum range for sampling. This vector defines the upper bounds for each dimension.
rminThe new minimum range for sampling. This vector defines the lower bounds for each dimension.
locrmaxThe new local maximum range for sampling. This vector defines the upper bounds for each dimension for a given rank.
locrminThe new minimum range for sampling. This vector defines the lower bounds for each dimension for a given rank.

The documentation for this class was generated from the following file: