What problem does it solve?
The Hadamard Test Skill enables efficient estimation of the real and imaginary parts of the expectation ⟨ψ|U|ψ⟩ for a unitary U on a state |ψ⟩, and it also supports measuring overlaps via a swap test. It provides a reusable workflow for quantum algorithm debugging, verification, and phase information extraction.
Core Features & Use Cases
- Three modes: 'expectation' (real/imag parts), 'swap_test' (overlap), and 'phase_estimation' (complex eigenphase).
- Optional imaginary component extraction via S† on the ancilla, and support for preparing arbitrary target states.
- Flexible backend simulation with shot-based noise and optional circuit diagram export for visualization.
- Works with a GateSequence representation and a HadamardTestAlgorithm runner to integrate into larger quantum workflows.
- Educational and prototyping friendly, suitable for learning, experimentation, and algorithm development.
Quick Start
Instantiate U and prepare_psi, then run HadamardTestAlgorithm with mode set to 'expectation' to obtain the Re/Im estimates.