1
1
#include " Components/HamiltonianSimulation/HamiltonianSimulation.h"
2
2
#include " Core/QuantumCircuit/QGate.h"
3
- #include " Core/Utilities/Utilities .h"
3
+ #include " Core/Utilities/Tools/Utils .h"
4
4
5
5
namespace QPanda
6
6
{
@@ -17,14 +17,12 @@ namespace QPanda
17
17
}
18
18
else if (1 == qubit_vec.size ())
19
19
{
20
- circuit << QGateNodeFactory::getInstance ()->getGateNode (
21
- " RZ" , qubit_vec[0 ], 2 *coef*t);
20
+ circuit << RZ (qubit_vec[0 ], 2 * coef*t);
22
21
}
23
22
else
24
23
{
25
24
circuit << parityCheckCircuit (qubit_vec);
26
- circuit << QGateNodeFactory::getInstance ()->getGateNode (
27
- " RZ" , qubit_vec[qubit_vec.size () - 1 ], 2 *coef * t);
25
+ circuit << RZ (qubit_vec[qubit_vec.size () - 1 ], 2 * coef * t);
28
26
circuit << parityCheckCircuit (qubit_vec);
29
27
}
30
28
@@ -56,12 +54,10 @@ namespace QPanda
56
54
switch (ch)
57
55
{
58
56
case ' X' :
59
- transform << QGateNodeFactory::getInstance ()->getGateNode (
60
- " H" , qubit_vec[key]);
57
+ transform << H (qubit_vec[key]);
61
58
break ;
62
59
case ' Y' :
63
- transform << QGateNodeFactory::getInstance ()->getGateNode (
64
- " RX" , qubit_vec[key], Q_PI_2);
60
+ transform << RX (qubit_vec[key], Q_PI_2);
65
61
break ;
66
62
case ' Z' :
67
63
break ;
@@ -151,7 +147,7 @@ namespace QPanda
151
147
QCircuit circuit;
152
148
for_each (qubit_vec.begin (), qubit_vec.end (), [&](Qubit* qubit)
153
149
{
154
- circuit << QGateNodeFactory::getInstance ()->getGateNode (gate, qubit);
150
+ circuit << QGateNodeFactory::getInstance ()->getGateNode (gate, { qubit } );
155
151
});
156
152
157
153
return circuit;
@@ -164,7 +160,7 @@ namespace QPanda
164
160
{
165
161
for_each (qubit_vec.begin (), qubit_vec.end (), [&](Qubit* qubit)
166
162
{
167
- circuit << QGateNodeFactory::getInstance ()->getGateNode (gate, qubit);
163
+ circuit << QGateNodeFactory::getInstance ()->getGateNode (gate, { qubit } );
168
164
});
169
165
}
170
166
@@ -180,21 +176,12 @@ namespace QPanda
180
176
QCircuit qcirc = QCircuit ();
181
177
for_each (graph.begin (), graph.end (), [&](const QGraphItem &item)
182
178
{
183
- qcirc << QGateNodeFactory::getInstance ()->getGateNode (
184
- " CNOT" ,
185
- qubit_vec[item.first ],
186
- qubit_vec[item.second ]
187
- );
188
- qcirc << QGateNodeFactory::getInstance ()->getGateNode (
189
- " RZ" ,
190
- qubit_vec[item.second ],
191
- 2 * gamma [i] * item.weight
192
- );
193
- qcirc << QGateNodeFactory::getInstance ()->getGateNode (
194
- " CNOT" ,
195
- qubit_vec[item.first ],
196
- qubit_vec[item.second ]
197
- );
179
+ qcirc << CNOT (qubit_vec[item.first ],
180
+ qubit_vec[item.second ]);
181
+ qcirc << RZ (qubit_vec[item.second ],
182
+ 2 * gamma [i] * item.weight );
183
+ qcirc << CNOT (qubit_vec[item.first ],
184
+ qubit_vec[item.second ]);
198
185
});
199
186
200
187
circuit << qcirc;
@@ -212,13 +199,9 @@ namespace QPanda
212
199
for (size_t i = 0 ; i < beta.size (); i++)
213
200
{
214
201
QCircuit qcirc = QCircuit ();
215
- for_each (qubit_vec.begin (), qubit_vec.end (), [&](Qubit* qubit)
216
- {
217
- qcirc << QGateNodeFactory::getInstance ()->getGateNode (
218
- " RX" ,
219
- qubit,
220
- 2 * beta[i]
221
- );
202
+ for_each (qubit_vec.begin (), qubit_vec.end (), [&](Qubit* qubit)
203
+ {
204
+ qcirc << RX (qubit,2 * beta[i]);
222
205
223
206
circuit << qcirc;
224
207
});
0 commit comments