param

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package param provides symbolic parameters and expressions for parameterized quantum circuits.

A Parameter represents a named symbolic value; related parameters can be grouped in a Vector. Parameters are combined into an Expr tree using Literal, Add, Sub, Mul, Div, and Neg.

Symbolic gate constructors (SymRX, SymRY, SymRZ, SymPhase, SymU3, SymCP) accept Expr arguments instead of float64 values. Before simulation, bind all free parameters to concrete values with [ir.Bind].

Package param provides symbolic parameters and expressions for variational circuits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SymCP

func SymCP(phi Expr) gate.Gate

SymCP creates a symbolic controlled-phase gate.

func SymFSim added in v1.2.0

func SymFSim(theta, phi Expr) gate.Gate

SymFSim creates a symbolic FSim gate.

func SymGlobalPhase added in v1.2.0

func SymGlobalPhase(phi Expr) gate.Gate

SymGlobalPhase creates a symbolic GlobalPhase gate.

func SymPSwap added in v1.2.0

func SymPSwap(phi Expr) gate.Gate

SymPSwap creates a symbolic PSwap gate.

func SymPhase

func SymPhase(phi Expr) gate.Gate

SymPhase creates a symbolic Phase gate.

func SymRX

func SymRX(theta Expr) gate.Gate

SymRX creates a symbolic RX gate.

func SymRXX

func SymRXX(theta Expr) gate.Gate

SymRXX creates a symbolic Ising XX gate.

func SymRY

func SymRY(theta Expr) gate.Gate

SymRY creates a symbolic RY gate.

func SymRYY

func SymRYY(theta Expr) gate.Gate

SymRYY creates a symbolic Ising YY gate.

func SymRZ

func SymRZ(theta Expr) gate.Gate

SymRZ creates a symbolic RZ gate.

func SymRZZ

func SymRZZ(theta Expr) gate.Gate

SymRZZ creates a symbolic Ising ZZ gate.

func SymRot added in v1.2.0

func SymRot(phi, theta, omega Expr) gate.Gate

SymRot creates a symbolic Rot gate.

func SymU1 added in v1.2.0

func SymU1(lambda Expr) gate.Gate

SymU1 creates a symbolic U1 gate.

func SymU2 added in v1.2.0

func SymU2(phi, lambda Expr) gate.Gate

SymU2 creates a symbolic U2 gate.

func SymU3

func SymU3(theta, phi, lambda Expr) gate.Gate

SymU3 creates a symbolic U3 gate.

Types

type Expr

type Expr interface {
	// Eval evaluates the expression with the given bindings.
	// Returns an error if any required parameter is unbound.
	Eval(bindings map[string]float64) (float64, error)

	// Parameters returns all free parameters in the expression.
	Parameters() []*Parameter

	// String returns a human-readable representation.
	String() string

	// IsNumeric returns true if this expression has no free parameters.
	IsNumeric() bool
}

Expr represents a symbolic expression over parameters.

func Add

func Add(a, b Expr) Expr

Add returns a + b.

func Div

func Div(a, b Expr) Expr

Div returns a / b.

func Literal

func Literal(v float64) Expr

Literal creates a constant numeric expression.

func Mul

func Mul(a, b Expr) Expr

Mul returns a * b.

func Neg

func Neg(a Expr) Expr

Neg returns -a.

func Sub

func Sub(a, b Expr) Expr

Sub returns a - b.

type Parameter

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

Parameter is a named symbolic parameter.

func New

func New(name string) *Parameter

New creates a standalone Parameter.

func (*Parameter) Expr

func (p *Parameter) Expr() Expr

Expr returns this parameter as an expression.

func (*Parameter) Name

func (p *Parameter) Name() string

Name returns the parameter name.

type Vector

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

Vector is a named collection of related parameters.

func NewVector

func NewVector(name string, size int) *Vector

NewVector creates a parameter vector of the given size.

func (*Vector) At

func (v *Vector) At(i int) *Parameter

At returns the i-th parameter.

func (*Vector) Name

func (v *Vector) Name() string

Name returns the vector name.

func (*Vector) Size

func (v *Vector) Size() int

Size returns the number of parameters.

Jump to

Keyboard shortcuts

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