A collection of quantum information tools covering density-matrix operations (Python) and optimal catalyst search for pure-state conversion (C++).
partials/
density.py # Partial transpose & partial trace for multi-qubit states
requirements.txt # Python dependencies
optimalCatalyst/
algorithm.cpp # Catalyst optimizer for entanglement-assisted state conversion
- Python 3.10+
- NumPy 2.4.2
pip install -r partials/requirements.txtfrom density import partial_transpose_multi, partial_trace_multiPerforms the partial transpose on subsystem sys (0-based) of a density matrix rho.
| Parameter | Type | Description |
|---|---|---|
rho |
ndarray (D, D) |
Density matrix, where D = prod(dims) |
dims |
tuple[int, ...] |
Dimensions of each subsystem, e.g. (2, 2, 2) for three qubits |
sys |
int |
Index of the subsystem to transpose (0 = first, 1 = second, …) |
# Partial transpose on qubit B of a 2-qubit state
rho_TB = partial_transpose_multi(rho, (2, 2), sys=1)Traces out all subsystems not listed in keep, returning the reduced density matrix on the kept subsystems.
| Parameter | Type | Description |
|---|---|---|
rho |
ndarray (D, D) |
Density matrix |
dims |
tuple[int, ...] |
Dimensions of each subsystem |
keep |
list[int] |
0-based indices of subsystems to keep |
# Trace out qubit C, keep AB
rho_AB = partial_trace_multi(rho, (2, 2, 2), keep=[0, 1])Running density.py directly prints partial transpose and partial trace results for three example states:
python partials/density.py-
Bell state
$|\Phi^+\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$ -
Product state
$|00\rangle\langle 00|$ -
GHZ state
$\frac{1}{\sqrt{2}}(|000\rangle + |111\rangle)$
Implements a randomized search algorithm that finds a catalyst state
A deterministic conversion
- A C++17-compatible compiler (e.g.
g++,clang++, MSVC)
g++ -O2 -std=c++17 -o catalyst optimalCatalyst/algorithm.cppEdit the main() function in optimalCatalyst/algorithm.cpp to set the input Schmidt vectors, then run the compiled binary:
./catalystExample output for
psi -> phi: P=1.0 deterministic=yes catalyst=(...)
phi -> psi: P=0.8 deterministic=no catalyst=(0.5, 0.5)
| Parameter | Default | Description |
|---|---|---|
from_raw |
— | Schmidt coefficients of the source state |
to_raw |
— | Schmidt coefficients of the target state |
m_max |
6 |
Maximum catalyst dimension to search over |
samples_per_m |
50000 |
Number of random catalyst samples per dimension |
local_steps |
2000 |
Local perturbation steps for polishing the best candidate |
seed |
12345 |
RNG seed for reproducibility |
The function returns a Result struct with:
prob— optimal success probability foundcatalyst— best catalyst Schmidt vector (empty if none improves the result)deterministic—trueif exact conversion is achievable