You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# same implementation as Base.copyto!(dest::AbstractArray, bc::Broadcasted{<:AbstractArrayStyle{0}}) in https://github.com/JuliaLang/julia/blob/master/base/broadcast.jl
459
+
@inlinefunction Base.copyto!(dest::DataOperator{BL,BR}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {BL,BR,Style<:Broadcast.DefaultArrayStyle{0},Axes,F,Args}
460
+
# Typically, we must independently execute bc for every storage location in `dest`, but:
461
+
# IF we're in the common no-op identity case with no nested args (like `dest .= val`),
462
+
if bc.f === identity && bc.args isa Tuple{Any} && Broadcast.isflat(bc)
463
+
# THEN we can just extract the argument and `fill!` the destination with it
464
+
returnfill!(dest, bc.args[1][])
465
+
else
466
+
throw(ArgumentError("no fallback implementation has been defined outside of dest .= val."))
467
+
end
468
+
end
458
469
@inline Base.copyto!(A::DataOperator{BL,BR},B::DataOperator{BL,BR}) where {BL,BR} = (copyto!(A.data,B.data); A)
459
470
@inline Base.copyto!(dest::DataOperator{BL,BR}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {BL,BR,Style<:DataOperatorStyle,Axes,F,Args} =
Copy file name to clipboardExpand all lines: src/states.jl
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -227,6 +227,17 @@ Base.@propagate_inbounds Base.Broadcast._broadcast_getindex(x::T, i) where {T<:U
227
227
end
228
228
return dest
229
229
end
230
+
# same implementation as Base.copyto!(dest::AbstractArray, bc::Broadcasted{<:AbstractArrayStyle{0}}) in https://github.com/JuliaLang/julia/blob/master/base/broadcast.jl
231
+
@inlinefunction Base.copyto!(dest::Ket{B}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {B,Style<:Broadcast.DefaultArrayStyle{0},Axes,F,Args}
232
+
# Typically, we must independently execute bc for every storage location in `dest`, but:
233
+
# IF we're in the common no-op identity case with no nested args (like `dest .= val`),
234
+
if bc.f === identity && bc.args isa Tuple{Any} && Broadcast.isflat(bc)
235
+
# THEN we can just extract the argument and `fill!` the destination with it
236
+
returnfill!(dest, bc.args[1][])
237
+
else
238
+
throw(ArgumentError("no fallback implementation has been defined outside of dest .= val."))
239
+
end
240
+
end
230
241
@inline Base.copyto!(dest::Ket{B1}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {B1,B2,Style<:KetStyle{B2},Axes,F,Args} =
231
242
throw(IncompatibleBases())
232
243
@@ -240,6 +251,17 @@ end
240
251
end
241
252
return dest
242
253
end
254
+
# same implementation as Base.copyto!(dest::AbstractArray, bc::Broadcasted{<:AbstractArrayStyle{0}}) in https://github.com/JuliaLang/julia/blob/master/base/broadcast.jl
255
+
@inlinefunction Base.copyto!(dest::Bra{B}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {B,Style<:Broadcast.DefaultArrayStyle{0},Axes,F,Args}
256
+
# Typically, we must independently execute bc for every storage location in `dest`, but:
257
+
# IF we're in the common no-op identity case with no nested args (like `dest .= val`),
258
+
if bc.f === identity && bc.args isa Tuple{Any} && Broadcast.isflat(bc)
259
+
# THEN we can just extract the argument and `fill!` the destination with it
260
+
returnfill!(dest, bc.args[1][])
261
+
else
262
+
throw(ArgumentError("no fallback implementation has been defined outside of dest .= val."))
263
+
end
264
+
end
243
265
@inline Base.copyto!(dest::Bra{B1}, bc::Broadcast.Broadcasted{Style,Axes,F,Args}) where {B1,B2,Style<:BraStyle{B2},Axes,F,Args} =
0 commit comments