arb
arb copied to clipboard
arf_interval_* are marked as static inline
and therefore are not visible e.g. when calling from julia (am I really correct here? :) )
anyway:
~/.julia/artifacts/1f4e5762991b4f836993de3fc70599603880c0da/lib
$ nm -DC --with-symbol-versions libarb.so | grep interval
0000000000079510 T arb_get_interval_arf
00000000000a8510 T arb_get_interval_fmpz_2exp
000000000008be30 T arb_get_interval_mpfr
00000000000a2d60 T arb_set_interval_arf
00000000000b6720 T arb_set_interval_mag
00000000000b66a0 T arb_set_interval_mpfr
0000000000088d40 T arb_set_interval_neg_pos_mag
000000000008dfb0 T arb_unit_interval
Background:
I tried to wrap arb_calc_isolate_roots without arf_interval functions like this:
https://gist.github.com/kalmarek/cf4b2b9be4d2300e6060018a60fed049
but when calling it with:
using Test
using Arblib
include("calc_roots.jl")
a,b = Arf(1.0), Arf(2.0)
v = arf_interval(a, b) #works
function Arblib.Arb(v::arf_interval; prec)
res = Arb(;prec=prec)
Arblib.set_interval!(res, v.lo, v.hi)
return res
end
let a = Arb(v, prec=128)
@info "" Arblib.midref(a) Float64(Arblib.radref(a))
end
#correctly prints
#┌ Info:
#│ Arblib.midref(a) = 1.5
#└ Float64(Arblib.radref(a)) = 0.5000000009313226
get!(Arb(), v) # undefined symbol, could not load symbol "arf_interval_get_arb"
@test Arblib.set!(Arb(), v.lo) == 1
@test Arblib.set!(Arb(), v.hi) == 2
isolate_roots(x->x^2, a, b, maxfound=1) # crash
I get
Exception (FLINT memory_manager). Unable to allocate memory (560099371045632).
signal (6): Aborted
in expression starting at /home/kalmar/.julia/dev/Arblib/tmp.jl:29
gsignal at /usr/lib/libc.so.6 (unknown line)
abort at /usr/lib/libc.so.6 (unknown line)
flint_abort at /workspace/srcdir/flint-2.6.2/exception.c:46
flint_memory_error at /workspace/srcdir/flint-2.6.2/memory_manager.c:53
flint_malloc at /workspace/srcdir/flint-2.6.2/memory_manager.c:94
_arf_promote at /workspace/srcdir/arb-2.18.1/arf/memory_manager.c:62
arf_set at /workspace/srcdir/arb-2.18.1/arf.h:397 [inlined]
arb_set_arf at /workspace/srcdir/arb-2.18.1/arb.h:186 [inlined]
arb_calc_isolate_roots at /workspace/srcdir/arb-2.18.1/arb_calc/isolate_roots.c:164
calc_isolate_roots! at /home/kalmar/.julia/dev/Arblib/calc_roots.jl:106
which happens when Arb tries to set arb from upper/lower end of the constructed arf_interval. This may mean that I'm not initializing it correctly.
Yeah, we could fix these so that they appear in the library.
The arb_calc_isolate_roots code is not particularly good though. You could just as well implement bisection + Newton iteration directly in Julia and make it more robust.