-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[RFC] MPFR and MPC on Base #2814
Conversation
@staticfloat Do you think we can support these in travis before we merge this? |
The types should probably be called Correspondingly, I would use You don't need Why isn't there a |
I will do the replacements and renamings right now. The I'll add these issues to the checklist on the top, and update it as I do them, thanks! |
Also, one question: I'm currently using 53 bits as the default precision (i.e. a Float64), but BigFloat currently uses the GMP default, 64 bits. Should I up the default to match it (for compatibility), or should I use a higher number (maybe 256), to give a nice precision by default for those who don't want to mess with it? |
I would default to 256-ish (~octuple) precision. It would be much nicer to implement I'm confused: why is |
I don't know if it's the case here, but in cases where a fixed amount of memory is used to store some C blob, you can make the thing serializable by using a Julia array for the storage. E.g. that's how compiled PCRE regex patterns work: https://github.com/JuliaLang/julia/blob/master/base/regex.jl#L10. Not sure if that's what's going on here though. |
@StefanKarpinski, that doesn't seem to be what's going on here. The problem here is that MPFR's interface, now that I look at it, requires the caller to know the layout (or at least the size) of the There are two possibilities that occur to me. One is to just make
However, since this will be part of the Julia build, it should be straightforward to extract the correct types from the header files to insert into the (It shouldn't be immutable since the contents are, in fact, mutable by the C API.) This would avoid the double allocation (where you now allocate a type whose contents are a pointer to an array that contains another struct). Then you would pass a |
Also, it's not completely clear to me that we need MPC. If we just do (There doesn't seem to be anything too special in the MPC implementations; they just convert everything into the corresponding operations on the real and imaginary parts. They might be more clever about minimizing the number of temporary values compared to |
@stevengj That is useful to know. In that case, let's get MPFR in shape. It would be nice to leverage |
PS. It looks like you need to wrap the |
Everything looks good. Once this lands, we can make some very simple changes to I suppose we could also include the travis changes in this pull request..... that might actually be the best plan, as then we get to test the travis integration with the pull request itself. |
Another TODO item: This is also a flaw of our |
I notice that the
to match the C struct and avoid the double allocation. Again, I think it should be mutable (since the entries are mutable in the C API). |
I wrote a comment here, but you all basically said everything I was going to say and more, so thanks for the help. I was trying to make the suggestion work with |
@staticfloat @ViralBShah the build I did for this pull request is already with a modified |
hahaha, so I ended up putting |
|
(by the way, kudos to the one who implemented |
Actually the purpose of #2818 is to help eliminate uses of pointer_from_objref. In this case, it would make the following work: |
@andrioni, note that you shouldn't need to have a separate
Similarly, |
I was having some issues with constructors before, but then again, it seems a recompile after |
Ok, I got more stack overflows. Here's the code I tried to use. I'll keep improving this using the auxiliary |
@JeffBezanson, do you see why this version of the |
Passing |
Why it works then when I use the auxiliary |
If that works, then maybe I'm wrong about this. The |
… and MPFRFloat The four basic operations are now implemented using the MPFR functions instead of promotion to MPFRFloat.
Some sign issues were found and commented in test file, and no errors are thrown yet.
As they are being used by @jiahao in the new Kahan complex functions, it is needed to have them in MPFRFloat.
Now BigComplex support is given directly through Complex{BigFloat}.
Can someone comment on the rounding modes? Currently I'm using constants in the MPFR module, should I rename/export them? Other than that, I think it is finally reasonably finished. I've also rebased it (up to 9a72fab), so the merge should be simple. |
Why are we now back to using separate |
Ahem, I unfortunately destroyed the changes on the repo trying to merge it on my lab computer, I'll restore it as soon as I get back home. |
Which should be in twenty minutes. |
Restored now. (that's why one should never use rebase to rewrite history nor try to manually push changes on a Friday afternoon :)) |
Awesome! Hoping to merge this today. |
[RFC] MPFR and MPC on Base
Feel free to assign me to any issues related to BigFloat or BigInt, I'm willing to support them and help as much as I can :) |
Thanks, and thanks again for doing this. After a couple small tweaks it's looking good! |
@andrioni It would be great if you could add the documentation for Fantastic work. |
Hello,
as it was discussed in #2564, I am doing this pull request with a tentative integration of both MPFR and MPC on Base. It is currently working and passes all tests (I used the same tests I wrote when they were in packages), so it's easy for anyone to try it.
Known issues:
make check
for MPFR and MPC runs their test suites, lengthening considerably the build process, asmake check
is always called, and I have yet to discover how to bypass this.MPFRFloat
toBigFloat
.convert
methods forBigComplex
BigInt
BigFloat
mpfr_hypot
-dev
libraries to.travis.yml
sum
forMPFRFloat
in a way that works, as it needs an array of pointers.make distclean
option, it seems.