From fb591ce19164ccc0a95e86c1e242a1acbcc559a3 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Tue, 24 Oct 2023 17:32:33 +0200 Subject: [PATCH] add method Matrix --- QElephant/Matrix.py | 7 +++++++ docs/Matrix.md | 4 ++++ 2 files changed, 11 insertions(+) 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