Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/index_double_sums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ function *(elem::IndexedObSym, sum::DoubleSum)
return elem*sum_
end
NEI = copy(sum.NEI)
if elem.ind ∉ [sum.sum_index, sum.innerSum.sum_index]
aon_sum = sum.sum_index.aon
aon_elem = elem.ind.aon
if aon_sum ≠ aon_elem # issue QuantumCumulants 256
return DoubleSum(elem*sum.innerSum, sum.sum_index, NEI)
end
if elem.ind != sum.sum_index && elem.ind ∉ NEI
Expand Down Expand Up @@ -184,10 +186,12 @@ function *(sum::DoubleSum, elem::IndexedObSym)
return sum_*elem
end
NEI = copy(sum.NEI)
if elem.ind ∉ [sum.sum_index, sum.innerSum.sum_index]
aon_sum = sum.sum_index.aon
aon_elem = elem.ind.aon
if aon_sum ≠ aon_elem # issue QuantumCumulants 256
return DoubleSum(sum.innerSum*elem, sum.sum_index, NEI)
end
if elem.ind != sum.sum_index && elem.ind ∉ NEI
if elem.ind != sum.sum_index && elem.ind ∉ NEI # TODO: What if elem is a BasicSymboli{IndexedVariable}?
if (sum.sum_index.aon != sum.innerSum.sum_index.aon) # indices for different ops
if isequal(elem.ind.aon, sum.sum_index.aon)
push!(NEI, elem.ind)
Expand Down
22 changes: 15 additions & 7 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,25 @@ end #put elements from outside into sum
-(sum::SingleSum, op::Any) = -1*op + sum

function *(op1::IndexedOperator, op2::IndexedOperator)
if isequal(op1.ind, op2.ind)
if op1.op isa Transition
return IndexedOperator(op1.op*op2.op, op1.ind)
end
if op1.op isa Destroy && op2.op isa Create
return op2*op1 + 1
aon1 = acts_on(op1) # sort by HilbertSpace
aon2 = acts_on(op2)
if aon1==aon2
if isequal(op1.ind, op2.ind)
if op1.op isa Transition
return IndexedOperator(op1.op*op2.op, op1.ind)
end
if op1.op isa Destroy && op2.op isa Create
return op2*op1 + 1
else
return QMul(1, [op1, op2])
end
else
return QMul(1, [op1, op2])
end
else
elseif aon1 < aon2
return QMul(1, [op1, op2])
else # aon2 < aon1
return QMul(1, [op2, op1])
end
end

Expand Down
Loading