qlauncher.hampy.object#
Summary#
Classes:
Reference#
- class qlauncher.hampy.object.Equation(size: int, /)[source]#
- class qlauncher.hampy.object.Equation(hamiltonian: SparsePauliOp, /)
- class qlauncher.hampy.object.Equation(sparse_list: list[tuple], size: int, /)
Bases:
object## Hampy Equation Represents a binary or general-purpose Hamiltonian equation built on
qiskit.quantum_info.SparsePauliOp. The class provides logical-style operators (AND, OR, XOR, NOT) interpreted as operations on Hamiltonians with binary energies {0, 1}, along with basic arithmetic operations and utilities for analyzing the resulting operator.Examples#
Create an empty equation of size 3: >>> eq = Equation(3) >>> eq.hamiltonian SparsePauliOp([‘III’], coeffs=[0.])
Create from a SparsePauliOp: >>> from qiskit.quantum_info import SparsePauliOp >>> H = SparsePauliOp.from_sparse_list([(‘Z’, [0], 1.0)], 1) >>> eq = Equation(H) >>> eq.get_order() 1
Use variables and logical operators: >>> eq = Equation(2) >>> x0 = eq[0] >>> x1 = eq[1]
XOR: >>> h_xor = x0 ^ x1 >>> h_xor.hamiltonian SparsePauliOp([…])
OR: >>> h_or = x0 | x1
AND: >>> h_and = x0 & x1
Negation: >>> h_not = ~x0
Combine equations arithmetically: >>> h_sum = (x0 ^ x1) + (x0 & x1) >>> h_scaled = 2.0 * h_sum >>> h_divided = h_sum / 3
Export back to SparsePauliOp: >>> H = h_sum.hamiltonian
- property hamiltonian: SparsePauliOp#