New answers tagged

2

I think the simplest way to handle the general case is to use TensorProduct and TensorContract, as follows: Take a rank 3 array for example, in dimension 100: In[1]:= A = RandomReal[{-1, 1}, {100, 100, 100}]; Construct a rank 12 array. Note the use of Inactive, to avoid TensorProduct constructing a large intermediate array: In[2]:= A4 = ...


2

I am illustrating my answer with a very short code. Rather, it is a long comment. The computational complexity of your two examples is cardinally different. In the first case you perform 7 matrix multiplications and perform a trace on the result. The last operation has a quadratic scaling. Therefore leading complexity is $7 N^3$, where $N$ is the matrix ...



Top 50 recent answers are included