Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Tensor contraction over more than one index' topicStudent Support Forum > General > "Tensor contraction over more than one index"

Next Comment >Help | Reply To Topic
Author Comment/Response
Ben
03/22/12 5:34pm

Hello,

I work with tensor-networks and often have to contract two tensors. Usually they are only connected by one index and can be contracted using ‘Dot’.
But this doesn’t work if the network has loops. Consider this situation:

A-C
| |
B-D

A, B, C and D are supposed to represent tensors. I contract A and B to some tensor E. In the next step I contract C-D to tensor F. The network looks like:

E=F

E and F are connected by two indices. I can apply ‘Dot’ as well and obtain a Tensor G, but this contracts only on index. So my resulting network looks like this:

+-G-+
| |
+---+

I believe this is trace[G]. In a more general case two tensors may have N equal indices. This means I have to take the trace N-1 times.

I guess this should work in general, but I fear it is not very efficient and unfortunately efficiency is important in this project. I'm also not sure how to implement this in Mathematica.

Actually I'm looking for some function F[A,B,num] which returns a fully contracted tensor over all indices. num is the number of equal indices. I assume that tensor A has an index ordering like this {...,a,b,c,d,i1,i2,i3} and B {i3,i2,i1,e,f,...}, so num=3 in this case. If A is of rank k and B of rank n the resulting tensor is of rank k+n - 2*num.

I'm not used to Mathematica. I would be very thankful if someone post code for F[A,B,num]. Also versions that are not the most efficient are very welcome.

Thanks a lot.
Ben


URL: ,

Subject (listing for 'Tensor contraction over more than one index')
Author Date Posted
Tensor contraction over more than one index Ben 03/22/12 5:34pm
Re: Tensor contraction over more than one index Ben 03/23/12 02:53am
Re: Re: Tensor contraction over more than one i... Forum Modera... 03/23/12 08:53am
Re: Re: Re: Tensor contraction over more than o... Ben 03/23/12 4:00pm
Next Comment >Help | Reply To Topic