Uses the "random" odd 32 bit integer seed
to map the 32 bit integer key
to
an unsigned integer value with only nbits
bits where nbits
is less than 32
(Specification)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | key | |||
integer(kind=int32), | intent(in) | :: | seed | |||
integer, | intent(in) | :: | nbits |
elemental function universal_mult_hash( key, seed, nbits ) result( sample ) !! Version: experimental !! !! Uses the "random" odd 32 bit integer `seed` to map the 32 bit integer `key` to !! an unsigned integer value with only `nbits` bits where `nbits` is less than 32 !! ([Specification](../page/specs/stdlib_hash_procedures.html#universal_mult_hash-maps-an-integer-to-a-smaller-number-of-bits)) integer(int32), intent(in) :: key integer(int32), intent(in) :: seed integer, intent(in) :: nbits integer(int32) :: sample sample = ishft( key*seed, -32 + nbits ) end function universal_mult_hash