-
-
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: Adds random number generation for BigInts and BigFloats #4845
Conversation
This means that ranges between numbers bigger than `typemax(Int)` work now, but range lengths are still limited to up to `typemax(Int)`.
Very nice. Don't let this question slow you down, but is there any way we could get GMP to sync up with the Julia RNG state? |
This is a great pull request. I'm not sure how one would sync up the RNGs since it seems like BigRNG probably needs a lot more state than dSFMT. |
That's probably true: hadn't thought about that at all. |
Well, technically we could make GMP use Julia's dSFMT instead of its own internal Mersenne Twister, but it'll require large amounts of glue code to make it work. |
Probably not worth it. |
@andrioni thanks for picking this up again. I had completely forgotten about this. |
Do we want to be able to reproduce the same sequence of all random numbers (big or small) from a single |
It would be nice if we could, but may not be easy. What happens when we mix random numbers from BigRNG and existing RNGs? |
Currently, both RNGs are completely independent. You have to reseed them separately if you want to, and they don't affect each other's state. |
I would tend to prefer that |
That should be easy enough to do. |
I would prefer seeding both with |
OS X doesn't have `sha1sum` available, so the fallback used to get the initial seed whenever /dev/urandom isn't available doesn't work.
I've just changed the (I have no idea whatsoever why travis failed, especially since it worked here with the same commit) |
BTW, this should also get a mention in NEWS.md as we have started it for 0.3. Is this good to merge otherwise? |
I think everything I need/wanted to do is done, so barring other suggestions/objections, it should be good to merge. |
It requires JuliaLang/julia#4845 to be merged, since it uses BigRNG.
Now a macro is used to check if BigRNG is available, this means the same codebase is compatible with both julia post- JuliaLang/julia#4845 and julia 0.2.
The clang build prints a ton of garbage and dies. Perhaps worth investigating before merging. |
Bump. @andrioni Can you please rebase and check if the tests are passing? This would be good to have. |
I was able to merge and get this running with all the tests passing. |
convert(BigInt, first(r) + randu(ulen)) | ||
end | ||
|
||
function rand!(r::Range1{BigInt}, A::Array{BigInt}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant with definitions in random.jl
Since this patch was merged, why am I getting the error:
? |
It was rolled back after some time, since it was bugging out on some configurations (including the Travis one, IIRC). |
@andrioni Do you recall what exacly went wrong? |
@mschauer not off the top of my head, but I could take a look. |
This pull request extends the work done by @jiahao in #3077, adding a default RNG for BigInts and BigFloats (since they share the gmp_randstate interface) and BigFloat support (including for
randn
).I'll update it later with the documentation as soon as we settle on the interface.