fibonacci_hash Function

public elemental function fibonacci_hash(key, nbits) result(sample)

Maps the 64 bit integer key to an unsigned integer value with only nbits bits where nbits is less than 64 (Specification)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: key
integer, intent(in) :: nbits

Return Value integer(kind=int64)


Source Code

    elemental function fibonacci_hash( key, nbits ) result( sample )
!! Version: experimental
!!
!! Maps 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#fibonacci_hash-maps-an-integer-to-a-smaller-number-of-bits_1))

        integer(int64), intent(in) :: key
        integer, intent(in)        :: nbits
        integer(int64)             :: sample

        sample = ishft( key*pow64_over_phi, -64 + nbits )

    end function fibonacci_hash