Skip to content

Commit

Permalink
added no ansatz
Browse files Browse the repository at this point in the history
Signed-off-by: Melvin Strobl <[email protected]>
  • Loading branch information
Melvin Strobl committed Aug 12, 2024
1 parent 9c0bef4 commit 6f8ab9b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions qml_essentials/ansaetze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6f8ab9b

Please sign in to comment.