JuliaNLSolvers / LineSearches.jl

Line search methods for optimization and root-finding
Other
122 stars 34 forks source link

Unnecessary call to `log2`? #140

Open dzhang314 opened 5 years ago

dzhang314 commented 5 years ago

Hey, I'm the author of MultiFloats.jl, a new Julia package for extended precision arithmetic. I'd like to make my MultiFloat{T,N} type compatible with Optim.jl, but unfortunately I don't have an implementation of log2(::MultiFloat) yet, which trips up this one line in hagerzhang.jl:

iterfinitemax::Int = ceil(Int, -log2(eps(T)))

Is there any reason that this couldn't be replaced with precision(T)-1 or -exponent(eps(T)), to allow floating-point types that don't have log2 implemented? Of course I'm also working on implementing transcendental functions in MultiFloat.jl, but for the simple task of getting the exponent of epsilon, I figure a call to a transcendental function is unnecessary anyway.

pkofod commented 4 years ago

I think it's just left over from the Float64 implementation. Sorry I didn't answer sooner, but Github refuses to notify me about anything, even on my own packages... I wonder if your suggestion could trip up other number packages? :)