Error for basic ITensor contraction

Hi,

I’m getting an error in my code that wasn’t there before. It also shows up if I use example code, so I’m not sure if this is a bug from an updated version. The following code is from the ITensor website,

i = Index(2,“index_i”); j = Index(4,“index_j”); k = Index(3,“index_k”)

A = randomITensor(i,j)
B = randomITensor(j,k)
C = A * B # contract over Index j

A = randomITensor(i,i’)
B = randomITensor(i,i’')
C = A * B # contract over Index i

A = randomITensor(i)
B = randomITensor(j)
C = A * B # outer product of A and B, no contraction

A = randomITensor(i,j,k)
B = randomITensor(k,i,j)
C = A * B # inner product of A and B, all indices contracted.

If I run this after importing ITensor, I get the following error
no method matching to_shape(::Tuple{Index{Int64}, Index{Int64}}).

Any help would be greatly appreciated.

Thanks for posting this, but I don’t get any error when I run your code on my machine. Here’s the exact code that I ran (I personally am suspicious of running code in global scope so I put mine into a let...end block.)

using ITensors

let
  i = Index(2,"index_i"); j = Index(4,"index_j"); k = Index(3,"index_k")

  A = randomITensor(i,j)
  B = randomITensor(j,k)
  C = A * B # contract over Index j

  A = randomITensor(i,i')
  B = randomITensor(i,i'')
  C = A * B # contract over Index i

  A = randomITensor(i)
  B = randomITensor(j)
  C = A * B # outer product of A and B, no contraction

  A = randomITensor(i,j,k)
  B = randomITensor(k,i,j)
  C = A * B # inner product of A and B, all indices contracted.
  return
end

Can you please check that you are upgraded to the most recent version of ITensors.jl?

Hi,

Thanks for the reply! Yes, turns out it was sorted when I updated my ITensor.jl.

1 Like

Glad to hear it!