xoshiro256

package
v0.0.0-...-a8cedd3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package xoshiro256 implements the xoshiro256** random number generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source struct {
	S [4]uint64 // Generator state (256 bits).
}

A Source is a xoshiro256** 1.0 random number generator.

The zero Source is not usable; it produces a stream of zeros.

Note that Sources constructed by New or initialized with Seed can produce 2^64 distinct streams of random numbers. The state S is public for applications that need more.

func New

func New(seed uint64) *Source

New returns a Source initialized with the given seed. It is equivalent to allocating a Source and calling Seed on it.

func (*Source) Int63

func (s *Source) Int63() int64

Int63 returns a non-negative pseudo-random 63-bit integer as an int64.

func (*Source) Jump

func (s *Source) Jump()

Jump advances the Source by 2^128 positions.

func (*Source) MarshalBinary

func (s *Source) MarshalBinary() (data []byte, err error)

MarshalBinary encodes s in a binary format for serialization.

The format starts with a 16-byte header, followed by the four 64-bit integers of state in little-endian format.

The returned error is always nil.

func (*Source) Seed

func (s *Source) Seed(seed int64)

Seed uses the provided seed value to initialize the generator to a deterministic state. The seed value may be any 64-bit integer.

It uses a SplitMix64 generator to turn seed into four non-zero pseudo-random numbers.

func (*Source) Uint64

func (s *Source) Uint64() uint64

Uint64 returns a pseudo-random 64-bit value as a uint64.

func (*Source) UnmarshalBinary

func (s *Source) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes s from the binary format used by MarshalBinary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL