loom.cliffordsim.operations.controlled_operation

Copyright 2024 Entropica Labs Pte Ltd

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class loom.cliffordsim.operations.controlled_operation.ControlledOperation(app_operation, reg_name, bit_order=None, bit_id=None)[source]

Bases: Operation

A decorator of the Operation class that turns any operation into a classically controlled operation. The Operation will be conditioned on the value of a single bit.

NOTE: The Operation classes decorated by the ControlledOperation class can only be controlled by one bit.

Parameters:
  • app_operation (loom.cliffordsim.operations.base_operation.Operation) – The Operation that will be Classically Controlled.

  • reg_name (str) – The name of the Classical Register where the bit that classically controls app_operation will be located.

  • bit_order (Optional[int]) – The ordering of the bit within the classical register that app_operation will be conditioned on. Either bit_order or bit_id needs to be specified. If both or none are specified, an error is raised.

  • bit_id (Optional[str]) – The bit ID of the bit within the classical register that app_operation will be conditioned on. Either bit_order or bit_id needs to be specified. If both or none are specified, an error is raised.

app_operation: Operation
bit_id: Optional[str] = None
bit_order: Optional[int] = None
name: str = 'ControlledOperation'
operation_type: Enum = 'CControl'
reg_name: str
loom.cliffordsim.operations.controlled_operation.has_ccontrol(cls)[source]

This function acts as a decorator that adds the with_ccontrol method to the input Operation class.