In general, matrices do not need to be square in order to compute their product... rather in computing A*B, the number of columns in matrix A must be equal to the number of rows in matrix B. Regardless...
We can think of each matrix as being composed of row and column vectors. Then, each entry [i,j] in the product matrix is the result of a dot product of a certain combination of these row/column vectors. We can denote the row vectors in matrix A as row[1] ... row[n] and the column vectors in matrix B as col[1] ... col[n].
Then, element [i,j] in the resultant product matrix would in fact be the result of the dot product <row, col[j]> , for 1<= i,j <= n
So the question is... how do you extract the column and row vectors using your particular representation of a matrix?