qdk_chemistry.algorithms.hadamard_test.hadamard_test module
QDK/Chemistry Hadamard test circuit generator abstractions and utilities.
- class qdk_chemistry.algorithms.hadamard_test.hadamard_test.HadamardTest(test_basis=HadamardTestBasis.X, circuit_executor=None, controlled_circuit_mapper=None)[source]
Bases:
AlgorithmHadamard test generator.
Orchestrates the backend-agnostic Hadamard test workflow: it validates the inputs, delegates circuit construction (including mapping the target unitary into a controlled evolution circuit) to
hadamard_test_circuit_builder(currently fixed toqdk), and executes the resulting circuit with the nestedcircuit_executor.- Parameters:
test_basis (HadamardTestBasis)
circuit_executor (AlgorithmRef | None)
controlled_circuit_mapper (AlgorithmRef | None)
- __init__(test_basis=HadamardTestBasis.X, circuit_executor=None, controlled_circuit_mapper=None)[source]
Initialize a Hadamard test generator.
- Parameters:
test_basis (HadamardTestBasis) – Measurement basis for the control qubit.
circuit_executor (AlgorithmRef | None) – Optional algorithm reference for circuit execution.
controlled_circuit_mapper (AlgorithmRef | None) – Optional algorithm reference for controlled circuit mapping.
- run(*args, **kwargs)
Run the algorithm with the provided arguments.
This method wraps the internal _run_impl method to provide a consistent interface for executing the algorithm.
- Parameters:
args – The arguments required to run the algorithm.
kwargs – The keyword arguments required to run the algorithm.
- Returns:
The results of the algorithm
- Return type:
Any
- class qdk_chemistry.algorithms.hadamard_test.hadamard_test.HadamardTestBasis(*values)[source]
Bases:
EnumMeasurement bases supported by the Hadamard test control qubit.
- X = 'X'
- Y = 'Y'
- class qdk_chemistry.algorithms.hadamard_test.hadamard_test.HadamardTestFactory[source]
Bases:
AlgorithmFactoryFactory class for creating Hadamard test generator instances.
- qdk_chemistry.algorithms.hadamard_test.hadamard_test.basis_to_qsharp_pauli(basis)[source]
Map a
HadamardTestBasistoqsharp.Paulifor Q# interop.- Return type:
- Parameters:
basis (HadamardTestBasis)