Algorithm Guide

The SparQ algorithm stack has two layers that mirror each other:

  • C++ layer (SparQ_Algorithm/): production implementations composed from the core operators, rendered per header in the C++ API Reference.

  • Python layer (pysparq.algorithms): pure-Python counterparts used for rapid prototyping and cross-validation, auto-documented in the API tree below.

Each algorithm below lists its Python entry points, the C++ header it replicates, and where to see it running. The line-level correspondence between the two layers is documented in the algorithm porting guide.

Shor’s Factoring

Shor factoring (standard and semiclassical variants) built on modular multiplication.

Quantum Linear Systems (QDA)

Discrete-adiabatic quantum linear-system solvers built on block encoding and state preparation.

Hamiltonian Simulation (CKS)

Hamiltonian simulation via quantum walk / LCU / sparse-matrix oracle, with the CKS experiment as the reference implementation.

  • Python: TOperator, QuantumWalkNSteps in pysparq.algorithms.cks_solver

  • C++: hamiltonian_simulation.h in the algorithm library (the T state-preparation operator and SparseMatrixOracle1 live here); for constant-diagonal tridiagonal matrices the QRAM-free direct-oracle path lives in hamiltonian_simulation_tridiagonal.h (same page), validated at 2^20 dimensions on a single A800 (docs/verification/v1e-cks-direct-oracle-linsolver.md)

  • Related: the quantum-walk dynamic operator example in Dynamic Operator Extension

Block Encoding

Encodes a classical matrix into a larger unitary — the core subroutine of the linear-system and Hamiltonian-simulation algorithms above.

State Preparation

QRAM-based preparation of arbitrary target states from |0⟩.