mirror of https://github.com/Qiskit/qiskit.git
Fix the matrix representation of CUGate in Rust (#13121)
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
This commit is contained in:
parent
1962704cf1
commit
8929e12bab
|
@ -387,12 +387,12 @@ pub fn cu_gate(theta: f64, phi: f64, lam: f64, gamma: f64) -> GateArray2Q {
|
|||
C_ZERO,
|
||||
c64(0., gamma).exp() * cos_theta,
|
||||
C_ZERO,
|
||||
c64(0., gamma + phi).exp() * (-1.) * sin_theta,
|
||||
c64(0., gamma + lam).exp() * (-1.) * sin_theta,
|
||||
],
|
||||
[C_ZERO, C_ZERO, C_ONE, C_ZERO],
|
||||
[
|
||||
C_ZERO,
|
||||
c64(0., gamma + lam).exp() * sin_theta,
|
||||
c64(0., gamma + phi).exp() * sin_theta,
|
||||
C_ZERO,
|
||||
c64(0., gamma + phi + lam).exp() * cos_theta,
|
||||
],
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed the definition of the :class:`.CUGate` matrix in Rust-space.
|
||||
While this was not noticable while handling the :class:`.CUGate` purely on
|
||||
Python side, this had knock-on effects when transpiler passes were using the
|
||||
Rust representation, such as could happen in :class:`.Consolidate2qBlocks`.
|
||||
Fixed `#13118 <https://github.com/Qiskit/qiskit/issues/13118>`__.
|
||||
|
|
@ -66,7 +66,7 @@ class TestRustGateEquivalence(QiskitTestCase):
|
|||
continue
|
||||
|
||||
with self.subTest(name=name):
|
||||
params = [pi] * standard_gate._num_params()
|
||||
params = [0.1 * (i + 1) for i in range(standard_gate._num_params())]
|
||||
py_def = gate_class.base_class(*params).definition
|
||||
rs_def = standard_gate._get_definition(params)
|
||||
if py_def is None:
|
||||
|
@ -141,7 +141,7 @@ class TestRustGateEquivalence(QiskitTestCase):
|
|||
continue
|
||||
|
||||
with self.subTest(name=name):
|
||||
params = [0.1] * standard_gate._num_params()
|
||||
params = [0.1 * (i + 1) for i in range(standard_gate._num_params())]
|
||||
py_def = gate_class.base_class(*params).to_matrix()
|
||||
rs_def = standard_gate._to_matrix(params)
|
||||
np.testing.assert_allclose(rs_def, py_def)
|
||||
|
|
Loading…
Reference in New Issue