Skip to content
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

[WIP] enable randn(::BigFloat) and randexp(::BigFloat) (implemented in MPFR) #35111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rfourquet
Copy link
Member

@rfourquet rfourquet commented Mar 14, 2020

Closes #17629.

@rfourquet rfourquet added domain:randomness Random number generation and the Random stdlib domain:bignums BigInt and BigFloat labels Mar 14, 2020
@rfourquet
Copy link
Member Author

This currently doesn't support immutable RNGs. I tried the approach of wrapping an immutable RNG inside a mutable one, but this segfaults. Ideas welcome :)

@rfourquet rfourquet changed the title enable randn(::BigFloat) and randexp(::BigFloat) (implemented in MPFR) [WIP] enable randn(::BigFloat) and randexp(::BigFloat) (implemented in MPFR) Mar 14, 2020
@ViralBShah
Copy link
Member

Would be nice to revive this and get it done.

@rfourquet
Copy link
Member Author

This is now updated. It doesn't segfault anymore with immutable RNGs, but I had to add a special case for TaskLocalRNG, as it otherwise segfaults with this error:

signal (11): Segmentation fault
in expression starting at REPL[18]:1
typekeyvalue_hash at /local/src/julia/src/jltypes.c:1167 [inlined]
lookup_typevalue at /local/src/julia/src/jltypes.c:725
jl_inst_arg_tuple_type at /local/src/julia/src/jltypes.c:1603
arg_type_tuple at /local/src/julia/src/gf.c:1894 [inlined]
jl_lookup_generic_ at /local/src/julia/src/gf.c:2493 [inlined]
ijl_apply_generic at /local/src/julia/src/gf.c:2545
_randget_fn at /local/src/julia/usr/share/julia/stdlib/v1.9/Random/src/normal.jl:185
unknown function (ip: 0x7f134fa5f34c)
__gmp_urandomb_ui at /home/rf/.nix-profile/lib/libgmp.so (unknown line)
random_deviate_generate at /home/rf/.nix-profile/lib/libmpfr.so (unknown line)
mpfr_random_deviate_tstbit at /home/rf/.nix-profile/lib/libmpfr.so (unknown line)
mpfr_nrandom at /home/rf/.nix-profile/lib/libmpfr.so (unknown line)
rand at /local/src/julia/usr/share/julia/stdlib/v1.9/Random/src/normal.jl:224
[...]

I don't understand this error of course... This also means that the segfault would probably occur with custom RNGs which wrap a TaskLocalRNG, so we would have to warn to not do that, but this is really not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:bignums BigInt and BigFloat domain:randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding BigFloat support for randn/randexp
2 participants