Skip to content

Commit 03cb231

Browse files
committed
WIP
1 parent 624a629 commit 03cb231

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

src/QuantumOpticsBase.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ using SparseArrays, LinearAlgebra, LRUCache, Strided, UnsafeArrays, FillArrays
44
import LinearAlgebra: mul!, rmul!
55
import RecursiveArrayTools
66

7-
import QuantumInterface: dagger, directsum, , dm, embed, nsubsystems, expect, identityoperator, identitysuperoperator,
8-
permutesystems, projector, ptrace, reduced, tensor, , variance, apply!, basis, basis_l, basis_r
7+
import QuantumInterface: Basis, GenericBasis, CompositeBasis, basis, basis_l, basis_r,
8+
IncompatibleBases, @compatiblebases, samebases, check_samebases,
9+
addible, check_addible, multiplicable, check_multiplicable, reduced, ptrace, permutesystems,
10+
dagger, directsum, , dm, embed, nsubsystems, expect, identityoperator, identitysuperoperator,
11+
permutesystems, projector, ptrace, reduced, tensor, , variance, apply!,
12+
super, choi, kraus, vec, spre, spost, sprepost, liouvillian
913

1014
# index helpers
1115
import QuantumInterface: complement, remove, shiftremove, reducedindices!, check_indices, check_sortedindices, check_embed_indices
@@ -35,9 +39,8 @@ export Basis, GenericBasis, CompositeBasis, basis, basis_l, basis_r,
3539
AbstractTimeDependentOperator, TimeDependentSum, set_time!,
3640
current_time, time_shift, time_stretch, time_restrict, static_operator,
3741
#superoperators
38-
SuperOperator, DenseSuperOperator, DenseSuperOpType,
39-
SparseSuperOperator, SparseSuperOpType, spre, spost, sprepost, liouvillian,
40-
identitysuperoperator,
42+
KetBraBasis, ChoiBasis, super, choi, kraus, vec,
43+
spre, spost, sprepost, liouvillian, identitysuperoperator,
4144
#fock
4245
FockBasis, number, destroy, create,
4346
fockstate, coherentstate, coherentstate!,
@@ -71,7 +74,6 @@ export Basis, GenericBasis, CompositeBasis, basis, basis_l, basis_r,
7174
#apply
7275
apply!
7376

74-
include("bases.jl")
7577
include("states.jl")
7678
include("operators.jl")
7779
include("operators_dense.jl")
@@ -92,7 +94,7 @@ include("particle.jl")
9294
include("nlevel.jl")
9395
include("manybody.jl")
9496
include("transformations.jl")
95-
include("pauli.jl")
97+
#include("pauli.jl")
9698
include("metrics.jl")
9799
include("spinors.jl")
98100
include("phasespace.jl")

src/apply.jl

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

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

30-
function apply!(state::Operator, indices, operation::T) where {T<:AbstractSuperOperator}
30+
function apply!(state::Operator, indices, operation::T) where {T<:SuperOperatorType}
3131
if is_apply_shortcircuit(state, indices, operation)
3232
state.data = (operation*state).data
3333
return state

src/bases.jl

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/metrics.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,14 @@ logarithmic_negativity(rho::DenseOpType{B,B}, index) where B<:CompositeBasis = l
253253
avg_gate_fidelity(x, y)
254254
255255
The average gate fidelity between two superoperators x and y.
256+
"""
257+
256258
"""
257259
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}
258260
dim = 2 ^ length(x.basis_l)
259261
return (tr(transpose(x.data) * y.data) + dim) / (dim^2 + dim)
260262
end
263+
"""
261264

262265
"""
263266
entanglement_entropy(state, partition, [entropy_fun=entropy_vn])

src/operators.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ Embed operator acting on a joint Hilbert space where missing indices are filled
2323
"""
2424
function embed(bl::CompositeBasis, br::CompositeBasis,
2525
indices, op::T) where T<:DataOperator
26-
(nsubsystems(basis_l) == nsubsystems(basis_r)) || throw(ArgumentError("Must have nsubsystems(bl) == nsubsystems(br) in embed"))
27-
N = nsubsystems(basis_l)
26+
(nsubsystems(bl) == nsubsystems(br)) || throw(ArgumentError("Must have nsubsystems(bl) == nsubsystems(br) in embed"))
27+
N = nsubsystems(bl)
2828

29-
reduce(tensor, bl[indices]) == op.basis_l || throw(IncompatibleBases())
30-
reduce(tensor, br[indices]) == op.basis_r || throw(IncompatibleBases())
29+
reduce(tensor, bl[indices]) == basis_l(op) || throw(IncompatibleBases())
30+
reduce(tensor, br[indices]) == basis_r(op) || throw(IncompatibleBases())
3131

3232
index_order = [idx for idx in 1:N if idx indices]
3333
all_operators = AbstractOperator[identityoperator(T, eltype(op), bl[i], br[i]) for i in index_order]
@@ -44,8 +44,8 @@ function embed(bl::CompositeBasis, br::CompositeBasis,
4444

4545
# Reorient the matrix to act in the correctly ordered basis.
4646
# Get the dimensions necessary for index permuting.
47-
dims_l = size(basis_l)
48-
dims_r = size(basis_r)
47+
dims_l = size(bl)
48+
dims_r = size(br)
4949

5050
# Get the order of indices to use in the first reshape. Julia indices go in
5151
# reverse order.
@@ -65,7 +65,7 @@ function embed(bl::CompositeBasis, br::CompositeBasis,
6565

6666
# Create operator with proper data and bases
6767
constructor = Base.typename(T)
68-
unpermuted_op = constructor.wrapper(basis_l, basis_r, M)
68+
unpermuted_op = constructor.wrapper(bl, br, M)
6969

7070
return unpermuted_op
7171
end

src/superoperators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import LinearAlgebra: vec
1+
import QuantumInterface: KetBraBasis, ChoiBasis
22

33
const SuperOperatorType = Operator{<:KetBraBasis,<:KetBraBasis}
4-
const ChoiStateType = Operator{CompositeBasis{<:Integer,<:Choi},CompositeBasis{<:Integer,<:Choi}}
4+
const ChoiStateType = Operator{CompositeBasis{<:Integer,<:ChoiBasis},CompositeBasis{<:Integer,<:ChoiBasis}}
55

66
vec(op::Operator) = Ket(KetBraBasis(basis_l(op), basis_r(op)), reshape(op.data, length(op.data)))
77

0 commit comments

Comments
 (0)