Created
March 8, 2015 03:27
-
-
Save goyalankit/cebb790d8710523ffe3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define X_1 5 | |
#define Y_1 5 | |
#define X_2 5 | |
#define Y_2 5 | |
#define Z_1 5 | |
#define Z_2 5 | |
void mul() | |
{ | |
double m1[X_1][Y_1]; | |
double m2[Y_1][Y_2]; | |
double m3[Z_1][Z_2]; | |
int i,j,k; | |
// warm up the cache | |
for (i = 0; i < X_1; ++i) | |
{ | |
for (j = 0; j < Y_2; ++j) | |
{ | |
m1[i][j] = 1; | |
m2[i][j] = 3; | |
m3[i][j] = 0; | |
} | |
} | |
int sum=0; | |
for(i = 0; i < X_1; ++i) | |
{ | |
for (j = 0; j < Y_2; ++j) | |
{ | |
for (k = 0; k < Y_2; ++k) | |
{ | |
sum = sum + m1[i][k] * m2[k][j]; | |
} | |
m3[i][j] = sum; | |
sum=0; | |
} | |
} | |
#ifdef PRINT | |
for (i = 0; i < X_1; ++i) | |
{ | |
for (j = 0; j < Y_2; ++j) | |
{ | |
printf("%f\t", m3[i][j]); | |
} | |
printf("\n"); | |
} | |
#endif | |
} | |
int main(void) | |
{ | |
mul(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment