Q. Show Matrix Multiplication Problem?
Let there be 2 matrices M1 and M2 of sizes a x b and b x c correspondingly. If we multiply M1 and M2 product matrix O will be of size a x c.
The values of elements which are stored in the matrix O are in proportion to the subsequent formula:
Oij = Summation x of (M1ix * M2xj) x=1 to b, where 1
Remember for multiplying a matrix M1 with other matrix M2 number of columns in M1 should be equal to number of rows in M2. The renowned matrix multiplication algorithm on sequential computers occupies O(n3) running time. For multiplication of two 2x2 matrices the algorithm needs 8 multiplication and 4 addition operations. One other algorithm known as Strassen algorithm has been worked out that requires 7 multiplication and 14 addition or subtraction operations. Time complexity of Strassen's algorithm is O(n2.81). The fundamental sequential algorithm is explained below:
Algorithm: Matrix Multiplication
Input// Two Matrices M1 and M2
For I=1 to n
For j=1 to n
{
Oij = 0;
For k=1 to n
Oij= Oij + M1ik * M2kj
End For
}
End For
End For