Esempio n. 1
0
    def test_zero_basis(self):

        ARMAs = [SchWARMA.ARMA([.5, .25], [1])]
        ARMAs.append(SchWARMA.ARMA([], [1]))

        D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}

        sch = SchWARMA.SchWARMA(ARMAs, [s_z, np.zeros((8, 2))], D)

        self.assertEqual(sch.N, 2)
        self.assertTrue(all([b.shape == (8, 8) for b in sch.basis]))
        self.assertEqual(la.norm(1j * s_z - sch.basis[0][:2, :2]), 0)
        self.assertEqual(la.norm(sch.basis[0][2:, :]), 0)
        self.assertEqual(la.norm(sch.basis[0][:, 2:]), 0)

        out = sch['I']
        self.assertEqual(out.rank(), 1)
        self.assertEqual(out.chi()[1, 1], 0)
        self.assertEqual(out.chi()[2, 2], 0)

        avg = ch.QuantumChannel(
            np.mean([sch['I'].choi() for _ in range(3)], 0), 'choi')
        self.assertEqual(avg.rank(), 2)
        self.assertEqual(avg.chi()[1, 1], 0)
        self.assertEqual(avg.chi()[2, 2], 0)
Esempio n. 2
0
    def test_hamiltonian_basis(self):

        ARMAs = [SchWARMA.ARMA([.5, .25], [1])]
        ARMAs.append(SchWARMA.ARMA([], [1]))
        ARMAs.append(SchWARMA.ARMA([], [1, 1, 1]))

        D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}

        sch = SchWARMA.SchWARMA(ARMAs, [s_x, s_y, s_z], D)

        self.assertTrue(
            all([la.norm(b + b.conj().T < 1e-9) for b in sch.basis]))
Esempio n. 3
0
    def test_zero_basis(self):

        ARMAs = [SchWARMA.ARMA([.5, .25], [1])]
        ARMAs.append(SchWARMA.ARMA([], [1]))

        D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}

        sch = SchWARMA.SchWARMA(ARMAs, [np.zeros((8, 2)), np.zeros((2, 2))], D)

        self.assertEqual(sch.N, 2)
        self.assertTrue(all([b.shape == (8, 8) for b in sch.basis]))

        self.assertEqual(la.norm(sch['I'].liouvillian() - np.eye(4)), 0)
Esempio n. 4
0
    def test_no_SchWARMA(self):

        ARMAs = [SchWARMA.ARMA([], [0])]
        ARMAs.append(SchWARMA.ARMA([], [0]))
        ARMAs.append(SchWARMA.ARMA([], [0]))

        D = {
            'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex))),
            'X': ch.QuantumChannel(np.kron(s_x.conj(), s_x))
        }

        sch = SchWARMA.SchWARMA(ARMAs, [s_x, s_y, s_z], D)

        sch.init_ARMAs

        self.assertEqual(la.norm(D['I'].choi() - sch['I'].choi()), 0)
        self.assertEqual(la.norm(D['X'].choi() - sch['X'].choi()), 0)
Esempio n. 5
0
    def test_mixed_basis(self):
        ARMAs = [SchWARMA.ARMA([.5, .25], [1])]
        ARMAs.append(SchWARMA.ARMA([], [1]))
        ARMAs.append(SchWARMA.ARMA([], [1, 1, 1]))

        D = {
            'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex))),
            'X': ch.QuantumChannel(np.kron(s_x.conj(), s_x))
        }

        ad = np.zeros((4, 2), dtype=complex)
        ad[2, 1] = .1
        sch = SchWARMA.SchWARMA(ARMAs, [s_x, 1j * s_y, ad], D)

        self.assertEqual(sch.N, 2)
        self.assertTrue(
            all([la.norm(b + b.conj().T < 1e-9) for b in sch.basis]))
Esempio n. 6
0
 def test_bad_init(self):
     ARMAS = [
         SchWARMA.ARMA(np.random.randn(1),
                       np.random.randn(np.random.randint(5)) + 2)
         for _ in range(3)
     ]
     D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}
     self.assertRaises(AssertionError, SchWARMA.SchWMA,
                       *[ARMAS, [s_x, s_y, s_z], D])
Esempio n. 7
0
    def test_init(self):

        ARMAS = [
            SchWARMA.ARMA([],
                          np.random.randn(np.random.randint(5)) + 2)
            for _ in range(3)
        ]
        D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}
        MA = SchWARMA.SchWMA(ARMAS, [s_x, s_y, s_z], D)
Esempio n. 8
0
    def test_init(self):

        ARMAs = [SchWARMA.ARMA([.5, .25], [1])]
        ARMAs.append(SchWARMA.ARMA([], [1]))
        ARMAs.append(SchWARMA.ARMA([], [1, 1, 1]))

        D = {'I': ch.QuantumChannel(np.array(np.eye(4, dtype=complex)))}

        sch = SchWARMA.SchWARMA(ARMAs, [s_x, s_y, s_z], D)

        xs = [copy.copy(model.x) for model in sch.models]
        ys = [copy.copy(model.y) for model in sch.models]

        sch.init_ARMAs()

        xs2 = [copy.copy(model.x) for model in sch.models]
        ys2 = [copy.copy(model.y) for model in sch.models]

        xdiff = np.array([la.norm(x - xx) for x, xx in zip(xs, xs2)])
        ydiff = np.array([la.norm(yy) for y, yy in zip(ys, ys2)])

        self.assertTrue(np.all(xdiff > 0))
        self.assertTrue(np.all(ydiff == 0))