# pmm_tools.utils

*module*

## pmm_tools.utils.evaluate_hamiltonian

*function*

```python
def evaluate_hamiltonian(params, terms, sparse)
```

Compute the Hamiltonian from `terms` for a set of parameters

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/utils.py#L6-L23)

## pmm_tools.utils.fermionic_eigsh

*function*

```python
def fermionic_eigsh(hamiltonian, parity, k=6)
```

Diagonalize a Hamiltonian using fermionic superselection rules.
The Hamiltonian is assumed to be block-diagonal in the parity
subspaces. The function returns the eigenvalues and eigenvectors
of the Hamiltonian, sorted by increasing energy.

**Parameters**

- `hamiltonian` (`scipy.sparse.csr_matrix`) — The Hamiltonian matrix to be diagonalized.
- `parity` (`scipy.sparse.csr_matrix`) — The parity operator matrix, which is assumed to be diagonal in the same basis as the Hamiltonian.
- `k` (`int`) (default: `6`) — The number of eigenvalues and eigenvectors to compute. Default is 6.

**Returns**

- `evals` (`list of numpy.ndarray`) — The eigenvalues of the Hamiltonian separated in parity subspaces.
- `evecs` (`list of numpy.ndarray`) — The eigenvectors of the Hamiltonian separated in parity subspaces.

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/utils.py#L26-L75)
