I am struggling with a problem which has been anticipated in a different question here for 3 qubits. I need a sequence of gates (Pauli, controlled also), such that the unitary matrix associated with the circuit is:
$$ U = \begin{bmatrix} -1 & 0 & 0 & 0 & ... \\ 0 & 1 & 0 & 0 & ... \\ 0 & 0 & 1 & 0 & ... \\ 0 & 0 & 0 & 1 & ... \\ &&... \\ \end{bmatrix}, $$
that is, the identity matrix having -1 as the first entry. I have not made any attempt as I do not know exactly how to approach this problem.
Edit:
This can be done by first computing the matrix having -1 at the end of the diagonal and using X-gates to put that '-1' on the first diagonal entry like this:
nq = 4
qc = QuantumCircuit(nq)
qc.x([j for j in range(0, nq)])
qc.h(0)
qc.mcx([j for j in range(1, nq)], 0, mode='noancilla')
qc.h(0)
qc.x([j for j in range(0, nq)])