tensorcircuit.templates.conversions#

helper functions for conversions

tensorcircuit.templates.conversions.QUBO_to_Ising(Q: Any) Tuple[Any, List[float], float][源代码]#

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.

参数

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][源代码]#

Get Pauli string array and weights array for a qubit Hamiltonian as a sum of Pauli strings defined in openfermion QubitOperator.

参数
  • qo (openfermion.ops.operators.qubit_operator.QubitOperator) -- openfermion.ops.operators.qubit_operator.QubitOperator

  • n (int) -- The number of qubits

返回

Pauli String array and weights array

返回类型

Tuple[Tensor, Tensor]