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

Faster implementation of rand(Range1) #3779

Merged
merged 1 commit into from
Jul 21, 2013
Merged

Faster implementation of rand(Range1) #3779

merged 1 commit into from
Jul 21, 2013

Conversation

lindahua
Copy link
Contributor

Faster & simpler implementation of rand(Range1), and it strictly guarantees equal probabilities of choosing each integer within the range.

My benchmark shows that it is about 1.7x - 2.1x faster than the original implementation.

@johnmyleswhite
Copy link
Member

+1

@StefanKarpinski
Copy link
Sponsor Member

This is great. As far as I'm concerned you can merge at will.

lindahua added a commit that referenced this pull request Jul 21, 2013
Faster implementation of rand(Range1)
@lindahua lindahua merged commit 878e8d2 into JuliaLang:master Jul 21, 2013
ulen = convert(Uint128, length(r))
convert(Int128, first(r) + randu(ulen))
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there were a more compact way to write the above three functions without all the duplication. How about convert these to a macro?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A macro seems like overkill here. Surely there is another way to write it. Maybe randu(unsigned(length(r)))?

@ViralBShah ViralBShah added the system:32-bit Affects only 32-bit systems label Nov 22, 2014
@tkelman
Copy link
Contributor

tkelman commented Nov 22, 2014

@ViralBShah I think you mis-labeled this

@tkelman tkelman added domain:randomness Random number generation and the Random stdlib and removed system:32-bit Affects only 32-bit systems labels Nov 22, 2014
@ViralBShah
Copy link
Member

Thanks. In the labelling spree, this happened a few times and I thought I had fixed all the cases.

KristofferC added a commit that referenced this pull request Feb 8, 2024
…53220)

Replaces #53216 (I can't push to
that repo branch)

Adds
- making pkgimages for REPLExt
- Fixes PkgCompletionProvider location

Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: f3b81f1aa
New commit: 6dd0e7c9e
Julia version: 1.11.0-DEV
Pkg version: 1.11.0
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@f3b81f1...6dd0e7c

```
$ git log --oneline f3b81f1aa..6dd0e7c9e
6dd0e7c9e Revert "add test for recurring precompile" (#3779)
dbf114fa9 Merge pull request #3777 from JuliaLang/kc/repl_extension
a49d47981 fixup
e3edf3917 avoid prompting for git creds on CI (#3778)
510454343 make the `REPL` specific code into an extension
12d2de14e make `pkgstr` independent of REPL
```

---------

Co-authored-by: Dilum Aluthge <[email protected]>
Co-authored-by: Valentin Churavy <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants