def test_fixedgate_get_fun_vals(self):
        reset_tensor_cache()
        fg = FixedGate("Test", 4, 2, (0, 1))

        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            fun_vals = fg.get_fun_vals(sess)

        self.assertTrue(np.array_equal(fun_vals, [0.25] * 16))
    def test_fixedgate_get_unitary(self):
        reset_tensor_cache()
        fg = FixedGate("Test", 4, 2, (0, 1))

        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            gate = fg.get_unitary(sess)

        paulis = get_pauli_n_qubit_projection(4, (0, 1))
        H = pauli_dot_product([0.25] * 16, paulis)
        U = la.expm(1j * H)
        self.assertTrue(hilbert_schmidt_distance(gate, U) <= 1e-16)
    def test_fixedgate_get_herm ( self ):
        reset_tensor_cache()
        fg = FixedGate( "Test", 4, 2, (0, 1) )
        herm = fg.get_herm()

        with tf.Session() as sess:
            sess.run( tf.global_variables_initializer() )
            herm = herm.eval()

        paulis = get_pauli_n_qubit_projection( 4, (0, 1) )
        H = pauli_dot_product( [ 0.25 ] * 16, paulis )
        self.assertTrue( np.array_equal( herm, H )  )
 def test_fixedgate_constructor_valid(self):
     fg = FixedGate("Test", 4, 2, (0, 1))
     self.assertEqual(fg.name, "Test")
     self.assertEqual(fg.num_qubits, 4)
     self.assertEqual(fg.gate_size, 2)
     self.assertTrue(np.array_equal(fg.location, (0, 1)))
     self.assertTrue(np.array_equal(fg.fun_vals, [0.25] * 16))
Beispiel #5
0
 def test_fixedgate_get_location(self):
     reset_tensor_cache()
     fg = FixedGate("Test", 4, 2, (0, 1))
     self.assertTrue(np.array_equal(fg.get_location(), (0, 1)))