New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add operation to trace oper-ket without reshaping #2126
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I don't see a way to do this without adjusting the data layer somehow, since it doesn't have the information to decide whether a matrix is a stacked operator or not.
What happens in one wants to trace the adjoint of an oper_ket? I.e. an oper_bra? Or does QuTiP not really support that?
@@ -225,12 +225,12 @@ def reset(self, hard=False): | |||
|
|||
def _prob_func(self, state): | |||
if self.issuper: | |||
return _data.norm.trace(unstack_columns(state)) | |||
return _data.trace_oper_ket(state).real |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should trace_oper_ket
not be exposed under data.norm
the way the other norm operations are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have both data.trace
and data.norm.trace
.
data.norm.trace
is defined as tr(sqrt(A @ A.adjoint()))
...
For dm, they give the same result and the normal trace is faster, so I should have used that one from the start.
Not a fan of having 2 functions with the same name, I sometime get confused and use the wrong one.
But this one should not be in data.norm
.
@hodgestar, is there anything else you want me to fix in this PR? ps. Right now, to trace oper-bra, you would need to get it's adjoint first, use this or unstack then trace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@Ericgig Apologies for the delay. I wanted to go look at |
Description
Add and operation to compute the trace of column stacked operators without reshaping them.
The reshape would otherwise do a temporary copy of the data.
Another addition to improve stochastic solvers timings.