From b17614a99faba5c6811f776f2ef9536fc99545f4 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt <46929125+Abhishek-1Bhatt@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:47:09 -0400 Subject: [PATCH] some renaming and a correction in project_traceout! (#42) --- src/backends/quantumoptics/express.jl | 2 +- src/backends/quantumoptics/quantumoptics.jl | 2 +- src/baseops/traceout.jl | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backends/quantumoptics/express.jl b/src/backends/quantumoptics/express.jl index 35b20a6b..66fd151d 100644 --- a/src/backends/quantumoptics/express.jl +++ b/src/backends/quantumoptics/express.jl @@ -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 diff --git a/src/backends/quantumoptics/quantumoptics.jl b/src/backends/quantumoptics/quantumoptics.jl index f1b97284..6ec699f6 100644 --- a/src/backends/quantumoptics/quantumoptics.jl +++ b/src/backends/quantumoptics/quantumoptics.jl @@ -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) diff --git a/src/baseops/traceout.jl b/src/baseops/traceout.jl index 9a739c5d..57773099 100644 --- a/src/baseops/traceout.jl +++ b/src/baseops/traceout.jl @@ -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)