init_probs_AliasSampler_t Subroutine

private subroutine init_probs_AliasSampler_t(this, rank_with_info, arr)

load the probability distribution from arr into this%probs @param[in] arr array containing the (not necessarily normalized) probabilities we want to use for sampling

Type Bound

AliasSampler_t

Arguments

Type IntentOptional Attributes Name
class(AliasSampler_t), intent(inout) :: this
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(:)

Contents


Source Code

    subroutine init_probs_AliasSampler_t(this, rank_with_info, arr)
        class(AliasSampler_t), intent(inout) :: this
        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(dp), intent(in) :: arr(:)

        ! the array is shared memory, so only node-root has to do this
        if (iProcIndex_intra == rank_with_info) then
            ! the probabilities are taken from input and normalized
            this%probs%ptr = arr / sum(arr)
        end if
    end subroutine init_probs_AliasSampler_t