mirror of
https://github.com/tgorordo/WignerSymbols.jl.git
synced 2026-06-13 02:02:14 -07:00
speed improvement plus v0.7 compatibility
This commit is contained in:
parent
21688c9a2b
commit
cdb460332c
4 changed files with 19 additions and 4 deletions
|
|
@ -30,6 +30,20 @@ Base.convert(T::Type{<:Rational}, s::HalfInteger) = convert(T, s.num//2)
|
|||
Base.convert(T::Type{<:Real}, s::HalfInteger) = convert(T, s.num/2)
|
||||
Base.convert(::Type{HalfInteger}, s::HalfInteger) = s
|
||||
|
||||
function Base.hash(a::HalfInteger, h::UInt)
|
||||
iseven(a.num) && return hash(a.num>>1, h)
|
||||
num, den = a.num, 2
|
||||
den = 1
|
||||
pow = -1
|
||||
if abs(num) < 9007199254740992
|
||||
return hash(ldexp(Float64(num),pow), h)
|
||||
end
|
||||
h = Base.hash_integer(den, h)
|
||||
h = Base.hash_integer(pow, h)
|
||||
h = Base.hash_integer(num, h)
|
||||
return h
|
||||
end
|
||||
|
||||
Base.isinteger(a::HalfInteger) = iseven(a.num)
|
||||
ishalfinteger(a::HalfInteger) = true
|
||||
ishalfinteger(a::Integer) = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue