Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with NaNMath.jl? #626

Open
kapple19 opened this issue Feb 11, 2024 · 1 comment
Open

Compatibility with NaNMath.jl? #626

kapple19 opened this issue Feb 11, 2024 · 1 comment

Comments

@kapple19
Copy link

kapple19 commented Feb 11, 2024

Having written some of my functions with NaNMath.jl versions of mathematical functions, feeding them Intervals results in a StackOverflowError.

E.g.

julia> ntv = interval(0, 1)
[0.0, 1.0]_com

julia> NaNMath.sin(ntv)
ERROR: StackOverflowError:
Stacktrace:
  [1] bareinterval(x::Interval{Float64})
    @ IntervalArithmetic C:\Users\Aaron\.julia\packages\IntervalArithmetic\7FL3g\src\intervals\construction.jl:298
  [2] float
    @ C:\Users\Aaron\.julia\packages\IntervalArithmetic\7FL3g\src\intervals\real_interface.jl:27 [inlined]   
  [3] sin(x::Interval{Float64}) (repeats 43500 times)
    @ NaNMath C:\Users\Aaron\.julia\packages\NaNMath\ceWIc\src\NaNMath.jl:11
  [4] eval
    @ .\boot.jl:385 [inlined]
  [5] eval
    @ .\Base.jl:88 [inlined]
  [6] repleval(m::Module, code::Expr, ::String)
    @ VSCodeServer c:\Users\Aaron\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\repl.jl:229
  [7] (::VSCodeServer.var"#110#112"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\Aaron\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\repl.jl:192
  [8] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:515
  [9] with_logger
    @ .\logging.jl:627 [inlined]
 [10] (::VSCodeServer.var"#109#111"{Module, Expr, REPL.LineEditREPL, REPL.LineEdit.Prompt})()
    @ VSCodeServer c:\Users\Aaron\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\repl.jl:193
 [11] #invokelatest#2
    @ Base .\essentials.jl:887 [inlined]
 [12] invokelatest(::Any)
    @ Base .\essentials.jl:884
 [13] (::VSCodeServer.var"#62#63")()
    @ VSCodeServer c:\Users\Aaron\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\VSCodeServer\src\eval.jl:34

Any possibility of future compatibility?

Not sure if this is an issue to raise in NaNMath.jl or here.

My first guess would be to overload NaNMath functions with Interval arguments as a package extension? Maybe such an overload would call the regular Julia functions back.

@Kolaru
Copy link
Collaborator

Kolaru commented Feb 13, 2024

There are two things here

  • NaNMath assumes that a Real converted with float becomes either a Float64 or a Float32. That is not currently the case for Intervals and causes the stack overflow.
  • NaNMath doesn't use functions from Base internally, so it currently can not reuse anything we have defined here for intervals. I don't know why it is so, but as long as it is, making them compatible would indeed require a package extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants