From 6f8ab9b43d992a7609a5a223e8a3d4744d5a975e Mon Sep 17 00:00:00 2001 From: Melvin Strobl Date: Mon, 12 Aug 2024 16:00:18 +0200 Subject: [PATCH] added no ansatz Signed-off-by: Melvin Strobl --- qml_essentials/ansaetze.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/qml_essentials/ansaetze.py b/qml_essentials/ansaetze.py index 6942753..810294e 100644 --- a/qml_essentials/ansaetze.py +++ b/qml_essentials/ansaetze.py @@ -38,9 +38,7 @@ def get_control_indices(self, n_qubits: int) -> List[int]: """ return - def get_control_angles( - self, w: np.ndarray, n_qubits: int - ) -> Optional[np.ndarray]: + def get_control_angles(self, w: np.ndarray, n_qubits: int) -> Optional[np.ndarray]: """ Returns the angles for the controlled rotation gates from the list of all parameters for one layer. @@ -75,6 +73,7 @@ def __call__(self, *args: Any, **kwds: Any) -> Any: class Ansaetze: def get_available(): return [ + Ansaetze.No_Ansatz, Ansaetze.Circuit_1, Ansaetze.Circuit_9, Ansaetze.Circuit_15, @@ -85,6 +84,19 @@ def get_available(): Ansaetze.Hardware_Efficient, ] + class No_Ansatz(Circuit): + @staticmethod + def n_params_per_layer(n_qubits: int) -> int: + return 0 + + @staticmethod + def get_control_indices(n_qubits: int) -> Optional[np.ndarray]: + return None + + @staticmethod + def build(w: np.ndarray, n_qubits: int): + pass + class Hardware_Efficient(Circuit): @staticmethod def n_params_per_layer(n_qubits: int) -> int: @@ -241,9 +253,7 @@ def build(w: np.ndarray, n_qubits: int): if n_qubits > 1: for q in range(n_qubits): - qml.CNOT( - wires=[n_qubits - q - 1, (n_qubits - q) % n_qubits] - ) + qml.CNOT(wires=[n_qubits - q - 1, (n_qubits - q) % n_qubits]) for q in range(n_qubits): qml.RZ(w[w_idx], wires=q)