xorshift1024s

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: 2 Imported by: 0

Documentation

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

http://vigna.di.unimi.it/ftp/papers/xorshift.pdf https://arxiv.org/abs/1402.6246 https://doi.org/10.1145%2F2845077 Vigna, Sebastiano (July 2016). "An experimental exploration of Marsaglia's xorshift generators, scrambled" (PDF). ACM Transactions on Mathematical Software. 42 (4): 30. arXiv:1402.6246. doi:10.1145/2845077. Proposes xorshift* generators, adding a final multiplication by a constant.

Example
package main

import (
	"fmt"
	"math/rand"

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

func main() {
	src := xorshift1024s.New([16]uint64{1})
	r := rand.New(src)
	for i := 0; i < 10; i++ {
		fmt.Println(r.Int63())
	}
}
Output:
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490
590891748638326490

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