fibonacci_hash Function

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

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

Arguments

TypeIntentOptionalAttributesName
integer(kind=int32), intent(in) :: key
integer, intent(in) :: nbits

Return Value integer(kind=int32)


Contents

Source Code


Source Code

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

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

        sample = ishft( key*pow32_over_phi, -32 + nbits )

    end function fibonacci_hash