diff --git a/src/dense_cliffords.jl b/src/dense_cliffords.jl index e4113e0e2..135089901 100644 --- a/src/dense_cliffords.jl +++ b/src/dense_cliffords.jl @@ -104,6 +104,48 @@ function apply!(r::CliffordOperator, l::AbstractCliffordOperator; phases=false) r end +""" +Embed a single-qubit Clifford operator in a larger Clifford operator. + +```jldoctest +julia> embed(5, 4, sHadamard) +X₁ ⟼ + X____ +X₂ ⟼ + _X___ +X₃ ⟼ + __X__ +X₄ ⟼ + ___Z_ +X₅ ⟼ + ____X +Z₁ ⟼ + Z____ +Z₂ ⟼ + _Z___ +Z₃ ⟼ + __Z__ +Z₄ ⟼ + ___X_ +Z₅ ⟼ + ____Z +``` + +Embed a two-qubit Clifford operator in a larger Clifford operator. + +```jldoctest +julia> embed(5, (2,3), sCNOT) +X₁ ⟼ + X____ +X₂ ⟼ + _XX__ +X₃ ⟼ + __X__ +X₄ ⟼ + ___X_ +X₅ ⟼ + ____X +Z₁ ⟼ + Z____ +Z₂ ⟼ + _Z___ +Z₃ ⟼ + _ZZ__ +Z₄ ⟼ + ___Z_ +Z₅ ⟼ + ____Z +``` +""" +function embed(n::Int, i::Int, t::DataType) + return CliffordOperator(t(i), n) +end + +function embed(n::Int, indices::Tuple{Int,Int}, t::DataType) + i, j = collect(indices) + return CliffordOperator(t(i, j), n) +end + # TODO create Base.permute! and getindex(..., permutation_array) function permute(c::CliffordOperator,p) # TODO this is a slow stupid implementation CliffordOperator(Tableau([tab(c)[i][p] for i in 1:2*nqubits(c)][vcat(p,p.+nqubits(c))]))