please write a program that reads two matrices and determines their product matr
ID: 673294 • Letter: P
Question
please write a program that reads two matrices and determines their product matrix.
Example :
M1 =
1 2 3
3 2 1
M2 =
1 2 3 4 5
2 5 3 1 4
5 4 3 2 1
equals to:
P =
20 24 18 12 16
12 20 18 16 24
These are the requirements:
Implement the following functions:
Please use only the following functions:
float *allocate(int rows, int cols);
void readm(float *matrix, int rows, int cols);
void writem(float *matrix, int rows, int cols);
void mulmatrix(float *matrix1, int rows1, int cols1, float *matrix2, int cols2, float *product);
Input the row size and column size for matrix M1 and M2
Input the matrix
Validate the product matrix dimension
Validate the memory allocation
Please use this for the multiplication function:
void mulmatrix(float *matrix1, int rows1, int cols1, float *matrix2, int cols2, float *product)
{int i, j, k;
for (i = 0; ________________ )
for(j=0;________________ )
{
for(k = 0, *product = 0;________________________)
/* p[i,j] += m1[i,k] * m2[k j]*/
*product += matrix1[_____________] * matrix2[_________________];
product++;
}
}