QuantumOptics.jl
QuantumOptics.jl copied to clipboard
laziness-preserving embed?
Should there be embed()
methods for LazyTensor
, LazySum
, and LazyProduct
that preserve laziness? The method would "embed" each of the component operators. For example:
function embed(basis, indices, op::LazyTensor)
LazyTensor(basis, indices, op.operators, op.factor)
end
function embed(basis, indices, op::LazySum)
LazySum(basis, [embed(basis, indices, o) for o in op.operators], op.factors)
end
To be honest, I thought there already was an embed
for LazyTensor
(but I guess I was wrong). Would be nice to have all of those methods, of course. Another thing that's also missing is an embed
for directsum
stuff, but that's a different issue.
I took another look. Indeed it seems everything is there, but something is going wrong: It looks like the identityoperator()
method for the LazyTensor type is not working properly. For a LazyTensor O
I get
embed(b123, [1,2], O)
ERROR: ArgumentError: Identity operator not defined for operator type LazyTensor{CompositeBasis{Vector{Int64}, Tuple{FockBasis{Int64}, FockBasis{Int64}}}, CompositeBasis{Vector{Int64}, Tuple{FockBasis{Int64}, FockBasis{Int64}}}, ComplexF64, Vector{Int64}, Tuple{Operator{FockBasis{Int64}, FockBasis{Int64}, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}}}.
LazySum is different:
embed(b, 1, ls)
ERROR: ArgumentError: Tensor product is not defined for this combination of types of operators: LazySum{FockBasis{Int64}, FockBasis{Int64}, Vector{ComplexF64}, Tuple{Operator{FockBasis{Int64}, FockBasis{Int64}, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}}}, LazySum{FockBasis{Int64}, FockBasis{Int64}, Vector{ComplexF64}, Tuple{Operator{FockBasis{Int64}, FockBasis{Int64}, SparseArrays.SparseMatrixCSC{ComplexF64, Int64}}}}.
Maybe we just need a parametric type in the first argument for the identityoperator()
method for LazyTensor. For LazySum, we would need to add (tensor) products.
Mostly fixed in https://github.com/qojulia/QuantumOpticsBase.jl/pull/51