how to multiply 2 matrices

This is a discussion on how to multiply 2 matrices within the C Programming forums, part of the General Programming Boards category; Hi all,
I've to multiply 2 matrices together, As you know, for example , an ( A by B matrix ...

how to multiply 2 matrices

Hi all,
I've to multiply 2 matrices together, As you know, for example , an ( A by B matrix multiplied by a C by D matrix will return a A by D matrix. Condition is that B = C . How do we define each matrix? maybe an A by B matrix is like this: A by B matrix: ( 1 3 2 )
( 2 2 3 ). So this 2( rows) by 3( columns) matrix is going to be multiplied by another matrix.

What I can think of so far is :

Start with the first row of the first matrix . The first element of the first row is multiplied by the first element of the first column of the second matrix, second to second.. third to third.. and the total sum stored will be the addition of these results. They'll be stored in the First row and first column of the answer matrix. Then I carry on till i get the answer. Anyone have any ideas on how to do this, especially when the user should be able to define any matrix he likes( up to a certain limit).

> maybe an A by B matrix is like this: A by B matrix: ( 1 3 2 )
( 2 2 3 ).
This would be

Code:

int matrix_ab[2][3] = {
{ 1, 3, 2 },
{ 2, 2, 3 },
};

> especially when the user should be able to define any matrix he likes( up to a certain limit)
Well if the limit is say 10, then
int matrix_ab[10][10];
int matrix_cd[10][10];
int matrix_result[10][10];