def add_fresh_qubit(self): """ Add a new qubit initialized in the \|0\> state. """ # Check if we are still allowed to add qubits if self.activeQubits >= self.maxQubits: raise noQubitError("No more qubits available in register.") num = self.activeQubits self.activeQubits += 1 return num
def add_fresh_qubit(self): """ Add a new qubit initialized in the \|0\> state. """ # Check if we are still allowed to add qubits if self.activeQubits >= self.maxQubits: raise noQubitError("No more qubits available in register.") # Prepare a clean qubit state in |0> qubit = self.eng.allocate_qubit() self.qubitReg.append(qubit) num = self.activeQubits self.activeQubits += 1 return num
def add_qubit(self, newQubit): """ Add new qubit in the state described by the density matrix newQubit """ # Check if we are still allowed to add qubits if self.activeQubits >= self.maxQubits: raise noQubitError("No more qubits available in register.") # Append to the existing state at the end if self.activeQubits > 0: self.qubitReg = qp.tensor(self.qubitReg, newQubit) else: self.qubitReg = newQubit # Index number of that qubit num = self.activeQubits # Increment the number of qubits self.activeQubits = self.activeQubits + 1 return num