tensorcircuit.templates.conversions#
helper functions for conversions
- tensorcircuit.templates.conversions.QUBO_to_Ising(Q: Any) Tuple[Any, List[float], float] [source]#
Cnvert the Q matrix into a the indication of pauli terms, the corresponding weights, and the offset. The outputs are used to construct an Ising Hamiltonian for QAOA.
- Parameters
Q – The n-by-n square and symmetric Q-matrix.
- Return pauli_terms
A list of 0/1 series, where each element represents a Pauli term.
A value of 1 indicates the presence of a Pauli-Z operator, while a value of 0 indicates its absence. :return weights: A list of weights corresponding to each Pauli term. :return offset: A float representing the offset term of the Ising Hamiltonian.
- tensorcircuit.templates.conversions.get_ps(qo: Any, n: int) Tuple[Any, Any] [source]#
Get Pauli string array and weights array for a qubit Hamiltonian as a sum of Pauli strings defined in openfermion
QubitOperator
.- Parameters
qo (
openfermion.ops.operators.qubit_operator.QubitOperator
) –openfermion.ops.operators.qubit_operator.QubitOperator
n (int) – The number of qubits
- Returns
Pauli String array and weights array
- Return type
Tuple[Tensor, Tensor]