next_range Interface

public interface next_range

Draw a uniform integer in the inclusive range [lo, hi].

The span is computed in unsigned 64-bit arithmetic, so the full range of default_int works: next_range(gen, -huge(1)-1, huge(1)) spans every int32 value and is still exactly uniform. Rejection sampling gives every value in range exactly one preimage per draw, so there is no modulo bias.

hi < lo is a usage error: it returns lo and, if err is present, sets ERROR_VALIDATION. lo == hi returns lo without consuming a draw.

Calls

interface~~next_range~~CallsGraph interface~next_range next_range proc~pcg32_next_range pcg32_next_range interface~next_range->proc~pcg32_next_range proc~splitmix64_next_range splitmix64_next_range interface~next_range->proc~splitmix64_next_range proc~error_set error_t%error_set proc~pcg32_next_range->proc~error_set proc~pcg32_uniform_below pcg32_uniform_below proc~pcg32_next_range->proc~pcg32_uniform_below proc~u64_add u64_add proc~pcg32_next_range->proc~u64_add proc~splitmix64_next_range->proc~error_set proc~splitmix64_uniform_below splitmix64_uniform_below proc~splitmix64_next_range->proc~splitmix64_uniform_below proc~splitmix64_next_range->proc~u64_add proc~pcg32_next_u64 pcg32_t%pcg32_next_u64 proc~pcg32_uniform_below->proc~pcg32_next_u64 proc~rejection_mask~2 rejection_mask proc~pcg32_uniform_below->proc~rejection_mask~2 proc~u64_less u64_less proc~pcg32_uniform_below->proc~u64_less proc~splitmix64_uniform_below->proc~rejection_mask~2 proc~splitmix64_next_u64 splitmix64_t%splitmix64_next_u64 proc~splitmix64_uniform_below->proc~splitmix64_next_u64 proc~splitmix64_uniform_below->proc~u64_less proc~pcg32_step pcg32_step proc~pcg32_next_u64->proc~pcg32_step proc~u64_shr u64_shr proc~rejection_mask~2->proc~u64_shr proc~splitmix64_next splitmix64_t%splitmix64_next proc~splitmix64_next_u64->proc~splitmix64_next proc~pcg32_step->proc~u64_add proc~pcg32_step->proc~u64_shr proc~rotate_right32 rotate_right32 proc~pcg32_step->proc~rotate_right32 proc~u64_mul u64_mul proc~pcg32_step->proc~u64_mul proc~splitmix64_next->proc~u64_add proc~mix64 mix64 proc~splitmix64_next->proc~mix64

Module Procedures

private function splitmix64_next_range(gen, lo, hi, err) result(r)

Uniform integer in [lo, hi] from a splitmix64_t generator.

Arguments

Type IntentOptional Attributes Name
type(splitmix64_t), intent(inout) :: gen

Generator, advanced by the draw.

integer(kind=default_int), intent(in) :: lo

Inclusive lower bound.

integer(kind=default_int), intent(in) :: hi

Inclusive upper bound; must not be below lo.

type(error_t), intent(inout), optional :: err

Set to ERROR_VALIDATION when hi < lo.

Return Value integer(kind=default_int)

private function pcg32_next_range(gen, lo, hi, err) result(r)

Uniform integer in [lo, hi] from a pcg32_t generator.

Arguments

Type IntentOptional Attributes Name
type(pcg32_t), intent(inout) :: gen

Generator, advanced by the draw.

integer(kind=default_int), intent(in) :: lo

Inclusive lower bound.

integer(kind=default_int), intent(in) :: hi

Inclusive upper bound; must not be below lo.

type(error_t), intent(inout), optional :: err

Set to ERROR_VALIDATION when hi < lo.

Return Value integer(kind=default_int)