input: other vector assumes: other vector has the same size returns a new vector that represents the difference.
(self, other: Vector)
| 83 | raise Exception("must have the same size") |
| 84 | |
| 85 | def __sub__(self, other: Vector) -> Vector: |
| 86 | """ |
| 87 | input: other vector |
| 88 | assumes: other vector has the same size |
| 89 | returns a new vector that represents the difference. |
| 90 | """ |
| 91 | size = len(self) |
| 92 | if size == len(other): |
| 93 | result = [self.__components[i] - other.component(i) for i in range(size)] |
| 94 | return Vector(result) |
| 95 | else: # error case |
| 96 | raise Exception("must have the same size") |
| 97 | |
| 98 | def __eq__(self, other: object) -> bool: |
| 99 | """ |