diff --git a/src/backends/quantumoptics/quantumoptics.jl b/src/backends/quantumoptics/quantumoptics.jl index f1b97284..e5c657c5 100644 --- a/src/backends/quantumoptics/quantumoptics.jl +++ b/src/backends/quantumoptics/quantumoptics.jl @@ -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 @@ -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) diff --git a/src/baseops/apply.jl b/src/baseops/apply.jl index d2fb15f9..1228935e 100644 --- a/src/baseops/apply.jl +++ b/src/baseops/apply.jl @@ -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