MCPcopy Index your code
hub / github.com/geekcomputers/Python / __sub__

Method __sub__

linear-algebra-python/src/lib.py:371–384  ·  view source on GitHub ↗

implements the matrix-subtraction.

(self, other)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 5

MatrixClass · 0.85
widthMethod · 0.80
heightMethod · 0.80
appendMethod · 0.45
componentMethod · 0.45

Tested by

no test coverage detected