-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.py
More file actions
51 lines (40 loc) · 1.58 KB
/
verify.py
File metadata and controls
51 lines (40 loc) · 1.58 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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import os
def read_matrix(path, size):
df = pd.read_csv(path, header=None)
return df.values[:size, :size]
def verify_all():
print("🔍 Верификация результатов перемножения:\n")
A_full = read_matrix("matrices/matrix_A.csv", 1000)
B_full = read_matrix("matrices/matrix_B.csv", 1000)
for size in range(100, 1001, 100):
A = A_full[:size, :size]
B = B_full[:size, :size]
result_path = f"results/{size}x{size}/result.csv"
label = f"{size}x{size}".rjust(9)
if not os.path.exists(result_path):
print(f"📏 Размер: {label} | ⚠️ Файл отсутствует")
continue
C = read_matrix(result_path, size)
expected = A @ B
if np.allclose(expected, C, atol=1e-5):
print(f"📏 Размер: {label} | ✅ Вычисление корректно")
else:
diff = np.abs(expected - C)
print(f"📏 Размер: {label} | ❌ Ошибка: отклонение {np.max(diff):.6f}")
def plot():
df = pd.read_csv("results/benchmark.csv")
plt.figure(figsize=(10, 6))
plt.plot(df["Size"], df["Time_ms"], marker='o', linewidth=2)
plt.title("Время перемножения матриц")
plt.xlabel("Размер матрицы N×N")
plt.ylabel("Время (мс)")
plt.grid(True)
plt.tight_layout()
plt.savefig("results/benchmarkplot.png")
plt.show()
if __name__ == "__main__":
verify_all()
plot()