跳转至

Operator

QuICT.core.operator.Operator

Operator(targets: int, name: str = None)

The SuperClass of all the operator.

Parameters:

  • targets (int) –

    the number of the target bits of the gate

  • name (str, default: None ) –

    The name of current trigger, Default to None.

Source code in QuICT/core/operator/_operator.py
def __init__(
    self,
    targets: int,
    name: str = None
):
    """
    Args:
        targets (int): the number of the target bits of the gate
        name (str): The name of current trigger, Default to None.
    """
    assert targets >= 0 and isinstance(targets, int), f"targets must be a positive integer, not {type(targets)}"
    self._qubit_number = targets
    self._targs = []
    self.cargs = []
    self._name = name

__and__

__and__(targets: Union[List[int], int])

Assigned the trigger's target qubits.

Parameters:

  • targets (Union[List[int], int]) –

    The indexes of target qubits.

Source code in QuICT/core/operator/_operator.py
def __and__(self, targets: Union[List[int], int],):
    """ Assigned the trigger's target qubits.

    Args:
        targets (Union[List[int], int]): The indexes of target qubits.
    """
    if isinstance(targets, int):
        assert targets >= 0 and self.qubits == 1
        self._targs = [targets]
    elif isinstance(targets, list):
        assert len(targets) == self.qubits
        for q in targets:
            assert q >= 0 and isinstance(q, int), f"targets must be a positive integer, not {q}"

        self._targs = targets
    else:
        raise TypeError(f"qubits must be one of [List[int], int], not {type(targets)}")

    return self

__or__

__or__(targets)

Append the trigger to the circuit.

Parameters:

  • targets (Circuit) –

    The circuit which contains the trigger.

Source code in QuICT/core/operator/_operator.py
def __or__(self, targets):
    """ Append the trigger to the circuit.

    Args:
        targets (Circuit): The circuit which contains the trigger.
    """
    try:
        targets.append(self)
    except Exception as e:
        raise TypeError(f"Failure to append Trigger to targets, due to {e}")