ansatz

package
v1.2.1 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 ansatz provides parameterized circuit templates for variational algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ansatz

type Ansatz interface {
	// Circuit returns the parameterized circuit.
	Circuit() (*ir.Circuit, error)
	// NumParams returns the number of free parameters.
	NumParams() int
	// ParamVector returns the parameter vector used by the circuit.
	ParamVector() *param.Vector
}

Ansatz is a parameterized quantum circuit template.

type BasicEntanglerLayers

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

BasicEntanglerLayers is an ansatz with single-parameter rotation layers and a CNOT ring entanglement pattern. Each layer applies RX(theta) on every qubit followed by a circular CNOT entangling layer. The circuit has numQubits*layers parameters.

func NewBasicEntanglerLayers

func NewBasicEntanglerLayers(numQubits, layers int) *BasicEntanglerLayers

NewBasicEntanglerLayers creates a BasicEntanglerLayers ansatz.

func (*BasicEntanglerLayers) Circuit

func (be *BasicEntanglerLayers) Circuit() (*ir.Circuit, error)

func (*BasicEntanglerLayers) NumParams

func (be *BasicEntanglerLayers) NumParams() int

func (*BasicEntanglerLayers) ParamVector

func (be *BasicEntanglerLayers) ParamVector() *param.Vector

type EfficientSU2

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

EfficientSU2 is an ansatz with RY+RZ rotation layers and CNOT entanglement. The circuit has 2*numQubits*(reps+1) parameters.

func NewEfficientSU2

func NewEfficientSU2(numQubits, reps int, ent Entanglement) *EfficientSU2

NewEfficientSU2 creates an EfficientSU2 ansatz.

func (*EfficientSU2) Circuit

func (es *EfficientSU2) Circuit() (*ir.Circuit, error)

func (*EfficientSU2) NumParams

func (es *EfficientSU2) NumParams() int

func (*EfficientSU2) ParamVector

func (es *EfficientSU2) ParamVector() *param.Vector

type Entanglement

type Entanglement int

Entanglement describes the entangling layer pattern.

const (
	// Linear applies CNOT between adjacent qubits: (0,1), (1,2), ...
	Linear Entanglement = iota
	// Full applies CNOT between all pairs.
	Full
	// Circular extends Linear with an additional (n-1, 0) CNOT.
	Circular
)

type RealAmplitudes

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

RealAmplitudes is an ansatz with RY rotation layers and CNOT entanglement. The circuit has numQubits*(reps+1) parameters.

func NewRealAmplitudes

func NewRealAmplitudes(numQubits, reps int, ent Entanglement) *RealAmplitudes

NewRealAmplitudes creates a RealAmplitudes ansatz.

func (*RealAmplitudes) Circuit

func (ra *RealAmplitudes) Circuit() (*ir.Circuit, error)

func (*RealAmplitudes) NumParams

func (ra *RealAmplitudes) NumParams() int

func (*RealAmplitudes) ParamVector

func (ra *RealAmplitudes) ParamVector() *param.Vector

type StronglyEntanglingLayers

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

StronglyEntanglingLayers is an ansatz with Rot(phi, theta, omega) rotation layers and a shifted CNOT entanglement pattern. Each layer uses 3 parameters per qubit and a CNOT offset that cycles through 1, 2, ..., numQubits-1. The circuit has 3*numQubits*layers parameters.

func NewStronglyEntanglingLayers

func NewStronglyEntanglingLayers(numQubits, layers int) *StronglyEntanglingLayers

NewStronglyEntanglingLayers creates a StronglyEntanglingLayers ansatz.

func (*StronglyEntanglingLayers) Circuit

func (s *StronglyEntanglingLayers) Circuit() (*ir.Circuit, error)

func (*StronglyEntanglingLayers) NumParams

func (s *StronglyEntanglingLayers) NumParams() int

func (*StronglyEntanglingLayers) ParamVector

func (s *StronglyEntanglingLayers) ParamVector() *param.Vector

type UCCSD

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

UCCSD is a Unitary Coupled-Cluster Singles and Doubles ansatz for quantum chemistry. It implements the Jordan-Wigner-mapped UCCSD circuit, consisting of a Hartree-Fock reference state followed by fermionic single and double excitation operators.

The parameter vector is ordered as [singles..., doubles...], but the circuit applies doubles before singles (matching PennyLane's convention).

func NewUCCSD

func NewUCCSD(numQubits, numElectrons int) *UCCSD

NewUCCSD creates a UCCSD ansatz for the given number of spin-orbitals (qubits) and electrons.

func (*UCCSD) Circuit

func (u *UCCSD) Circuit() (*ir.Circuit, error)

func (*UCCSD) NumParams

func (u *UCCSD) NumParams() int

func (*UCCSD) ParamVector

func (u *UCCSD) ParamVector() *param.Vector

Jump to

Keyboard shortcuts

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