Skip to content

Commit

Permalink
fix error and remove Ket from project_traceout! just for this pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro committed Sep 2, 2023
1 parent a5d1907 commit bceecfa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/backends/quantumoptics/quantumoptics.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QuantumOpticsBase
import QuantumOpticsBase: GenericBasis, CompositeBasis,
StateVector, AbstractSuperOperator, Ket, Operator,
StateVector, AbstractSuperOperator, Ket, Operator,basis,
basisstate, spinup, spindown, sigmap, sigmax, sigmay, sigmaz, destroy,
projector, identityoperator, embed, dm, expect, ptrace, spre, spost
import QuantumOptics
Expand Down 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{})
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
4 changes: 2 additions & 2 deletions src/baseops/apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function apply!(regs::Vector{Register}, indices::Vector{Int}, operation; time=no
uptotime!(regs, indices, max_time)
subsystemcompose(regs,indices)
state = regs[1].staterefs[indices[1]].state[]
if !(basis(state)==basis(operation)) # e.g., performing a 2 qubit operation on a 4 qubit ket state
if (typeof(state) <: Ket) && !(basis(state)==basis(operation)) # e.g., performing a 2 qubit operation on a 4 qubit ket state
state_indices_app = [r.stateindices[i] for (r,i) in zip(regs, indices)] # state indices on which we are performing the op
state_indices = [idx for idx in 1:length(basis(state).bases) if idx state_indices_app] #state indices on which no op is performed
else
state_indices = []
state_indices = [r.stateindices[i] for (r,i) in zip(regs, indices)]
end
state = apply!(state, state_indices, operation)
regs[1].staterefs[indices[1]].state[] = state
Expand Down

0 comments on commit bceecfa

Please sign in to comment.