Skip to content

Commit

Permalink
add test density_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles MOUSSA committed Nov 11, 2024
1 parent 5062c1e commit 9680d56
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyqtorch/hamiltonians/evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
finitediff,
is_diag,
is_parametric,
DensityMatrix,
density_mat,
)

BATCH_DIM = 2
Expand Down Expand Up @@ -439,6 +441,8 @@ def Ht(t: torch.Tensor) -> torch.Tensor:

return state.reshape([2] * n_qubits + [batch_size])
else:
if not isinstance(state, DensityMatrix):
state = density_mat(state)
sol = mesolve(
Ht,
torch.flatten(state, start_dim=0, end_dim=-2),
Expand Down

0 comments on commit 9680d56

Please sign in to comment.