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

Function MAJ2

Extensions/QAlg/ArithmeticUnit/ArithmeticUnit.cpp:24–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24QCircuit MAJ2(QVec &adder1, QVec &adder2, Qubit* c)
25{
26 if ((adder1.size() == 0) || (adder1.size() != adder2.size()))
27 {
28 QCERR("adder1 and adder2 must be equal, but not equal to 0!");
29 throw ("adder1 and adder2 must be equal, but not equal to 0!");
30 }
31
32 int nbit = adder1.size();
33 QCircuit circuit;
34
35 circuit << MAJ(c, adder1[0], adder2[0]);
36
37 for (auto i = 1; i < nbit; i++)
38 {
39 circuit << MAJ(adder2[i - 1], adder1[i], adder2[i]);
40 }
41
42 return circuit;
43
44}
45
46QCircuit isCarry(
47 QVec &adder1,

Callers 1

isCarryFunction · 0.70

Calls 2

MAJFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected