Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/dense_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ end
CliffordOperator(op::CliffordOperator) = op
CliffordOperator(paulis::AbstractVector{<:PauliOperator}) = CliffordOperator(Tableau(paulis))
CliffordOperator(destab::Destabilizer) = CliffordOperator(tab(destab))
function CliffordOperator(pauli::PauliOperator)
res = one(CliffordOperator, nqubits(pauli))
tab(res).phases = 0x02 * comm(pauli, tab(res))
return res
end

Base.:(==)(l::CliffordOperator, r::CliffordOperator) = tab(l) == tab(r)
Base.hash(c::T, h::UInt) where {T<:CliffordOperator} = hash(T, hash(tab(c), h))
Expand Down Expand Up @@ -91,6 +96,7 @@ function Base.copy(c::CliffordOperator)
end

@inline nqubits(c::CliffordOperator) = nqubits(tab(c))
@inline phases(c::CliffordOperator) = phases(tab(c))

Base.zero(c::CliffordOperator) = CliffordOperator(zero(tab(c)))
Base.zero(::Type{<:CliffordOperator}, n) = CliffordOperator(zero(Tableau, 2n, n))
Expand Down
7 changes: 7 additions & 0 deletions test/test_cliff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
@testset "Constructors" begin
@test_throws DimensionMismatch CliffordOperator(T"X")
end
@testset "Constructor from PauliOperator" begin
for n in test_sizes
l = random_clifford(n)
pauli = random_pauli(n)
@test isequal(apply!(copy(l), pauli; phases=true), apply!(l, CliffordOperator(pauli); phases=true))
end
end
@testset "Permutations of qubits" begin
for c in [tCNOT, tId1tHadamard, tCNOTtCNOT, tensor_pow(tCNOT,6), tensor_pow(tCNOT,7), tensor_pow(tCNOT,6)tPhase, tensor_pow(tCNOT,7)tPhase]
for rep in 1:5
Expand Down
Loading