Exemplo n.º 1
0
        ])
    ])
}

swap_data = {
    "opaque": False,
    "n_args": 0,
    "n_bits": 2,
    "args": [],
    "bits": ["a", "b"],
    # gate swap a,b { cx a,b; cx b,a; cx a,b; }
    "body": node.GateBody([
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([
                node.Id("a", 0, ""),
                node.Id("b", 0, "")
            ])
        ]),
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([
                node.Id("b", 0, ""),
                node.Id("a", 0, "")
            ])
        ]),
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([
                node.Id("a", 0, ""),
                node.Id("b", 0, "")
Exemplo n.º 2
0
        False,
        "opaque":
        False,
        "n_args":
        0,
        "n_bits":
        1,
        "args": [],
        "bits": ["a"],
        # gate x a { u3(pi,0,pi) a; }
        "body":
        node.GateBody([
            node.CustomUnitary([
                node.Id("u3", 0, ""),
                node.ExpressionList(
                    [node.Real(sympy.pi),
                     node.Int(0),
                     node.Real(sympy.pi)]),
                node.PrimaryList([node.Id("a", 0, "")])
            ])
        ])
    }

    # Pauli gate: bit and phase flip
    QuantumCircuit.definitions["y"] = {
        "print":
        False,
        "opaque":
        False,
        "n_args":
        0,
        "n_bits":
Exemplo n.º 3
0
    "print":
    True,
    "opaque":
    False,
    "n_args":
    1,
    "n_bits":
    2,
    "args": ["theta"],
    "bits": ["a", "b"],
    # gate rzz(theta) a, b { cx a, b; u1(theta) b; cx a, b; }
    "body":
    node.GateBody([
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([node.Id("a", 0, ""),
                              node.Id("b", 0, "")])
        ]),
        node.CustomUnitary([
            node.Id("u1", 0, ""),
            node.ExpressionList([node.Id("theta", 0, "")]),
            node.PrimaryList([node.Id("b", 0, "")])
        ]),
        node.CustomUnitary([
            node.Id("cx", 0, ""),
            node.PrimaryList([node.Id("a", 0, ""),
                              node.Id("b", 0, "")])
        ])
    ])
}