-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
32 lines (26 loc) · 943 Bytes
/
check.py
File metadata and controls
32 lines (26 loc) · 943 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
import numpy as np
def read_matrix_from_file(filename):
matrix = []
with open(filename, 'r') as file:
for line in file:
row = list(map(int, line.strip().split()))
matrix.append(row)
return np.array(matrix) # Convert to NumPy array
def check_transpose(input_matrix, output_matrix):
transpose = np.transpose(input_matrix)
return np.array_equal(transpose, output_matrix) # Use np.array_equal to compare arrays
def main():
# Read matrices from files
input_matrix = read_matrix_from_file("in.txt")
# print("Input Matrix:")
# print(input_matrix)
output_matrix = read_matrix_from_file("out.txt")
# print("Output Matrix:")
# print(output_matrix)
# Check if transpose is correct
if check_transpose(input_matrix, output_matrix):
print("Transpose is correct.")
else:
print("Transpose is incorrect.")
if __name__ == "__main__":
main()