@@ -46,10 +46,9 @@ static std::size_t countGatesOfType(const OneQubitGateSequence& seq,
4646// / Compare ``seq.getUnitaryMatrix()`` to ``u`` embedded on qubit 0 (4×4
4747// / layout).
4848static bool sequenceMatchesSingleQubitMatrix (const Eigen::Matrix2cd& u,
49- const OneQubitGateSequence& seq,
50- double tol = 1e-10 ) {
49+ const OneQubitGateSequence& seq) {
5150 const Eigen::Matrix4cd expanded = expandToTwoQubits (u, 0 );
52- return expanded.isApprox (seq.getUnitaryMatrix (), tol );
51+ return expanded.isApprox (seq.getUnitaryMatrix ());
5352}
5453
5554// NOLINTNEXTLINE(misc-use-internal-linkage) -- gtest `TEST_P` at global scope
@@ -117,10 +116,19 @@ TEST(EulerDecompositionTest, ZyzAnglesFromUnitaryReconstructHadamard) {
117116
118117 const auto angles =
119118 EulerDecomposition::anglesFromUnitary (hadamard, EulerBasis::ZYZ);
119+ OneQubitGateSequence zyzSeq{
120+ .gates =
121+ {
122+ {.type = GateKind::RZ, .parameter = {angles[2 ]}},
123+ {.type = GateKind::RY, .parameter = {angles[0 ]}},
124+ {.type = GateKind::RZ, .parameter = {angles[1 ]}},
125+ },
126+ .globalPhase = angles[3 ],
127+ };
120128 const Eigen::Matrix2cd reconstructed =
121- u3Matrix (angles[ 0 ], angles[ 1 ], angles[ 2 ] );
129+ EulerDecompositionTest::restore (zyzSeq );
122130
123- EXPECT_TRUE (isEquivalentUpToGlobalPhase (hadamard, reconstructed ));
131+ EXPECT_TRUE (reconstructed. isApprox (hadamard));
124132}
125133
126134TEST (EulerDecompositionTest, NativeEulerBasesRandomReconstruction) {
@@ -134,7 +142,7 @@ TEST(EulerDecompositionTest, NativeEulerBasesRandomReconstruction) {
134142 const double phase = angleDist (rng);
135143 const Eigen::Matrix2cd unitary =
136144 std::exp (std::complex <double >(0.0 , phase)) *
137- u3Matrix (theta, phi, lambda);
145+ decomposition::uMatrix (theta, phi, lambda);
138146 const Eigen::Matrix4cd expanded = expandToTwoQubits (unitary, 0 );
139147
140148 const auto u3Seq = EulerDecomposition::generateCircuit (
@@ -144,10 +152,8 @@ TEST(EulerDecompositionTest, NativeEulerBasesRandomReconstruction) {
144152 const auto zsxxSeq = EulerDecomposition::generateCircuit (
145153 EulerBasis::ZSXX, unitary, true , std::nullopt );
146154
147- EXPECT_TRUE (
148- isEquivalentUpToGlobalPhase (expanded, u3Seq.getUnitaryMatrix ()));
149- EXPECT_TRUE (
150- isEquivalentUpToGlobalPhase (expanded, zsxSeq.getUnitaryMatrix ()));
155+ EXPECT_TRUE (expanded.isApprox (u3Seq.getUnitaryMatrix ()));
156+ EXPECT_TRUE (expanded.isApprox (zsxSeq.getUnitaryMatrix ()));
151157 EXPECT_TRUE (sequenceMatchesSingleQubitMatrix (unitary, zsxSeq));
152158 EXPECT_TRUE (sequenceMatchesSingleQubitMatrix (unitary, zsxxSeq));
153159
0 commit comments