-
Notifications
You must be signed in to change notification settings - Fork 174
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
Proliferating matrix elements in LocalOperator
s
#1504
Comments
Hmm.. is this a bug? In [34]: (Sz@Sx).operators[1]
Out[34]:
array([[ 0., 1., 1., 0.],
[ 1., 0., 0., -1.],
[ 1., 0., 0., -1.],
[ 0., -1., -1., -0.]])
As for conflating matrix terms... What matrix terms would you conflate? |
I've had a quick look at
Would this be slower than the current code under numba? |
Sx_i @ Sz_j produce the same connections for every value of j, because every Sz is diagonal. These could be aggregated
What do you mean? |
I would expect that
PauliString supports products of PauliStrings, so if you write Sx and Sz as PauliStrings (simply pass it in
You can still write those operators as "Sx +1j Sy" but indeed, it won't be efficient.
This code is quite old, but the reason we do that is to avoid duplicating the diagonal term on every term of the sum as we do for the off diagonal terms.
That's a good idea actually! I would be curious to see this implemented. |
This is fine, it just combines Sx_i @ Sz_j and Sx_j @ Sz_i into the same matrix.
Yep, that's true.
Actually, it seems that the zero matrix elements of "Sx + 1j Sy" get eliminated, which is nice. I think this solves my immediate issue.
I could give this a go when I have time. I imagine constructing the connected matrix elements is the cheapest part of calculating expectation values, so even if this is a bit slower, it might be better for code readability. |
Is this a bug then? |
No |
It is true though that |
I have been trying to compute the expectation values of
LocalOperator
s of the formSx @ Sz
, whereSx
andSz
are linear combinations of Pauli X and Z operators acting on all N lattice sites.Sx
connects each element of the Hilbert space to N others, andSz
is diagonal, both of these work out with the output ofget_conn
. However, their product ends up having N^2 non-unique connections:and the same for
Sx@Sz
.Is there a way to force
LocalOperator
to aggregate these matrix elements? I imagine something like this must be in place for the purely diagonal operators already...The text was updated successfully, but these errors were encountered: