MCPcopy Index your code
hub / github.com/subbarayudu-j/TheAlgorithms-Python / __sub__

Method __sub__

linear_algebra_python/src/lib.py:290–303  ·  view source on GitHub ↗

implements the matrix-subtraction.

(self,other)

Source from the content-addressed store, hash-verified

288 else:
289 raise Exception("matrix must have the same dimension!")
290 def __sub__(self,other):
291 """
292 implements the matrix-subtraction.
293 """
294 if (self.__width == other.width() and self.__height == other.height()):
295 matrix = []
296 for i in range(self.__height):
297 row = []
298 for j in range(self.__width):
299 row.append(self.__matrix[i][j] - other.component(i,j))
300 matrix.append(row)
301 return Matrix(matrix,self.__width,self.__height)
302 else:
303 raise Exception("matrix must have the same dimension!")
304
305
306def squareZeroMatrix(N):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected