Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(AliasSampler_t), | private, | allocatable | :: | samplerArray(:,:,:) | |||
type(shared_array_real_t), | private | :: | allProbs | ||||
type(shared_array_real_t), | private | :: | allBiasTable | ||||
type(shared_array_int32_t), | private | :: | allAliasTable |
Setup an array of samplers using a single shared resource (split into parts associated with one of them each). This only does the allocation. @param[in] dims Dimension of the three-dimensional array of samplers. @param[in] entry_size number of values per sampler
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | dims(3) | |||
integer, | intent(in) | :: | entry_size | |||
character(len=*), | intent(in) | :: | name |
@brief Initialise one sampler of an array
@param[in] i Index of the entry to initialize @param[in] j Index of the entry to initialize @param[in] k Index of the entry to initialize @param[in] arr data to be loaded by that entry
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(inout) | :: | this | |||
integer, | intent(in) | :: | i | |||
integer, | intent(in) | :: | j | |||
integer, | intent(in) | :: | k | |||
integer, | intent(in) | :: | rank_with_info |
The intra-node rank that contains the weights to be used all other arr of all other ranks are ignored (and can be allocated with size 0). |
||
real(kind=dp), | intent(in) | :: | arr(:) |
@brief Deallocate an array of samplers
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(inout) | :: | this |
Draw a random element from 1:size(this%probs) with the probabilities listed in prob
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i |
The index of the sampler. |
||
integer, | intent(in) | :: | j |
The index of the sampler. |
||
integer, | intent(in) | :: | k |
The index of the sampler. |
||
integer, | intent(out) | :: | tgt |
The sampled value |
||
real(kind=dp), | intent(out) | :: | prob |
The probability of sampling |
Draw a random element from 1:size(this%probs) with the probabilities listed in prob while adherring to constraints
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i |
The index of the sampler. |
||
integer, | intent(in) | :: | j |
The index of the sampler. |
||
integer, | intent(in) | :: | k |
The index of the sampler. |
||
integer, | intent(in) | :: | contain(:) |
The constraint in nI format. |
||
real(kind=dp), | intent(in) | :: | renorm |
The renormalization. (i.e. sum(this%get_prob(… contain…)) |
||
integer, | intent(out) | :: | pos |
The sampled value |
||
integer, | intent(out) | :: | tgt |
The sampled value |
||
real(kind=dp), | intent(out) | :: | prob |
The probability of sampling |
Draw a random element from 1:size(this%probs) with the probabilities listed in prob while adherring to constraints
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i |
The index of the sampler. |
||
integer, | intent(in) | :: | j |
The index of the sampler. |
||
integer, | intent(in) | :: | k |
The index of the sampler. |
||
integer, | intent(in) | :: | contain(:) |
The constraint in nI format. |
||
integer(kind=n_int), | intent(in) | :: | contain_ilut(0:) |
The constraint in ilut (bitmask) format |
||
real(kind=dp), | intent(in) | :: | renormalization |
The renormalization. (i.e. sum(this%get_prob(… contain…)) |
||
integer, | intent(out) | :: | pos |
The sampled value |
||
integer, | intent(out) | :: | tgt |
The sampled value |
||
real(kind=dp), | intent(out) | :: | prob |
The probability of sampling |
Draw a random element from 1:size(this%probs) with the probabilities listed in prob while adherring to constraints
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i |
The index of the sampler. |
||
integer, | intent(in) | :: | j |
The index of the sampler. |
||
integer, | intent(in) | :: | k |
The index of the sampler. |
||
integer, | intent(in) | :: | contain(:) |
The constraint in nI format. |
||
integer(kind=n_int), | intent(in) | :: | contain_ilut(0:) |
The constraint in ilut (bitmask) format |
||
real(kind=dp), | intent(in) | :: | renormalization |
The renormalization. (i.e. sum(this%get_prob(… contain…)) |
||
integer, | intent(out) | :: | pos |
The sampled value |
||
integer, | intent(out) | :: | tgt |
The sampled value |
||
real(kind=dp), | intent(out) | :: | prob |
The probability of sampling |
Draw a random element from 1:size(this%probs) with the probabilities listed in prob while adherring to constraints
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i |
The index of the sampler. |
||
integer, | intent(in) | :: | j |
The index of the sampler. |
||
integer, | intent(in) | :: | k |
The index of the sampler. |
||
integer, | intent(in) | :: | contain(:) |
The constraint in nI format. |
||
real(kind=dp), | intent(in) | :: | renorm |
The renormalization. (i.e. sum(this%get_prob(… contain…)) |
||
integer, | intent(out) | :: | pos |
The sampled value |
||
integer, | intent(out) | :: | tgt |
The sampled value |
||
real(kind=dp), | intent(out) | :: | prob |
The probability of sampling |
Returns the probability to draw tgt from the sampler with index iEntry @param[in] i Index of the sampler to use @param[in] j Index of the sampler to use @param[in] k Index of the sampler to use @param[in] tgt the number for which we request the probability of sampling @return prob the probability of drawing tgt with the sample routine
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i | |||
integer, | intent(in) | :: | j | |||
integer, | intent(in) | :: | k | |||
integer, | intent(in) | :: | tgt |
Returns the probability to draw tgt from the sampler with index iEntry @param[in] i Index of the sampler to use @param[in] j Index of the sampler to use @param[in] k Index of the sampler to use @param[in] constraint pick only elements from constraint @param[in] tgt the number for which we request the probability of sampling @return prob the probability of drawing tgt with the sample routine from constraint
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(AliasSampler_3D_t), | intent(in) | :: | this | |||
integer, | intent(in) | :: | i | |||
integer, | intent(in) | :: | j | |||
integer, | intent(in) | :: | k | |||
integer, | intent(in) | :: | contain(:) | |||
real(kind=dp), | intent(in) | :: | renorm | |||
integer, | intent(in) | :: | tgt |
type AliasSampler_3D_t
private
! this is an array of aliasSamplers, in the end
type(AliasSampler_t), allocatable :: samplerArray(:, :, :)
! shared resources of the array entries
type(shared_array_real_t) :: allProbs
type(shared_array_real_t) :: allBiasTable
type(shared_array_int32_t) :: allAliasTable
contains
! constructor
procedure :: shared_alloc => setupSamplerArray_3D
procedure :: setup_entry => setupEntry_3D
! destructor
procedure :: finalize => samplerArrayDestructor_3D
! get a random element and the generation probability from one of the samplers
procedure :: sample => aSample_3D
generic :: constrained_sample => constrained_sample_3D_nI, constrained_sample_3D_fast
procedure, private :: constrained_sample_3D_nI, constrained_sample_3D_fast
procedure :: get_prob => aGetProb_3D
procedure :: constrained_getProb => constrained_get_prob_3D
end type AliasSampler_3D_t