Operator Library

Schrodinger.createMethod
create(N)

Generate a quantum harmonic oscillator raising (creation) operator $\hat{a}^†$ in a truncated Hilbert space of size N. Returns a sparse matrix.

Example

julia> create(4)
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 4
  ⋅    ⋅        ⋅        ⋅
 1.0   ⋅        ⋅        ⋅
  ⋅   1.41421   ⋅        ⋅
  ⋅    ⋅       1.73205   ⋅
source
Schrodinger.destroyMethod
destroy(N)

Generate a quantum harmonic oscillator lowering (annihilation) operator $\hat{a}$ in a truncated Hilbert space of size N. Returns a sparse matrix.

Example

julia> destroy(4)
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 4
  ⋅   1.0   ⋅        ⋅
  ⋅    ⋅   1.41421   ⋅
  ⋅    ⋅    ⋅       1.73205
  ⋅    ⋅    ⋅        ⋅
source
Schrodinger.displacementopMethod
displacementop(N, α)

Generate a quantum harmonic oscillator displacement operator $\hat{D}(α)$ in a truncated Hilbert space of size N. Returns a dense matrix.

\[\hat{D}(α) = \exp\left(α\hat{a}^† - α^*\hat{a}\right)\]

Example

julia> displacementop(3,0.5im)
3×3 Operator{Matrix{ComplexF64}, 1} with dimensions 3
   0.88262+0.0im            0.0+0.439802im  -0.166001+0.0im
       0.0+0.439802im  0.647859+0.0im             0.0+0.621974im
 -0.166001+0.0im            0.0+0.621974im    0.76524+0.0im
source
Schrodinger.numberopMethod
numberop(N)

Generate a number operator $\hat{n}$ in a Hilbert space of size N. Returns a sparse matrix.

Example

julia> numberop(4)
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 4
 0.0   ⋅    ⋅    ⋅
  ⋅   1.0   ⋅    ⋅
  ⋅    ⋅   2.0   ⋅
  ⋅    ⋅    ⋅   3.0
source
Schrodinger.projectoropMethod
projectorop(N,S)

Generate a projector on the subspaces defined by an integer or a vector/range of integers S:

\[P = ∑_{i∈S} |i⟩⟨i|.\]

Example

julia> projectorop(5,[1,3])
5×5 Operator{SparseMatrixCSC{Float64, Int64}, 1} with dimensions 5
  ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅   1.0   ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅   1.0   ⋅
  ⋅    ⋅    ⋅    ⋅    ⋅
source
Schrodinger.qeyeMethod
qeye(N, dims=(N,))

Generate an identity operator for a Hilbert space of size N. It is possible to specify the subspace dimensions with the dims argument. Returns a sparse matrix.

Example

julia> qeye(4,(2,2))
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 2} with dimensions 2⊗2
 1.0   ⋅    ⋅    ⋅
  ⋅   1.0   ⋅    ⋅
  ⋅    ⋅   1.0   ⋅
  ⋅    ⋅    ⋅   1.0
source
Schrodinger.qzeroMethod
qzero(N, dims=(N,))

Generate a zero operator for a Hilbert space of size N. It is possible to specify the subspace dimensions with the dims argument. Returns a sparse matrix.

Example

julia> qzero(4,(2,2))
4×4 Operator{SparseMatrixCSC{Float64, Int64}, 2} with dimensions 2⊗2
  ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅
  ⋅    ⋅    ⋅    ⋅
source
Schrodinger.squeezeopMethod
squeezeop(N, z)

Generate a quantum harmonic oscillator squeeze operator $\hat{S}(z)$ in a truncated Hilbert space of size N. Returns a dense matrix.

\[\hat{S}(z) = \exp\left(\frac{1}{2}\left(z^*\hat{a}^2 - z\hat{a}^{†2}\right)\right)\]

Example

julia> squeezeop(3,0.5im)
3×3 Operator{Matrix{ComplexF64}, 1} with dimensions 3
 0.938148-0.0im       0.0-0.0im       0.0-0.346234im
      0.0+0.0im       1.0+0.0im       0.0+0.0im
      0.0-0.346234im  0.0-0.0im  0.938148-0.0im
source
Schrodinger.sylvesteropMethod
sylvesterop(N,k,l)

Generate the $(k,j)^\text{th}$ Sylvester generalized Pauli matrix in N-d. https://en.wikipedia.org/wiki/GeneralizationsofPauli_matrices

source
Schrodinger.rand_unitaryFunction
rand_unitary(N, dims=(N,))

Generate a Haar distributed random unitary operator for a Hilbert space of size N. It is possible to specify the subspace dimensions with the dims argument. Returns a dense matrix.

Example

julia> U = rand_unitary(4,(2,2));

julia> U'*U ≈ qeye(4,(2,2))
true
source
Schrodinger.Gate.rotationFunction
Gate.rotation(θ, n=(1,0,0))

Generate a qubit rotation operator giving a θ rad rotation about an axis defined by the vector $\vec{n}$. Note that n will be normalized, allowing for inputs like (1,1,0). The rotation operator is defined as

\[\hat{R}_{\vec{n}}(θ) = \exp\left(−iθ\vec{n}⋅\vec{σ}/2\right) = \cos\frac{θ}{2}𝕀 - i\sin\frac{θ}{2}(n_x σ_x + n_y σ_y + n_z σ_z).\]

source
Schrodinger.Gate.HConstant
Gate.H

The Hadamard gate:

\[H = \frac{1}{\sqrt 2} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]

The Hadamard is a $π$ rotation about the axis $\vec{n} = (1,0,1)$, plus a global $i$ phase.

source
Schrodinger.Gate.SConstant
Gate.S

The phase gate:

\[S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\]

The phase gate is the square of the T gate: $S = T^2$.

source
Schrodinger.Gate.TConstant
Gate.T

The T gate:

\[T = \begin{pmatrix} 1 & 0 \\ 0 & \exp(iπ/4) \end{pmatrix}\]

The phase gate is the square of the T gate: $S = T^2$.

source