*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
