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

Function QSub

QAlg/ArithmeticUnit/ArithmeticUnit.cpp:166–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166QCircuit QSub(QVec& a, QVec& b, QVec& k)
167{
168 auto len = a.size();
169 QVec anc(k.begin(), k.begin() + len + 2);
170 auto t = k[len];
171 //auto q1 = k[len + 1];
172 QCircuit circ, circ1, circ2;
173
174 circ << X(b[len - 1])
175 << QComplement(a, anc)
176 << QComplement(b, anc)
177 << QAdder(a, b, t)
178 << QComplement(a, anc)
179 << QComplement(b, anc)
180 << X(b[len - 1]);
181
182 return circ;
183}
184
185/**
186* @brief Shift the quantum state one bit to the left

Callers 4

QAddFunction · 0.70
QDividerFunction · 0.70
test_QSubFunction · 0.50
testQAdder.pyFile · 0.50

Calls 5

XClass · 0.85
QComplementFunction · 0.70
QAdderFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45

Tested by 1

test_QSubFunction · 0.40