-
Notifications
You must be signed in to change notification settings - Fork 6
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
ArbVector (first try) #24
Comments
Nice! So this would be an example where indexing does not required allocations right? And then it would be the users responsibility to not use any variables gotten from indexing after the vector is freed. I have some ideas for how we could do the unsafe indexing in Arblib, I'll write about it in the other issue. |
Never mind, I'll just write it here. If we define an v = ArbVector([1, 2, 3])
Arblib.add!(Arblib.unsafe_getindex(v, 1), Arblib.unsafe_getindex(v, 1), 5, prec = precision(v)) It should also work for referencing radius and midpoint x = Arb(pi)
r = Mag(1e-10)
Arblib.cmp(x.radius, r) The higher level interface, |
I just tried v = [1,2,3]
CC = AcbField(256)
jlv = CC.(v)
arbv = AcbVector(jlv)
unsafe_wrap(Array, arbv.ptr, (3,)) # ← truly non-allocating but it crashes instantly :D |
Okay, so it does allocation for the struct but does not call |
@Joel-Dahne that is correct: v = ArbVector([1, 2, 3])
GC.@preserve v
Arblib.add!(Arblib.unsafe_getindex(v, 1), Arblib.unsafe_getindex(v, 1), 5, prec = precision(v))
b = Arblib.unsafe_getindex(v, 1)
# do something with b, but never leak it out of @preserve block:
(b > 1 ? true : false)
end I'm not sure if |
One problem I see if we copy the struct is that some of the data is stored directly in the struct and some of it where the fields are pointing to, which data is stored in the struct also depends on the data. So if we copy the struct and update the fields the original copy might or might not be updated correctly. |
The struct for |
Just to let you know, I tried the following:
and it works pretty well (this is still Nemo based). Eigenvalues in Nemo are incorrect so if you need them quickly here there are:
EDIT: Updated with
precision
fieldThe text was updated successfully, but these errors were encountered: