tensorproduct - Multiplication of multidimensional arrays
Implementation of Einstein summation convention for multidimensional matlab arrays, where repeated indices sum over.
Supports multiple:
- Outer products
- Inner products
- Singleton dimensions
- Pages
Example:
A = rand(5, 1,4,8); B = rand(4,10,5 ); R = tensorproduct('jzgi',A,'gxki',B,'kjg');
Outer: 'i','j', Inner: 'k', Page: 'g', Singleton: 'x','z', size(R) = [10,1,5,8].
Inputs:
- ind_R : string with indices of the output
- A : (non-empty) (multidimensional) matlab array
- ind_A : string with indices of array A
- B : (non-empty) (multidimensional) matlab array
- ind_B : string with indices of array B
Version compatibility: This implementation makes use of Matlab built-in function pagemtimes,
introduced in Matlab version R2020b. To make use of this implementation in previous Matlab releases, comment/uncomment few lines in the body of tensorproduct_core, as specified in the routine.
The performance of tensorproduct can be assessed by calling the function tensorproduct_benchmark.
Cite As
David Codony (2023). tensorproduct - Multiplication of multidimensional arrays (https://www.mathworks.com/matlabcentral/fileexchange/90586-tensorproduct-multiplication-of-multidimensional-arrays), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.