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

Method __init__

maths/matrix_exponentiation.py:14–20  ·  view source on GitHub ↗
(self, arg: list[list] | int)

Source from the content-addressed store, hash-verified

12
13class Matrix:
14 def __init__(self, arg: list[list] | int) -> None:
15 if isinstance(arg, list): # Initializes a matrix identical to the one provided.
16 self.t = arg
17 self.n = len(arg)
18 else: # Initializes a square matrix of the given size and set values to zero.
19 self.n = arg
20 self.t = [[0 for _ in range(self.n)] for _ in range(self.n)]
21
22 def __mul__(self, b: Matrix) -> Matrix:
23 matrix = Matrix(self.n)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected