Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Contract a tensor train (TT) of low-rank cores back into the dense multidimensional array it represents
ResourceFunction["TensorTrainContract"][{A1,A2…,An}] contracts the tensor train formed by the rank-3 cores list {A1,A2…,An} back into the dense array it represents. |
Decompose a tensor and contract it back to recover the original array:
| In[1]:= |
| Out[2]= | ![]() |
| In[3]:= |
| In[4]:= |
| Out[5]= | ![]() |
The original and the reconstructed tensors are exactly equal up to floating-point error:
| In[6]:= |
| Out[6]= |
Because contraction works on any valid train, you can decompose with a capped bond dimension and contract the result to obtain a low-rank approximation of the original tensor. The difference is the truncation error:
| In[7]:= | ![]() |
| Out[4]= |
Cores whose adjacent bond dimensions do not match cannot be contracted (here 3 ≠ 4):
| In[8]:= |
| Out[8]= |
The first and last cores must have boundary bond dimension 1:
| In[9]:= |
| Out[9]= |
Reconstruct a non-separable pattern from tensor trains of increasing bond dimension to watch a low-rank approximation sharpen into the exact array:
| In[10]:= | ![]() |
| Out[6]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License