def test_ChoiKrausChoi(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(h_5, scipy.rand(),
                                [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     kraus_ops = choi_to_kraus(choi_matrix)
     test_choi = kraus_to_choi(kraus_ops)
     assert_((test_choi - choi_matrix).norm() < 1e-12)
Exemple #2
0
 def test_ChoiKrausChoi(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(
         h_5, scipy.rand(),
         [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     kraus_ops = choi_to_kraus(choi_matrix)
     test_choi = kraus_to_choi(kraus_ops)
     assert_((test_choi - choi_matrix).norm() < 1e-12)
    def test_ChoiKrausChoi(self, superoperator):
        """
        Superoperator: Convert superoperator to Choi matrix and back.
        """
        choi_matrix = to_choi(superoperator)
        kraus_ops = to_kraus(choi_matrix)
        test_choi = kraus_to_choi(kraus_ops)

        # Assert both that the result is close to expected, and has the right
        # type.
        assert (test_choi - choi_matrix).norm() < tol
        assert choi_matrix.type == "super" and choi_matrix.superrep == "choi"
        assert test_choi.type == "super" and test_choi.superrep == "choi"
    def test_ChoiKrausChoi(self):
        """
        Superoperator: Convert superoperator to Choi matrix and back.
        """
        superoperator = rand_super()
        choi_matrix = to_choi(superoperator)
        kraus_ops = to_kraus(choi_matrix)
        test_choi = kraus_to_choi(kraus_ops)

        # Assert both that the result is close to expected, and has the right
        # type.
        assert_((test_choi - choi_matrix).norm() < tol)
        assert_(choi_matrix.type == "super" and choi_matrix.superrep == "choi")
        assert_(test_choi.type == "super" and test_choi.superrep == "choi")
Exemple #5
0
 def test_ChoiKrausChoi(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     superoperator = rand_super()
     choi_matrix = to_choi(superoperator)
     kraus_ops = to_kraus(choi_matrix)
     test_choi = kraus_to_choi(kraus_ops)
     
     # Assert both that the result is close to expected, and has the right
     # type.
     assert_((test_choi - choi_matrix).norm() < 1e-12)
     assert_(choi_matrix.type == "super" and choi_matrix.superrep == "choi")
     assert_(test_choi.type == "super" and test_choi.superrep == "choi")
Exemple #6
0
    def test_dnorm_on_sparse_matrix(self):
        """
        Tests sparse versus dense dnorm calculation on sparse matrices.
        """
        force_solve = True

        def AmpDampChoi(p):
            Kraus = [(1 - p)**.5 * qeye(2), p**.5 * destroy(2),
                     p**.5 * fock_dm(2, 0)]
            return kraus_to_choi(Kraus)

        # Choi matrix for identity channel on 1 qubit
        A = kraus_to_choi([qeye(2)])
        p = np.random.uniform(0.1, 0.9)
        B = AmpDampChoi(p)
        dense_run_result = dnorm(A, B, force_solve=force_solve, sparse=False)
        sparse_run_result = dnorm(A, B, force_solve=force_solve, sparse=True)
        assert dense_run_result == pytest.approx(sparse_run_result, abs=1e-7)
Exemple #7
0
 def AmpDampChoi(p):
     Kraus = [(1 - p)**.5 * qeye(2), p**.5 * destroy(2),
              p**.5 * fock_dm(2, 0)]
     return kraus_to_choi(Kraus)