How to use the expect function to compute the expectation values of operators with complex entries

Hi I have a 1D quantum chain with an ising variable and a six state clock model on each side,Basically 12 physical dimensions on each site. I want to compute the expectation values or say correlation matrix of custom operators that have complex entries an example is -

‘’‘[1 0 0 0 0 0 0 0 0 0 0 0
0 (1/2 + imsqrt(3)/2) 0 0 0 0 0 0 0 0 0 0
0 0 (-1/2 + im
sqrt(3)/2) 0 0 0 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0 0 0 0
0 0 0 0 (-1/2 - imsqrt(3)/2) 0 0 0 0 0 0 0
0 0 0 0 0 (1/2 - im
sqrt(3)/2) 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 (1/2 + imsqrt(3)/2) 0 0 0 0
0 0 0 0 0 0 0 0 (-1/2 + im
sqrt(3)/2) 0 0 0
0 0 0 0 0 0 0 0 0 -1 0 0
0 0 0 0 0 0 0 0 0 0 (-1/2 - imsqrt(3)/2) 0
0 0 0 0 0 0 0 0 0 0 0 (1/2 - im
sqrt(3)/2)]
‘’’
For this if I use the predefined expect function or corretaion_matrix function due to there being complex entries in the matrix it is giving an error.
Is there a way that I modify the code such that the code works without doing things manually like using orthogonalize to change the orthogonality center and then taking the inner product or something like that.

Thanks for taking the time to answer this silly question by the way :slight_smile:

Hi @JayZoldyck, thanks for letting us know about this issue. It actually sounds like it could just be a bug in ITensor. Could you post a very minimal working example of the code and also the error message you are getting?

Maybe related to the bug reported here: [ITensors] [BUG] Can't measure complex operator on real MPS in expect · Issue #1019 · ITensor/ITensors.jl · GitHub. If so, a simple workaround for that bug would be to convert the state to be complex with the function complex(...), for example:

N = 10
s = siteinds("S=1/2", N)
psi = randomMPS(s; linkdims=4)
vals = expect(complex(psi), "Sy")