diff --git a/src/Quadmath.jl b/src/Quadmath.jl index 06a48c9..298aede 100644 --- a/src/Quadmath.jl +++ b/src/Quadmath.jl @@ -327,6 +327,13 @@ if _WIN_PTR_ABI (Ptr{Cfloat128}, Ref{Cfloat128}, Ref{Cfloat128}), r, x, y) Float128(r[]) end +elseif Sys.iswindows() + function (^)(x::Float128, y::Float128) + r = Ref{Cfloat128}() + p = PadPtr(r) + ccall((:powq,quadoplib), Cvoid, (PF128, Cfloat128, Cfloat128), p, x, y) + Float128(r[]) + end else (^)(x::Float128, y::Float128) = Float128(ccall((:powq, libquadmath), Cfloat128, @@ -391,7 +398,7 @@ end for f in (:copysign, :hypot, ) if _WIN_PTR_ABI @eval function $f(x::Float128, y::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() ccall(($(string(f,:q)), libquadmath), Cvoid, (Ptr{Cfloat128}, Ref{Cfloat128}, Ref{Cfloat128}), r, x, y) @@ -399,7 +406,7 @@ for f in (:copysign, :hypot, ) end elseif Sys.iswindows() @eval function $f(x::Float128, y::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() p = PadPtr(r) ccall(($(string(f,:q)), libquadmath), Cvoid, (PF128, Cfloat128, Cfloat128), @@ -417,14 +424,14 @@ flipsign(x::Float128, y::Float128) = signbit(y) ? -x : x if _WIN_PTR_ABI function atan(x::Float128, y::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() ccall((:atan2q, libquadmath), Cvoid, (Ptr{Cfloat128}, Ref{Cfloat128}, Ref{Cfloat128}), r, x, y) Float128(r[]) end ## misc function fma(x::Float128, y::Float128, z::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() ccall((:fmaq,libquadmath), Cvoid, (Ptr{Cfloat128}, Ref{Cfloat128}, Ref{Cfloat128}, Ref{Cfloat128}), r, x, y, z) Float128(r[]) end @@ -438,7 +445,7 @@ if _WIN_PTR_ABI else if Sys.iswindows() function atan(x::Float128, y::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() p = PadPtr(r) ccall((:atan2q, libquadmath), Cvoid, (PF128, Cfloat128, Cfloat128), p, x, y) @@ -446,7 +453,7 @@ else end function fma(x::Float128, y::Float128, z::Float128) - r = Ref{Cloat128}() + r = Ref{Cfloat128}() p = PadPtr(r) ccall((:fmaq,libquadmath), Cvoid, (PF128, Cfloat128, Cfloat128, Cfloat128), p, x, y, z) diff --git a/test/runtests.jl b/test/runtests.jl index 701004d..61eeee6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -60,3 +60,19 @@ end fpart, ipart = modf(x) .+ modf(y) @test x+y == ipart+fpart end + +@testset "transcendental etc. calls" begin + # at least enough to cover all the wrapping code + x = sqrt(Float128(2.0)) + xd = Float64(x) + @test (x^Float128(4.0)) ≈ Float128(4.0) + @test exp(x) ≈ exp(xd) + @test abs(x) == x + @test hypot(Float128(3),Float128(4)) == Float128(5) + @test atan(x,x) ≈ Float128(pi) / 4 + @test fma(x,x,Float128(-1.0)) ≈ Float128(1) +end + +if !Sys.iswindows() || (Sys.WORD_SIZE == 64) + include("specfun.jl") +end diff --git a/test/specfun.jl b/test/specfun.jl new file mode 100644 index 0000000..aa44201 --- /dev/null +++ b/test/specfun.jl @@ -0,0 +1,15 @@ +using SpecialFunctions + +@testset "special functions" begin + # The intention here is not to check the accuracy of the libraries, + # rather the sanity of library calls: + piq = Float128(pi) + halfq = Float128(0.5) + @test gamma(halfq) ≈ sqrt(piq) + for func in (erf, erfc, besselj0, besselj1, bessely0, bessely1, lgamma) + @test func(halfq) ≈ func(0.5) + end + for func in (bessely, besselj) + @test func(3,halfq) ≈ func(3,0.5) + end +end