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

Function isCarry

Extensions/QAlg/ArithmeticUnit/ArithmeticUnit.cpp:46–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46QCircuit isCarry(
47 QVec &adder1,
48 QVec &adder2,
49 Qubit* c,
50 Qubit* is_carry)
51{
52 if ((adder1.size() == 0) || (adder1.size() != adder2.size()))
53 {
54 QCERR("adder1 and adder2 must be equal, but not equal to 0!");
55 throw ("adder1 and adder2 must be equal, but not equal to 0!");
56 }
57 QCircuit circuit;
58
59 circuit << MAJ2(adder1, adder2, c) << CNOT(adder2[adder2.size() - 1], is_carry) << MAJ2(adder1, adder2, c).dagger();
60
61 return circuit;
62}
63
64QCircuit QAdder(
65 QVec &adder1,

Callers 1

constModAddFunction · 0.70

Calls 4

CNOTClass · 0.85
MAJ2Function · 0.70
sizeMethod · 0.45
daggerMethod · 0.45

Tested by

no test coverage detected