nolta / Elliptic.jl

Elliptic integral and Jacobi elliptic special functions
MIT License
31 stars 16 forks source link

Support for extended precision (BigFloats)? #11

Open PerezHz opened 7 years ago

PerezHz commented 7 years ago

Hi! I was trying to use Elliptic.jl in order to evaluate K(k) to high accuracy using BigFloats, but noticed that if given a BigFloat as an input, Elliptic.K returns a Float64:

julia> using Elliptic

julia> Elliptic.K(big"0.512341234")
1.8646739600308775

@oxinabox explained to me that, by construction, Elliptic.jl functions explicitly cast all Reals down to Float64, and was wondering if the code may be adapted for other types such as BigFloat, perhaps adapting the constants such as D1MACH1 with something like const D1MACH1 = realmin(T) with T<:AbstractFloat, etc., for these types?

ettersi commented 6 years ago

See https://github.com/JuliaMath/SpecialFunctions.jl/pull/79.

dlfivefifty commented 1 year ago

I think this fallback should be removed:

https://github.com/nolta/Elliptic.jl/blob/7ed7dfbb0df9398920562b27df7d3cf782b0fa76/src/Elliptic.jl#L63

It would be better for the code to error on a BigFloat value than to silently convert to Float64>