quantax.operator.Operator#
- class quantax.operator.Operator#
Quantum operator
- __init__(op_list: list)#
- Parameters:
op_list –
The operator represented as a list in the QuSpin format
[[opstr1, [strength1, index11, index12, ...]], [opstr2, [strength2, index21, index22, ...]], ...]
- __matmul__(state: State) DenseState #
Apply the operator on a ket state by
H @ state
to get \(H \left| \psi \right>\). The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed bystate @ H @ state
.
- __rmatmul__(state: State) DenseState #
Apply the operator on a bra state by
state @ H
to get \(\left< \psi \right| H\). The exact expectation value \(\left<\psi|H|\psi \right>\) can be computed bystate @ H @ state
.
- property op_list: list#
Operator represented as a list in the QuSpin format
- property jax_op_list: list#
Operator list with jax arrays, made easy for applying operator to fock states
- property expression: str#
The operator as a human-readable expression
- get_quspin_op(symm: Symmetry | None = None) hamiltonian #
Obtain the corresponding QuSpin operator
- Parameters:
symm – The symmetry used for generate the operator basis, by default the basis without symmetry
- todense(symm: Symmetry | None = None) ndarray #
Obtain the dense matrix representing the operator
- Parameters:
symm – The symmetry used for generate the operator basis, by default the basis without symmetry
- diagonalize(symm: Symmetry | None = None, k: int | str = 1) Tuple[ndarray, ndarray] #
Diagonalize the hamiltonian \(H = V D V^†\)
- Parameters:
symm – Symmetry for generating basis.
k – A number specifying how many lowest states to obtain, or “full” for all eigenstates.
- Returns:
- w:
Array of k eigenvalues.
- v:
An array of k eigenvectors.
v[:, i]
is the eigenvector corresponding to the eigenvaluew[i]
.
- Oloc(state: State, samples: Samples | ndarray | Array) Array #
Computes the local operator \(O_\mathrm{loc}(s) = \sum_{s'} \frac{\psi_{s'}}{\psi_s} \left< s|O|s' \right>\)
- Parameters:
state – A
quantax.state.State
for computing \(\psi\)samples – A batch of samples \(s\)
- Returns:
A 1D jax array \(O_\mathrm{loc}(s)\)
- expectation(state: State, samples: Samples | ndarray | Array, return_var: bool = False) float | Tuple[float, float] #
The expectation value of the operator
- Parameters:
state – The state for computing \(\psi\) in \(O_\mathrm{loc}\)
samples – The samples for estimating \(\left< O_\mathrm{loc} \right>\)
return_var – Whether the variance should also be returned, default to False
- Returns:
- Omean:
Mean value of the operator \(\left< O_\mathrm{loc} \right>\)
- Ovar:
Variance of the operator \(\left< |O_\mathrm{loc}|^2 \right> - |\left< O_\mathrm{loc} \right>|^2\), only returned when
return_var = True