Skip to content

Commit

Permalink
Merge branch 'master' into dw/revert_rmath_update
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Apr 3, 2022
2 parents bf538f7 + 4451970 commit 3decb2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ lstirling_asym(x::BigFloat) = loggamma(x) + x - log(x)*(x - big(0.5)) - log2π/b
lstirling_asym(x::Integer) = lstirling_asym(float(x))

const lstirlingF64 = Float64[lstirling_asym(k) for k in big(1):big(64)]
const lstirlingF32 = Float64[lstirling_asym(k) for k in big(1):big(40)]
const lstirlingF32 = [Float32(lstirlingF64[i]) for i in 1:40]

function lstirling_asym(x::Float64)
isinteger(x) && (0 < x length(lstirlingF64)) && return lstirlingF64[Int(x)]
Expand Down
7 changes: 7 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ end
@test isone(binompdf(n, p, k))
end
end

@testset "lstirling_asym" begin
# can test for equality here because the lhs is the way the value is created
@test Float32(lstirling_asym(1.0)) == @inferred lstirling_asym(1.0f0)
# for 64.0f0 the expansion is used but for 64.0 the BigFloat value is rounded
@test Float32(lstirling_asym(64.0)) @inferred lstirling_asym(64.0f0)
end

0 comments on commit 3decb2b

Please sign in to comment.