counting

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: 9 Imported by: 0

Documentation

Overview

Package counting implements Quantum Approximate Counting.

The algorithm combines Grover's search operator with Quantum Phase Estimation to estimate the number of solutions M in a search space of size N = 2^n. The Grover iterate Q has eigenvalues e^{±2iθ} where sin²(θ) = M/N, so QPE on Q yields θ from which M is recovered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// NumQubits is the number of search space qubits.
	NumQubits int
	// Oracle marks the target states.
	Oracle grover.Oracle
	// NumPhaseBits is the number of precision bits for phase estimation.
	NumPhaseBits int
	// Shots is the number of measurement shots. Default: 1024.
	Shots int
}

Config specifies the Quantum Approximate Counting parameters.

type Result

type Result struct {
	// Circuit is the full quantum circuit used.
	Circuit *ir.Circuit
	// Count is the estimated number of solutions.
	Count float64
	// Phase is the raw phase θ extracted from QPE.
	Phase float64
	// Counts is the measurement histogram.
	Counts map[string]int
}

Result holds the counting output.

func Run

func Run(ctx context.Context, cfg Config) (*Result, error)

Run executes Quantum Approximate Counting.

Jump to

Keyboard shortcuts

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