Utilities¶
Helpers the state factories are built from.
ketbra(a, b) is the outer product \(|a\rangle\langle b|\), defaulting to
\(|a\rangle\langle a|\).
upb(basis) turns an unextendible product basis \(\{|v_i\rangle\}_{i=1}^{k}\) in
total dimension \(D\) into the bound entangled state on its orthogonal
complement,
Each \(|v_i\rangle\langle v_i|\) is a product-state projector, which partial transposition leaves a product-state projector, so \(\rho\) is PPT; the basis being unextendible means no product vector lies in the range of \(\rho\), so by the range criterion it is entangled. Every UPB state in the library — Tiles, Pyramid, Parametrized, GenTiles1 and GenTiles2 — goes through it.
The rest are the small linear-algebra pieces the constructions need, written
on plain NumPy so the package does not depend on a quantum-information toolbox:
tensor, max_entangled, pauli, fourier, permute_systems, and
partial_transpose with is_ppt for the PPT test, plus
random_density_matrix for the random states. The test suite checks each of
them entrywise against toqito.
References¶
- Charles H. Bennett, David P. DiVincenzo, Tal Mor, Peter W. Shor, John A. Smolin and Barbara M. Terhal, "Unextendible product bases and bound entanglement", Phys. Rev. Lett. 82, 5385–5388 (1999). arXiv:quant-ph/9808030 · doi:10.1103/PhysRevLett.82.5385
ketbra ¶
The outer product |a><b|.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
ndarray
|
the "ket" vector. |
required |
b
|
ndarray | None
|
the "bra" vector (its complex conjugate is used). |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
the rank-1 operator |a><b|. |
Source code in src/bound_entangled/utils/ketbra.py
upb ¶
Bound entangled state built from an unextendible product basis (UPB).
The uniform mixture over the orthogonal complement of a UPB is PPT (each |v_i><v_i| being a product-state projector, partial transposition leaves it unchanged) yet has no product vector in its range, hence is entangled: a bound entangled state.
Reference: C. H. Bennett, D. P. DiVincenzo, T. Mor, P. W. Shor, J. A. Smolin, B. M. Terhal, "Unextendible Product Bases and Bound Entanglement", Phys. Rev. Lett. 82, 5385 (1999), https://arxiv.org/abs/quant-ph/9808030
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis
|
list[ndarray]
|
the product vectors (as column vectors) forming the UPB. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
the corresponding bound entangled density matrix. |
Examples:
>>> from toqito.matrix_props import is_density
>>> from toqito.state_props import is_ppt, is_separable
>>> from bound_entangled.c3_otimes_c3.upb.pyramid_UPB import pyramid_basis
>>> state = upb(pyramid_basis())
>>> is_density(state)
True
>>> is_ppt(state, dim=[3, 3])
True
>>> sep, _ = is_separable(state, dim=[3, 3])
>>> sep
False
Every basis vector lies in the kernel, the defining property of the construction:
Source code in src/bound_entangled/utils/upb.py
tensor ¶
The tensor (Kronecker) product of the given vectors or matrices, left to right.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*arrays
|
ndarray
|
the factors, in order. |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
Examples:
Source code in src/bound_entangled/utils/tensor.py
max_entangled ¶
The maximally entangled state (1/sqrt(d)) sum_i |ii> of C^d ⊗ C^d.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
the local dimension d. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
the normalized state as a (d², 1) column vector. |
Examples:
Source code in src/bound_entangled/utils/max_entangled.py
pauli ¶
A Pauli matrix, or a tensor product of them.
Indices follow 0 = I, 1 = X, 2 = Y, 3 = Z.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ind
|
int | list[int]
|
one index, or a list of indices for the product sigma_{ind[0]} ⊗ sigma_{ind[1]} ⊗ ... |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
the 2x2 Pauli matrix, or the 2^n x 2^n product. |
Examples:
Source code in src/bound_entangled/utils/pauli.py
fourier ¶
The d x d discrete Fourier transform matrix, with entries omega^(jk) / sqrt(d).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
the dimension d, with omega = exp(2 pi i / d). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
the unitary Fourier matrix. |
Examples:
Source code in src/bound_entangled/utils/fourier.py
permute_systems ¶
Reorder the subsystems of an operator on C^dim[0] ⊗ C^dim[1] ⊗ ...
Subsystem i of the result is subsystem perm[i] of mat, so
perm = [0, 2, 1, 3] turns an ABA'B' ordering into AA'BB'.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mat
|
ndarray
|
a square matrix on the tensor product of the subsystems. |
required |
perm
|
list[int]
|
the new order of the subsystems. |
required |
dim
|
list[int]
|
the dimension of each subsystem, in the current order. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
the matrix with its subsystems reordered. |
Examples:
Swapping the two factors of a product operator swaps the factors:
>>> import numpy as np
>>> a, b = np.diag([1.0, 2.0]), np.diag([1.0, 3.0, 5.0])
>>> bool(np.allclose(permute_systems(np.kron(a, b), [1, 0], [2, 3]), np.kron(b, a)))
True
Source code in src/bound_entangled/utils/permute_systems.py
partial_transpose ¶
The partial transpose of an operator on C^dim[0] ⊗ C^dim[1] over the second system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mat
|
ndarray
|
a square matrix on C^dim[0] ⊗ C^dim[1]. |
required |
dim
|
list[int]
|
the two local dimensions [d_A, d_B]. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
(1 ⊗ T)(mat). |
Examples:
The partial transpose of the projector onto the two-qubit maximally entangled state is half the swap operator:
>>> import numpy as np
>>> phi = np.array([1, 0, 0, 1]) / np.sqrt(2)
>>> np.rint(partial_transpose(np.outer(phi, phi), [2, 2]) * 2).astype(int)
array([[1, 0, 0, 0],
[0, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 0, 1]])
Source code in src/bound_entangled/utils/partial_transpose.py
is_ppt ¶
Whether a bipartite operator has a positive partial transpose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mat
|
ndarray
|
a square matrix on C^dim[0] ⊗ C^dim[1]. |
required |
dim
|
list[int]
|
the two local dimensions [d_A, d_B]. |
required |
tol
|
float | None
|
eigenvalues down to -tol count as non-negative. Defaults to the square root of machine epsilon. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if every eigenvalue of the partial transpose is >= -tol. |
Examples:
>>> import numpy as np
>>> phi = np.array([1, 0, 0, 1]) / np.sqrt(2)
>>> is_ppt(np.outer(phi, phi), [2, 2])
False
>>> is_ppt(np.identity(4) / 4, [2, 2])
True
Source code in src/bound_entangled/utils/partial_transpose.py
random_density_matrix ¶
A random density matrix drawn from the Hilbert-Schmidt measure.
Draws a complex Ginibre matrix G with standard normal entries and returns G G^dagger / tr(G G^dagger).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dim
|
int
|
the dimension of the density matrix. |
required |
seed
|
int | None
|
seed for the random number generator, for reproducible draws. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
a dim x dim density matrix. |
Examples:
>>> import numpy as np
>>> rho = random_density_matrix(4, seed=0)
>>> bool(np.isclose(np.trace(rho).real, 1)), bool(np.linalg.eigvalsh(rho).min() >= 0)
(True, True)