Skip to content

Latest commit

 

History

History
112 lines (84 loc) · 1.38 KB

gates.md

File metadata and controls

112 lines (84 loc) · 1.38 KB

Gates

DocTestSetup = quote
    using Quac
    using LinearAlgebra
end

In Quac, gates are symbolic, i.e. they do not store their representation. A gate instance just stores the qubit lane in which it acts and its parameters if needed. Thanks to Julia's multiple-dispatch different representations can be queried lazily from type information.

For example, this is a $Z$ that acts on qubit 4.

julia> gate = Z(4)
Z() on 4

Any gate can be represented by a dense matrix.

julia> Matrix(gate)
2×2 Matrix{ComplexF64}:
 1.0+0.0im   0.0+0.0im
 0.0+0.0im  -1.0+0.0im

You can even specify the eltype!

julia> Matrix{Int}(gate)
2×2 Matrix{Int64}:
 1   0
 0  -1

Furthermore, the $Z$ gate allows a Diagonal representation!

julia> Diagonal{Float32}(gate)
2×2 Diagonal{Float32, Vector{Float32}}:
 1.0    ⋅
  ⋅   -1.0
Quac.Operator
Gate

Pauli gates

Quac.I
X
Y
Z

Hadamard gate

H

Phase gates

S
Sd
T
Td

Rotation gates

Rx
Ry
Rz
Rxx
Ryy
Rzz

General U2, U3 gates

U2
U3

Controlled gates

Control

SWAP gate

Swap

Special Unitary gate

!!! warn "Experimental interface" This interface is experimental and may change in the future.

Quac.SU{N}