I want to do the tensor product of two arrays A and B, of size L x M, and reshape the result AB so that its size is L^2 x M^2. To me, the easiest way to do it is with this code
abj=0
do aj=1,M
do bj=1,M
 abj=abj+1   
 abi=0 
 do ai=1,L
 do bi=1,L
    abi=abi+1
    AB(abi,abj)=A(ai,aj)*B(bi,bj) 
 end do
 end do
end do
end do
Is there a more efficient way to accomplish the same task?
EDIT
Two clarifications
- Using BLAS/LAPACK is totally fine 
- Typically, L and M are of the order of hundreds 
 
    