Skip to content

Commit 446a776

Browse files
🐛 Fix numerical issues in ThreeQubitRemoveUnconnected test (#978)
1 parent fa3c204 commit 446a776

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/dd/test_approximations.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,28 +316,28 @@ TEST(ApproximationTest, ThreeQubitRemoveUnconnected) {
316316

317317
// Test: Remove multiple nodes.
318318
//
319-
// |state⟩ = 0.069|000⟩ - 0.601|001⟩ - 0.069|010⟩ - 0.601|011⟩
320-
// - 0.347|100⟩ - 0.119|101⟩ + 0.347|110⟩ - 0.119|111⟩
319+
// |state⟩ = 0.069|000⟩ - 0.601|001⟩ - 0.196|010⟩ - 0.509|011⟩
320+
// - 0.347|100⟩ - 0.119|101⟩ + 0.294|110⟩ - 0.34|111⟩
321321
//
322-
// Eliminate |1xx⟩ and |01x⟩ with contribution ~0.27 and ~0.36
323-
// & terminal |000⟩ with contribution ~0.005
322+
// Eliminate |1xx⟩ and |01x⟩ with contribution ~0.34 and ~0.25
323+
// & terminal |000⟩ with contribution ~0.005
324324
// → |approx⟩ = -|001⟩
325325
//
326-
// * = 1/sqrt(2) -1│ -1│
326+
// -1│ -1│
327327
// ┌─┴─┐ ┌─┴─┐
328328
// ┌──────│ q2│──────┐ ┌─│ q2│─┐
329-
// .85│ └───┘ │.52 1| └───┘ 0
329+
// .81│ └───┘ │.58 1| └───┘ 0
330330
// ┌─┴─┐ ┌─┴─┐ -(approx)→ ┌─┴─┐
331331
// ┌──│ q1│──┐ ┌──│ q1│──┐ ┌─│ q1│──┐
332-
// *| └───┘ |* *| └───┘ |* 1| └───┘ 0
332+
// .74| └───┘ |.67 .63| └───┘ |.77 1| └───┘ 0
333333
// ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐ ┌─┴─┐
334334
// ┌│ q0│┐ ┌│ q0│┐ ┌│ q0│┐ ┌│ q0│┐ ┌─│ q0│─┐
335-
//-0.11|└───┘| |└───┘| |└───┘| |└───┘| 0 └───┘ |1
335+
// -.11|└───┘| |└───┘| |└───┘| |└───┘| 0 └───┘ |1
336336
// □ □ □ □ □ □ □ □ □
337337
//
338338

339339
constexpr std::size_t nq = 3;
340-
constexpr double fidelity = 1 - 0.64;
340+
constexpr double fidelity = 1 - 0.65;
341341

342342
auto dd = std::make_unique<dd::Package>(nq);
343343

@@ -348,6 +348,7 @@ TEST(ApproximationTest, ThreeQubitRemoveUnconnected) {
348348
qc.cx(1, 2);
349349
qc.ry(qc::PI / 8, 2);
350350
qc.ry(qc::PI / 2, 1);
351+
qc.cry(qc::PI / 4, 1, 2);
351352

352353
auto state = simulate(qc, dd->makeZeroState(nq), *dd);
353354
auto meta = approximate(state, fidelity, *dd);

0 commit comments

Comments
 (0)