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
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 Diagonal
representation!
julia> Diagonal{Float32}(gate)
2×2 Diagonal{Float32, Vector{Float32}}:
1.0 ⋅
⋅ -1.0
Quac.Operator
Gate
Quac.I
X
Y
Z
H
S
Sd
T
Td
Rx
Ry
Rz
Rxx
Ryy
Rzz
U2
U3
Control
Swap
!!! warn "Experimental interface" This interface is experimental and may change in the future.
Quac.SU{N}