I have two matrices A, B with the same dimension. I want to perform element-wise matrix multiplication. So, I iterate two for loops and perform element-wise multiplication.
for (int i = 0; i < length; i++){
for(int j = 0; j < width; j++){
ans[i][j] = A[i][j] * B[i][j] ;
}
}
but this is slow if the matrix size is huge (million elements or more). Is there any way to improve or speedup this process? How to do this?