Skip to content

Commit cc4a1ff

Browse files
Fix eigenstates in QTensorNetwork::ForceM()
1 parent 3df04eb commit cc4a1ff

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/qtensornetwork.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,13 @@ bool QTensorNetwork::ForceM(bitLenInt qubit, bool result, bool doForce, bool doA
284284
nonMeasuredQubits.push_back(i);
285285
}
286286
std::map<bitLenInt, bool> m = measurements[layerId];
287-
std::vector<bool> eigens(qubitCount, false);
288287
for (const bitLenInt& q : nonMeasuredQubits) {
289288
size_t layer = layerId;
290289
eigen = false;
291290
while (true) {
292291
std::map<bitLenInt, bool>& ml = measurements[layer];
293292
if (ml.find(q) != ml.end()) {
294293
m[q] = ml[q] ^ eigen;
295-
eigens[q] = eigen;
296294
break;
297295
}
298296
if (circuit[layer]->IsNonClassicalTarget(q, &eigen)) {
@@ -301,7 +299,6 @@ bool QTensorNetwork::ForceM(bitLenInt qubit, bool result, bool doForce, bool doA
301299
}
302300
if (!layer) {
303301
m[q] = eigen;
304-
eigens[q] = eigen;
305302
break;
306303
}
307304
--layer;
@@ -318,24 +315,14 @@ bool QTensorNetwork::ForceM(bitLenInt qubit, bool result, bool doForce, bool doA
318315
measurements.erase(measurements.begin() + layerId - i);
319316
}
320317
circuit[0U] = std::make_shared<QCircuit>();
321-
measurements[0U] = m;
318+
measurements.erase(measurements.begin());
322319

323320
// Sync layer 0U as state preparation for deterministic measurement.
324321
QRACK_CONST complex pauliX[4U]{ ZERO_CMPLX, ONE_CMPLX, ONE_CMPLX, ZERO_CMPLX };
325322
for (const auto& b : m) {
326323
if (b.second) {
327324
circuit[0U]->AppendGate(std::make_shared<QCircuitGate>(b.first, pauliX));
328325
}
329-
if (b.second != eigens[b.first]) {
330-
if (!b.second) {
331-
circuit[0U]->AppendGate(std::make_shared<QCircuitGate>(b.first, pauliX));
332-
continue;
333-
}
334-
if (circuit.size() < 2U) {
335-
circuit.emplace_back();
336-
}
337-
circuit[1U]->AppendGate(std::make_shared<QCircuitGate>(b.first, pauliX));
338-
}
339326
}
340327

341328
// Tell the user the result.

0 commit comments

Comments
 (0)