add method Matrix

This commit is contained in:
Didictateur 2023-10-24 17:32:33 +02:00
parent e9b1cfd056
commit fb591ce191
2 changed files with 11 additions and 0 deletions

View file

@ -43,6 +43,13 @@ class Matrix:
def __str__(self) -> str: def __str__(self) -> str:
return str(self.__m) return str(self.__m)
@staticmethod
def to_list(matrix: "Matrix") -> list[list[complex]]:
if type(matrix) is not Matrix:
raise ValueError(f"cannot multiply Matrix with {type(matrix)}")
return matrix._Matrix__m.copy()
@staticmethod @staticmethod
def I() -> "Matrix": def I() -> "Matrix":
return Matrix([ return Matrix([

View file

@ -35,6 +35,10 @@ Matrix(l: list[list[complexe]])
### Staticmethods ### Staticmethods
- ```to_list(matrix: Matrix) -> list[list[complex]]```
returns the a list representing the given Matrix.
- ```I() -> Matrix``` - ```I() -> Matrix```
returns the matrix returns the matrix