diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index dd365d9..535ccb1 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-07T07:11:07","documenter_version":"1.4.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-07T07:17:31","documenter_version":"1.4.1"}} \ No newline at end of file diff --git a/dev/checkmatrix/index.html b/dev/checkmatrix/index.html index 9b71114..f11a99d 100644 --- a/dev/checkmatrix/index.html +++ b/dev/checkmatrix/index.html @@ -1,8 +1,8 @@ -Details on check matrix operations · QuantumLegos.jl

Details on check matrix operations

Basic features of check matrix

  • All action on state can be represented as operations on check matrix.
  • QuantumLegos which don't connect each other are represented by block diagonal check matrix.

Thus, one needs only one check matrix to represent state.

  • Generated group from generators represented by check matrix is invariant under row-swap and row-multiplying transforms on the check matrix.

Thus, one can freely perform these row operations on check matrices.

Construction of check matrices and retrieving features

Use CheckMatrix from Matrix{Bool} and checkmatrix from Vector{PauliOp}.

QuantumLegos.CheckMatrixType

CheckMatrix

Fields

  • cmat: matrix itself (matrix of Bool since we consider only pauli ops.)
  • nlegs: number of columns ÷ 2
  • ngens: number of rows

Constructor

CheckMatrix(cmat::AbstractMatrix{Bool})

See also checkmatrix.

source

Get xpart and zpart of check matrix.

Get generators from check matrix with generators.

See also, GeneratedPauliGroup and Base.Set to get group generated by generators.

Direct sum

Used when adding lego without edge.

QuantumLegos.direct_sumFunction
direct_sum(cmat_1::T, cmat_2::T)::T where {T <: CheckMatrix}

Returns block diagonal CheckMatrix consists of cmat_1 and cmat_2.

CheckMatrix transform

When adding a lego $l$ with check matrix $H_l$ to a state with check matrix $H_s$, the resulting check matrix of the state will be

\[\begin{pmatrix} +Details on check matrix operations · QuantumLegos.jl

Details on check matrix operations

Basic features of check matrix

  • All action on state can be represented as operations on check matrix.
  • QuantumLegos which don't connect each other are represented by block diagonal check matrix.

Thus, one needs only one check matrix to represent state.

  • Generated group from generators represented by check matrix is invariant under row-swap and row-multiplying transforms on the check matrix.

Thus, one can freely perform these row operations on check matrices.

Construction of check matrices and retrieving features

Use CheckMatrix from Matrix{Bool} and checkmatrix from Vector{PauliOp}.

QuantumLegos.CheckMatrixType

CheckMatrix

Fields

  • cmat: matrix itself (matrix of Bool since we consider only pauli ops.)
  • nlegs: number of columns ÷ 2
  • ngens: number of rows

Constructor

CheckMatrix(cmat::AbstractMatrix{Bool})

See also checkmatrix.

source

Get xpart and zpart of check matrix.

Get generators from check matrix with generators.

See also, GeneratedPauliGroup and Base.Set to get group generated by generators.

Direct sum

Used when adding lego without edge.

QuantumLegos.direct_sumFunction
direct_sum(cmat_1::T, cmat_2::T)::T where {T <: CheckMatrix}

Returns block diagonal CheckMatrix consists of cmat_1 and cmat_2.

CheckMatrix transform

When adding a lego $l$ with check matrix $H_l$ to a state with check matrix $H_s$, the resulting check matrix of the state will be

\[\begin{pmatrix} H_s & O \\ O & H_l \\ -\end{pmatrix}\]

source

Self-tracing

self-tracing

QuantumLegos.self_trace!Function
self_trace!(cmat::CheckMatrix, col_1::Integer, col_2::Integer)

Take a self-trace of checkmatrix cmat with column col_1 and col_2.

Example

TODO

source

During self-tracing, pre-formatting and post-formatting described below is performed.

pre-formatting

Self-tracing

self-tracing

QuantumLegos.self_trace!Function
self_trace!(cmat::CheckMatrix, col_1::Integer, col_2::Integer)

Take a self-trace of checkmatrix cmat with column col_1 and col_2.

Example

TODO

source

During self-tracing, pre-formatting and post-formatting described below is performed.

pre-formatting

QuantumLegos.eliminate_column!Function
eliminate_column!(
     cmat::CheckMatrix,
     col::Integer,
     avoid_row::AbstractVector{T},
@@ -17,9 +17,9 @@ julia> QuantumLegos.eliminate_column!(ex_cmat, 1, Int64[])
 julia> ex_cmat
 CheckMatrix with 2 generators, 2 legs:
   1  0 | 1  0
-  0  1 | 0  1
source
eliminate_column!(cmat::CheckMatrix, col::Integer,
-avoid_row::AbstractVector{T}) where {T <: Union{Nothing, Integer}}

avoid_row can include Nothing, which is ignored in actual evaluation.

source
QuantumLegos.align_row!Function
align_row!(m::AbstractMatrix, row::Integer, occupied::Vector{Union{Nothing, Integer}}) -> Integer
-align_row!(m::AbstractMatrix, row::Nothing, occupied::Vector{Union{Nothing, Integer}}) -> Nothing

Swap row at row in m and row at next to the maximum in occupied. occupied is supposed to be a list of returns from eliminate_column!. If row is in occupied, do nothing and returns row. If row is nothing, return nothing.

Arguments

  • m::AbstractMatrix: mutated
  • row::Union{Nothing, Integer}: row to be aligned
  • occupied::Vector{Union{Nothing, Integer}}: indices of already occupied rows. row will be next to these rows.

Return

  • Row index where row is moved.
source

QuantumLegos.align_row!

By this process, all columns to be traced have 1s on only 1st to 4th rows. So during QuantumLegos.self_trace!, all stabilizers generated from top three rows are calculated and perform operator matching.

post-formatting

Remove rows which are linear combinations of other rows.

QuantumLegos.ref!Function
ref!(cmat::CheckMatrix) -> Int

Convert cmat to row echelon form.

Returns rank of check matrix.

Examples

julia> cmat = CheckMatrix(Bool[
+  0  1 | 0  1
source
eliminate_column!(cmat::CheckMatrix, col::Integer,
+avoid_row::AbstractVector{T}) where {T <: Union{Nothing, Integer}}

avoid_row can include Nothing, which is ignored in actual evaluation.

source
QuantumLegos.align_row!Function
align_row!(m::AbstractMatrix, row::Integer, occupied::Vector{Union{Nothing, Integer}}) -> Integer
+align_row!(m::AbstractMatrix, row::Nothing, occupied::Vector{Union{Nothing, Integer}}) -> Nothing

Swap row at row in m and row at next to the maximum in occupied. occupied is supposed to be a list of returns from eliminate_column!. If row is in occupied, do nothing and returns row. If row is nothing, return nothing.

Arguments

  • m::AbstractMatrix: mutated
  • row::Union{Nothing, Integer}: row to be aligned
  • occupied::Vector{Union{Nothing, Integer}}: indices of already occupied rows. row will be next to these rows.

Return

  • Row index where row is moved.
source

QuantumLegos.align_row!

By this process, all columns to be traced have 1s on only 1st to 4th rows. So during QuantumLegos.self_trace!, all stabilizers generated from top three rows are calculated and perform operator matching.

post-formatting

Remove rows which are linear combinations of other rows.

QuantumLegos.ref!Function
ref!(cmat::CheckMatrix) -> Int

Convert cmat to row echelon form.

Returns rank of check matrix.

Examples

julia> cmat = CheckMatrix(Bool[
            1 0 1 0 1 1 0 1
            0 1 0 0 0 1 0 0
            1 1 1 0 1 0 1 1
@@ -41,4 +41,4 @@ CheckMatrix with 4 generators, 4 legs:
   0  1  0  0 | 0  1  0  0
   0  0  0  0 | 0  0  1  0
   0  0  0  0 | 0  0  0  0
-
source
+
source
diff --git a/dev/distance/index.html b/dev/distance/index.html index c13522e..c2eba08 100644 --- a/dev/distance/index.html +++ b/dev/distance/index.html @@ -164,4 +164,4 @@ Accumulator{Int64, Int64} with 2 entries: julia> [norm_x..., norm_y..., norm_z...] .|> weight(2) |> counter |> keys |> minimum 3 -

Code distance of the encoding is the minimum degree of the non-zero term in the normalizer's polynomial($B$) and not in the stabilizer's polynomial($A$). So the code distance of this encoding is $3$.

+

Code distance of the encoding is the minimum degree of the non-zero term in the normalizer's polynomial($B$) and not in the stabilizer's polynomial($A$). So the code distance of this encoding is $3$.

diff --git a/dev/index.html b/dev/index.html index cc90955..e8b4ce4 100644 --- a/dev/index.html +++ b/dev/index.html @@ -142,7 +142,7 @@ true pauliop("XX") julia> Lego(stabgens) -Lego{2}(2, StaticArraysCore.SVector{2, QuantumLegos.PauliOps.SinglePauliOp}[pauliop("II"), pauliop("XX")])source
QuantumLegos.LegoLegType
mutable struct State

To be used in State.

Fields

  • lego_id::Int64: index in legos in State
  • edge_id::Int64: index in Lego in legos in State. No validation check included in LegoLeg.

Example

julia> x = LegoLeg.([(2, 1), (1, 1), (1, 0)])
+Lego{2}(2, StaticArraysCore.SVector{2, QuantumLegos.PauliOps.SinglePauliOp}[pauliop("II"), pauliop("XX")])
source
QuantumLegos.LegoLegType
mutable struct State

To be used in State.

Fields

  • lego_id::Int64: index in legos in State
  • edge_id::Int64: index in Lego in legos in State. No validation check included in LegoLeg.

Example

julia> x = LegoLeg.([(2, 1), (1, 1), (1, 0)])
 3-element Vector{LegoLeg}:
  LegoLeg(2, 1)
  LegoLeg(1, 1)
@@ -152,4 +152,4 @@ julia> sort(x)
 3-element Vector{LegoLeg}:
  LegoLeg(1, 0)
  LegoLeg(1, 1)
- LegoLeg(2, 1)
source
QuantumLegos.StateType
mutable struct State

State (in p.4)

Fields

  • legos: Vector{Lego}
  • edges: Vector of ((lego_i, leg_n), (lego_j, leg_m)). Each element is sorted (i.e. lego_i < lego_j or lego_i == lego_j && leg_n < leg_m). This feature is used in is_connected_to_firstlego.
  • cmat::CheckMatrix: CheckMatrix

Constructor

State(legos::Vector{Lego{N}}, edges::Vector{Tuple{LegoLeg, LegoLeg}})

Methods with

Example

TODO

source
QuantumLegos._naive_distanceMethod

Calculate distance. Use minimum distance of all generated normalizers.

source
QuantumLegos.add_edge!Method
add_edge!(state::State, leg_1::LegoLeg, leg_2::LegoLeg)::State

Add a new edge between leg_1 and leg_2, updating state.

source
QuantumLegos.add_lego!Method
add_lego!(state::State, lego::Lego) -> State

Add a new lego, updating state.

source
QuantumLegos.cmat_indexMethod
cmat_index(state::State, leg::LegoLeg)::Int64

Get column index corresponds to leg in check matrix of state. If given leg is already connected, it throws ArgumentError. If given lego_id of leg is out of state.legos, throws ArgumentError.

source
QuantumLegos.distanceMethod
distance(state::State) -> Int

Calculate code distance when the first leg of state is assigned as logical.

source
QuantumLegos.edgeFunction

Helper function to create Tuple{LegoLeg, LegoLeg} to represent edge.

source
QuantumLegos.edgeMethod
edge(t::Tuple{T, T, T, T}) where {T <: Integer}
source
QuantumLegos.edgeMethod
edge(t::Tuple{T, T}) where {T <: Tuple{Integer, Integer}}
source
QuantumLegos.edgeMethod
edge(x::T, y::T, z::T, w::T) where {T <: Integer}
source
QuantumLegos.is_connected_to_firstlegoMethod
is_connected_to_firstlego(state::State)::BitVector

Returns vector which stores whether each lego is connected to the first lego.

source
+ LegoLeg(2, 1)source
QuantumLegos.StateType
mutable struct State

State (in p.4)

Fields

  • legos: Vector{Lego}
  • edges: Vector of ((lego_i, leg_n), (lego_j, leg_m)). Each element is sorted (i.e. lego_i < lego_j or lego_i == lego_j && leg_n < leg_m). This feature is used in is_connected_to_firstlego.
  • cmat::CheckMatrix: CheckMatrix

Constructor

State(legos::Vector{Lego{N}}, edges::Vector{Tuple{LegoLeg, LegoLeg}})

Methods with

Example

TODO

source
QuantumLegos._naive_distanceMethod

Calculate distance. Use minimum distance of all generated normalizers.

source
QuantumLegos.add_edge!Method
add_edge!(state::State, leg_1::LegoLeg, leg_2::LegoLeg)::State

Add a new edge between leg_1 and leg_2, updating state.

source
QuantumLegos.add_lego!Method
add_lego!(state::State, lego::Lego) -> State

Add a new lego, updating state.

source
QuantumLegos.cmat_indexMethod
cmat_index(state::State, leg::LegoLeg)::Int64

Get column index corresponds to leg in check matrix of state. If given leg is already connected, it throws ArgumentError. If given lego_id of leg is out of state.legos, throws ArgumentError.

source
QuantumLegos.distanceMethod
distance(state::State) -> Int

Calculate code distance when the first leg of state is assigned as logical.

source
QuantumLegos.edgeFunction

Helper function to create Tuple{LegoLeg, LegoLeg} to represent edge.

source
QuantumLegos.edgeMethod
edge(t::Tuple{T, T, T, T}) where {T <: Integer}
source
QuantumLegos.edgeMethod
edge(t::Tuple{T, T}) where {T <: Tuple{Integer, Integer}}
source
QuantumLegos.edgeMethod
edge(x::T, y::T, z::T, w::T) where {T <: Integer}
source
QuantumLegos.is_connected_to_firstlegoMethod
is_connected_to_firstlego(state::State)::BitVector

Returns vector which stores whether each lego is connected to the first lego.

source
diff --git a/dev/pauliops/index.html b/dev/pauliops/index.html index 6b86143..071a2aa 100644 --- a/dev/pauliops/index.html +++ b/dev/pauliops/index.html @@ -31,7 +31,7 @@ julia> pauliop("IIX") .* pauliop("XIY") 3-element PauliOp: X::SinglePauliOp = 1 I::SinglePauliOp = 0 - Z::SinglePauliOp = 3

API

QuantumLegos.PauliOpsModule

Pauli operator

source
QuantumLegos.PauliOps.GeneratedPauliGroupType
struct GeneratedPauliGroup

Iterator for group generated from gens.

GeneratedPauliGroup(gens::AbstractVector{T}) where {T <: PauliOp}

Examples

julia> gens = pauliop.(["IIXX", "IZZI"])
+ Z::SinglePauliOp = 3

API

QuantumLegos.PauliOps.GeneratedPauliGroupType
struct GeneratedPauliGroup

Iterator for group generated from gens.

GeneratedPauliGroup(gens::AbstractVector{T}) where {T <: PauliOp}

Examples

julia> gens = pauliop.(["IIXX", "IZZI"])
 2-element Vector{StaticArraysCore.SVector{4, QuantumLegos.PauliOps.SinglePauliOp}}:
  pauliop("IIXX")
  pauliop("IZZI")
@@ -44,9 +44,9 @@ julia> collect(g)
  pauliop("IIII")
  pauliop("IIXX")
  pauliop("IZZI")
- pauliop("IZYX")
source
+end

Pauli Operator on a single qubit.

source
QuantumLegos.PauliOps.pauliopMethod
pauliop(str::AbstractString)::PauliOp

Convert str to PauliOp.

source
QuantumLegos.PauliOps.single_pauliopMethod
single_pauliop(char::Char)::SinglePauliOp

Convert char to SinglePauliOp.

source
QuantumLegos.PauliOps.weightFunction
weight(p::PauliOp, [init = 1])

Weight of the operator p, i.e. non $I$ operator.

source
QuantumLegos.PauliOps.xweightFunction
xweight(p::PauliOp, [init = 1])

Number of $X, Y$ in p.

source
QuantumLegos.PauliOps.zweightFunction
zweight(p::PauliOp, [init = 1])

Number of $Z, Y$ in p. a

source