Ejemplo n.º 1
0
 def _positivity_result(evals, qpt=False):
     """Check if eigenvalues are positive"""
     cond = np.sum(np.abs(evals[evals < 0]))
     is_pos = bool(np.isclose(cond, 0))
     name = "completely_positive" if qpt else "positive"
     result = AnalysisResultData(name, is_pos)
     if not is_pos:
         result.extra = {"delta": cond}
     return result
Ejemplo n.º 2
0
 def _tp_result(evals, evecs):
     """Check if QPT channel is trace preserving"""
     size = len(evals)
     dim = int(np.sqrt(size))
     mats = np.reshape(evecs.T, (size, dim, dim), order="F")
     kraus_cond = np.einsum("i,ija,ijb->ab", evals, mats.conj(), mats)
     cond = np.sum(np.abs(la.eigvalsh(kraus_cond - np.eye(dim))))
     is_tp = bool(np.isclose(cond, 0))
     result = AnalysisResultData("trace_preserving", is_tp)
     if not is_tp:
         result.extra = {"delta": cond}
     return result
Ejemplo n.º 3
0
 def _tp_result(
     state_result: AnalysisResultData,
     input_dim: int = 1,
 ) -> AnalysisResultData:
     """Check if QPT channel is trace preserving"""
     evals = state_result.extra["eigvals"]
     evecs = state_result.extra["eigvecs"]
     size = len(evals)
     output_dim = size // input_dim
     mats = np.reshape(evecs.T, (size, output_dim, input_dim), order="F")
     kraus_cond = np.einsum("i,ija,ijb->ab", evals, mats.conj(), mats)
     cond = np.sum(np.abs(la.eigvalsh(kraus_cond - np.eye(input_dim))))
     is_tp = bool(np.isclose(cond, 0))
     result = AnalysisResultData("trace_preserving", is_tp)
     if not is_tp:
         result.extra = {"delta": cond}
     return result