forked from vim-jp/vital.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXor128.txt
81 lines (56 loc) · 2.7 KB
/
Xor128.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
*vital/Random/Xor128.txt* random number generator using xor128
Maintainer: Linda_pp <lin90162@gmail.com>
==============================================================================
CONTENTS *Vital.Random.Xor128-contents*
INTRODUCTION |Vital.Random.Xor128-introduction|
INTERFACE |Vital.Random.Xor128-interface|
FUNCTIONS |Vital.Random.Xor128-functions|
==============================================================================
INTRODUCTION *Vital.Random.Xor128-introduction*
*Vital.Random.Xor128* provides a Random Number Generator (RNG) using an
xorshift algorithm. Although xorshift has a reasonable period (2^128-1), it
is fast and has less internal states.
The paper about xorshift is http://www.jstatsoft.org/v08/i14/paper .
This implementation always generates 32bit number [-2147483648, 2147483647],
even when you use Vim with |+num64|.
>
let s:V = vital#{plugin-name}#new()
let s:X = s:V.import("Random.Xor128")
call s:X.srand(1)
echo s:X.rand()
" -232950721
echo s:X.rand()
" 739248423
call s:X.srand(1)
echo s:X.rand()
" -232950721
<
==============================================================================
INTERFACE *Vital.Random.Xor128-interface*
------------------------------------------------------------------------------
FUNCTIONS *Vital.Random.Xor128-functions*
srand([{seed}]) *Vital.Random.Xor128.srand()*
Initialize the global generator with the given seed number. When
{seed} is omitted, a return value of |reltime()| is used. When {seed}
is omitted and vim doesn't have |reltime()|, a return value of
|localtime()| is used.
rand() *Vital.Random.Xor128.rand()*
Generate a random number from the global generator.
Note: A return value is possibly negative. This is because Vim script
doesn't have an unsigned integer type.
new_generator() *Vital.Random.Xor128.new_generator()*
Create a new Generator object(|Vital.Random.Xor128-Generator|).
==============================================================================
OBJECTS *Vital.Random.Xor128-objects*
------------------------------------------------------------------------------
Generator Object *Vital.Random.Xor128-Generator*
Generator.next() *Vital.Random.Xor128-Generator.next()*
Generate the next random number in the sequence.
Generator.min() *Vital.Random.Xor128-Generator.min()*
Get the smallest possible value in the output range.
Generator.max() *Vital.Random.Xor128-Generator.max()*
Get the largest possible value in the output range.
Generator.seed({seeds}) *Vital.Random.Xor128-Generator.seed()*
Initialze the generator with the given seed list.
==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl