Skip to content

Commit f4b872e

Browse files
committed
Tuples now used in lazyarithmetic
1 parent f9c3a8c commit f4b872e

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/QuantumOpticsBase.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ include("metrics.jl")
8080
include("spinors.jl")
8181
include("phasespace.jl")
8282
include("printing.jl")
83+
include("operators_lazyaritmetic.jl")
8384

8485
end # module

src/LazyOperatorAritmetic.jl renamed to src/operators_lazyaritmetic.jl

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,30 @@ function QuantumOpticsBase.:⊗(a::Operator,b::LazyTensor)
5151
end
5252

5353

54-
5554
function QuantumOpticsBase.:(a::Operator,b::LazySum)
5655
btotal_l = a.basis_l b.basis_l
5756
btotal_r = a.basis_r b.basis_r
58-
ops = Vector{AbstractOperator}(undef,length(b.operators))
59-
for i in eachindex(ops)
60-
ops[i] = a b.operators[i]
61-
end
57+
ops = ([a op op in b.operators]...,)
6258
LazySum(btotal_l,btotal_r,b.factors,ops)
6359
end
6460
function QuantumOpticsBase.:(a::LazySum,b::Operator)
6561
btotal_l = a.basis_l b.basis_l
6662
btotal_r = a.basis_r b.basis_r
67-
ops = Vector{AbstractOperator}(undef,length(a.operators))
68-
for i in eachindex(ops)
69-
ops[i] = a.operators[i] b
70-
end
63+
ops = ([op b op in a.operators]...,)
7164
LazySum(btotal_l,btotal_r,a.factors,ops)
7265
end
7366

7467

7568
function QuantumOpticsBase.:(a::Operator,b::LazyProduct)
7669
btotal_l = a.basis_l b.basis_l
7770
btotal_r = a.basis_r b.basis_r
78-
ops = Vector{AbstractOperator}(undef,length(b.operators))
79-
for i in eachindex(ops)
80-
ops[i] = a b.operators[i]
81-
end
71+
ops = ([a op op in b.operators]...,)
8272
LazyProduct(btotal_l,btotal_r,b.factor,ops)
8373
end
8474
function QuantumOpticsBase.:(a::LazyProduct,b::Operator)
8575
btotal_l = a.basis_l b.basis_l
8676
btotal_r = a.basis_r b.basis_r
87-
ops = Vector{AbstractOperator}(undef,length(a.operators))
88-
for i in eachindex(ops)
89-
ops[i] = a.operators[i] b
90-
end
77+
ops = ([op b op in a.operators]...,)
9178
LazyProduct(btotal_l,btotal_r,a.factor,ops)
9279
end
9380

@@ -105,3 +92,8 @@ function QuantumOpticsBase.:⊗(a::LazyTensor,b::AbstractOperator)
10592
ops = (a.operators...,b)
10693
LazyTensor(btotal_l,btotal_r,indices,ops,a.factor)
10794
end
95+
96+
97+
98+
99+

0 commit comments

Comments
 (0)