MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __sub__

Method __sub__

matrix/matrix_class.py:308–316  ·  view source on GitHub ↗
(self, other: Matrix)

Source from the content-addressed store, hash-verified

306 )
307
308 def __sub__(self, other: Matrix) -> Matrix:
309 if self.order != other.order:
310 raise ValueError("Subtraction requires matrices of the same order")
311 return Matrix(
312 [
313 [self.rows[i][j] - other.rows[i][j] for j in range(self.num_columns)]
314 for i in range(self.num_rows)
315 ]
316 )
317
318 def __mul__(self, other: Matrix | float) -> Matrix:
319 if isinstance(other, (int, float)):

Callers

nothing calls this directly

Calls 1

MatrixClass · 0.70

Tested by

no test coverage detected