Repository navigation
How to add functions? #48
Description
Activity
I think it should be
Float128(@ccall(libquadmath.fmodq(x::Cfloat128, y::Cfloat128)::Cfloat128))
Same question for complex functions libquadmath supports.
quadmath.h:
__complex128 clogq (__complex128 x)
is used through Julia in one of these two ways:log(z::Complex128)::Complex128log(z::Complex{Float128})::Complex{Float128}.
--- from quadmath.jl ---
# we use this slightly cumbersome definition to ensure # that the value is 128-bit aligned # and passed on the xmm registers, # matching the x86_64 ABI for __float128. const Cfloat128 = NTuple{2,VecElement{Float64}} struct Float128 <: AbstractFloat data::Cfloat128 end convert(::Type{Float128}, x::Number) = Float128(x) const ComplexF128 = Complex{Float128} Base.cconvert(::Type{Cfloat128}, x::Float128) = x.data Base.cconvert(::Type{Ref{Cfloat128}}, x::Float128) = Ref{Cfloat128}(x.data)I think defining
Ccomplex128would be more robust and performant when using Complex elementary functions fromlibquadmath. Which def is best?NTuple{2, Cfloat128}NTuple{4, VecElement{Float64}})
With constructors or converters or, probably, both:
convert{::Type{Ccomplex128}, x::ComplexF128)and
convert{::Type{ComplexF128}, x::Ccomplex128).
Hi @JeffreySarnoff @simonbyrne
Do you know how to adapt thecconvert/unsafe_convertsuch we can pass a reference / vector ofFloat128from Julia to the following wrappers?# f(x) function cutest_ufn_q_(status, n, x, f) ptr_cutest_ufn_q_ = Libdl.dlsym(cutest_lib_quadruple, :cutest_ufn_q_) @ccall $ptr_cutest_ufn_q_(status::Ptr{Cint}, n::Ptr{Cint}, x::Ptr{Cfloat128}, f::Ptr{Cfloat128})::Cvoid end # gradient(x) function cutest_ugr_q_(status, n, x, g) ptr_cutest_ugr_q_ = Libdl.dlsym(cutest_lib_quadruple, :cutest_ugr_q_) @ccall $ptr_cutest_ugr_q_(status::Ptr{Cint}, n::Ptr{Cint}, x::Ptr{Cfloat128}, g::Ptr{Cfloat128})::Cvoid end function cutest_cint_uofg_q_(status, n, x, f, g, grad) ptr_cutest_cint_uofg_q_ = Libdl.dlsym(cutest_lib_quadruple, :cutest_cint_uofg_q_) @ccall $ptr_cutest_cint_uofg_q_(status::Ptr{Cint}, n::Ptr{Cint}, x::Ptr{Cfloat128}, f::Ptr{Cfloat128}, g::Ptr{Cfloat128}, grad::Ptr{Bool})::Cvoid end
I'm working on a new version of
CUTEst.jlthat supports quadruple precision.
We recently added the support of__float128in the Fortran library.I do not how to do that.
Have you tried using the generic
Array -> Ptrmethod ofunsafe_convert(or a replica for whatever you use forf,g, etc.)?I think defining
Ccomplex128would be more robust and performant when using Complex elementary functions fromlibquadmath.From my testing,
Complex{Float128}works as-is inccalland the results are identical to those of the generic methods in Base. So I don't think a separateCcomplex128type is likely to be needed. It also seems unlikely that there would be much benefit to wrapping the complex libquadmath functions vs. relying on existing methods, though admittedly I did not compare performance.@amontoison, please open a separate issue if you still need help with the CUTEst.jl quadruple precision support.
Reacted by Steven G. Johnson
I'm not sure what you are doing with the local version of
@ccall.I'd like to add some functions via PR. I know how to do it this way:
How is this best done in keeping with the structure of the package?