# Issue using eigen() in Julia

+1 vote

Hi,

I ran into what might be a bug with the eigendecomposition function eigen() in ITensors.jl. Depending on the order of the Indices in my ITensor, eigen() gives me an error or not. Here is a minimum working code that gives me an error:

using ITensors

i1 = Index(1); i2=Index(2); i3=Index(3);
T = randomITensor(i1', i2, i3, i2', i3', i1)
F = eigen(T) # ERROR: In eigen, indices must come in pairs with equal spaces.


(I am using eigen()'s default behavior that the primed indices are the "left" indices and the rest are the "right" indices.) Note that the order of Indices that I provide to T is important. For example, the code below does not produce an error:

using ITensors

i1 = Index(1); i2=Index(2); i3=Index(3);
T = randomITensor(i2, i3, i2', i3', i1', i1)
F = eigen(T) # no error


Any suggestions on how to avoid this issue or what could be going wrong?

commented by (70.1k points)
Hi Eli,
Thanks for the helpful bug report. After digging into it for a minute, it looks like an issue with an incorrectly written error check in that function (so not like a deep bug, but more like some code meant to check for correctness which is itself not correct).

For now a workaround could be to use the permute! function to put the primed indices in the same order as the unprimed ones (so like i1, i2, i3, i1', i2', i3').

Best,
Miles
commented by (70.1k points)
And of course we will work on fixing this!
commented by (130 points)
Hi Miles,

I see, thanks for looking into it! For my use-case, I could instead use the svd() function which worked correctly, but I will keep permute!() in mind when I use eigen() in the future. And I will keep an eye out for the future bug fix :) Thanks!

Best,
Eli