parity

package
v0.0.0-...-f1b6caa Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: LGPL-2.1 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sampler

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

Sampler is a sampler that randomly generates test samples of the parity function. this is to be used together with the FunBool type to generate a function to see how well the SPSO optimisers perform when searching for a boolean dag to represent the the parity checker.

func NewSampler

func NewSampler(inputSize int) *Sampler

NewSampler creates an instance of the parity sampler for inputSize bits.

Example
p := NewSampler(4)
x := big.NewInt(0)
y := big.NewInt(0)
fmt.Printf("About:\n%s\n", p.About())
rnd := rand.New(rand.NewSource(3142))
for i := 0; i < 16; i++ {
	p.Sample(x, y, rnd)
	fmt.Printf("%b => %b\n", x, y)
}
Output:

func (*Sampler) About

func (p *Sampler) About() string

About gives description of sampler

func (*Sampler) InputSize

func (p *Sampler) InputSize() int

InputSize is the number of bits to parity check.

func (*Sampler) OutputSize

func (p *Sampler) OutputSize() int

OutputSize gives the output size in bits, which in this case is 1.

func (*Sampler) Sample

func (p *Sampler) Sample(x, y *big.Int, rnd *rand.Rand)

Sample generates a sample with input x and output y.

Jump to

Keyboard shortcuts

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