@@ -12,7 +12,7 @@ from collections.abc import ItemsView, Iterable, Iterator, Mapping, MutableMappi
12
12
from os import PathLike
13
13
from typing import overload
14
14
15
- from .operations import ComparisonKind , Control , Operation
15
+ from .operations import ComparisonKind , Control , Operation , OpType
16
16
from .registers import ClassicalRegister , QuantumRegister
17
17
from .symbolic import Expression , Variable
18
18
@@ -1868,17 +1868,17 @@ class QuantumComputation(MutableSequence[Operation]):
1868
1868
self ,
1869
1869
then_operation : Operation ,
1870
1870
else_operation : Operation | None ,
1871
- creg : ClassicalRegister ,
1871
+ control_register : ClassicalRegister ,
1872
1872
expected_value : int = 1 ,
1873
1873
comparison_kind : ComparisonKind = ComparisonKind .eq ,
1874
1874
) -> None :
1875
- """Add a classic-controlled operation to the circuit.
1875
+ """Add an if-else operation to the circuit.
1876
1876
1877
1877
Args:
1878
1878
then_operation: The operation to apply if the condition is met
1879
1879
else_operation: The operation to apply if the condition is not met
1880
- creg : The classical register
1881
- expected_value: The expected value of the classical register
1880
+ control_register : The classical register to check against
1881
+ expected_value: The expected value of the control register
1882
1882
comparison_kind: The kind of comparison to perform
1883
1883
"""
1884
1884
@@ -1887,16 +1887,150 @@ class QuantumComputation(MutableSequence[Operation]):
1887
1887
self ,
1888
1888
then_operation : Operation ,
1889
1889
else_operation : Operation | None ,
1890
- cbit : int ,
1890
+ control_bit : int ,
1891
1891
expected_value : int = 1 ,
1892
1892
comparison_kind : ComparisonKind = ComparisonKind .eq ,
1893
1893
) -> None :
1894
- """Add a classic-controlled operation to the circuit.
1894
+ """Add an if-else operation to the circuit.
1895
1895
1896
1896
Args:
1897
1897
then_operation: The operation to apply if the condition is met
1898
1898
else_operation: The operation to apply if the condition is not met
1899
- cbit: The classical bit index
1900
- expected_value: The expected value of the classical register
1899
+ control_bit: The index of the classical bit to check against
1900
+ expected_value: The expected value of the control bit
1901
+ comparison_kind: The kind of comparison to perform
1902
+ """
1903
+
1904
+ @overload
1905
+ def if_ (
1906
+ self ,
1907
+ op : OpType ,
1908
+ target : int ,
1909
+ control_register : ClassicalRegister ,
1910
+ expected_value : int = 1 ,
1911
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
1912
+ params : Sequence [float ] = (),
1913
+ ) -> None :
1914
+ """Add an if operartion to the circuit.
1915
+
1916
+ Args:
1917
+ op: The operation to apply
1918
+ target: The target qubit
1919
+ control_register: The classical register to check against
1920
+ expected_value: The expected value of the control register
1921
+ comparison_kind: The kind of comparison to perform
1922
+ params: The parameters of the operation
1923
+ """
1924
+
1925
+ @overload
1926
+ def if_ (
1927
+ self ,
1928
+ op : OpType ,
1929
+ target : int ,
1930
+ control : Control | int ,
1931
+ control_register : ClassicalRegister ,
1932
+ expected_value : int = 1 ,
1933
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
1934
+ params : Sequence [float ] = (),
1935
+ ) -> None :
1936
+ """Add a classic-controlled operation to the circuit.
1937
+
1938
+ Args:
1939
+ op: The operation to apply
1940
+ target: The target qubit
1941
+ control: The control qubit
1942
+ control_register: The classical register to check against
1943
+ expected_value: The expected value of the control register
1944
+ comparison_kind: The kind of comparison to perform
1945
+ params: The parameters of the operation.
1946
+ """
1947
+
1948
+ @overload
1949
+ def if_ (
1950
+ self ,
1951
+ op : OpType ,
1952
+ target : int ,
1953
+ controls : set [Control | int ],
1954
+ control_register : ClassicalRegister ,
1955
+ expected_value : int = 1 ,
1956
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
1957
+ params : Sequence [float ] = (),
1958
+ ) -> None :
1959
+ """Add a classic-controlled operation to the circuit.
1960
+
1961
+ Args:
1962
+ op: The operation to apply
1963
+ target: The target qubit
1964
+ controls: The control qubits
1965
+ control_register: The classical register to check against
1966
+ expected_value: The expected value of the control register
1967
+ comparison_kind: The kind of comparison to perform
1968
+ params: The parameters of the operation.
1969
+ """
1970
+
1971
+ @overload
1972
+ def if_ (
1973
+ self ,
1974
+ op : OpType ,
1975
+ target : int ,
1976
+ control_bit : int ,
1977
+ expected_value : bool = True ,
1978
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
1979
+ params : Sequence [float ] = (),
1980
+ ) -> None :
1981
+ """Add a classic-controlled operation to the circuit.
1982
+
1983
+ Args:
1984
+ op: The operation to apply
1985
+ target: The target qubit
1986
+ control_bit: The index of the classical bit to check against
1987
+ expected_value: The expected value of the control bit
1988
+ comparison_kind: The kind of comparison to perform
1989
+ params: The parameters of the operation.
1990
+ """
1991
+
1992
+ @overload
1993
+ def if_ (
1994
+ self ,
1995
+ op : OpType ,
1996
+ target : int ,
1997
+ control : Control | int ,
1998
+ control_bit : int ,
1999
+ expected_value : bool = True ,
2000
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
2001
+ params : Sequence [float ] = (),
2002
+ ) -> None :
2003
+ """Add a classic-controlled operation to the circuit.
2004
+
2005
+ Args:
2006
+ op: The operation to apply
2007
+ target: The target qubit
2008
+ control: The control qubit
2009
+ control_bit: The index of the classical bit to check against
2010
+ expected_value: The expected value of the control bit
2011
+ comparison_kind: The kind of comparison to perform
2012
+ params: The parameters of the operation.
2013
+ """
2014
+
2015
+ @overload
2016
+ def if_ (
2017
+ self ,
2018
+ op : OpType ,
2019
+ target : int ,
2020
+ controls : set [Control | int ],
2021
+ control_bit : int ,
2022
+ expected_value : bool = True ,
2023
+ comparison_kind : ComparisonKind = ComparisonKind .eq ,
2024
+ params : Sequence [float ] = (),
2025
+ ) -> None :
2026
+ """Add a classic-controlled operation to the circuit.
2027
+
2028
+ Args:
2029
+ op: The operation to apply
2030
+ target: The target qubit
2031
+ controls: The control qubits
2032
+ control_bit: The index of the classical bit to check against
2033
+ expected_value: The expected value of the control bit
1901
2034
comparison_kind: The kind of comparison to perform
2035
+ params: The parameters of the operation.
1902
2036
"""
0 commit comments