diff --git a/QElephant/Matrix.py b/QElephant/Matrix.py index 68c5730..3c6bd0c 100644 --- a/QElephant/Matrix.py +++ b/QElephant/Matrix.py @@ -43,6 +43,13 @@ class Matrix: def __str__(self) -> str: 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 def I() -> "Matrix": return Matrix([ diff --git a/docs/Matrix.md b/docs/Matrix.md index 51863e6..10f4c66 100644 --- a/docs/Matrix.md +++ b/docs/Matrix.md @@ -35,6 +35,10 @@ Matrix(l: list[list[complexe]]) ### Staticmethods +- ```to_list(matrix: Matrix) -> list[list[complex]]``` + + returns the a list representing the given Matrix. + - ```I() -> Matrix``` returns the matrix