Ejemplo n.º 1
0
def print_gate(t):
    print('t =', t)
    matrix = U00(t)
    gates = qd.matrix_to_gates(matrix)
    circuit = qd.matrix_to_cirq_circuit(matrix)
    print(circuit)
    print()
Ejemplo n.º 2
0
 def test_matrix_to_gates_SWAP(self):
     gates = qd.matrix_to_gates(SWAP)
     assert np.allclose(SWAP, gates_to_matrix(gates))
Ejemplo n.º 3
0
 def test_matrix_to_gates_random_orthogonal(self):
     np.random.seed(100)
     for matrix_size in [2, 4, 8]:
         for _ in range(10):
             A = np.array(ortho_group.rvs(matrix_size))
             check_decomp(A, qd.matrix_to_gates(A))
Ejemplo n.º 4
0
    def test_matrix_to_gates_identity(self):
        A = np.eye(16)
        gates = qd.matrix_to_gates(A)

        assert len(gates) == 0
Ejemplo n.º 5
0
 def test_matrix_to_gates_random_unitary(self):
     np.random.seed(100)
     for matrix_size in [2, 4, 8, 16]:
         for _ in range(10):
             A = np.array(unitary_group.rvs(matrix_size))
             check_decomp(A, qd.matrix_to_gates(A))