diff --git a/perceval/components/unitary_components.py b/perceval/components/unitary_components.py index 94ed990c3..c7c84a2b6 100644 --- a/perceval/components/unitary_components.py +++ b/perceval/components/unitary_components.py @@ -461,6 +461,16 @@ def describe(self): params.append("use_polarization=True") return f"Unitary({', '.join(params)})" + @staticmethod + def random(m: int) -> "Unitary": # Python 3.11 : Replace using Self typing + r"""Static method generating a random unitary component. + + :param m: Number of modes in random unitary. + :return: a Unitary circuit component + """ + matrix = Matrix.random_unitary(m) + return Unitary(matrix) + class PERM(Unitary): """Permutation