Commit graph

346 commits

Author SHA1 Message Date
Cameron Ross
df10d1e331 Fix issue 21609 - LinearCongruentialEngine fails for m = 0 2021-02-05 02:37:24 +01:00
Bernhard Seckinger
9cb7755041 Replace approxEqual with isClose 2021-01-28 10:39:50 +01:00
Nathan Sashihara
fdf20e718a Fix Issue 21384 - std.random.uniform!T() and std.random.uniform!T(urng) when T is dchar with any qualifiers can exceed dchar.max 2020-11-13 06:58:07 -08:00
Nathan Sashihara
f5c9556e48 Fix Issue 21383 - std.random.uniform!T(urng) when T is dchar disregards urng and always uses a thread-local random 2020-11-13 06:52:08 -08:00
Lance Bachmeier
dec85a4a57
Remove trailing whitespace 2020-08-10 10:33:54 -05:00
Lance Bachmeier
a864971c45
Update std/random.d
Co-authored-by: Sebastian Wilzbach <seb@wilzba.ch>
2020-08-10 10:25:45 -05:00
Lance Bachmeier
94132a52f5
Update std/random.d
Co-authored-by: Sebastian Wilzbach <seb@wilzba.ch>
2020-08-10 10:25:18 -05:00
Lance Bachmeier
945f9510b1
Update random.d
Demonstrate basic usage of uniform01. The existing example is confusing because it mixes in feqrel without any explanation, as you can see from [this question on the forum](https://forum.dlang.org/post/utjsiocsbearbenpaiut@forum.dlang.org).
2020-08-10 10:09:39 -05:00
Andrei Alexandrescu
42138c021c
Replace Unqual-based idiom with immutable-based idiom (#7576)
Replace Unqual-based idiom with immutable-based idiom
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
2020-08-04 04:32:14 +02:00
Andrei Alexandrescu
05c79e1af1 unsignedToTempString: use the template version 2020-07-27 03:37:52 +02:00
The Dlang Bot
be16aba1cf
Merge pull request #7436 from n8sh/issue-20723
std.random.unpredictableSeed: on x86/x86-64 try using RDRAND when there is no arc4random
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2020-04-16 20:35:57 +02:00
Geod24
04f3979317 Replace 'Issue XXX' with Bugzilla links
Make the links clickable, as was done in the DMD repository.
Also avoids any ambiguity w.r.t. where the issue is stored.
2020-04-13 16:28:09 +09:00
Nathan Sashihara
f6a3678adc Fix Issue 20723 - std.random.unpredictableSeed: on x86/x86-64 try using RDRAND when there is no arc4random
This code works in both DMD and LDC because LDC version 1.20.0
added support for data directives in DMD-style inline asm.
2020-04-06 21:57:13 -07:00
Jacob Carlborg
d7e574e964 Use arc4random on iOS derived platforms 2020-03-14 15:08:54 +01:00
Adam D. Ruppe
ae93f5317c Use consistent quickindex wrapper around hand-written list-of-links tables 2020-02-21 21:04:05 -05:00
Nathan Sashihara
67e4a08684 Issue 20548 followup: in 32-bit builds RandomCoverChoices allocates more memory than needed for the bit vector 2020-02-03 02:00:30 -08:00
Nathan Sashihara
9014d77ab0 Fix Issue 20548 - Use bit vector instead of bool[] in RandomCover when choices cannot be packed in a single word 2020-01-30 23:15:57 -08:00
Alexandru Militaru
bb62aaca3d Replaced version (unittest) with version (StdUnittest) to avoid unnecessary overhead when compiling with -unittest 2020-01-19 14:05:17 +02:00
Bernhard Seckinger
97abb91952 Fix Issue 10902 - some phobos unittests take an excessive amount of time 2019-11-12 20:21:03 +01:00
Mike
b3416948d9 Replace sizediff_t with ptrdiff_t in std.random.d 2019-08-30 17:38:39 +09:00
Martin Nowak
b42d6291ab Merge remote-tracking branch 'upstream/stable' into merge_stable 2019-06-13 01:06:21 +02:00
Nicholas Wilson
5e72cf5c1d
Merge pull request #7013 from n8sh/rndGenUnusedImports
Remove unused imports from std.random.rndGen
2019-05-18 13:48:34 +08:00
Nathan Sashihara
e4a38e8ea5 Remove unused imports from std.random.rndGen 2019-05-17 19:49:58 -04:00
Nathan Sashihara
8d49976514 Issue 19836 followup - also fix on 32 bit machines
Changed the private enhanced seeding method for `rndGen` to something
that is fast on both 64 bit and 32 bit machines so can be enabled
regardless of architecture. When compiled with LDC it is about 1.35x
the speed of public `Mt19937.seed(uint)`.
2019-05-06 05:13:56 -04:00
Nathan Sashihara
b7389926ee Fix Issue 19837 - std.random.isUniformRNG(Rng, ElementType) should not require Rng.front to be annotated @property 2019-04-29 10:03:45 -04:00
Nathan Sashihara
5d0f1d3471 Fix Issue 19836 - Excessive probability of UUID collisions in std.uuid.randomUUID
On 64-bit architectures use 64 bits of entropy to initialize
thread-local `rndGen`.

The motivation for this change is std.uuid defaults to using `rndGen`
to generate UUIDs. If every `rndGen` starts in one of 2^^32 states then
if 77000 independent programs each generate a single UUID there is a 50%
chance that at least two of them generate the same initial UUID (and all
subsequent UUIDs would be identical as well). Not just Phobos but also
C++ boost::uuids::random_generator defaults to generating UUIDs with a
Mersenne Twister initialized from a 32-bit seed, exacerbating the
collision problem further. If instead there are 2^^64 possible initial
states of `rndGen` there can be over 5 billion independent `rndGen`s
before there is a 50% chance of two having identical initial states.

This change is limited to 64-bit architectures to avoid a measurable
performance decrease, because many programs are not generating UUIDs.
2019-04-28 16:16:11 -04:00
Rainer Schuetze
2e13c10025 add workaround for https://issues.dlang.org/show_bug.cgi?id=2396 to reduce compile time of unittests 2019-03-29 12:12:53 +01:00
Nathan Sashihara
25300d32d1 Fix issue 15853 - std.random save methods must be const
Revival of dlang/phobos#4136
2019-02-08 16:52:20 -05:00
Nathan Sashihara
21120a4972 Fix Issue 19580 - [non-DMD] std.random seed bootstrap: don't count on reading an uninitialized variable being treated as an ordinary read 2019-01-14 02:05:04 -05:00
Walter Bright
233d7d617f std.random: make dip1000 compliant 2019-01-10 03:33:08 -08:00
Nathan Sashihara
dc1a3d3efa Fix Issue 18680 - std.random.LinearCongruentialEngine has opEquals but no toHash
The custom opEquals is unnecessary. Autogenerated struct equals is correct.
2018-11-21 15:05:48 -05:00
Nathan Sashihara
dcca23edca Fix Issue 19164 - malloc may be considered pure when failure results in program exit (no need to reset errno) 2018-11-17 17:00:16 -05:00
The Dlang Bot
ac2c7c627d
Merge pull request #6424 from n8sh/xorshift-18327
Fix Issue 18327 - std.random.XorshiftEngine is parameterized by UIntType but only works with uint
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
2018-11-15 16:49:25 +01:00
Nathan Sashihara
c75d6f712a Fix Issue 18595 & Issue 18596: replace MindstdRand0 w/SplitMix & templatize unpredictableSeed!UIntType 2018-11-14 05:40:48 -05:00
ARaspiK
9bb605b8d1
Made unittest for rndGen also nothrow @nogc
As requested by @ZombineDev
2018-11-11 08:08:01 +01:00
ARaspiK
3d54b63c5d
Make rndgen nothrow
This passes all Phobos tests and would be really nice for no-exceptions situations, instead of appending `assumeWontThrow` to everything. Should be quick.
2018-11-10 21:47:25 +01:00
Nathan Sashihara
c99a1855f6 Fix Issue 18327 - std.random.XorshiftEngine is parameterized by UIntType but only works with uint
Also:
* Add ability to specify shift directions.
* Allow arbitrary XorshiftEngine sizes instead of predefined list only.
* Except when array is small, use index to make speed of `popFront`
  independent of array size.
2018-09-24 08:55:00 -04:00
Iain Buclaw
fd5facfe04 posix.mak: Enforce whitespace before opening parenthesis for version conditions 2018-09-22 16:57:24 +02:00
Sebastian Wilzbach
91c9973d72
Merge pull request #6657 from n8sh/std-random-14001-19156
Fix Issue 14001 & Issue 19156 - `@nogc` std.random.randomCover and std.random.randomShuffle
2018-08-14 13:54:44 +02:00
Martin Nowak
050464eda6 Merge remote-tracking branch 'upstream/stable' into merge_stable
# Conflicts:
#	std/conv.d
2018-08-12 16:36:44 +02:00
Nathan Sashihara
3a212c0c72 Fix Issue 14001 - Optionally @nogc std.random.randomCover
Fix Issue 19156 - `@nogc` std.random.randomShuffle

Solution is to use a private `_randomIndex` function that is guaranteed
to be called only with valid bounds.
2018-08-10 18:24:34 -04:00
Martin Kinkelin
4de15cec63 Remove superfluous core.stdc.* dependencies in std.{conv,random} 2018-08-06 21:40:38 +02:00
The Dlang Bot
c7b1cf1994
Merge pull request #6576 from BBasile/rnd-cov-nogc-buff
RandomCover use a `@nogc` buffer to store already chosen results
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2018-07-15 12:25:40 +02:00
Sebastian Wilzbach
84b98fc3f0 Remove invalid Markdown backticks in std.{container,path,random}.d 2018-06-19 22:04:01 +02:00
Basile Burg
a716ad69f1 address review: use memcpy and disable assignment 2018-06-14 07:03:23 +02:00
Basile Burg
d3a933b748 remove wrong ddoc and make disable default ctor 2018-06-13 14:13:34 +02:00
Basile Burg
4b3d0ed23c address review: make the custom array pure 2018-06-13 07:24:07 +02:00
Basile Burg
047f7272cb address review: use static OOME and remove useless null check 2018-06-13 06:28:49 +02:00
Basile Burg
76491474ef cover postblit when heap storage is used 2018-06-12 09:42:01 +02:00
Basile Burg
acb48117d0 fine tweaks 2018-06-11 07:12:25 +02:00