forked from mayanks0ni/matrix-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultMatrix.c
More file actions
32 lines (30 loc) · 1022 Bytes
/
multMatrix.c
File metadata and controls
32 lines (30 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <time.h>
#include "./headers/operations.h"
#include "./operations/multMatrix.c"
#include "./util/allocateMatrix.c"
int main()
{
int n = 500;
float **toM1 = allocateMatrix(n, n);
float **toM2 = allocateMatrix(n, n);
;
float **rm = allocateMatrix(n, n);
;
FILE *file1 = fopen("./sample matrix/matrix_500A.txt", "r");
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
fscanf(file1, "%d", &toM1[i][j]);
FILE *file2 = fopen("./sample matrix/matrix_500B.txt", "r");
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
fscanf(file2, "%d", &toM2[i][j]);
clock_t start = clock();
multMatrix(n, n, n, toM1, toM2, rm);
clock_t end = clock();
double time_taken = ((double)(end - start));
FILE *toWrite = fopen("timeTakenC.txt", "a");
fprintf(toWrite, "\nTime taken for 500x500 Matrix in C: %.4f seconds\n", time_taken);
fclose(file1);
fclose(file2);
}