Skip to content

Commit 1436938

Browse files
Trying to directly access control qubit and increment it
1 parent 2efb7d1 commit 1436938

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/algorithms/StatePreparation.cpp

+5-11
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,8 @@ gatesToUncompute(std::vector<std::complex<double>>& amplitudes,
221221
for (auto& target : op->getTargets()) {
222222
target += static_cast<unsigned int>(i);
223223
}
224-
for (auto control : op->getControls()) {
225-
// there were some errors when accessing the qubit directly and
226-
// adding to it
227-
op->setControls(
228-
Controls{Control{control.qubit + static_cast<unsigned int>(i)}});
224+
for (auto& control: op->getControls()) {
225+
control.qubit += static_cast<Qubit>(i);
229226
}
230227
}
231228
disentangler.emplace_back<Operation>(rzMultiplexer.asOperation());
@@ -242,12 +239,9 @@ gatesToUncompute(std::vector<std::complex<double>>& amplitudes,
242239
for (auto& target : op->getTargets()) {
243240
target += static_cast<unsigned int>(i);
244241
}
245-
for (auto control : op->getControls()) {
246-
// there were some errors when accessing the qubit directly and
247-
// adding to it
248-
op->setControls(
249-
Controls{Control{control.qubit + static_cast<unsigned int>(i)}});
250-
}
242+
for (auto& control: op->getControls()) {
243+
control.qubit += static_cast<Qubit>(i);
244+
}
251245
}
252246
disentangler.emplace_back<Operation>(ryMultiplexer.asOperation());
253247
}

0 commit comments

Comments
 (0)