requsim.libs package

requsim.libs.aux_functions module

Functions:

distance(pos1, pos2)

Return the euclidean distance between two positions or world objects.

apply_single_qubit_map(map_func, ...)

Applies a single-qubit map to a density matrix of n qubits.

apply_m_qubit_map(map_func, qubit_indices, ...)

Applies an m-qubit map to a density matrix of n qubits.

requsim.libs.aux_functions.distance(pos1, pos2)

Return the euclidean distance between two positions or world objects.

Parameters
  • pos1 (scalar, np.ndarray or WorldObject) – The first position. If it is a WorldObject must have a position attribute.

  • pos2 (scalar, np.ndarray or WorldObject) – The second position. If it is a WorldObject must have a position attribute.

Returns

scalar – Distance between the world objects.

requsim.libs.aux_functions.apply_single_qubit_map(map_func, qubit_index, rho, *args, **kwargs)

Applies a single-qubit map to a density matrix of n qubits.

Parameters
  • map_func (callable) – The map to apply. Should be a function that takes a single-qubit density matrix as input and applies the map to it.

  • qubit_index (int) – Index of qubit to which the map is applied. 0…n-1

  • rho (np.ndarray) – Density matrix of n qubits. Shape (2**n, 2**n)

  • *args (any, optional) – additional args and kwargs passed to map_func

  • **kwargs (any, optional) – additional args and kwargs passed to map_func

Returns

np.ndarray – The density matrix with the map applied. Shape (2**n, 2**n)

requsim.libs.aux_functions.apply_m_qubit_map(map_func, qubit_indices, rho, *args, **kwargs)

Applies an m-qubit map to a density matrix of n qubits.

Parameters
  • map_func (callable) – The map to apply. Should be a function that takes a single-qubit density matrix as input and applies the map to it.

  • qubit_indices (list of ints) – Indices of qubit to which the map is applied. Indices from 0…n-1

  • rho (np.ndarray) – Density matrix of n qubits. Shape (2**n, 2**n)

  • *args (any, optional) – additional args and kwargs passed to map_func

  • **kwargs (any, optional) – additional args and kwargs passed to map_func

Returns

np.ndarray – The density matrix with the map applied. Shape (2**n, 2**n)

requsim.libs.epp module

Functions for pre-defined entanglement purification protocols.

Functions:

dejmps_protocol(rho)

Applies the DEJMPS entanglement purification protocol.

requsim.libs.epp.dejmps_protocol(rho)

Applies the DEJMPS entanglement purification protocol.

Input is usually two entangled pairs and output is one entangled pair if successful. This protocol was introduced in: D. Deutsch, et. al., Phys. Rev. Lett., vol. 77, pp. 2818–2821 (1996) arXiv:quant-ph/9604039

Parameters

rho (np.ndarray) – Four-qubit density matrix (16x16).

Returns

  • p_suc (scalar) – probability of success for the protocol

  • state (np.ndarray) – Two-qubit density matrix (4x4). The state of the remaining pair IF the protocol was successful.

requsim.libs.matrix module

A collection of useful matrix functions.

Mainly used to specify and manipulate density matrices of graph states.

Functions:

H(rho)

I(n)

tensor(*args)

Returns the matrix representation of the tensor product of an arbitrary number of matrices.

znoisy(rho, n)

xnoisy(rho, n)

ynoisy(rho, n)

znoise(rho, n, p)

xnoise(rho, n, p)

ynoise(rho, n, p)

wnoise(rho, n, p)

wnoise_all(rho, p)

noise_global(rho, p)

CNOT(n, m, N)

gives the N-qubit CNOT unitary with with the n-th qubit as source and the m-th qubit as target

CZ(n, m, N)

gives the N-qubit CZ unitary acting on n-th and m-th qubit

Ucnot(psi, n, m)

Ucz(psi, n, m)

Mcnot(rho, n, m)

Mcz(rho, n, m)

vec_reorder(psi, sys)

reorder(rho, sys)

ptranspose(rho, sys)

ptrace(rho, sys)

requsim.libs.matrix.H(rho)
requsim.libs.matrix.I(n)
requsim.libs.matrix.tensor(*args)

Returns the matrix representation of the tensor product of an arbitrary number of matrices.

requsim.libs.matrix.znoisy(rho, n)
requsim.libs.matrix.xnoisy(rho, n)
requsim.libs.matrix.ynoisy(rho, n)
requsim.libs.matrix.znoise(rho, n, p)
requsim.libs.matrix.xnoise(rho, n, p)
requsim.libs.matrix.ynoise(rho, n, p)
requsim.libs.matrix.wnoise(rho, n, p)
requsim.libs.matrix.wnoise_all(rho, p)
requsim.libs.matrix.noise_global(rho, p)
requsim.libs.matrix.CNOT(n, m, N)

gives the N-qubit CNOT unitary with with the n-th qubit as source and the m-th qubit as target

requsim.libs.matrix.CZ(n, m, N)

gives the N-qubit CZ unitary acting on n-th and m-th qubit

requsim.libs.matrix.Ucnot(psi, n, m)
requsim.libs.matrix.Ucz(psi, n, m)
requsim.libs.matrix.Mcnot(rho, n, m)
requsim.libs.matrix.Mcz(rho, n, m)
requsim.libs.matrix.vec_reorder(psi, sys)
requsim.libs.matrix.reorder(rho, sys)
requsim.libs.matrix.ptranspose(rho, sys)
requsim.libs.matrix.ptrace(rho, sys)