Skip to content

Commit e6ead20

Browse files
committed
Add comment about similar implementation
1 parent ee1ba54 commit e6ead20

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/generators.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ function Base.iterate(O::Operator, k = 1)
201201
return (O[i, j], k + 1)
202202
end
203203

204+
205+
# We define `similar` to return a standard `Array` because `Operator` does not
206+
# implement `setindex!`. So it it questionable to what extent returning an
207+
# `Operator` would create an "uninitialized _mutable_ array". It would be
208+
# possible to apply `similar` recursively and get something that at least we
209+
# can `copyto!`. However, there is currently nothing in the JuliaQuantumControl
210+
# codebase that would require this, so we're leaving that for a later time.
204211
Base.similar(O::Operator) = Array{eltype(O)}(undef, size(O))
205212
Base.similar(O::Operator, ::Type{S}) where {S} = Array{S}(undef, size(O))
206213
Base.similar(O::Operator, dims::Tuple{Vararg{Int}}) = Array{eltype(O)}(undef, dims)

0 commit comments

Comments
 (0)