# Error for basic ITensor contraction

**URL:** <https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716>\
**Category:** ITensor Julia Questions\
**Created:** [March 21, 2023, 11:23am UTC](https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716 "2023-03-21T11:23:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidStrachan1](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/davidstrachan1/32/165_2.png) [@DavidStrachan1](https://itensor.discourse.group/u/DavidStrachan1)\
**Post date:** [March 21, 2023, 11:23am UTC](https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716/1 "2023-03-21T11:23:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [March 21, 2023, 3:43pm UTC](https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716/2 "2023-03-21T15:43:28Z")

</div>

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.)

```julia
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?

---

<div class="post-metadata">

**Author:** ![DavidStrachan1](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/davidstrachan1/32/165_2.png) [@DavidStrachan1](https://itensor.discourse.group/u/DavidStrachan1)\
**Post date:** [March 21, 2023, 3:57pm UTC](https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716/3 "2023-03-21T15:57:34Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [March 21, 2023, 4:08pm UTC](https://itensor.discourse.group/t/error-for-basic-itensor-contraction/716/4 "2023-03-21T16:08:41Z")

</div>

Glad to hear it!
