xoroshiro128pp

package
v0.0.0-...-17533aa Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package xoroshiro128pp implements xoroshiro128++ 1.0, one of our all-purpose, rock-solid, small-state generators. It is extremely (sub-ns) fast and it passes all tests we are aware of, but its state space is large enough only for mild parallelism.

For generating just floating-point numbers, xoroshiro128+ is even faster (but it has a very mild bias, see notes in the comments).

The state must be seeded so that it is not everywhere zero. If you have a 64-bit seed, we suggest to seed a splitmix64 generator and use its output to fill s

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source is a random source using xoroshiro128++ algorithm.

Go port of http://prng.di.unimi.it/xoroshiro128plusplus.c

Example
package main

import (
	"fmt"
	"math/rand"

	"github.com/shogo82148/randsrc/xoroshiro128pp"
)

func main() {
	src := xoroshiro128pp.New([2]uint64{1})
	r := rand.New(src)
	for i := 0; i < 10; i++ {
		fmt.Println(r.Int63())
	}
}
Output:
65536
299204602822658
289675143695892772
5082613694791532834
271823060665434799
3628234659518064874
7563027819649276380
2173227447226003975
8233774529164765107
2037889483630097538

func New

func New(state [2]uint64) *Source

New create a new source.

func (*Source) Int63

func (s *Source) Int63() int64

Int63 implements math/rand.Source.

func (*Source) Seed

func (s *Source) Seed(seed int64)

Seed implements math/rand.Source.

func (*Source) Uint64

func (s *Source) Uint64() uint64

Uint64 implements math/rand.Source64

Jump to

Keyboard shortcuts

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