diff --git a/Project.toml b/Project.toml index de04aeb..a009764 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BFloat16s" uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" authors = ["Keno Fischer "] -version = "0.5.1" +version = "0.5.2" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/bfloat16.jl b/src/bfloat16.jl index 79ef956..31d0576 100644 --- a/src/bfloat16.jl +++ b/src/bfloat16.jl @@ -5,7 +5,7 @@ import Base: isfinite, isnan, precision, iszero, eps, exponent_one, exponent_half, leading_zeros, signbit, exponent, significand, frexp, ldexp, round, Int16, Int32, Int64, - +, -, *, /, ^, ==, <, <=, inv, + +, -, *, /, ^, fma, ==, <, <=, inv, abs, abs2, uabs, sqrt, cbrt, exp, exp2, exp10, expm1, log, log2, log10, log1p, @@ -440,5 +440,7 @@ for F in (:abs, :abs2, :sqrt, :cbrt, end end +Base.fma(x::BFloat16, y::BFloat16, z::BFloat16) = ccall("llvm.fma.bf16", llvmcall, BFloat16, (BFloat16, BFloat16, BFloat16), x, y, z) + # irrationals BFloat16(x::AbstractIrrational) = BFloat16(Float32(x)::Float32) diff --git a/test/mathfuncs.jl b/test/mathfuncs.jl index d4aed2d..8207604 100644 --- a/test/mathfuncs.jl +++ b/test/mathfuncs.jl @@ -13,6 +13,8 @@ for F in (:abs, :abs2, :sqrt, :cbrt, end end +@test fma(phi, invphi, invphi) == BFloat16(fma(Float32(phi), Float32(invphi), Float32(invphi))) + for F in (:asec, :acsc, :cosh, :acosh, :acoth) @eval begin @test $F(phi) == BFloat16($F(Float32(phi)))