Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
5694-Change-mwc59-multiplier.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5694-Change-mwc59-multiplier.patch of Package erlang
From 7e9261cae537c1824373848512d279c0e9245cd2 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen <raimo@erlang.org> Date: Tue, 3 May 2022 14:44:42 +0200 Subject: [PATCH 4/6] Change `mwc59` multiplier --- lib/stdlib/doc/src/rand.xml | 6 +++--- lib/stdlib/src/rand.erl | 13 +++++-------- lib/stdlib/test/rand_SUITE.erl | 12 ++++++------ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/stdlib/doc/src/rand.xml b/lib/stdlib/doc/src/rand.xml index 22135d3443..839c6c0ce5 100644 --- a/lib/stdlib/doc/src/rand.xml +++ b/lib/stdlib/doc/src/rand.xml @@ -898,7 +898,7 @@ end.</pre> </p> <p> This generator uses the multiplier 2^32 and the modulus - 16#7f17555 * 2^32 - 1, + 16#7fa6502 * 2^32 - 1, which have been selected, in collaboration with Sebastiano Vigna, to avoid bignum operations @@ -906,7 +906,7 @@ end.</pre> It can be written as:<br/> <c>C = <anno>CX0</anno> bsr 32</c><br/> <c>X = <anno>CX0</anno> band ((1 bsl 32)-1))</c><br/> - <c><anno>CX1</anno> = 16#7f17555 * X + C</c> + <c><anno>CX1</anno> = 16#7fa6502 * X + C</c> </p> <p> The quality of the generated bits is best in the low end; @@ -946,7 +946,7 @@ end.</pre> than the default generator, which in itself is a quality concern, although when used with the value scramblers it passes strict PRNG tests - (TestU01 BigCrush and PractRand 2 TB). + (most of TestU01 BigCrush and PractRand 2 TB). The generator is significantly faster than <seemfa marker="#exsp_next/1"><c>exsp_next/1</c></seemfa> but with a bit lower quality. diff --git a/lib/stdlib/src/rand.erl b/lib/stdlib/src/rand.erl index 5f94804bfb..47766f2547 100644 --- a/lib/stdlib/src/rand.erl +++ b/lib/stdlib/src/rand.erl @@ -1476,9 +1476,9 @@ dummy_seed({A1, A2, A3}) -> %% and a double Xorshift to get all bits good enough. %% %% The chosen parameters are: -%% A = 16#7f17555 +%% A = 16#7fa6502 %% B = 32 -%% Single Xorshift: 10 +%% Single Xorshift: 16 %% Double Xorshift: 8, 16 %% %% These parameters gives the MWC "digit" size 32 bits @@ -1493,17 +1493,14 @@ dummy_seed({A1, A2, A3}) -> %%% -define(MWC_A, (6)). %%% -define(MWC_B, (3)). -%%% -define(MWC59_A, (16#20075dc0)). -%%% -define(MWC59_A, (16#1ffb0729)). +%%% -define(MWC59_A, (16#20075dc0)). % 16#1ffb0729 %%% -define(MWC59_B, (29)). -%%% -define(MWC59_A, (16#7fa6502)). --define(MWC59_A, (16#7f17555)). -%%% -define(MWC59_A, (16#3f35301)). +-define(MWC59_A, (16#7fa6502)). % 16#7f17555 16#3f35301 -define(MWC59_B, (32)). -define(MWC59_P, ((?MWC59_A bsl ?MWC59_B) - 1)). --define(MWC59_XS, 10). +-define(MWC59_XS, 16). -define(MWC59_XS1, 8). -define(MWC59_XS2, 16). diff --git a/lib/stdlib/test/rand_SUITE.erl b/lib/stdlib/test/rand_SUITE.erl index 90ea2890e8..eabb9396ad 100644 --- a/lib/stdlib/test/rand_SUITE.erl +++ b/lib/stdlib/test/rand_SUITE.erl @@ -214,20 +214,20 @@ mwc59_api(Config) when is_list(Config) -> mwc59_api(1, 1000000). mwc59_api(CX0, 0) -> - CX = 298134347579367847, + CX = 216355295181821136, {CX, CX} = {CX0, CX}, V0 = rand:mwc59_value(CX0), - V = 44296811804442023, + V = 215617979550160080, {V, V} = {V0, V}, W0 = rand:mwc59_full_value(CX0), - W = 43477957222139559, + W = 70209996550472912, {W, W} = {W0, W}, F0 = rand:mwc59_float(CX0), F = (W band ((1 bsl 53) - 1)) * (1 / (1 bsl 53)), {F, F} = {F0, F}, ok; mwc59_api(CX, N) - when is_integer(CX), 1 =< CX, CX < (16#7f17555 bsl 32) - 1 -> + when is_integer(CX), 1 =< CX, CX < (16#7fa6502 bsl 32) - 1 -> V = rand:mwc59_value(CX), W = rand:mwc59_full_value(CX), F = rand:mwc59_float(CX), @@ -1354,7 +1354,7 @@ do_measure(Iterations) -> _ = measure_1( fun (_Mod, _State) -> - Range = (16#7f17555 bsl 32) - 1, + Range = (16#7fa6502 bsl 32) - 1, fun (St0) -> St1 = rand:mwc59(St0), V = St1, @@ -1455,7 +1455,7 @@ do_measure(Iterations) -> _ = measure_1( fun (_Mod, _State) -> - Range = (16#7f17555 bsl 32) - 1, + Range = (16#7fa6502 bsl 32) - 1, fun (St0) -> case put(mwc59_procdict, -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor