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