Random objects¶
graphix.random_objects module¶
This module provides functions to generate various random objects.
- graphix.random_objects.rand_herm(sz: int, rng: Generator | None = None) npt.NDArray[source]¶
Generate random hermitian matrix of size sz*sz.
- graphix.random_objects.rand_unit(sz: int, rng: Generator | None = None) npt.NDArray[source]¶
Generate haar random unitary matrix of size sz*sz.
- graphix.random_objects.rand_dm(dim: int, rng: Generator | None = None, rank: int | None = None, dm_dtype=True) DensityMatrix | npt.NDArray[source]¶
Generate random density matrices (positive semi-definite matrices with unit trace).
Returns either a
graphix.sim.density_matrix.DensityMatrixor anp.ndarraydepending on the parameter dm_dtype.- Parameters:
dim (int) – Linear dimension of the (square) matrix
rank (int, optional) – Rank of the density matrix (1 = pure state). If not specified then sent to dim (maximal rank). Defaults to None
dm_dtype (bool, optional) – If True returns a
graphix.sim.density_matrix.DensityMatrixobject. If False`returns a :class:`np.ndarray
- Returns:
the density matrix in the specified format.
- Return type:
DensityMatrix | np.ndarray
Note
Thanks to Ulysse Chabaud.
Warning
Note that setting dm_dtype=False allows to generate “density matrices” inconsistent with qubits i.e. with dimensions not being powers of 2.
- graphix.random_objects.rand_gauss_cpx_mat(dim: int, rng: Generator | None = None, sig: float = np.float64(0.7071067811865475)) npt.NDArray[source]¶
Return a square array of standard normal complex random variates.
Code from QuTiP: https://qutip.org/docs/4.0.2/modules/qutip/random_objects.html
- Parameters:
dim (int) – Linear dimension of the (square) matrix
sig (float) – standard deviation of random variates.
sig = 'ginibredraws from the Ginibre ensemble ie sig = 1 / sqrt(2 * dim).
- graphix.random_objects.rand_channel_kraus(dim: int, rng: Generator | None = None, rank: int | None = None, sig: float = np.float64(0.7071067811865475)) KrausChannel[source]¶
Return a random
graphix.sim.channels.KrausChannelobject of given dimension and rank.Following the method of [KNPPZ21] Kukulski, Nechita, Pawela, Puchała, Życzkowsk https://arxiv.org/pdf/2011.02994.pdf
- Parameters:
dim (int) – Linear dimension of the (square) matrix of each Kraus operator. Only square operators so far.
rank (int (default to full rank dimension**2)) – Choi rank ie the number of Kraus operators. Must be between one and dim**2.
sig (see rand_cpx)
- graphix.random_objects.rand_pauli_channel_kraus(dim: int, rng: Generator | None = None, rank: int | None = None) KrausChannel[source]¶
Return a random Kraus channel operator.