Open ikkoham opened 1 month ago
Workaround:
def reverse_endian(spin: cudaq.SpinOperator) -> cudaq.SpinOperator:
return sum(
term.get_coefficient() * SpinOperator.from_word(term.to_string(False)[::-1])
for term in spin
)
print(state @ reverse_endian(observable).to_matrix() @ state)
I think the endian of observable.to_matrix()
is wrong. [should be confirmed]
Required prerequisites
Describe the bug
Endian is inconsistent between State and SpinOperator.to_matrix.
Steps to reproduce the bug
0.9999999403953552
0j
Expected behavior
These two examples should return the same result. In my understanding, CUDA-Q is big-endian, so observe's behavior is correct.
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
Suggestions
No response