-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
141 additions
and
86 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import '60_xoshiro128pp.dart'; | ||
|
||
class Drandom extends Xoshiro128pp { | ||
Drandom() | ||
: super(Xoshiro128pp.defaultSeedA, Xoshiro128pp.defaultSeedB, Xoshiro128pp.defaultSeedC, | ||
Xoshiro128pp.defaultSeedD); | ||
|
||
/// Generates a non-negative random integer uniformly distributed in | ||
/// the range from 0, inclusive, to [max], exclusive. | ||
/// | ||
/// To make the distribution uniform, we use the so-called | ||
/// [Debiased Modulo Once - Java Method](https://git.io/Jm0D7). | ||
/// | ||
/// This implementation is slightly faster than the standard one for | ||
/// all [max] values, except for [max], which are powers of two. | ||
@override | ||
int nextInt(int max) { | ||
if (max < 1 || max > 0x80000000) { | ||
throw RangeError.range(max, 1, 0x80000000); | ||
} | ||
int r = nextRaw32(); | ||
int m = max - 1; | ||
for (int u = r; u - (r = u % max) + m < 0; u = nextRaw32()) {} | ||
return r; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-FileCopyrightText: (c) 2021-2022 Art Galkin <github.com/rtmigo> | ||
// SPDX-License-Identifier: MIT | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:xrandom/xrandom.dart'; // no imports for src should be here | ||
|
||
void main() { | ||
test('Drandom readme', () { | ||
final random = Drandom(); | ||
expect( List.generate(5, (_) => random.nextInt(100)), | ||
[42, 17, 96, 23, 46] ); | ||
}); | ||
|
||
test('Drandom large', () { | ||
final random = Drandom(); | ||
expect( List.generate(5, (_) => random.nextInt(0x7FEEDDAA)), | ||
[1686059242, 361797217, 1133571596, 465717623, 1522544346] ); | ||
}); | ||
|
||
test('Drandom nextInt range', () { | ||
final random = Drandom(); | ||
|
||
expect(()=>random.nextInt(0x80000001), throwsRangeError); | ||
random.nextInt(0x80000000); // does not throw anything | ||
}); | ||
|
||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
void addReferenceData( | ||
{String? algorithm, String? seed, String? type, List? values}) {} | ||
|
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.