quantum

package
v0.0.0-...-32c6aa8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diffusion

func Diffusion(qreg *QReg, target int)

func DiffusionRange

func DiffusionRange(qreg *QReg, target_range_start int, target_range_end int)

func DiffusionReg

func DiffusionReg(qreg *QReg)

func Hadamard

func Hadamard(qreg *QReg, target int)

func HadamardRange

func HadamardRange(qreg *QReg, target_range_start int, target_range_end int)

func HadamardReg

func HadamardReg(qreg *QReg)

Types

type Gate

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

func NewArrayGate

func NewArrayGate(arr []complex128) *Gate

func NewClassicalGate

func NewClassicalGate(f func(x int) int, bits int) *Gate

func NewDiffusionGate

func NewDiffusionGate(bits int) *Gate

func NewFuncGate

func NewFuncGate(f func(row int, col int) complex128, bits int) *Gate

func NewFuncGateNoCheck

func NewFuncGateNoCheck(f func(row int, col int) complex128, bits int) *Gate

func NewHadamardGate

func NewHadamardGate(bits int) *Gate

func NewRealArrayGate

func NewRealArrayGate(arr []float64) *Gate

func (*Gate) Apply

func (gate *Gate) Apply(qreg *QReg, targets []int)

Apply an arbitrary matrix to a quantum register len(matrix) == 4 ** len(targets)

func (*Gate) ApplyRange

func (gate *Gate) ApplyRange(qreg *QReg, target_range_start int)

func (*Gate) ApplyReg

func (gate *Gate) ApplyReg(qreg *QReg)

func (*Gate) IsUnitary

func (gate *Gate) IsUnitary() bool

This tells us whether or not a gate is unitary (it should always be)

func (*Gate) Print

func (gate *Gate) Print()

type QReg

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

Represents a quantum register

func NewQReg

func NewQReg(width int, values ...int) *QReg

Constructor for a QReg

func (*QReg) BMeasure

func (qreg *QReg) BMeasure(index int) int

Measure a bit (the quantum state of this qubit will collapse)

func (*QReg) BMeasurePreserve

func (qreg *QReg) BMeasurePreserve(index int) int

Measure a bit without collapsing its quantum state

func (*QReg) BProb

func (qreg *QReg) BProb(index int, value int) float64

Get the probability of observing a state for a specific bit

func (*QReg) BSet

func (qreg *QReg) BSet(index int, value int)

Set a particular bit in a QReg

func (*QReg) Copy

func (qreg *QReg) Copy() *QReg

Copy a quantum register

func (*QReg) Measure

func (qreg *QReg) Measure() int

Measure a register

func (*QReg) MeasurePreserve

func (qreg *QReg) MeasurePreserve() int

Measure a register without collapsing its quantum state

func (*QReg) Print

func (qreg *QReg) Print()

func (*QReg) PrintNonZero

func (qreg *QReg) PrintNonZero()

func (*QReg) PrintState

func (qreg *QReg) PrintState(index int)

func (*QReg) PrintStateln

func (qreg *QReg) PrintStateln(index int)

func (*QReg) Set

func (qreg *QReg) Set(values ...int)

Set the QReg to a state in the standard basis. If no value is given, default to the all zero state. If one value is given, interpret it as the integer representation of a basis state. If a series of binary values are given, interpret them as the binary representation of a basis state.

func (*QReg) StateProb

func (qreg *QReg) StateProb(state int) float64

Get the probability of observing a state

func (*QReg) Width

func (qreg *QReg) Width() int

Accessor for the width of a QReg

Jump to

Keyboard shortcuts

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