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: Algorithm

Hadamard 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 to qdk), and executes the resulting circuit with the nested circuit_executor.

Parameters:
__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.

type_name()[source]

Return the algorithm type name as hadamard_test.

Return type:

str

name()[source]

Return the name of the Hadamard test algorithm.

Return type:

str

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: Enum

Measurement bases supported by the Hadamard test control qubit.

X = 'X'
Y = 'Y'
class qdk_chemistry.algorithms.hadamard_test.hadamard_test.HadamardTestFactory[source]

Bases: AlgorithmFactory

Factory class for creating Hadamard test generator instances.

__init__()[source]

Initialize the HadamardTestFactory.

algorithm_type_name()[source]

Return the algorithm type name as hadamard_test.

Return type:

str

default_algorithm_name()[source]

Return ‘qdk’ as the default algorithm name.

Return type:

str

qdk_chemistry.algorithms.hadamard_test.hadamard_test.basis_to_qsharp_pauli(basis)[source]

Map a HadamardTestBasis to qsharp.Pauli for Q# interop.

Return type:

Any

Parameters:

basis (HadamardTestBasis)