Matrices are shown in the standard computational basis. Single-qubit basis is |0>, |1>. Two-qubit basis is |00>, |01>, |10>, |11>. Three-qubit basis is |000>..|111>.
X (Pauli-X)
Bit flip.
[ [0, 1],
[1, 0] ]
Y (Pauli-Y)
Bit+phase rotation.
[ [0, -i],
[i, 0] ]
Z (Pauli-Z)
Phase flip.
[ [ 1, 0],
[ 0,-1] ]
H (Hadamard)
Creates/undoes equal superposition.
(1/sqrt(2)) * [ [ 1, 1],
[ 1, -1] ]
S (Phase)
Applies +90 degree phase to |1>.
[ [1, 0],
[0, i] ]
T (pi/8)
Applies +45 degree phase to |1>.
[ [1, 0],
[0, exp(i*pi/4)] ]
CX (Controlled-X)
Flip target when control is |1>.
[ [1,0,0,0],
[0,1,0,0],
[0,0,0,1],
[0,0,1,0] ]
CZ (Controlled-Z)
Apply phase flip to |11>.
[ [1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,-1] ]
SWAP
Exchange two qubits.
[ [1,0,0,0],
[0,0,1,0],
[0,1,0,0],
[0,0,0,1] ]
CCX (Toffoli)
Flip target when both controls are |1>.
[ [1,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0],
[0,0,0,1,0,0,0,0],
[0,0,0,0,1,0,0,0],
[0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,1,0] ]
CSWAP (Fredkin)
Swap two targets when control is |1>.
[ [1,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0],
[0,0,0,1,0,0,0,0],
[0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,1,0],
[0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,1] ]