Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compare_floats(f1, f2):
- '''
- compare two floats
- '''
- epsilon = 1e-6
- if(math.fabs(f1 - f2) > epsilon):
- return False
- else:
- return True
- def matrix_compare(matrixA, matrixB):
- '''
- compare two matrices and returns True or False
- '''
- if (matrixA.col_size != matrixB.col_size) or (matrixA.row_size != matrixB.row_size):
- return False
- rows = matrixA.row_size
- cols = matrixA.col_size
- # iterate over the matrix
- for row in range(rows):
- for col in range(cols):
- if compare_floats(matrixA[row][col], matrixB[row][col]) == False:
- return False
- return True
Add Comment
Please, Sign In to add comment