shor

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

Documentation

Overview

Package shor implements Shor's quantum factoring algorithm.

Given a composite integer N, the algorithm finds a non-trivial factor by using quantum phase estimation to determine the period of modular exponentiation. For small N (suitable for simulation), it builds the full order-finding circuit and extracts factors classically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// N is the number to factor.
	N int
	// NumPhaseBits is the precision bits for phase estimation.
	// 0 means auto: 2*ceil(log2(N)).
	NumPhaseBits int
	// Shots is the number of measurement shots. Default: 1024.
	Shots int
	// MaxAttempts is the maximum number of random base attempts. Default: 10.
	MaxAttempts int
}

Config specifies the Shor factoring parameters.

type Result

type Result struct {
	Factors  [2]int
	Period   int
	Base     int
	Attempts int
	Circuit  *ir.Circuit
}

Result holds the factoring output.

func Run

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

Run executes Shor's factoring algorithm.

Jump to

Keyboard shortcuts

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