mirror of
https://github.com/tgorordo/WignerSymbols.jl.git
synced 2026-06-05 15:42:15 -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
|
|
@ -117,7 +117,7 @@ function wigner3j(T::Type{<:AbstractFloat}, j₁, j₂, j₃, m₁, m₂, m₃ =
|
|||
Wigner3j[(β₁, β₂, β₃, α₁, α₂)] = (r,s)
|
||||
end
|
||||
|
||||
return sgn*sqrt(convert(T, r))*convert(T, s)
|
||||
return sgn*sqrt(convert(T, r.num)/convert(T, r.den))*(convert(T, s.num)/convert(T, s.den))
|
||||
end
|
||||
|
||||
"""
|
||||
|
|
@ -214,7 +214,7 @@ function wigner6j(T::Type{<:AbstractFloat}, j₁, j₂, j₃, j₄, j₅, j₆)
|
|||
Wigner6j[(β₁, β₂, β₃, α₁, α₂, α₃)] = (r, s)
|
||||
end
|
||||
|
||||
return sqrt(convert(T, r))*convert(T, s)
|
||||
return sqrt(convert(T, r.num)/convert(T, r.den))*(convert(T, s.num)/convert(T, s.den))
|
||||
end
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ struct PrimeIterator
|
|||
end
|
||||
primes() = PrimeIterator()
|
||||
|
||||
Base.iteratorsize(::Type{PrimeIterator}) = Base.IsInfinite()
|
||||
Base.iteratoreltype(::Type{PrimeIterator}) = Base.HasEltype()
|
||||
Compat.IteratorSize(::Type{PrimeIterator}) = Base.IsInfinite()
|
||||
Compat.IteratorEltype(::Type{PrimeIterator}) = Base.HasEltype()
|
||||
Base.eltype(::PrimeIterator) = Int
|
||||
|
||||
# Get the `n`th prime; store all primes up to the `n`th if not yet available
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ end
|
|||
using Test
|
||||
using WignerSymbols
|
||||
using Compat
|
||||
using Compat.LinearAlgebra
|
||||
|
||||
smalljlist = 0:1//2:10
|
||||
largejlist = 0:1//2:1000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue