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.CheckMatrix — TypeCheckMatrix
Fields
cmat: matrix itself (matrix ofBoolsince we consider only pauli ops.)nlegs: number of columns ÷ 2ngens: number of rows
Constructor
CheckMatrix(cmat::AbstractMatrix{Bool})See also checkmatrix.
QuantumLegos.checkmatrix — Functioncheckmatrix(stbgens::AbstractVector{T})::CheckMatrix where {T <: PauliOp}Get CheckMatrix from stabilizer generator.
Get xpart and zpart of check matrix.
QuantumLegos.xpart — Functionxpart(cmat::CheckMatrix)Get X part (left half) of CheckMatrix.
QuantumLegos.zpart — Functionzpart(cmat::CheckMatrix)Get Z part (right half) of CheckMatrix.
Get generators from check matrix with generators.
QuantumLegos.generators — Functiongenerators(cmat::CheckMatrix)::Vector{PauliOp}Get generators from CheckMatrix.
See also, GeneratedPauliGroup and Base.Set to get group generated by generators.
Direct sum
Used when adding lego without edge.
QuantumLegos.direct_sum — Functiondirect_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}\]
Self-tracing
self-tracing
QuantumLegos.self_trace! — Functionself_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
During self-tracing, pre-formatting and post-formatting described below is performed.
pre-formatting
QuantumLegos.eliminate_column! — Functioneliminate_column!(
cmat::CheckMatrix,
col::Integer,
avoid_row::AbstractVector{T},
)::Union{Nothing, Int64} where {T <: Integer}Perform Gauss Elimination on col. Keep only one 1 on col and remove from other rows by performing multiplication. Choose row not in avoid_row. If all rows with 1 on col are in avoid_row, then the last row of them is chose to keep 1. If all rows on col is 0, return nothing.
Return
Row index which have 1 on col. If all row on col is 0, return nothing.
Example
julia> ex_cmat = CheckMatrix(Bool[1 0 1 0; 1 1 1 1])
CheckMatrix with 2 generators, 2 legs:
1 0 | 1 0
1 1 | 1 1
julia> QuantumLegos.eliminate_column!(ex_cmat, 1, Int64[])
1
julia> ex_cmat
CheckMatrix with 2 generators, 2 legs:
1 0 | 1 0
0 1 | 0 1eliminate_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.
QuantumLegos.align_row! — Functionalign_row!(m::AbstractMatrix, row::Integer, occupied::Vector{Union{Nothing, Integer}}) -> Integer
align_row!(m::AbstractMatrix, row::Nothing, occupied::Vector{Union{Nothing, Integer}}) -> NothingSwap 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: mutatedrow::Union{Nothing, Integer}: row to be alignedoccupied::Vector{Union{Nothing, Integer}}: indices of already occupied rows.rowwill be next to these rows.
Return
- Row index where
rowis moved.
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! — Functionref!(cmat::CheckMatrix) -> IntConvert 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
0 1 0 0 0 1 0 0
])
CheckMatrix with 4 generators, 4 legs:
1 0 1 0 | 1 1 0 1
0 1 0 0 | 0 1 0 0
1 1 1 0 | 1 0 1 1
0 1 0 0 | 0 1 0 0
julia> QuantumLegos.ref!(cmat)
3
julia> cmat
CheckMatrix with 4 generators, 4 legs:
1 0 1 0 | 1 1 0 1
0 1 0 0 | 0 1 0 0
0 0 0 0 | 0 0 1 0
0 0 0 0 | 0 0 0 0
QuantumLegos.eliminate_dependent_row! — Functioneliminate_dependent_row!(cmat::CheckMatrix) -> CheckMatrixRemove dependent rows to keep only independent generators.