xoroshiro1024s

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 xoroshiro1024s implements xoroshiro1024* 1.0, our large-state generator for floating-point numbers. We suggest to use its upper bits for floating-point generation, as it is slightly faster than xoroshiro1024++/xoroshiro1024**. Its state however is too large--in general, the xoshiro256 family should be preferred. It is a better replacement for xorshift1024*.

It passes all tests we are aware of except for the lowest three bits, which might fail linearity tests (and just those), so if low linear complexity is not considered an issue (as it is usually the case) it can be used to generate 64-bit outputs, too.

We suggest to use a sign test to extract a random Boolean value, and right shifts to extract subsets of bits.

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 xoroshiro1024* algorithm.

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

Example
package main

import (
	"fmt"
	"math/rand"

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

func main() {
	var src xoroshiro1024s.Source
	src.Seed(1)
	r := rand.New(&src)
	for i := 0; i < 10; i++ {
		fmt.Println(r.Int63())
	}
}
Output:
5342038924001916882
2683941550217555709
6531581289886261224
3106969537905429597
6043697972756256704
5421517191659664927
3817051424625445335
2737981803588876732
1056458538821463057
1993465107093549081

func New

func New(state [16]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