def __init__( self, *, atol: float = 1e-8, required_sqrt_iswap_count: Optional[int] = None, use_sqrt_iswap_inv: bool = False, ): """Initializes `cirq.SqrtIswapTargetGateset` Args: atol: A limit on the amount of absolute error introduced by the decomposition. required_sqrt_iswap_count: When specified, the `decompose_to_target_gateset` will decompose each operation into exactly this many sqrt-iSWAP gates even if fewer is possible (maximum 3). A ValueError will be raised if this number is 2 or lower and synthesis of the operation requires more. use_sqrt_iswap_inv: If True, `cirq.SQRT_ISWAP_INV` is used as part of the gateset, instead of `cirq.SQRT_ISWAP`. Raises: ValueError: If `required_sqrt_iswap_count` is specified and is not 0, 1, 2, or 3. """ if required_sqrt_iswap_count is not None and not 0 <= required_sqrt_iswap_count <= 3: raise ValueError('the argument `required_sqrt_iswap_count` must be 0, 1, 2, or 3.') super().__init__( ops.SQRT_ISWAP_INV if use_sqrt_iswap_inv else ops.SQRT_ISWAP, ops.MeasurementGate, ops.AnyUnitaryGateFamily(1), name='SqrtIswapInvTargetGateset' if use_sqrt_iswap_inv else 'SqrtIswapTargetGateset', ) self.atol = atol self.required_sqrt_iswap_count = required_sqrt_iswap_count self.use_sqrt_iswap_inv = use_sqrt_iswap_inv
def __init__(self, *, atol: float = 1e-8, allow_partial_czs: bool = False) -> None: """Initializes CZTargetGateset Args: atol: A limit on the amount of absolute error introduced by the decomposition. allow_partial_czs: If set, all powers of the form `cirq.CZ**t`, and not just `cirq.CZ`, are part of this gateset. """ super().__init__( ops.CZPowGate if allow_partial_czs else ops.CZ, ops.MeasurementGate, ops.AnyUnitaryGateFamily(1), name='CZPowTargetGateset' if allow_partial_czs else 'CZTargetGateset', ) self.atol = atol self.allow_partial_czs = allow_partial_czs
def __init__(self, ignore_failures: bool = False, allow_partial_czs: bool = False) -> None: """Inits ConvertToCzAndSingleGates. Args: ignore_failures: If set, gates that fail to convert are forwarded unchanged. If not set, conversion failures raise a TypeError. allow_partial_czs: If set, the decomposition is permitted to use gates of the form `cirq.CZ**t`, instead of only `cirq.CZ`. """ super().__init__() self.ignore_failures = ignore_failures self.allow_partial_czs = allow_partial_czs self.gateset = ops.Gateset( ops.CZPowGate if allow_partial_czs else ops.CZ, ops.MeasurementGate, ops.AnyUnitaryGateFamily(1), )