-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
32 lines (28 loc) · 819 Bytes
/
plot.py
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
import matplotlib.pyplot as plt
import numpy as np
from struct import pack, unpack
def load_vector_fp(f):
result = []
length = unpack('>q', f.read(8))[0]
if 'calls' not in dir(load_vector_fp):
load_vector_fp.calls = 1
print(length, load_vector_fp.calls)
load_vector_fp.calls += 1
for i in range(length):
result.append(unpack('>d', f.read(8))[0])
return result
def load_matrix(filename):
result = []
f = open(filename, 'rb')
row_count = unpack('>q', f.read(8))[0]
col_count = unpack('>q', f.read(8))[0]
print(row_count, col_count);
for i in range(row_count):
row = load_vector_fp(f)
result.append(row)
f.close()
return result
A = load_matrix('result')
plt.imshow(A, origin='lower')
plt.grid(True)
plt.show()