observe¶
Compute the expectation value of an observable for a given state.
observe
¶
observe(
state: Union[MPS, MPO, Sequence[Tensor]],
observable: Union[MPO, Sequence[Tensor]],
) -> float
Compute the expectation value of an observable for a given state.
Dispatches to the appropriate contraction routine based on the type of
state:
MPS(or a plain sequence of tensors): evaluates ⟨ψ|O|ψ⟩ via a left-to-right MPS-MPO-MPS transfer-matrix sweep.MPO(thermal density matrix): not yet implemented.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Union[MPS, MPO, Sequence[Tensor]]
|
The state to evaluate. Either an |
required |
observable
|
Union[MPO, Sequence[Tensor]]
|
The observable encoded as an |
required |
Returns:
| Type | Description |
|---|---|
float
|
The expectation value of the observable. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
NotImplementedError
|
If |
Notes¶
observe performs a left-to-right MPS–MPO–MPS transfer-matrix sweep. At each site it contracts the bra (conjugated MPS tensor), the MPO tensor, and the ket (MPS tensor) into an updated environment. The final environment is a 1×1×1 tensor; the scalar value — corrected for SU(2) Bridge normalization — is returned.
See Also¶
- MPS, MPO — input types.
- build_hamiltonian — create the MPO to pass here.
- dmrg.run — uses
observeinternally for energy evaluation.