# pmm_tools.partial_trace

*module*

## pmm_tools.partial_trace.compute_basis

*function*

```python
def compute_basis(fermions)
```

Compute the basis of the fermionic operators in the Hilbert space.

**Parameters**

- `fermions` (`list`) — List of FermionOp objects representing the fermionic operators.

**Returns**

- `symbolic_list` (`list`) — List of products of fermionic operators corresponding to the basis states.

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/partial_trace.py#L132-L158)

## pmm_tools.partial_trace.reduced_operator

*function*

```python
def reduced_operator(state_e, state_o, subspace, complement, prefactor=sympy.S.One)
```

Compute the operator defined as the outer product of state_e and state_o.
The reduced operator has support only over the complement of the subspace.

**Parameters**

- `state_e` (`sympy.Expression`) — Even ground state.
- `state_o` (`sympy.Expression`) — Odd ground state.
- `subspace` (`list`) — List of fermionic operators in the subspace.
- `complement` (`list`) — List of fermionic operators in the complement of the subspace.

**Returns**

- `operator` (`sympy.Expression`) — Outer product as fermionic operator.

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/partial_trace.py#L47-L96)

## pmm_tools.partial_trace.remove_terms

*function*

```python
def remove_terms(expr, subspace)
```

Remove the terms in the expression that have support over the subspace.

**Parameters**

- `expr` (`sympy.Expression`) — The expression to be modified.
- `subspace` (`list`) — List of fermionic operators in the subspace.

**Returns**

- `expr` (`sympy.Expression`) — The modified expression.

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/partial_trace.py#L99-L129)

## pmm_tools.partial_trace.separate_subspace

*function*

```python
def separate_subspace(state, subspace)
```

Separate the operators in the state into two lists: one for the subspace
and one for the complement of the subspace.

**Parameters**

- `state` (`sympy.Expression`) — The state to be separated.
- `subspace` (`list`) — List of fermionic operators in the subspace.

**Returns**

- `ops_subspace` (`sympy.Expression`) — Terms in the subspace.
- `ops_complement` (`sympy.Expression`) — Terms in the complement of the subspace.

[View source](https://gitlab.kwant-project.org/qt/pmm_tools/-/blob/e412d66507a554f455ef935b755fc39f28ab4e05/pmm_tools/partial_trace.py#L10-L44)
