MPO¶
Matrix product operator.
MPO
¶
MPO(
tensors: List[Tensor],
bc: str = "OBC",
center: Optional[int] = None,
itag_prefix: Optional[str] = None,
)
Bases: Network
Matrix product operator.
Each site tensor has axes
(left_bond, right_bond, phys_in, phys_out) where:
phys_in(ket, axis 2) andphys_out(bra, axis 3) both carry itags{i:02d}at site i, differentiated by opposite directions.- Contracting an MPS ket (
s{i:02d}, IN) against this MPO is automatic: the MPO bra (s{i:02d}, OUT) pairs with the MPS ket.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensors
|
List[Tensor]
|
List of site tensors, each with exactly 4 axes
|
required |
bc
|
str
|
Boundary condition: |
'OBC'
|
center
|
Optional[int]
|
Orthogonality center site index, or |
None
|
itag_prefix
|
Optional[str]
|
Bond itag prefix string. Defaults to |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If any tensor has the wrong axis count, incorrect physical itags, physical axes with the same direction, or adjacent bond indices are inconsistent. |
Functions¶
compact
¶
Compress the MPO bond dimensions in-place with norm preservation.
Performs a two-sweep canonicalization:
- Left-to-right sweep without truncation, moving the orthogonality center to the rightmost site. This concentrates the full operator norm into the center tensor.
- Normalize the center tensor to unit Frobenius norm, temporarily factoring out the overall scale.
- Right-to-left sweep with SVD truncation (controlled by
trunc), moving the center to site 0. Because the environment is unit-normed, the truncation threshold is applied on a consistent scale. - Restore the overall scale into the new center tensor, then call
redistribute_norm()to spread it evenly across all sites.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trunc
|
Optional[dict]
|
Truncation options forwarded to |
None
|
redistribute_norm
¶
Redistribute the MPO norm equally across all site tensors.
Computes the total Frobenius norm N, multiplies every site tensor by
factor = N^(1/L), then divides the center tensor by N to remove the
excess. The product of all scale factors is factor^L / N = 1, so
the operator and its total norm are preserved. center is reset to
None because the per-site rescaling breaks any prior canonical form.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If the MPO norm is numerically zero (e.g. due to norm decay). |
String Representation¶
repr(mpo) (and therefore the interactive display in notebooks and REPLs) renders
a text diagram of the chain:
Matrix Product Operator (MPO)
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷
□───□───□───□─···─⊡─···─□───□───□───□
╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵ ╵
length: 100 max bond: 64
center: 49 norm: 1.00e+00
Chain row — each node is one site; consecutive sites are joined by ───.
When the chain is too long to show in full, a gap ─···─ is inserted and only
a subset of sites near the edges and center is displayed.
Physical-index rows — the downward stub ╵ beneath each node is the
physical-input (ket) index; the upward stub ╷ above is the physical-output
(bra) index.
Node symbols:
| Symbol | Meaning |
|---|---|
□ |
Regular site |
⊡ |
Orthogonality center (center attribute) |
Info block — length is the number of sites L; max bond is the largest
bond dimension across all virtual indices; center is the orthogonality center
index (None if not set); norm is ‖O‖.
See Also¶
- Network — base class providing
canonical(),norm(),serialize(), and more. - MPS — matrix product state.
- build_hamiltonian — creates an MPO from a list of interactions.
- observe — use this MPO as an observable.