Vectorize many matrix multiplications using the third dimension
12 次查看(过去 30 天)
显示 更早的评论
I have collections of matrices, say two collections A and B of n matrices each, implemented as cell arrays. I would like to produce a third collection C by multiplying the matrices from the first two collections:
C = cell(1, n);
for i = 1:n
C{i} = A{i} * B{i};
end
Is it possible instead to use 3D arrays to vectorize this operation? Suppose that A and B are m x m x n arrays, where the ith page (where i ranges from 1 to n) of the arrays are the same as the ith cell in the previous example. Then, is it possible to write something that would look like
C = A * B;
to perform the multiplications in a way that is transparent for the pages of A and B?
0 个评论
采纳的回答
James Tursa
2019-4-17
See this link:
And see these FEX submissions:
MTIMESX: (mex, needs C-compiler)
MMX: (mex, needs C-compiler)
MULTIPROD: (M-code)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!