@@ -88,7 +88,7 @@ template <typename T>
88
88
for (size_t i = 0 ; i < matrixVec.size (); ++i) {
89
89
sum += matrixVec[i] * vector[i];
90
90
}
91
- result.push_back (sum);
91
+ result.emplace_back (sum);
92
92
}
93
93
return result;
94
94
}
@@ -175,7 +175,7 @@ template <typename T>
175
175
// works out Ry and Rz rotation angles used to disentangle LSB qubit
176
176
// rotations make up block diagonal matrix U
177
177
[[nodiscard]] auto
178
- rotationsToDisentangle (std::vector<std::complex<double >> amplitudes, double EPS)
178
+ rotationsToDisentangle (std::vector<std::complex<double >>& const amplitudes, double EPS)
179
179
-> std::tuple<std::vector<std::complex<double >>, std::vector<double >,
180
180
std::vector<double >> {
181
181
std::vector<std::complex<double >> remainingVector;
@@ -184,10 +184,10 @@ rotationsToDisentangle(std::vector<std::complex<double>> amplitudes, double EPS)
184
184
for (size_t i = 0 ; i < (amplitudes.size () / 2 ); ++i) {
185
185
auto [remains, theta, phi] =
186
186
blochAngles (amplitudes[2 * i], amplitudes[2 * i + 1 ], EPS);
187
- remainingVector.push_back (remains);
187
+ remainingVector.emplace_back (remains);
188
188
// minus sign because we move it to zero
189
- thetas.push_back (-theta);
190
- phis.push_back (-phi);
189
+ thetas.emplace_back (-theta);
190
+ phis.emplace_back (-phi);
191
191
}
192
192
return {remainingVector, thetas, phis};
193
193
}
@@ -222,7 +222,7 @@ gatesToUncompute(std::vector<std::complex<double>>& amplitudes,
222
222
// qubit directly the controls are collected and then newly set
223
223
std::vector<qc::Control> newControls;
224
224
for (const auto & control : op->getControls ()) {
225
- newControls.push_back (
225
+ newControls.emplace_back (
226
226
qc::Control{control.qubit + static_cast <Qubit>(i)});
227
227
}
228
228
op->setControls (qc::Controls{newControls.begin (), newControls.end ()});
@@ -244,7 +244,7 @@ gatesToUncompute(std::vector<std::complex<double>>& amplitudes,
244
244
// qubit directly the controls are collected and then newly set
245
245
std::vector<qc::Control> newControls;
246
246
for (const auto & control : op->getControls ()) {
247
- newControls.push_back (
247
+ newControls.emplace_back (
248
248
qc::Control{control.qubit + static_cast <Qubit>(i)});
249
249
}
250
250
op->setControls (qc::Controls{newControls.begin (), newControls.end ()});
0 commit comments