Skip to content

Commit 1f13ead

Browse files
committed
fix adding error to state
1 parent 8a0e315 commit 1f13ead

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/isotropic/utils/state_transforms.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def hypersphere_to_statevector(S: Array) -> Array:
4747
return Phi
4848

4949

50-
def add_isotropic_error(Phi: Array, e2: Array, theta_zero: float) -> Array:
50+
def add_isotropic_error(Phi_sp: Array, e2: Array, theta_zero: float) -> Array:
5151
"""
5252
Add isotropic error to state Phi given e2 and theta_zero
5353
5454
Parameters
5555
----------
56-
Phi : ArrayLike
57-
state to which isotropic error is added
56+
Phi_sp : ArrayLike
57+
state to which isotropic error is added (in spherical form)
5858
e2 : ArrayLike
5959
vector e2 in S_{d-1} with uniform distribution
6060
theta_zero : float
@@ -63,8 +63,9 @@ def add_isotropic_error(Phi: Array, e2: Array, theta_zero: float) -> Array:
6363
Returns
6464
-------
6565
Array
66-
statevector after adding isotropic error
66+
statevector in spherical form after adding isotropic error
6767
"""
68-
# TODO: fix dimension mismatch between Phi and e2
69-
Psi = (Phi * jnp.cos(theta_zero)) + (e2 * jnp.sin(theta_zero))
70-
return Psi
68+
Psi_sp = (Phi_sp * jnp.cos(theta_zero)) + (
69+
(jnp.sum(e2, axis=0)) * jnp.sin(theta_zero)
70+
)
71+
return Psi_sp

0 commit comments

Comments
 (0)