# Quantum operations¶

PennyLane supports a wide variety of quantum operations—such as gates, noisy channels, state preparations and measurements. These operations can be used exclusively in quantum functions, like shown in the following example:

import pennylane as qml

def my_quantum_function(x, y):
qml.RZ(x, wires=0)
qml.CNOT(wires=[0,1])
qml.RY(y, wires=1)
qml.T(wires=0).inv()
qml.AmplitudeDamping(0.1, wires=0)
return qml.expval(qml.PauliZ(1))


This quantum function uses the RZ, CNOT, RY gates, the AmplitudeDamping noisy channel as well as the PauliZ observable.

Note that PennyLane supports inverting quantum operations via the Op(param, wires).inv() method. Additionally, PennyLane provides a function qml.inv that can be used to invert sequences of operations and Templates.

Below is a list of all quantum operations supported by PennyLane.

## Qubit operations¶

### Qubit gates¶

 Hadamard The Hadamard operator PauliX The Pauli X operator PauliY The Pauli Y operator PauliZ The Pauli Z operator S The single-qubit phase gate T The single-qubit T gate Rot Arbitrary single qubit rotation RX The single qubit X rotation RY The single qubit Y rotation RZ The single qubit Z rotation MultiRZ Arbitrary multi Z rotation. PauliRot Arbitrary Pauli word rotation. PhaseShift Arbitrary single qubit local phase shift CNOT The controlled-NOT operator CZ The controlled-Z operator CY The controlled-Y operator SWAP The swap operator U1 U1 gate. U2 U2 gate. U3 Arbitrary single qubit unitary. CRot The controlled-Rot operator CRX The controlled-RX operator CRY The controlled-RY operator CRZ The controlled-RZ operator Toffoli Toffoli (controlled-controlled-X) gate. CSWAP The controlled-swap operator QubitUnitary Apply an arbitrary fixed unitary matrix. DiagonalQubitUnitary Apply an arbitrary fixed diagonal unitary matrix.

### Qubit state preparation¶

 BasisState Prepares a single computational basis state. QubitStateVector Prepare subsystems using the given ket vector in the computational basis.

### Noisy channels¶

 AmplitudeDamping Single-qubit amplitude damping error channel. GeneralizedAmplitudeDamping Single-qubit generalized amplitude damping error channel. PhaseDamping Single-qubit phase damping error channel. DepolarizingChannel Single-qubit symmetrically depolarizing error channel. QubitChannel Apply an arbitrary fixed quantum channel.

### Qubit observables¶

 Hadamard The Hadamard operator Hermitian An arbitrary Hermitian observable. PauliX The Pauli X operator PauliY The Pauli Y operator PauliZ The Pauli Z operator

## Continuous-variable (CV) operations¶

### CV Gates¶

 Beamsplitter Beamsplitter interaction. ControlledAddition Controlled addition operation. ControlledPhase Controlled phase operation. CrossKerr Cross-Kerr interaction. CubicPhase Cubic phase shift. Displacement Phase space displacement. Interferometer A linear interferometer transforming the bosonic operators according to the unitary matrix $$U$$. Kerr Kerr interaction. QuadraticPhase Quadratic phase shift. Rotation Phase space rotation. Squeezing Phase space squeezing. TwoModeSqueezing Phase space two-mode squeezing.

### CV state preparation¶

 CatState Prepares a cat state. CoherentState Prepares a coherent state. DisplacedSqueezedState Prepares a displaced squeezed vacuum state. FockDensityMatrix Prepare subsystems using the given density matrix in the Fock basis. FockState Prepares a single Fock state. FockStateVector Prepare subsystems using the given ket vector in the Fock basis. GaussianState Prepare subsystems in a given Gaussian state. SqueezedState Prepares a squeezed vacuum state. ThermalState Prepares a thermal state.

### CV observables¶

 FockStateProjector The number state observable $$\ket{n}\bra{n}$$. NumberOperator The photon number observable $$\langle \hat{n}\rangle$$. TensorN The tensor product of the NumberOperator acting on different wires. P The momentum quadrature observable $$\hat{p}$$. PolyXP An arbitrary second-order polynomial observable. QuadOperator The generalized quadrature observable $$\x_\phi = \x cos\phi+\p\sin\phi$$. X The position quadrature observable $$\hat{x}$$.

## Shared operations¶

The only operation shared by both qubit and continouous-variable architectures is the Identity.

 Identity The identity observable $$\I$$.