State vectors in QuantumOptics.jl are interpreted as coefficients in respect to a certain Basis. For example the state $|\psi\rangle$ can be represented in the basis $\{|u_i\rangle\}_i$ as $\psi_i$. These quantities are connected by

\[|\psi\rangle = \sum_i \psi_i |u_i\rangle\]

and the conjugate equation

\[\langle\psi| = \sum_i \psi_i^* \langle u_i|.\]

The distinction between coefficients in respect to bra or ket states is strictly enforced which guarantees that algebraic mistakes raise an explicit error:

basis = FockBasis(2)
x = Ket(basis, [1,1,1]) # Not necessarily normalized
y = Bra(basis, [0,1,0])
# This throws an error:
# x + y

Many of the commonly used states are already implemented in the specific quantum systems, e.g. spinup for spins or coherentstate for systems described by a fock basis. The basisstate function is defined for every basis and is used to generate the i-th basis-state of this basis.

All expected arithmetic functions like *, /, +, - are implemented:

x + x
x - x
y*x # Inner product

The hermitian conjugate is performed by the dagger function which transforms a bra in a ket and vice versa:

dagger(x) # Bra(basis, [1,1,1])

Composite states can be created with the tensor function or with the equivalent $\otimes$ operator:

tensor(x, x)
x ⊗ x
tensor(x, x, x)

When working with the .data fields of composite states, please keep in mind the order of the data (see Operators for details).

Alternatively, one can use the tensor function to create a density operator by combining a ket with a bra:

tensor(x, dagger(x))

The following functions are also available for states: