| 164 | } |
| 165 | |
| 166 | QCircuit 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 |