def grover_u_s(n_qubits): plus_state = (qit.state('0') + qit.state('1')) / np.sqrt(2) state = (qit.state('0') + qit.state('1')) / np.sqrt(2) for i in range(1, n_qubits): state = qit.state.tensor(state, plus_state) I = qit.tensor(qit.lmap(np.eye(2))) for i in range(1, n_qubits): I = qit.tensor(I, qit.lmap(np.eye(2))) return -1 * I + 2 * qit.state.projector(state)
def grover_u_w(state, n_qubits): I = qit.tensor(qit.lmap(np.eye(2))) for i in range(1, n_qubits): I = qit.tensor(I, qit.lmap(np.eye(2))) return -2 * qit.state.projector(state) + I