quairkit.qinfo.qinfo¶
-
quairkit.qinfo.qinfo.channel_repr_convert(representation, source, target, tol=
1e-06
)¶ convert the given representation of a channel to the target implementation
- Parameters:¶
- representation : Tensor | ndarray | List[Tensor] | List[ndarray]¶
input representation
- source : str¶
input form, should be
'choi'
,'kraus'
or'stinespring'
- target : str¶
target form, should be
'choi'
,'kraus'
or'stinespring'
- tol : float¶
error tolerance for the conversion from Choi, \(10^{-6}\) by default
- Raises:¶
ValueError – Unsupported channel representation: require Choi, Kraus or Stinespring.
- Returns:¶
quantum channel by the target implementation
- Return type:¶
Tensor | ndarray
Note
choi -> kraus currently has the error of order 1e-6 caused by eigh
- Raises:¶
NotImplementedError – does not support the conversion of input data type
-
quairkit.qinfo.qinfo.create_choi_repr(linear_map, input_dim, input_dtype=
None
)¶ Create the Choi representation of a linear map with input checks.
This function verifies if the map is linear and if the output is a square matrix.
-
quairkit.qinfo.qinfo.decomp_1qubit(unitary, return_global=
False
)¶ Decompose a single-qubit unitary operator into Z-Y-Z rotation angles.
- Parameters:¶
- Returns:¶
A tuple containing the angles (beta, gamma, delta) or (alpha, beta, gamma, delta) if return_global is True. The type of the tuple elements matches the input type.
- Raises:¶
ValueError – Raises a ValueError if the input matrix is not a batch of 2x2 unitary matrices.
- Return type:¶
Tuple[ndarray, …] | Tuple[Tensor, …]
- quairkit.qinfo.qinfo.decomp_ctrl_1qubit(unitary)¶
Decompose a controlled single-qubit unitary operator into its components.
- Parameters:¶
- unitary : ndarray | Tensor¶
A 2x2 unitary matrix representing the single-qubit gate, as either a numpy ndarray or a torch Tensor.
- Returns:¶
A tuple containing the global phase alpha and the matrices A, B, C, which are components of the decomposition. The type of the tuple elements matches the input type.
- Raises:¶
ValueError – Raises a ValueError if the input matrix is not a 2x2 unitary matrix.
- Return type:¶
Tuple[ndarray, …] | Tuple[Tensor, …]
- Reference:
Nielsen, M. A., & Chuang, I. L. (2000). Quantum Computation and Quantum Information. Corollary 4.2 for the decomposition of a single-qubit unitary operation.
-
quairkit.qinfo.qinfo.diamond_norm(channel_repr, dim_io=
None
, **kwargs)¶ Calculate the diamond norm of input.
- Parameters:¶
- Raises:¶
RuntimeError – channel_repr must be Channel or torch.Tensor.
TypeError – “dim_io” should be “int” or “tuple”.
Warning
channel_repr is not in Choi representation, and is converted into ChoiRepr.
- Reference:
Khatri, Sumeet, and Mark M. Wilde. “Principles of quantum communication theory: A modern approach.” arXiv preprint arXiv:2011.04672 (2020). Watrous, J. . “Semidefinite Programs for Completely Bounded Norms.” Theory of Computing 5.1(2009):217-238.
- quairkit.qinfo.qinfo.gate_fidelity(U, V)¶
calculate the fidelity between gates
\[F(U, V) = |\text{tr}(UV^\dagger)|/2^n\]\(U\) is a \(2^n\times 2^n\) unitary gate
- quairkit.qinfo.qinfo.logarithmic_negativity(density_op)¶
Calculate the Logarithmic Negativity \(E_N = ||\rho^{T_A}||\) of the input quantum state.
-
quairkit.qinfo.qinfo.mana(matrix, input_str, out_dim=
None
)¶ Compute the mana of states or channels
- quairkit.qinfo.qinfo.negativity(density_op)¶
Compute the Negativity \(N = ||\frac{\rho^{T_A}-1}{2}||\) of the input quantum state.
- quairkit.qinfo.qinfo.pauli_str_convertor(observable)¶
Concatenate the input observable with coefficient 1.
For example, if the input
observable
is[['z0,x1'], ['z1']]
, then this function returns the observable[[1, 'z0,x1'], [1, 'z1']]
.
- quairkit.qinfo.qinfo.purity(rho)¶
Calculate the purity of a quantum state.
\[P = \text{tr}(\rho^2)\]
-
quairkit.qinfo.qinfo.relative_entropy(rho, sigma, base=
2
)¶ Calculate the relative entropy of two quantum states.
\[S(\rho \| \sigma)=\text{tr} \rho(\log \rho-\log \sigma)\]
- quairkit.qinfo.qinfo.state_fidelity(rho, sigma)¶
Calculate the fidelity of two quantum states.
\[F(\rho, \sigma) = \text{tr}(\sqrt{\sqrt{\rho}\sigma\sqrt{\rho}})\]
- quairkit.qinfo.qinfo.trace_distance(rho, sigma)¶
Calculate the trace distance of two quantum states.
\[D(\rho, \sigma) = 1 / 2 * \text{tr}|\rho-\sigma|\]