Skip to content

Commit

Permalink
add a trace dispatch for normalized objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro committed Oct 31, 2023
1 parent 3d058f8 commit 62d01f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/StatesZoo/StatesZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import QuantumSymbolics: express_nolookup
using LinearAlgebra
import LinearAlgebra: tr

export SingleRailMidSwapBellU, SingleRailMidSwapBellN, DualRailMidSwapBellU, DualRailMidSwapBellN, ZALMSpinPairU, ZALMSpinPairN
export SingleRailMidSwapBellU, SingleRailMidSwapBellN, DualRailMidSwapBellU, DualRailMidSwapBellN, ZALMSpinPairU, ZALMSpinPairN, tr

abstract type AbstractTwoQubitState <: QuantumSymbolics.AbstractTwoQubitOp end #For representing density matrices
Base.show(io::IO, x::AbstractTwoQubitState) = print(io, "$(symbollabel(x))")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,9 @@ end
function express_nolookup(x::DualRailMidSwapBellN, ::QuantumOpticsRepr)
data = midswap_dual_rail(x.eA, x.eB, x.gA, x.gB, x.Pd, x.Vis)
return SparseOperator(_bspin_bspin, Complex.(data/tr(data)))
end
end

# Symbolic trace

tr(::SingleRailMidSwapBellN) = 1

Check warning on line 194 in src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl

View check run for this annotation

Codecov / codecov/patch

src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl#L194

Added line #L194 was not covered by tests
tr(::DualRailMidSwapBellN) = 1
5 changes: 4 additions & 1 deletion src/StatesZoo/zalm_pair/zalm_pair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,7 @@ end
function express_nolookup(x::ZALMSpinPairN, ::QuantumOpticsRepr)
data = cascaded_source_spin(x.Ns, x.gA, x.gB, x.eAm, x.eBm, x.eAs, x.eBs, x.eD, x.Pd, x.Pdo1, x.Pdo2, x.VisF)
return SparseOperator(_bspin_bspin, Complex.(data/tr(data)))
end
end

## Symbolic trace
tr(::ZALMSpinPairN) = 1

Check warning on line 678 in src/StatesZoo/zalm_pair/zalm_pair.jl

View check run for this annotation

Codecov / codecov/patch

src/StatesZoo/zalm_pair/zalm_pair.jl#L678

Added line #L678 was not covered by tests

0 comments on commit 62d01f8

Please sign in to comment.