Skip to content

eps not defined for LogFloat64 or ULogFloat64 #23

Description

@stecrotti

Any chance we can define eps(::LogFloat64) and eps(::ULogFloat64)? I don't have enough knowledge of the workings on eps to propose a sensible fix but i can try to follow suggestions.

Use case: I have a complex number whose real and imaginary parts are Logarithmics. When trying to take the absolute value i get an error because eps is not defined for ULogFloat64 and for some reason abs calls eps.

MWE
julia> using LogarithmicNumbers

julia> x = Logarithmic(1.0)
+exp(0.0)

julia> z = x + im*x
+exp(0.0) + +exp(0.0)*im

julia> eps(z)
ERROR: MethodError: no method matching eps(::Complex{LogFloat64})
The function `eps` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  eps(::Type{Dates.DateTime})
   @ Dates C:\Users\sky_9\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Dates\src\types.jl:452
  eps(::Type{Dates.Time})
   @ Dates C:\Users\sky_9\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Dates\src\types.jl:454
  eps(::Type{BigFloat})
   @ Base mpfr.jl:1075
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[13]:1
My use case
julia> using LogarithmicNumbers

julia> x = Logarithmic(1.0)
+exp(0.0)

julia> z = x + im*x
+exp(0.0) + +exp(0.0)*im

julia> abs(z)
ERROR: MethodError: no method matching eps(::Type{ULogFloat64})
The function `eps` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  eps(::Type{Dates.DateTime})
   @ Dates C:\Users\sky_9\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Dates\src\types.jl:452
  eps(::Type{Dates.Time})
   @ Dates C:\Users\sky_9\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Dates\src\types.jl:454
  eps(::Type{BigFloat})
   @ Base mpfr.jl:1075
  ...

Stacktrace:
 [1] _hypot
   @ .\math.jl:729 [inlined]
 [2] hypot
   @ .\math.jl:706 [inlined]
 [3] abs(z::Complex{LogFloat64})
   @ Base .\complex.jl:286
 [4] top-level scope
   @ REPL[8]:1

EDIT: the same issue also comes up while trying to use logarithmic numbers in combination with finite differences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions