Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- eps = 1e-9
- def diff(a, b):
- if a.shape != b.shape:
- raise Exception("Incompatible Matrices!")
- c = abs(a - b)
- return c.max() > eps
- if __name__ == "__main__":
- a = [[4, 3, 2], [1, 9, 8]]
- a = np.mat(a)
- b = [[12, 34, 19], [-9, 0, 1]]
- b = np.mat(b)
- if diff(a, b):
- print("OK!")
- else:
- print("NOT OK!")
Add Comment
Please, Sign In to add comment