Page-wise matrix multiplication in MATLAB
Last Updated :
04 Jul, 2021
Page-wise matrix multiplication is multiplying two N-D arrays along each dimension or page of two arrays. Matlab allows users to calculate page-wise multiplication using pagemtimes().
Different syntax of pagemtimes() method are:
- Z = pagemtimes(X,Y)
- Z = pagemtimes(X,transpX,Y,transpY)
Z = pagemtimes(X,Y)
- It returns the page-wise multiplication of N-D arrays X and Y. Each page product is given by Z(: , : , i) = X(: , : , i)*Y(: , : , i).
- If X and Y are N-D matrices then the first 2 dimensions of X and Y should be compatible with matrix multiplication.
Example:
Matlab
X = randi([1 6],3,3,3);
Y = randi([1 6],3,2,3);
M = pagemtimes(X,Y);
disp( "Page-wise multiplication :" );
disp(M);
|
Output :
If X is a matrix and Y N-D array, then Z(: , : , i) = X*Y(: , : , I). Dimensions of X should be compatible with the first 2 dimensions of Y.
Example:
Matlab
X = randi([1 6],2,3);
Y = randi([1 6],3,3,3);
M = pagemtimes(X,Y);
disp( "Page-wise multiplication :" );
disp(M);
|
Output :
Z = pagemtimes(X, transpX, Y, transpY)
- It returns the page-wise multiplication of X and Y by considering transpositions of X and Y as transpX and transpY.
- If transp = ‘none’, then it doesn’t change the transposition of the array
- If transp = ‘transpose’, then it transposes every page of the array.
- If transp = ‘ctranspose’, then it applies complex conjugate transpose on every page of the array.
Example:
Matlab
X = randi([1 6],3,2,3);
Y = randi([1 6],3,2,3);
M = pagemtimes(X, 'transpose' ,Y, 'none' );
disp( "Page-wise multiplication :" );
disp(M);
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...