Copyright 2017 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package rand

import (
	
	
	
)
PCGSource is an implementation of a 64-bit permuted congruential generator as defined in PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation Melissa E. O’Neill, Harvey Mudd College http://www.pcg-random.org/pdf/toms-oneill-pcg-family-v1.02.pdf The generator here is the congruential generator PCG XSL RR 128/64 (LCG) as found in the software available at http://www.pcg-random.org/. It has period 2^128 with 128 bits of state, producing 64-bit values. Is state is represented by two uint64 words.
type PCGSource struct {
	low  uint64
	high uint64
}

const (
	maxUint32 = (1 << 32) - 1

	multiplier = 47026247687942121848144207491837523525
	mulHigh    = multiplier >> 64
	mulLow     = multiplier & maxUint64

	increment = 117397592171526113268558934119004209487
	incHigh   = increment >> 64
	incLow    = increment & maxUint64
TODO: Use these?
	initializer = 245720598905631564143578724636268694099
	initHigh    = initializer >> 64
	initLow     = initializer & maxUint64
)
Seed uses the provided seed value to initialize the generator to a deterministic state.
func ( *PCGSource) ( uint64) {
	.low = 
	.high =  // TODO: What is right?
}
Uint64 returns a pseudo-random 64-bit unsigned integer as a uint64.
func ( *PCGSource) () uint64 {
	.multiply()
XOR high and low 64 bits together and rotate right by high 6 bits of state.
	return bits.RotateLeft64(.high^.low, -int(.high>>58))
}

func ( *PCGSource) () {
	var  uint64
	.low,  = bits.Add64(.low, incLow, 0)
	.high, _ = bits.Add64(.high, incHigh, )
}

func ( *PCGSource) () {
	,  := bits.Mul64(.low, mulLow)
	 += .high * mulLow
	 += .low * mulHigh
	.low = 
	.high = 
}
MarshalBinary returns the binary representation of the current state of the generator.
func ( *PCGSource) () ([]byte, error) {
	var  [16]byte
	binary.BigEndian.PutUint64([:8], .high)
	binary.BigEndian.PutUint64([8:], .low)
	return [:], nil
}
UnmarshalBinary sets the state of the generator to the state represented in data.
func ( *PCGSource) ( []byte) error {
	if len() < 16 {
		return io.ErrUnexpectedEOF
	}
	.low = binary.BigEndian.Uint64([8:])
	.high = binary.BigEndian.Uint64([:8])
	return nil