Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BFloat16s"
uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
authors = ["Keno Fischer <[email protected]>"]
version = "0.5.1"
version = "0.5.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
4 changes: 3 additions & 1 deletion src/bfloat16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions test/mathfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
Loading