Replies: 1 comment 3 replies
-
|
That's a good question. One way to do that is by contracting with a delta tensor but honestly our delta tensor contractions are not that great right now (I think some patterns are ok but others we just fall back to dense since they are hard to implement in an optimized way), and I think the best way to do some delta contractions may be something like the loop you wrote anyway (though implemented in a better way than onehot, which as you said it not designed in the best way right now). Do you know how that operation is actually handled in einsum internally? Are the tensors dense? If so you could manually do a slice of It doesn't help you right now, but note that in our ongoing rewrite of ITensors.jl (ITensorBase.jl and the surrounding packages) we will provide general slicing of ITensors so you'll be able to write something like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose I have a calculation such as,
One example might be that I obtain the eigenvectors
Vby diagonalising some other ITensor, and want the expectation values with respect to the operator(B * C).Is there a way to calculate this more efficiently than computing the intermediate matrix
dag(V') * B * C * Vand taking the diagonal?For example, in numpy, one could do
np.einsum(V.conj(), B, C, V, "ji,jk,kl,li->i"). However in ITensors, the best option seems to be looping over the eigen-index usingonehot(which surprisingly makes a dense ITensor), e.g.but this is actually quite a bit slower (10x for moderately sized V, e.g. about 2000 * 2000), with many more total allocations.
This makes me think there must be a more efficient way, especially as it must be a fairly common use pattern, but I haven't been able to find one by digging through the documentation. Is there one I've missed? Any help much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions