Skip to content

Commit

Permalink
Attempt to add cast to unitary for H-only LindbladErrorgen
Browse files Browse the repository at this point in the history
  • Loading branch information
sserita committed Jul 25, 2024
1 parent f643253 commit 01b9d3c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pygsti/modelmembers/operations/lindbladerrorgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,25 @@ def to_dense(self, on_space='minimal'):
numpy.ndarray
"""
if self._rep_type == 'lindblad errorgen':
assert(on_space in ('minimal', 'HilbertSchmidt'))
# assert(on_space in ('minimal', 'HilbertSchmidt'))
lnd_error_gen = sum([_np.tensordot(blk.block_data.flat, Lterm_superops, (0, 0)) for blk, (Lterm_superops, _)
in zip(self.coefficient_blocks, self.lindblad_term_superops_and_1norms)])

assert(_np.isclose(_np.linalg.norm(lnd_error_gen.imag), 0)), \
"Imaginary error gen norm: %g" % _np.linalg.norm(lnd_error_gen.imag)
return lnd_error_gen.real

superop = lnd_error_gen.real

if on_space == 'Hilbert' or (on_space == 'minimal' and self.evotype.minimal_space == 'Hilbert'):
# Attempt to cast down to unitary
try:
U = _ot.superop_to_unitary(lnd_error_gen.real, self.matrix_basis, True)
except ValueError as e:
raise ValueError("Could not convert to unitary. Check that only Hamiltonian errors are provided.") from e

return U

return superop

elif self._rep_type == 'sparse superop':
return self.to_sparse(on_space).toarray()
Expand Down

0 comments on commit 01b9d3c

Please sign in to comment.