Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pygsti/modelmembers/operations/linearop.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pygsti.baseobjs.opcalc import bulk_eval_compact_polynomials_complex as _bulk_eval_compact_polynomials_complex
from pygsti.modelmembers import modelmember as _modelmember
from pygsti.tools import optools as _ot
from pygsti.tools import matrixtools as _mt
from pygsti import SpaceT

from typing import Any
Expand Down Expand Up @@ -416,11 +417,14 @@ def frobeniusdist_squared(self, other_op, transform=None, inv_transform=None) ->
float
"""
self_mx = self.to_dense("minimal")
other_mx = other_op.to_dense("minimal")
if transform is not None:
self_mx = self_mx @ transform
if isinstance(inv_transform, _mt.IdentityOperator):
other_mx = other_mx @ transform
if inv_transform is not None:
self_mx = inv_transform @ self_mx
return _ot.frobeniusdist_squared(self_mx, other_op.to_dense("minimal"))
return _ot.frobeniusdist_squared(self_mx, other_mx)


def frobeniusdist(self, other_op, transform=None, inv_transform=None):
Expand Down Expand Up @@ -506,9 +510,8 @@ def jtracedist(self, other_op, transform=None, inv_transform=None):
if transform is None and inv_transform is None:
return _ot.jtracedist(self.to_dense("minimal"), other_op.to_dense("minimal"))
else:
return _ot.jtracedist(_np.dot(
inv_transform, _np.dot(self.to_dense("minimal"), transform)),
other_op.to_dense("minimal"))
arg = inv_transform @ self.to_dense("minimal") @ transform
return _ot.jtracedist(arg, other_op.to_dense("minimal"))

def diamonddist(self, other_op, transform=None, inv_transform=None):
"""
Expand All @@ -535,9 +538,8 @@ def diamonddist(self, other_op, transform=None, inv_transform=None):
if transform is None and inv_transform is None:
return _ot.diamonddist(self.to_dense("minimal"), other_op.to_dense("minimal"))
else:
return _ot.diamonddist(_np.dot(
inv_transform, _np.dot(self.to_dense("minimal"), transform)),
other_op.to_dense("minimal"))
arg = arg = inv_transform @ self.to_dense("minimal") @ transform
return _ot.diamonddist(arg, other_op.to_dense("minimal"))

def transform_inplace(self, s):
"""
Expand Down
6 changes: 5 additions & 1 deletion pygsti/modelmembers/povms/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from pygsti.modelmembers import modelmember as _modelmember
from pygsti.tools import optools as _ot
from pygsti.tools import matrixtools as _mt
from pygsti.baseobjs.opcalc import bulk_eval_compact_polynomials_complex as _bulk_eval_compact_polynomials_complex

from typing import Any
Expand Down Expand Up @@ -142,9 +143,12 @@ def frobeniusdist_squared(self, other_spam_vec, transform=None, inv_transform=No
float
"""
vec = self.to_dense()
other_vec = other_spam_vec.to_dense()
if transform is not None:
vec = transform.T @ vec
return _ot.frobeniusdist_squared(vec, other_spam_vec.to_dense())
if isinstance(inv_transform, _mt.IdentityOperator):
other_vec = transform.T @ other_vec
return _ot.frobeniusdist_squared(vec, other_vec)

def residuals(self, other_spam_vec, transform=None, inv_transform=None):
"""
Expand Down
Loading