13 #ifndef QUANTUM_GATE_XASMVISITOR_HPP_ 14 #define QUANTUM_GATE_XASMVISITOR_HPP_ 17 #include "AllGateVisitor.hpp" 30 std::string qubit = std::to_string(h.bits()[0]);
31 ss <<
"H(q[" << qubit <<
"]);\n";
35 std::string qubit = std::to_string(i.bits()[0]);
36 ss <<
"I(q[" << qubit <<
"]);\n";
40 std::string q1 = std::to_string(cz.bits()[0]);
41 std::string q2 = std::to_string(cz.bits()[1]);
42 ss <<
"Cz(q[" << q1 <<
"],q[" << q2 <<
"]);\n";
45 void visit(
CNOT &cn) {
46 std::string q1 = std::to_string(cn.bits()[0]);
47 std::string q2 = std::to_string(cn.bits()[1]);
48 ss <<
"CX(q[" << q1 <<
"],q[" << q2 <<
"]);\n";
52 std::string qubit = std::to_string(x.bits()[0]);
53 ss <<
"X(q[" << qubit <<
"]);\n";
56 std::string qubit = std::to_string(y.bits()[0]);
57 ss <<
"Y(q[" << qubit <<
"]);\n";
61 std::string qubit = std::to_string(z.bits()[0]);
62 ss <<
"Z(q[" << qubit <<
"]);\n";
65 void visit(
Measure &m) { ss <<
"Measure(q[" << m.bits()[0] <<
"]);\n"; }
68 std::string qubit = std::to_string(rx.bits()[0]);
69 ss <<
"Rx(q[" << qubit <<
"], " << rx.getParameter(0).toString()
74 std::string qubit = std::to_string(ry.bits()[0]);
75 ss <<
"Ry(q[" << qubit <<
"], " << ry.getParameter(0).toString()
80 std::string qubit = std::to_string(rz.bits()[0]);
81 ss <<
"Rz(q[" << qubit <<
"], " << rz.getParameter(0).toString()
86 std::string q1 = std::to_string(cp.bits()[0]);
87 std::string q2 = std::to_string(cp.bits()[1]);
88 auto angleStr = cp.getParameter(0).toString();
89 ss <<
"CPhase(q[" << q1 <<
"], q[" << q2 <<
"]," << angleStr <<
");\n";
102 auto t = u.getParameter(0).toString();
103 auto p = u.getParameter(1).toString();
104 auto l = u.getParameter(2).toString();
106 Rz rz(u.bits()[0], t);
107 Ry ry(u.bits()[0], p);
108 Rz rz2(u.bits()[0], l);
114 std::string getXasmString() {
return ss.str(); }
Definition: CommonGates.hpp:306
Definition: CommonGates.hpp:199
Definition: CommonGates.hpp:328
Definition: Accelerator.hpp:25
Definition: CommonGates.hpp:124
Definition: CommonGates.hpp:112
Definition: CommonGates.hpp:295
Definition: AllGateVisitor.hpp:24
Definition: CommonGates.hpp:368
Definition: xasm_visitor.hpp:22
Definition: CommonGates.hpp:216
Definition: CommonGates.hpp:254
Definition: CommonGates.hpp:235
Definition: CommonGates.hpp:317
Definition: CommonGates.hpp:381
Definition: CommonGates.hpp:270
Definition: CommonGates.hpp:100