MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / QDivider

Function QDivider

QAlg/ArithmeticUnit/ArithmeticUnit.cpp:245–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245QProg QDivider(QVec& a, QVec& b, QVec& c, QVec& k, ClassicalCondition& t)
246{
247 auto len = a.size();
248 QVec d(k.begin(), k.begin() + len);
249 QVec e(k.begin() + len, k.begin() + len * 2 + 2);
250 QProg prog;
251 prog << X(c[0]) << X(c[len - 1]) << X(d[0]) << X(d[len - 1]);
252 QProg prog_in;
253 prog_in << QSub(a, b, e) << QSub(c, d, e) << Measure(a[len - 1], t);
254 auto qwhile = createWhileProg(t < 1, prog_in);
255 prog << qwhile
256 << X(b[len - 1])
257 << QSub(a, b, e)
258 << X(b[len - 1])
259 << X(d[0])
260 << X(d[len - 1]);
261 return prog;
262}
263
264QProg QDiv(QVec& a, QVec& b, QVec& c, QVec& k, ClassicalCondition& t)
265{

Callers 3

QDivFunction · 0.70
test_QDividerFunction · 0.50

Calls 9

XClass · 0.85
SWAPClass · 0.85
QSubFunction · 0.70
shiftFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
set_valMethod · 0.45
daggerMethod · 0.45

Tested by 2

test_QDividerFunction · 0.40