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

Function QMultiplier

QAlg/ArithmeticUnit/ArithmeticUnit.cpp:203–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203QCircuit QMultiplier(QVec& a, QVec& b, QVec& k, QVec& d)
204{
205 auto len = a.size();
206 QVec c(a);
207 QVec tem(k.begin(), k.begin() + len);
208 c += tem;
209 auto t = k[len];
210 QCircuit fcirc;
211
212 QCircuit circ;
213 circ << QAdder(d, c, t);
214 fcirc << circ.control(b[0]);
215
216 for (auto i = 1; i < len; i++)
217 {
218 QCircuit circ1;
219 fcirc << shift(c);
220 circ1 << QAdder(d, c, t);
221 fcirc << circ1.control(b[i]);
222 }
223 for (auto i = 1; i < len; i++)
224 {
225 fcirc << shift(c).dagger();
226 }
227 return fcirc;
228}
229
230QCircuit QMul(QVec& a, QVec& b, QVec& k, QVec& d)
231{

Callers 2

QMulFunction · 0.70
test_QMultiplierFunction · 0.50

Calls 6

QAdderFunction · 0.70
shiftFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
controlMethod · 0.45
daggerMethod · 0.45

Tested by 1

test_QMultiplierFunction · 0.40