-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparision.py
More file actions
68 lines (63 loc) · 1.83 KB
/
Comparision.py
File metadata and controls
68 lines (63 loc) · 1.83 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
plt.rcParams["figure.figsize"] = (10,6)
fox_data = []
cannon_data = []
simple_matrix_data = []
order = []
i = 4
with open('fox_data.txt','r') as file:
for line in file:
j = 0
sum = 0
for word in line.split():
j+=1
sum+=float(word)
if(j==4):
fox_data.append(sum/j)
order.append(i)
i+=4
j=0
sum = 0
file.close()
with open('cannon_data.txt','r') as file:
for line in file:
j = 0
sum = 0
for word in line.split():
j+=1
sum+=float(word)
if(j==4):
cannon_data.append(sum/j)
j=0
sum = 0
file.close()
with open('simple_matrix_data.txt','r') as file:
for line in file:
for word in line.split():
simple_matrix_data.append(float(word))
file.close()
strassen_data = []
oreder = []
i = 4
with open('strassen_data.txt','r') as file:
for line in file:
for word in line.split():
strassen_data.append(float(word))
oreder.append(i)
i+=4
file.close()
plt.plot(order,fox_data,'r')
plt.plot(order,cannon_data,'b')
plt.plot(order,simple_matrix_data,'g')
plt.plot(oreder,strassen_data,'y')
plt.title("Execution Time for Fox and Cannon")
plt.ylabel("Time (in sec)")
plt.xlabel("Order of Matrix (n,n)")
red_patch = mpatches.Patch(color='red', label='Fox Algorithm')
blue_patch = mpatches.Patch(color='blue', label='Cannon Algorithm')
green_patch = mpatches.Patch(color='green', label='Normal Multiplication')
yellow_patch = mpatches.Patch(color='yellow', label='Stression Algorithm')
plt.legend(handles=[green_patch, yellow_patch, red_patch, blue_patch])
plt.show()