Skip to content

Commit 774662e

Browse files
committed
Get all tests passing!
1 parent 01d7ace commit 774662e

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1515
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
1616
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1717
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
18-
TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b"
1918
UnsafeArrays = "c4a57d5a-5b31-53a6-b365-19f8c011fbd6"
2019

2120
[compat]
@@ -31,6 +30,5 @@ Random = "1"
3130
RecursiveArrayTools = "3"
3231
SparseArrays = "1"
3332
Strided = "1, 2"
34-
TensorCast = "0.4"
3533
UnsafeArrays = "1"
3634
julia = "1.10"

src/apply.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ function apply!(state::Operator, indices, operation::Operator)
2323
state
2424
end
2525

26-
function apply!(state::Ket, indices, operation::T) where {T<:SuperOperatorType}
26+
function apply!(state::Ket, indices, operation::SuperOperatorType)
2727
apply!(dm(state), indices, operation)
2828
end
2929

30-
function apply!(state::Operator, indices, operation::T) where {T<:SuperOperatorType}
31-
if is_apply_shortcircuit(state, indices, operation)
32-
state.data = (operation*state).data
30+
function apply!(state::Operator, indices, operation::SuperOperatorType)
31+
vecd = vec(state)
32+
if is_apply_shortcircuit(vecd, indices, operation)
33+
state.data = unvec(operation*vecd).data
3334
return state
3435
else
3536
error("`apply!` does not yet support embedding superoperators acting only on a subsystem of the given state")

src/metrics.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,14 @@ logarithmic_negativity(rho::DenseOpType{B,B}, index) where B<:CompositeBasis = l
253253
254254
The average gate fidelity between two superoperators x and y.
255255
"""
256-
257-
"""
258-
function avg_gate_fidelity(x::T, y::T) where T <: Union{PauliTransferMatrix{B, B} where B, SuperOperator{B, B} where B, ChiMatrix{B, B} where B}
259-
dim = 2 ^ length(x.basis_l)
256+
function avg_gate_fidelity(x::T, y::T) where T <: Union{PauliTransferType, SuperOperatorType}
257+
check_multiplicable(x,x); check_multiplicable(y,y)
258+
check_samebases(basis_l(basis_l(x)), basis_r(basis_l(x)));
259+
dim = dimension(basis_l(basis_l(x)))
260260
return (tr(transpose(x.data) * y.data) + dim) / (dim^2 + dim)
261261
end
262-
"""
262+
263+
avg_gate_fidelity(x::T, y::T) where T <: Union{ChoiStateType, ChiType} = avg_gate_fidelity(super(x), super(y))
263264

264265
"""
265266
entanglement_entropy(state, partition, [entropy_fun=entropy_vn])

test/runtests.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
"""
21
names = [
32
"test_states.jl",
43

@@ -61,7 +60,3 @@ for name=names
6160
include(name)
6261
end
6362
end
64-
"""
65-
66-
include("test_pauli.jl")
67-
#include("test_superoperators.jl")

test/test_metrics.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ rho_mix = DenseOperator(rho_ent.basis_l, diagm(ComplexF64[1.0,1.0,1.0,1.0]))
128128
@test_throws ArgumentError entanglement_entropy(rho_mix, 3)
129129

130130
CNOT = dm(spinup(b1))identityoperator(b1) + dm(spindown(b1))sigmax(b1)
131-
CNOT_sop = SuperOperator(CNOT)
132-
CNOT_chi = ChiMatrix(CNOT)
133-
CNOT_ptm = PauliTransferMatrix(CNOT)
131+
CNOT_sop = sprepost(CNOT, dagger(CNOT))
132+
CNOT_chi = chi(CNOT_sop)
133+
CNOT_ptm = pauli(CNOT_sop)
134134

135-
@test avg_gate_fidelity(CNOT_sop, CNOT_sop) == 1
136-
@test avg_gate_fidelity(CNOT_chi, CNOT_chi) == 1
137-
@test avg_gate_fidelity(CNOT_ptm, CNOT_ptm) == 1
135+
@test avg_gate_fidelity(CNOT_sop, CNOT_sop) 1
136+
@test avg_gate_fidelity(CNOT_chi, CNOT_chi) 1
137+
@test avg_gate_fidelity(CNOT_ptm, CNOT_ptm) 1
138138

139139
@test_throws MethodError avg_gate_fidelity(CNOT_sop, CNOT_chi)
140140
@test_throws MethodError avg_gate_fidelity(CNOT_sop, CNOT_ptm)

0 commit comments

Comments
 (0)