-
Notifications
You must be signed in to change notification settings - Fork 57
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
Enh/acb integrate #382
Enh/acb integrate #382
Conversation
It looks like it tries to include a file acb_struct, which I don't see (I assume it is no longer needed). |
Thanks. I want to play with it a bit before I merge it. |
Sure, that's what I asked for. I've already found that this is not GC-safe??: for i in 1:10000
@time Nemo.integrate(x -> x^2 ,CC(-1), CC(1))
end
|
Yes, the handling of the pointers etc is not quite correct. It is too complicated to explain here. Do you mind if I open a new PR based on the commits here? For this it would be helpful if you could squash the commits here into one (rewrite the history). |
I would suggest extending the interface right away to support non-analytic/branch cut-containing integrands (we did it by passing a flag to the object function in Sage) as well as wrapping the optional settings (tolerances etc.). |
ok, I tried really hard to understand the troubles with memory management and julias GC destroying objects that arb has already a pointer to, but this still eludes me. struct acb_calc_func
f::Function
domain::AcbField
end
function acb_calc_func_wrap(res::acb_struct, x::acb_struct, param::Ptr{Void}, order::Int, precision::Int)
acbF = unsafe_pointer_to_objref(param)::acb_calc_func
@assert precision == prec(acbF.domain)
X = acb()
X.parent = acbF.domain
_acb_set(X, x)
z = acbF.f(X)
_acb_set(res, acb_struct(z))
return Cint(0)::Cint
end (following closely |
Julia can't know what Arb still has pointers to. It only knows about the
objects it created and that it still has references to.
Also, unsafe_blah means it is unsafe from the point of view of garbage
collection. The object needs to be kept alive manually, since Julia doesn't
know to keep it alive automatically.
Having said that, I've no idea what the specifics of your code are here.
I'll let Tommy and Fredrik respond.
|
RR = RealField()
if rel_tol is None:
cgoal = self._prec
else:
tmp = <RealNumber> RR(rel_tol)
mpfr_get_d_2exp(&cgoal, tmp.value, MPFR_RNDD)
cgoal = -cgoal Stupid question. Ignoring the sign change at the end, we want |
Sorry there is a minor rebase of this PR that is needed after a particularly large and unwieldy patch was merged. We have now completely split Nemo.jl and AbstractAlgebra.jl and updated all the docs accordingly. Apart from minor bugs that might manifest through use, there are no similarly large merges planned in the near future (famous last words). |
I have a local branch where I have this thing here almost working. I will finish it soon. |
Sorry for the delay. I think it is best to wait until 0.7 is released. Then |
If the C library follows modern conventions and provides some sort of |
Thanks for chimming in @vtjnash. Is https://julialang.org/blog/2013/05/callback still the recommended way? Is there an example somewhere in Base? |
Yes There are many examples. They aren't much changed from the blog post. |
@thofma any chances of this happening soon? Could You publish Your branch so that I can play with/study Your solution? |
My solution had some other flaws, so I took yours and fixed the memory problem. See |
fixed by #407 |
Please take a careful look, I am really not experienced in
C
.With this pull You can e.g.:
TODO:
Note: this does not allow to pass additional parameters to the integrand. Should it?
Also: should I rewrite history (i.e. prepare a new branch with clean commits)?