3278 Commits

Author SHA1 Message Date
Vinzent Steinberg
7d73990096
Make Uniform constructors return a result (#1229)
* Forbid unsafe code in crates without unsafe code

This helps tools like `cargo geiger`.

* Make `Uniform` constructors return a result

- This is a breaking change.
- The new error type had to be made public, otherwise `Uniform` could
  not be extended for user-defined types by implementing
  `UniformSampler`.
- `rand_distr` was updated accordingly.
- Also forbid unsafe code for crates where none is used.

Fixes #1195, #1211.

* Address review feedback
* Make `sample_single` return a `Result`
* Fix benchmarks
* Small fixes
* Update src/distributions/uniform.rs
2023-02-06 10:55:22 +00:00
Arya
ae4b48ece8
Add note about floating point weights in update_weights docs (#1280) 2023-02-02 09:30:08 +00:00
Mark Wainwright
4bde8a0adb
Performance improvements for shuffle and partial_shuffle (#1272)
* Made shuffle and partial_shuffle faster
* Use criterion benchmarks for shuffle
* Added a note about RNG word size
* Tidied comments
* Added a debug_assert
* Added a comment re possible further optimization
* Added and updated copyright notices
* Revert cfg mistake
* Reverted change to mod.rs
* Removed ChaCha20 benches from shuffle
* moved debug_assert out of a const fn
2023-01-08 16:14:26 +00:00
Mark Wainwright
1e96eb4593
Added new versions of choose and choose_stable (#1268)
* Added new versions of choose and choose_stable

* Removed coin_flipper tests which were unnecessary and not building on ci

* Performance optimizations in coin_flipper

* Clippy fixes and more documentation

* Added a correctness fix for coin_flipper

* Update benches/seq.rs

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>

* Update benches/seq.rs

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>

* Removed old version of choose and choose stable and updated value stability tests

* Moved sequence choose benchmarks to their own file

* Reworked coin_flipper

* Use criterion for seq_choose benches

* Removed an old comment

* Change how c is estimated in coin_flipper

* Revert "Use criterion for seq_choose benches"

This reverts commit 23395391370ab95694558be90686eb16494e590a.

* Added seq_choose benches for smaller numbers

* Removed some unneeded lines from seq_choose

* Improvements in coin_flipper.rs

* Small refactor of coin_flipper

* Tidied comments in coin_flipper

* Use criterion for seq_choose benchmarks

* Made choose not generate a random number if len=1

* small change to IteratorRandom::choose

* Made it easier to change seq_choose benchmarks RNG

* Added Pcg64 benchmarks for seq_choose

* Added TODO to coin_flipper

* Changed criterion settings in seq_choose

Co-authored-by: Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
2023-01-05 10:49:33 +00:00
Chayim Refael Friedman
3107a54aea
Relax Sized bound on Distribution<T> for &D (#1278) 2023-01-04 17:49:17 +00:00
Paul Crowley
e97b5b6887
Simpler and faster implementation of Floyd's F2 (#1277)
The previous implementation used either `Vec::insert` or a second
F-Y shuffling phase to achieve fair random order. Instead, use the
random numbers already drawn to achieve a fair shuffle.
2023-01-01 09:49:32 +00:00
TheIronBorn
b9e7d84c3b
use partition_point in WeightedIndex (#1276)
* use partition_point in WeightedIndex

* fix partition_point

* fix
2022-12-22 10:54:41 +00:00
Diggory Hardy
fbd95860b4
Add Criterion as dev-dependency, fix CI for MSRV and minimal-versions (#1275)
* Add criterion as dev-dependency

* CI[minimal-versions]: require regex 1.5.1
2022-12-11 17:47:51 +00:00
Alex
81d7dc7264
build: harden test.yml permissions (#1274)
Signed-off-by: Alex <aleksandrosansan@gmail.com>

Signed-off-by: Alex <aleksandrosansan@gmail.com>
2022-12-09 09:50:09 +00:00
Alex Saveau
0dddc2c559
Add read_adapter to avoid dynamic dispatch (#1267)
* Add read_adapter to avoid dynamic dispatch

* Get rid of the dyn Read impl since we can't deprecate it
2022-12-07 10:18:04 +00:00
Diggory Hardy
50b9a44741
fill_via_chunks: mutate src on BE (small optimisation) (#1182)
* fill_via_chunks: mutate src on BE (small optimisation)

* Add doc to fill_via_chunks
2022-12-07 09:47:45 +00:00
Diggory Hardy
19169cbce9
Bump MSRV to 1.56 (Edition 2021) (#1269)
* Bump MSRV to 1.56 (Edition 2021)

* Apply Clippy suggestions

* Bump edition and add rust-version field to Cargo.toml

* CI AVR test: unpin nightly rust version

* Disable AVR test

* Bump crate version numbers for a breaking release
2022-12-06 19:01:10 +00:00
Diggory Hardy
7aa25d577e
gh-pages action: add id-token write permission (#1265)
* gh-pages action: add id-token write permission

* gh-pages action: add environment
2022-11-14 16:41:49 +00:00
ironhaven
0aca9028f2
SmallRng uses wrong seed_from_u64 implementation (#1203)
* Forward inner seed_from_u64 implmentation for SmallRng

* increase tolerance of sparkline tests
2022-11-14 12:08:30 +00:00
Frank Steffahn
21131af61d
Remove redundant AsRef/AsMut bounds (#1207) 2022-11-14 11:37:49 +00:00
Yaron Sheffer
8339afc7ee
Fix typo (#1264) 2022-11-14 11:05:54 +00:00
Diggory Hardy
9720f110a6
Update GitHub Actions (#1263)
* examples/rayon-monte-carlo.rs: remove execute bit of file metadata

* Document in README that MSRV is 1.51.0

This was changed in #1246

* Update GitHub Actions
2022-11-10 15:36:40 +00:00
TheIronBorn
387dd644a2
fix outdated choose_multiple_weighted docs (#1237) 2022-11-09 14:50:09 +00:00
Ralf Jung
23f8b2986e
clarify shuffle docs (#1259) 2022-10-11 09:07:15 +01:00
ISibboI
8d70f5017f
Clarify documentation of choose_weighted(_mut) mentioning accurate behavior with floats (#1245)
* Fix the documentation for `choose_weighted(_mut)` as discussed in #1243.

* Mention that elements of zero weight are handled as expected by `WeightedIndex` as discussed in #1243.

Additionally fix some minor issues.

* Let the second example of `WeightedIndex` use floats to stress that they are handled correctly for the zero case.

* Manually indent doc comments.
2022-10-10 14:40:37 +01:00
Diggory Hardy
766c7eccd7
Doc: improve random, thread_rng, ThreadRng docs (#1257)
* Use a custom Debug impl for ThreadRng

* Adjust documentation of random, thread_rng, ThreadRng

* Fix no-std build

* Compatibility with older rustc
2022-09-30 09:48:10 +01:00
Alex Touchet
2b4f00add7
Update listed rand_core version number (#1254) 2022-09-16 07:41:28 +01:00
Diggory Hardy
89a1336b93
rand_core: update CHANGELOG for 0.6.4 (#1253) 2022-09-15 14:23:08 +01:00
TheIronBorn
b73640705d
Merge pull request #1246 from rust-random/work6
Bump MSRV to 1.51.0
2022-08-14 14:14:52 -07:00
Diggory Hardy
fbf06ff919 Optimized path of sample_efraimidis_spirakis is stable
This no longer requires nightly
2022-08-14 09:00:20 +01:00
Diggory Hardy
6951164ec6 Bump MSRV to 1.51.0: support const generics by default 2022-08-14 08:59:24 +01:00
Diggory Hardy
db80c40c4b Bump MSRV to 1.38.0: fixes crossbeam-utils dev-dependency 2022-08-14 08:59:24 +01:00
Pyry Kontio
2569e9d653
Mention disabling getrandom for wasm32-unknown-unknown in README (#1250) 2022-08-14 08:59:12 +01:00
TheIronBorn
9dd97b41c8
Merge pull request #1247 from rust-random/TheIronBorn-patch-1
optimize simd widening mul
2022-08-12 23:22:38 -07:00
TheIronBorn
d60ab387bf
optimize simd wmul 2022-08-11 05:45:51 +00:00
TheIronBorn
2c16a920cf
Merge pull request #1239 from TheIronBorn/std-simd
switch to std::simd, expand SIMD & docs
2022-08-10 11:56:46 -07:00
TheIronBorn
949d70f6a5 fix doc test 2022-08-07 17:42:24 -07:00
TheIronBorn
2fab15dcd7 fix stdsimd, add mask opt notes 2022-08-07 17:22:19 -07:00
TheIronBorn
1d55a97304
Merge pull request #1240 from TheIronBorn/patch-13
small deterministic example update
2022-08-04 13:54:38 -07:00
TheIronBorn
f89f15fc1f
fix doc link 2022-08-04 20:42:35 +00:00
TheIronBorn
d4b8748004 fix simd ints, clarify mask behavior 2022-07-11 11:29:13 -07:00
TheIronBorn
599d7f8f6d switch to std::simd, expand SIMD stuff & docs
move __m128i to stable, expand documentation, add SIMD to Bernoulli, add maskNxM, add __m512i

genericize simd uniform int

remove some debug stuff

remove bernoulli

foo

foo
2022-07-09 11:03:38 -07:00
TheIronBorn
89d7e4e184
another typo 2022-07-09 03:26:38 +00:00
TheIronBorn
1f99bb72dc
assert deterministic 2022-07-08 19:36:21 +00:00
TheIronBorn
6112c84365
small deterministic example update 2022-07-07 18:58:36 +00:00
masonk
330efe9d42
Deterministic Rayon monte carlo example (#1236)
* Deterministic Rayon monte carlo

* Update deterministic mt with a batching example

* discuss determinism in the context of rayon + rand

* reword the discussion

Co-authored-by: Mason Kramer <mason@masonkramer.net>
2022-07-07 08:20:11 +01:00
Chris Beck
3543f4b025
Make CryptoRngCore trait imply CryptoRng as well (#1230) 2022-05-19 17:55:31 +01:00
Vinzent Steinberg
f0f15b5ece
Merge pull request #1184 from vks/remove-unused-fields
Remove unused fields
2022-04-21 18:53:58 +02:00
Vinzent Steinberg
367cf50566
Merge pull request #1228 from cuishuang/master
fix typo
2022-04-20 22:49:28 +02:00
cuishuang
13193fcb8b fix typo
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-20 10:03:17 +08:00
Vinzent Steinberg
5f0d3a10a9 rand_distr: Remove unused fields
This breaks serialization compatibility with older versions.
2022-03-30 00:08:05 +02:00
Ralf Jung
a8474f7932
update Miri CI config (#1223) 2022-03-09 07:34:13 +00:00
Diggory Hardy
546acdc851
README: bump rand version 2022-02-14 08:38:55 +00:00
Diggory Hardy
937320cbfe
Update CHANGELOG for 0.8.5 (#1221) 2022-02-14 08:37:01 +00:00
Diggory Hardy
2924af688d
Merge pull request #1183 from vks/fill-float-doc
Mention that `Fill` supports floats
2022-02-11 14:29:28 +00:00