Skip to content

Commit b289061

Browse files
Merge pull request #147 from dgleich/patch-1
2 parents 8295987 + 7ea03bd commit b289061

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/extras/misc.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ end
6262
function Base.:(-)(m::Matrix{DoubleFloat{T}}, x::T) where {T}
6363
return m .- x
6464
end
65+
66+
# for getting fast floatmin2, used in Givens rotations in LinearAlgebra
67+
# these values were computed with the existing code saved
68+
# floatmin2(::Type{T}) where {T} = (twopar = 2one(T); twopar^trunc(Integer,log(floatmin(T)/eps(T))/log(twopar)/twopar))
69+
LinearAlgebra.floatmin2(::Type{Double64}) = Double64(reinterpret(Float64, 0x2350000000000000), 0.0)
70+
LinearAlgebra.floatmin2(::Type{Double32}) = Double32(reinterpret(Float32, 0x2c000000), 0.0f0)
71+
LinearAlgebra.floatmin2(::Type{Double16}) = Double16(Float16(8.0), Float16(0.0))

test/specialvalues.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ end
6161
@test isnan(asech(T(NaN)))
6262
@test isnan(acoth(T(NaN)))
6363
end
64+
65+
@testset "floatmin2 $T" for T in (Double16, Double32, Double64)
66+
trueval = (twopar = 2one(T); twopar^trunc(Integer,log(floatmin(T)/eps(T))/log(twopar)/twopar))
67+
@test LinearAlgebra.floatmin2(T) == trueval
68+
end

0 commit comments

Comments
 (0)