hamiltonian Module
The pyqpanda3.hamiltonian module provides classes for constructing, manipulating, and analyzing Pauli operators and Hamiltonians. These are the fundamental building blocks for defining quantum observables, problem Hamiltonians in variational algorithms (VQE, QAOA), and quantum simulation tasks.
Overview
A Hamiltonian in quantum mechanics is an operator that describes the total energy of a quantum system. In the context of quantum computing, Hamiltonians are commonly expressed as linear combinations of Pauli operators acting on qubits:
where each
The module exposes four main classes:
- PauliOperator -- A multi-term sum of Pauli strings with coefficients. Supports full arithmetic algebra (
+,-,*,@), tensor product via.tensor(), string serialization, matrix conversion, and commuting-term grouping. - PauliTerm -- A single term in a Pauli operator, consisting of a Pauli string and a coefficient. Provides access to the individual Pauli-with-qubit pairs and quantum circuit conversion.
- PauliWithQbit -- A Pauli matrix (
, , , ) associated with a specific qubit index. The smallest unit of a Pauli term. - Hamiltonian -- A higher-level wrapper around
PauliOperatorwith the same algebraic interface and additional convenience methods.
Class Hierarchy
Sub-topics
| Topic | Description |
|---|---|
| PauliOperator | Multi-term Pauli operator with full arithmetic algebra |
| PauliTerm | Single Pauli term with coefficient |
| PauliWithQbit | Pauli matrix bound to a qubit index |
| Hamiltonian | High-level Hamiltonian wrapper |