Expected Value of Absolute Value Hamiltonians #754
Unanswered
ComputationalBasis
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
Hi, sorry we missed this. I'd assume that block_to_tensor, diagonalize, then calculate should work, so I'm a bit confused. Is the issue a dimension mismatch? we return our states batched in PyQTorch, so probably you have a N x 2^n x 2^n tensor coming out. where N is the batch size - also if the batch size is 1. So you can probably do something like Hmat = block_to_tensor(H).squeeze(0).to(torch.complex128)
evals, U = torch.linalg.eigh(Hmat)
absH = U @ torch.diag(torch.abs(evals)).to(Hmat.dtype) @ U.conj().T
or loop or slice through the batch when doing the eigen decomposition. (do sanity check my maths there, I didn't run it) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello again everyone,
Given a Hamiltonian (mine only depends on number operators), I was wondering if there is a qadence function or a simple way of calculating its absolute value, to later compute the expected value. Basically, given
H, the thing I want to compute is<|H|>.I was trying usingblock_to_tensorbut everything kept giving me errors.Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions