implements the matrix-subtraction.
(self, other)
| 369 | raise Exception("matrix must have the same dimension!") |
| 370 | |
| 371 | def __sub__(self, other): |
| 372 | """ |
| 373 | implements the matrix-subtraction. |
| 374 | """ |
| 375 | if self.__width == other.width() and self.__height == other.height(): |
| 376 | matrix = [] |
| 377 | for i in range(self.__height): |
| 378 | row = [] |
| 379 | for j in range(self.__width): |
| 380 | row.append(self.__matrix[i][j] - other.component(i, j)) |
| 381 | matrix.append(row) |
| 382 | return Matrix(matrix, self.__width, self.__height) |
| 383 | else: |
| 384 | raise Exception("matrix must have the same dimension!") |
| 385 | |
| 386 | def __eq__(self, other): |
| 387 | """ |