Quantum gates in computational basis notation I stumbled upon such notations: $X=|0\rangle\langle1|+|1\rangle\langle0|$ for of logical NOT gate, or $|00\rangle\langle00|+|01\rangle\langle01|+|10\rangle\langle10|+|11\rangle\langle11|$ for 2-qubit indentity. 
I am not sure I understand it correctly: does it mean that gate $|0\rangle\langle0|+i|1\rangle\langle1|= \begin{bmatrix}1&0\\0&i\end{bmatrix}$? 
How would you write SWAP gate in such notation?
 A: $\newcommand{\ket}[1]{\left|#1\right\rangle}$
$\newcommand{\bra}[1]{\left\langle#1\right|}$
Lets say, we define our states as $\ket0 = \begin{bmatrix}1 \\0 \end{bmatrix}$ and $\ket{1} = \begin{bmatrix} 0\\ 1\end{bmatrix}$.
Then, the NOT operation does, $X\ket0 = \ket1$ and $X\ket1 =\ket0$, which can be described by the matrix
$$X = \begin{bmatrix}0&1\\1&0\end{bmatrix} = \ket0 \bra1 + \ket1 \bra0.$$
Now, if we consider two qubits, the states can be defined as,
$$\ket{00} = \begin{bmatrix}1 \\0\\0 \\0 \end{bmatrix},\quad
\ket{01} = \begin{bmatrix}0 \\1\\0 \\0 \end{bmatrix},\quad
\ket{10} = \begin{bmatrix}0 \\0\\1 \\0 \end{bmatrix},\quad
\ket{11} = \begin{bmatrix}0 \\0\\0 \\1 \end{bmatrix}$$
Now, the SWAP operation $S$ does the following:
$$
S\ket{00} = \ket{00}\\
S\ket{01} = \ket{10}\\
S\ket{10} = \ket{01}\\
\,S\ket{11} = \ket{11}.$$
This is represented by the matrix
$$S = \begin{bmatrix}0&0&0&1\\0&0&1&0 \\ 0&1&0&1\\ 0&0&0&1\end{bmatrix}.$$
And if you check that this matrix can be written as,
$$S = |00\rangle\langle00|+|01\rangle\langle10|+|10\rangle\langle01|+|11\rangle\langle11|.$$
So, the answer to your questions are yes.
