(x1, x2, e)
| 100 | # between vector and scalar types for our purposes here |
| 101 | |
| 102 | def equalWithAbsError(x1, x2, e): |
| 103 | if hasattr(x1, '__len__') and hasattr(x1, '__getitem__') and hasattr(x2, '__len__') and hasattr(x2, '__getitem__'): |
| 104 | assert(len(x1) == len(x2)) |
| 105 | for i in range(0, len(x1)): |
| 106 | if not equalWithAbsErrorScalar(x1[i], x2[i], e): |
| 107 | return False |
| 108 | return True |
| 109 | else: |
| 110 | return equalWithAbsErrorScalar(x1, x2, e) |
| 111 | |
| 112 | def equalWithRelErrorScalar(x1, x2, e): |
| 113 | return abs(x1 - x2) <= e * abs(x1) |
no test coverage detected