I'm learning a custom gate implementation from google Cirq official tutorial of shor algorithm(https://colab.research.google.com/github/quantumlib/Cirq/blob/master/docs/experiments/shor.ipynb#scrollTo=Q2ZlalhkYArv ), and I'm trying to understand the meaning of the numbers in input_register and target_register. Here's the custom Adder gate:

class Add(cirq.ArithmeticGate):
def __init__(
    target_register: [int, Sequence[int]],
    input_register: Union[int, Sequence[int]],
    self.target_register = target_register
    self.input_register = input_register

def registers(self) -> Sequence[Union[int, Sequence[int]]]:
    return self.target_register, self.input_register

def with_registers(
    self, *new_registers: Union[int, Sequence[int]]
) -> 'Add':
    return Add(*new_registers)

def apply(self, *register_values: int) -> Union[int, Iterable[int]]:
    return sum(register_values)

It defines the input_register and target_register as follows:

adder = Adder(input_register=[2, 2], target_register=[2, 2])

I'd like to understand what each 2 means in input_register = [2, 2] and target_register = [2, 2]. How do these numbers relate to the qubits and their dimensions, or do they have a different meaning? If so, what does it signify?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.