quantum

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownGate         = errors.New("unknown gate")
	ErrDuplicateWire       = errors.New("duplicate wire")
	ErrInvalidWireFormat   = errors.New("invalid wire format")
	ErrInvalidArgument     = errors.New("invalid argument")
	ErrGateMatrixNotSquare = errors.New("gate matrix is not square")
	ErrInvalidWireCount    = errors.New("invalid wire count")
	ErrInvalidBarrier      = errors.New("invalid barrier")
	ErrTooManyGates        = errors.New(fmt.Sprintf("too many gates, max: %d", maxGates))
	ErrTooManyWires        = errors.New(fmt.Sprintf("too many wires, max: %d", maxWires))
)

Functions

func Probabilities

func Probabilities(stateVector map[string]complex128) map[string]float64

func Symbofy

func Symbofy(s complex128) string

symbofy a single complex num

func SymbofyMap

func SymbofyMap(s map[string]complex128) map[string]string

map of complex128s to map of strings

Types

type CCXGate added in v0.0.5

type CCXGate struct {
	Gate
}

func (CCXGate) Example added in v0.0.5

func (g CCXGate) Example() string

func (CCXGate) FullName added in v0.0.5

func (g CCXGate) FullName() string

func (CCXGate) WiresNeeded added in v0.0.5

func (g CCXGate) WiresNeeded() int

type CCZGate added in v0.0.5

type CCZGate struct {
	Gate
}

func (CCZGate) Example added in v0.0.5

func (g CCZGate) Example() string

func (CCZGate) FullName added in v0.0.5

func (g CCZGate) FullName() string

func (CCZGate) WiresNeeded added in v0.0.5

func (g CCZGate) WiresNeeded() int

type CNOTGate

type CNOTGate struct {
	Gate
}

func (CNOTGate) Example added in v0.0.5

func (g CNOTGate) Example() string

func (CNOTGate) FullName added in v0.0.5

func (g CNOTGate) FullName() string

func (CNOTGate) WiresNeeded

func (g CNOTGate) WiresNeeded() int

type CRxGate added in v0.0.5

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

func (CRxGate) Example added in v0.0.5

func (g CRxGate) Example() string

func (CRxGate) FullName added in v0.0.5

func (g CRxGate) FullName() string

func (CRxGate) Name added in v0.0.5

func (g CRxGate) Name() string

func (CRxGate) WiresNeeded added in v0.0.5

func (g CRxGate) WiresNeeded() int

type CRyGate added in v0.0.5

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

func (CRyGate) Example added in v0.0.5

func (g CRyGate) Example() string

func (CRyGate) FullName added in v0.0.5

func (g CRyGate) FullName() string

func (CRyGate) Name added in v0.0.5

func (g CRyGate) Name() string

func (CRyGate) WiresNeeded added in v0.0.5

func (g CRyGate) WiresNeeded() int

type CRzGate added in v0.0.5

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

func (CRzGate) Example added in v0.0.5

func (g CRzGate) Example() string

func (CRzGate) FullName added in v0.0.5

func (g CRzGate) FullName() string

func (CRzGate) Name added in v0.0.5

func (g CRzGate) Name() string

func (CRzGate) WiresNeeded added in v0.0.5

func (g CRzGate) WiresNeeded() int

type CZGate

type CZGate struct {
	Gate
}

func (CZGate) Example added in v0.0.5

func (g CZGate) Example() string

func (CZGate) FullName added in v0.0.5

func (g CZGate) FullName() string

func (CZGate) WiresNeeded

func (g CZGate) WiresNeeded() int

type Circuit

type Circuit struct {
	Gates []CircuitGate
}

func NewCircuit

func NewCircuit(gates []string) (Circuit, error)

func (*Circuit) Draw

func (c *Circuit) Draw(atBarrier int) error

func (*Circuit) ExecuteToBarrier

func (c *Circuit) ExecuteToBarrier(atBarrier int) (Result, error)

executes the circuit up to a specific barrier n and returns the result

type CircuitGate

type CircuitGate struct {
	Gate  GateInterface
	Wires []int
}

type Gate

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

func (Gate) Data

func (g Gate) Data() Matrix

func (Gate) Name

func (g Gate) Name() string

type GateInterface

type GateInterface interface {
	WiresNeeded() int
	Name() string
	FullName() string
	Example() string
	Data() Matrix
}

func CCX added in v0.0.5

func CCX() GateInterface

func CCZ added in v0.0.5

func CCZ() GateInterface

func CNOT

func CNOT() GateInterface

func CRx added in v0.0.5

func CRx(theta float64) GateInterface

func CRy added in v0.0.5

func CRy(theta float64) GateInterface

func CRz added in v0.0.5

func CRz(theta float64) GateInterface

func CZ

func CZ() GateInterface

func Hadamard

func Hadamard() GateInterface

func Identity

func Identity(dim int) GateInterface

func PauliX

func PauliX() GateInterface

func PauliY

func PauliY() GateInterface

func PauliZ

func PauliZ() GateInterface

func Phase

func Phase() GateInterface

func Rx added in v0.0.5

func Rx(theta float64) GateInterface

func Ry added in v0.0.5

func Ry(theta float64) GateInterface

func Rz added in v0.0.5

func Rz(theta float64) GateInterface

func S

func S() GateInterface

func SWAP

func SWAP() GateInterface

func T

func T() GateInterface

func Toffoli

func Toffoli() GateInterface

type HadamardGate

type HadamardGate struct {
	Gate
}

func (HadamardGate) Example added in v0.0.5

func (g HadamardGate) Example() string

func (HadamardGate) FullName added in v0.0.5

func (g HadamardGate) FullName() string

func (HadamardGate) WiresNeeded

func (g HadamardGate) WiresNeeded() int

type IdentityGate

type IdentityGate struct {
	Gate
}

func (IdentityGate) Example added in v0.0.5

func (g IdentityGate) Example() string

func (IdentityGate) FullName added in v0.0.5

func (g IdentityGate) FullName() string

func (IdentityGate) WiresNeeded

func (g IdentityGate) WiresNeeded() int

type Matrix

type Matrix struct {
	Rows int
	Cols int
	Data [][]complex128
}

func NewMatrix

func NewMatrix(rows, cols int) Matrix

func (*Matrix) CanMultiply

func (m *Matrix) CanMultiply(n *Matrix) bool

func (*Matrix) MustMultiply

func (m *Matrix) MustMultiply(n *Matrix) Matrix

type PauliXGate

type PauliXGate struct {
	Gate
}

func (PauliXGate) Example added in v0.0.5

func (g PauliXGate) Example() string

func (PauliXGate) FullName added in v0.0.5

func (g PauliXGate) FullName() string

func (PauliXGate) WiresNeeded

func (g PauliXGate) WiresNeeded() int

type PauliYGate

type PauliYGate struct {
	Gate
}

func (PauliYGate) Example added in v0.0.5

func (g PauliYGate) Example() string

func (PauliYGate) FullName added in v0.0.5

func (g PauliYGate) FullName() string

func (PauliYGate) WiresNeeded

func (g PauliYGate) WiresNeeded() int

type PauliZGate

type PauliZGate struct {
	Gate
}

func (PauliZGate) Example added in v0.0.5

func (g PauliZGate) Example() string

func (PauliZGate) FullName added in v0.0.5

func (g PauliZGate) FullName() string

func (PauliZGate) WiresNeeded

func (g PauliZGate) WiresNeeded() int

type PhaseGate

type PhaseGate struct {
	Gate
}

func (PhaseGate) Example added in v0.0.5

func (g PhaseGate) Example() string

func (PhaseGate) FullName added in v0.0.5

func (g PhaseGate) FullName() string

func (PhaseGate) WiresNeeded

func (g PhaseGate) WiresNeeded() int

type Result

type Result struct {
	StateVector         map[string]complex128
	StateVectorSymbolic map[string]string
	Probabilities       map[string]float64
}

type RxGate added in v0.0.5

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

func (RxGate) Example added in v0.0.5

func (g RxGate) Example() string

func (RxGate) FullName added in v0.0.5

func (g RxGate) FullName() string

func (RxGate) Name added in v0.0.5

func (g RxGate) Name() string

func (RxGate) WiresNeeded added in v0.0.5

func (g RxGate) WiresNeeded() int

type RyGate added in v0.0.5

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

func (RyGate) Example added in v0.0.5

func (g RyGate) Example() string

func (RyGate) FullName added in v0.0.5

func (g RyGate) FullName() string

func (RyGate) Name added in v0.0.5

func (g RyGate) Name() string

func (RyGate) WiresNeeded added in v0.0.5

func (g RyGate) WiresNeeded() int

type RzGate added in v0.0.5

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

func (RzGate) Example added in v0.0.5

func (g RzGate) Example() string

func (RzGate) FullName added in v0.0.5

func (g RzGate) FullName() string

func (RzGate) Name added in v0.0.5

func (g RzGate) Name() string

func (RzGate) WiresNeeded added in v0.0.5

func (g RzGate) WiresNeeded() int

type SGate

type SGate struct {
	Gate
}

func (SGate) Example added in v0.0.5

func (g SGate) Example() string

func (SGate) FullName added in v0.0.5

func (g SGate) FullName() string

func (SGate) WiresNeeded

func (g SGate) WiresNeeded() int

type SWAPGate

type SWAPGate struct {
	Gate
}

func (SWAPGate) Example added in v0.0.5

func (g SWAPGate) Example() string

func (SWAPGate) FullName added in v0.0.5

func (g SWAPGate) FullName() string

func (SWAPGate) WiresNeeded

func (g SWAPGate) WiresNeeded() int

type TGate

type TGate struct {
	Gate
}

func (TGate) Example added in v0.0.5

func (g TGate) Example() string

func (TGate) FullName added in v0.0.5

func (g TGate) FullName() string

func (TGate) WiresNeeded

func (g TGate) WiresNeeded() int

type ToffoliGate

type ToffoliGate struct {
	Gate
}

func (ToffoliGate) Example added in v0.0.5

func (g ToffoliGate) Example() string

func (ToffoliGate) FullName added in v0.0.5

func (g ToffoliGate) FullName() string

func (ToffoliGate) WiresNeeded

func (g ToffoliGate) WiresNeeded() int

Jump to

Keyboard shortcuts

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