Vectorized Multi-Dimensional Matrix Multiplication

버전 1.2.0.0 (2.2 KB) 작성자: Darin Koblick
Take Any N-D Matrix and Multiply it by another N-D Matrix Without a For-Loop
다운로드 수: 770
업데이트 날짜: 2017/7/7

라이선스 보기

If you want to multiply multi-dimensional matrices together without having to write a for-loop to cycle through each additional dimension beyond two, this routine is for you. Not a single for-loop was used in the development of this routine. Consequently, you should see a significant runtime improvement when using the multi-dimensional matrix multiply operations contained in this code.
mntimes will support 2-D matrix multiplication much like the built-in mtimes.m routine (so you can overload it if desired), it will support 3-D matrix multiplication, 4-D multiplication, and so on (until you run out of system memory). Matrices don't have to be the same size (i.e. 3x3 * 3x3) they can be 1x3 * 3x1, 1x3 * 3x3, 3x3 * 3x1, the choices are unlimited as long as it is a valid 2-D operation. If you are sure to identify which dimension corresponds to a row, and which to a column there shouldn't be a N-D matrix case this code can't handle.
Example Function call:
z = mntimes(x,y,xrowdim,xcoldim,yrowdim,ycoldim);
Input List:
x - N-D input matrix
y - N-D input matrix
xrowdim - row dimension specifier for x
xcoldim - column dimension specifier for x
yrowdim - row dimension specifier for y
ycoldim - column dimension specifier for y
Output List:
z - N-D output matrix (resulting product of the z = x*y operation)

인용 양식

Darin Koblick (2024). Vectorized Multi-Dimensional Matrix Multiplication (https://www.mathworks.com/matlabcentral/fileexchange/47092-vectorized-multi-dimensional-matrix-multiplication), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2012a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Loops and Conditional Statements에 대해 자세히 알아보기
도움

줌: mmDerivative(t,y)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

*
Corrected bug which would not allow for transposing matricies when rowDim and colDim were swapped. This version was also regression tested.
Corrected routine to increase stability when dealing with higher dimensionality.

1.1.0.0

Updated last step on re-assembling the N-D matrix to ensure singleton dimension was preserved when set to one.

1.0.0.0