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 @ stateto 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 @ Hto 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 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.
- Returns:
- w:
Array of k eigenvalues.
- v:
An array of k eigenvectors.
v[:, i]is the eigenvector corresponding to the eigenvaluew[i].
- apply_diag(fock_states: ndarray) ndarray#
Apply the diagonal elements of the operator
- Parameters:
fock_states – A batch of fock states \(\left| x_i \right>\) with elements \(\pm 1\) that the operator acts on
- Returns:
A 1D array \(H_z\) with \(H_{z,i} = \left< x_i | H | x_i \right>\)
- apply_off_diag(fock_states: ndarray, return_basis_ints: bool = False) Tuple[ndarray, ndarray, ndarray]#
Apply the non-zero non-diagonal elements of the operator. Every input fock state \(\left| x_i \right>\) is mapped to multiple output fock states \(\left| x'_j \right>\).
- Parameters:
fock_states – A 2D array as a batch of input fock states \(\left| x_i \right>\) with elements \(\pm 1\)
return_basis_ints – Whether to return the connected states \(\left| x'_j \right>\) as basis integers or fock states, default to fock states.
- Returns:
- segment:
A 1D array showing how \(\left| x'_j \right>\) is connected to \(\left| x_i \right>\). The j’th element of this array is i.
- s_conn:
An array as a batch of connected states \(\left| x'_j \right>\)
- H_conn:
A 1D array \(H_c\) with \(H_{c,j} = \left< x'_j | H | x_i \right>\)
- 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.Statefor 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