示例#1
0
    def test_1d_fit(self):

        D = {'I': ch.QuantumChannel(np.array(np.eye(4)))}
        AR = SchWARMA.SchWAR([], [s_z], D)

        alpha = np.sqrt(.00001)
        sigma = 1.#1./2.

        arg = lambda t: alpha**2*sigma*(np.sqrt(np.pi)*t*sp.erf(t/sigma)+sigma*(np.exp(-t**2/sigma**2)-1))
        args = np.exp(-2*np.array([arg(t) for t in range(100)]))
        args = (1.-args)/2.

        AR.fit([args], 5)
        self.assertEqual(5,len(AR.models[0].a))
        self.assertEqual(1,len(AR.models[0].b))
        AR.init_ARMAs()
        AR['I']


        #Note now I have brackets on the second argument
        AR.fit([args], [7])
        self.assertEqual(7,len(AR.models[0].a))
        self.assertEqual(1,len(AR.models[0].b))
        AR.init_ARMAs()
        L = AR['I'].liouvillian()

        #Known structure of \sigma_z arma
        self.assertEqual(la.norm(L-np.diag(np.diag(L))),0.0)
        self.assertEqual(L[0,0], L[3,3])
        self.assertAlmostEqual(L[0,0], 1.,9)
        self.assertEqual(L[1,1], np.conj(L[2,2]))
示例#2
0
    def test_3d_fit(self):
        D = {'I': ch.QuantumChannel(np.array(np.eye(4,dtype=complex)))}
        AR = SchWARMA.SchWAR([], [s_z], D)

        alpha = np.sqrt(.00001)
        sigma = 1.#1./2.

        arg = lambda t: alpha**2*sigma*(np.sqrt(np.pi)*t*sp.erf(t/sigma)+sigma*(np.exp(-t**2/sigma**2)-1))
        args = np.exp(-2*np.array([arg(t) for t in range(100)]))
        args = (1.-args)/2.

        #Note now I have brackets on the second argument
        AR.fit([args, args, args], [3,5,7])
        self.assertEqual(3,len(AR.models[0].a))
        self.assertEqual(5,len(AR.models[1].a))
        self.assertEqual(7,len(AR.models[2].a))
        AR.init_ARMAs()
        L = AR['I']
示例#3
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)))}
        AR = SchWARMA.SchWAR(ARMAS, [s_x, s_y, s_z], D)