Skip to content

Commit

Permalink
some renaming and a correction in project_traceout! (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro authored Sep 12, 2023
1 parent 381a5bb commit b17614a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/backends/quantumoptics/express.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ function project_traceout!(state::Union{Ket,Operator},stateindex,basis::Symbolic
project_traceout!(state,stateindex,eigvecs(basis))
end

function project_traceout!(state::Union{Ket,Operator},stateindex,basis::Vector{<:Symbolic{AbstractKet}})
function project_traceout!(state::Union{Ket,Operator},stateindex,basis::Base.AbstractVecOrTuple{<:Symbolic{AbstractKet}})
project_traceout!(state,stateindex,express.(basis,(QOR,)))
end
2 changes: 1 addition & 1 deletion src/backends/quantumoptics/quantumoptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function observable(state::Union{<:Ket,<:Operator}, indices, operation)
expect(op, state)
end

function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Base.AbstractVecOrTuple{Ket})
function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Base.AbstractVecOrTuple{<:Ket})
if nsubsystems(state) == 1 # TODO is there a way to do this in a single function, instead of _overlap vs _project_and_drop
_overlaps = [_overlap(psi,state) for psi in psis]
branch_probs = cumsum(_overlaps)
Expand Down
12 changes: 6 additions & 6 deletions src/baseops/traceout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ A basis object can be specified on its own as well, e.g.
"""
function project_traceout! end

function project_traceout!(reg::Register, i::Int, psis; time=nothing)
project_traceout!(identity, reg, i, psis; time=time)
function project_traceout!(reg::Register, i::Int, basis; time=nothing)
project_traceout!(identity, reg, i, basis; time=time)
end
project_traceout!(r::RegRef, psis; time=nothing) = project_traceout!(r.reg, r.idx, psis; time=nothing)
project_traceout!(r::RegRef, basis; time=nothing) = project_traceout!(r.reg, r.idx, basis; time=nothing)

function project_traceout!(f, reg::Register, i::Int, psis; time=nothing)
function project_traceout!(f, reg::Register, i::Int, basis; time=nothing)
!isnothing(time) && uptotime!([reg], [i], time)
stateref = reg.staterefs[i]
stateindex = reg.stateindices[i]
if isnothing(stateref) # TODO maybe use isassigned
throw("error") # make it more descriptive
end
j, stateref.state[] = project_traceout!(stateref.state[],stateindex,psis)
j, stateref.state[] = project_traceout!(stateref.state[],stateindex,basis)
removebackref!(stateref, stateindex)
f(j)
end
project_traceout!(f, r::RegRef, psis; time=nothing) = project_traceout!(f, r.reg, r.idx, psis; time=nothing)
project_traceout!(f, r::RegRef, basis; time=nothing) = project_traceout!(f, r.reg, r.idx, basis; time=nothing)

0 comments on commit b17614a

Please sign in to comment.