Skip to content

Commit

Permalink
change tuple call new state dims
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles MOUSSA committed Dec 16, 2024
1 parent f2606d4 commit e3b1f2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions horqrux/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def apply_operator(
operator = operator.reshape(tuple(2 for _ in np.arange(2 * n_qubits_op)))
op_out_dims = tuple(np.arange(operator.ndim // 2, operator.ndim, dtype=int))
# Apply operator
new_state_dims = tuple(i for i in range(len(state_dims)))
new_state_dims = tuple(range(len(state_dims)))
state = jnp.tensordot(a=operator, b=state, axes=(op_out_dims, state_dims))
return jnp.moveaxis(a=state, source=new_state_dims, destination=state_dims)

Expand Down Expand Up @@ -91,7 +91,7 @@ def apply_operator_dm(
operator = operator.reshape(tuple(2 for _ in np.arange(2 * n_qubits_op)))
op_out_dims = tuple(np.arange(operator.ndim // 2, operator.ndim, dtype=int))
op_in_dims = tuple(np.arange(0, operator.ndim // 2, dtype=int))
new_state_dims = tuple(i for i in range(len(state_dims)))
new_state_dims = tuple(range(len(state_dims)))

# Apply operator to density matrix: ρ' = O ρ O†
support_perm = state_dims + tuple(set(tuple(range(state.ndim // 2))) - set(state_dims))
Expand Down

0 comments on commit e3b1f2d

Please sign in to comment.