# Controlled phase shift gate

How does a controlled R gate look like (matrixwise)? And how to generate CCR, CCCR and so on?

I found the answer and it seems like for a gate

$$U = \begin{bmatrix} x_{00} & x_{10}\\ x_{00} & x_{11} \end{bmatrix}$$

its controlled variant would be: $$CU=\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & x_{00} & x_{01} \\ 0 & 0 & x_{10} & x_{11} \end{bmatrix}$$

Hence for R, which is $$R(\theta) = \begin{bmatrix} 1 & 0\\ 0 & e^{i \theta} \end{bmatrix}$$

CR would be: $$CR(\theta)=\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i \theta} \end{bmatrix}$$

P.S.: Please, correct me if I'm wrong.

• Yes, you are right. Similarly you can get a C...CU gate, $U$ is in the right bottom corner of a C...CU gate, other diagonal elements are ones and other non-diagonal elements are zeros. – Martin Vesely Dec 8 '19 at 22:20