Skip to content

Tensor network contraction fails #156

Description

@mechapple

Hello,
I am trying to perform the following tensor contraction between tensors d,P,B,X.

  enum {I,J,K,L,M,N};  
  Tensor<double,4,4> d; Tensor<double,4,3> P; Tensor<double,4,4> B;  Tensor<double,4> X;
  d.random(); P.random(); B.random(); X.random();

The tensor contraction to be implemented is:

(1) The following fails in compilation.

auto dPBBXX2 = einsum<Index<K,M>,Index<L,N>,Index<K,I>,Index<L,J>,Index<I>,Index<J>>(d,P,B,B,X,X);

(2) However, the following code succeeds.

  auto dPB = einsum<Index<K,M>,Index<L,N>,Index<K,I>>(d,P,B);
  auto dPBB = einsum<Index<M,L,N,I>,Index<L,J>>(dPB,B);
  auto dPBBXX = einsum<Index<M,N,I,J>,Index<I>,Index<J>>(dPBB,X,X);
  print("my 2D array", dPBBXX);

Conceptually, they should be equivalent, and (1) should be the preferred way as per the wiki.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions