-
Notifications
You must be signed in to change notification settings - Fork 59
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
Various inplace operators #1166
Comments
So I am just now adding ZZi and QQi and will add more of these ! operations for ZZ (fmpz) and QQ (fmpq) in the process. |
let me also mention issue Nemocas/AbstractAlgebra.jl#1000 |
We have these operations, and also generic versions. Of course more specialized ones can always be added, but overall I think this has been addressed -- except for the suggested |
Hi!
I recently discovered that inplace operators can save a lot of memory allocations and in certain cases vastly improve performance.
However many inplace operators from FLINT are not yet wrapped in Nemo or only wrapped as non-inplace (here I'm mainly talking about
fmpz
andfmpq
, haven't looked at other types yet).Also some operators for example
fmpq_add
are wrapped multiple times aswhile certain ad hoc operators are not defined at all and hence fallback to generic implementations
I purpose to systematically wrap all such operators as "unsafe" and base the safe ones on them. So for
fmpq_add
this isThis way we can make all the inplace/"unsafe" operators available should one need to use them, and it's also easier to keep track of the ones that are already wrapped. And similarly ad hoc operators like
+(a::fmpq, b::Int)
should beadd!(fmpq(), a, b)
whereadd!
wrapsfmpq_add_si
.Also maybe some general interface could be implemented like
and then one can define macros like
@! a += b
that expands intoa = addeq!(a, b)
to preserve the readability of the code.The text was updated successfully, but these errors were encountered: