Documentation ¶
Overview ¶
The MIT License
PCG Random Number Generation for C.
Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License ¶
PCG Random Number Generation for C.
Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License ¶
PCG Random Number Generation for C.
Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- func Mul128Parts(x uint64, y uint64, z1 *uint64, z0 *uint64)
- func Ror64(value uint64, rot uint) uint64
- type Rng
- func (rng *Rng) Advance(delta Uint128)
- func (rng *Rng) BoundRand(bound uint64) uint64
- func (rng *Rng) CheapAdvance(delta Uint128)
- func (rng *Rng) CheapRand() uint64
- func (rng *Rng) CheapSeed(initState Uint128, initSeq Uint128)
- func (rng *Rng) CheapStep()
- func (rng *Rng) Rand() uint64
- func (rng *Rng) Seed(initState Uint128, initSeq Uint128)
- func (rng *Rng) Step()
- type State
- func (st *State) Advance(step []uint64)
- func (st *State) CheapAdvance(step []uint64)
- func (st *State) CheapNext32() uint32
- func (st *State) CheapNext64() uint64
- func (st *State) GetState(state []uint64, hasUi *int, ui *uint32)
- func (st *State) Next32() uint32
- func (st *State) Next64() uint64
- func (st *State) Seed(seed []uint64, inc []uint64)
- func (st *State) SetState(state []uint64, hasUi int, ui uint32)
- type Uint128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
func (*State) CheapAdvance ¶
func (*State) CheapNext32 ¶
func (*State) CheapNext64 ¶
type Uint128 ¶
func AdvanceLcg128 ¶
Muli-step advance functions (jump-ahead, jump-back)
The method used here is based on Brown, "Random Number Generation with Arbitrary Stride,", Transactions of the American Nuclear Society (Nov. 1994). The algorithm is very similar to fast exponentiation.
Even though delta is an unsigned integer, we can pass a signed integer to go backwards, it just goes "the long way round".