Matrix Multiplication Utility

 

This page contains a routine that computes the product of two matrices: [A] [B]   =   [C].
The maximum size of [A] and [B] is 12 X 12, and the elements of each are assumed to be real.



Consider the matrices [A] and [B]:

        a11   a12   a13   a14   a15
[A]   =   a21   a22   a23   a24   a25
        a31   a32   a33   a34   a35

        b11   b12
        b21   b22
[B]   =   b31   b32
        b41   b42
        b51   b52

The product of these two matrices, [A] [B]   =   [C], is computed by multiplying the columns of [B] by the rows of [A]. For example,

c11   =   a11*b11 + a12*b21 + a13*b31 + a14*b41 + a15*b51
c12   =   a11*b12 + a12*b22 + a13*b32 + a14*b42 + a15*b52

and so on . . .

        c11   c12
[C]   =   c21   c22
        c31   c32

If [A] is an M X N matrix (M rows, N columns), and [B] is an N X P matrix (N rows, P columns), the product of these matrices, [A] [B]   =   [C], is a matrix of size M X P (M rows, P columns).

In fact, it is important to note: If the number of columns of [A] does not equal the number of rows of [B], the multiplication of these two matrices cannot proceed. For example, if the order of these matrices were reversed, [B] [A], the multiplication could not be done.


HOW TO USE THIS UTILITY

(i) The first four entries should be the dimensions of the [A] and [B] matrices: M, N, N, and P (remember, none of these values can be greater than 12).

(ii) The next M x N entries should be the coefficients of the [A] Matrix.
The coefficients should be entered in the following order:
a11, a12, a13, . . .
a21, a22, a23, . . .
etc.

(iii) The next N x P entries should be the coefficients of the [B] Matrix.
The coefficients should be entered in the following order:
b11, b12, b13, . . .
b21, b22, b23, . . .
etc.

Do not enter commas, periods, brackets, etc. Also note that numbers in scientific notation are NOT recognized.

For example, say we want to multiply matrices with the dimensions of the sample matrices presented above.
Data input to the box should have the following format:

3   5   5   2    
a11   a12   a13   a14   a15
a21   a22   a23   a24   a25
a31   a32   a33   a34   a35
b11   b12            
b21   b22            
b31   b32            
b41   b42            
b51   b52            


Once all the data has been entered, click the Multiply button, and the product matrix, [C], will be computed.

 

Matrix Multiplication Program - C++ Source Code

Return to Math Functions Page

AKiTi.ca Home