My question is similar to this one Multiply a 3D matrix with a 2D matrix. However, I'm coding in Fortran.
Say, if I have a RxSxT matrix A and an SxU matrix B, where R,S,T,U are integers, and I want to multiply A(:,:,0) with B. How can I do this with matmul? When I do something like
C(:,:,0) = matmul(A(:,:,0),B)
The compiler (gfortran) gives:
Warning:Array reference at (1) is out of bounds (0 < 1) in dimension 3
f951: internal compiler error: Segmentation fault
Is there a way around this? Thanks.
EDIT: I should add that I'm actually transposing the second matrix. Say, A a RxSxT matrix and B a UxS matrix. Then
C(:,:,0) = matmul(B,transpose(A(:,:,0))
That transpose might be part of the problem. Does it convert A(i,j,k) to A(k,i,j)?