Skip to content

Commit 807f5f4

Browse files
authored
Merge pull request #499 from SciML/myb/bc
Fix @.. on MArrays
2 parents a114c4f + 4a9b939 commit 807f5f4

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqBase"
22
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "6.31.0"
4+
version = "6.31.1"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/diffeqfastbc.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,23 @@ preprocess_args(f::typeof(diffeqbc), dest, args::Tuple{}) = ()
4242

4343
# Performance optimization for the common identity scalar case: dest .= val
4444
@inline copyto!(dest::DiffEqBC, bc::Broadcasted{<:AbstractArrayStyle{0}}) = copyto!(dest.x, bc)
45-
@inline function copyto!(dest::DiffEqBC, bc::Broadcasted)
46-
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
47-
dest′ = dest.x
48-
# Performance optimization: broadcast!(identity, dest, A) is equivalent to copyto!(dest, A) if indices match
49-
if bc.f === identity && bc.args isa Tuple{AbstractArray} # only a single input argument to broadcast!
50-
A = bc.args[1]
51-
if axes(dest) == axes(A)
52-
return copyto!(dest′, A)
53-
end
54-
end
55-
bcs′ = preprocess(diffeqbc, dest, bc)
56-
@simd ivdep for I in eachindex(bcs′)
57-
@inbounds dest′[I] = bcs′[I]
58-
end
59-
return dest′ # return the original array without the wrapper
45+
for B in (Broadcasted, Broadcasted{<:StaticArrays.StaticArrayStyle}) # fix ambiguity
46+
@eval @inline function copyto!(dest::DiffEqBC, bc::$B)
47+
axes(dest) == axes(bc) || throwdm(axes(dest), axes(bc))
48+
dest′ = dest.x
49+
# Performance optimization: broadcast!(identity, dest, A) is equivalent to copyto!(dest, A) if indices match
50+
if bc.f === identity && bc.args isa Tuple{AbstractArray} # only a single input argument to broadcast!
51+
A = bc.args[1]
52+
if axes(dest) == axes(A)
53+
return copyto!(dest′, A)
54+
end
55+
end
56+
bcs′ = preprocess(diffeqbc, dest, bc)
57+
@simd ivdep for I in eachindex(bcs′)
58+
@inbounds dest′[I] = bcs′[I]
59+
end
60+
return dest′ # return the original array without the wrapper
61+
end
6062
end
6163

6264
# Forcing `broadcasted` to inline is not necessary, since `Vern9` plays well
@@ -79,12 +81,12 @@ macro ..(x)
7981
expr = Base.Broadcast.__dot__(x)
8082
if expr.head in (:(.=), :(.+=), :(.-=), :(.*=), :(./=), :(.\=), :(.^=)) # we exclude `÷=` `%=` `&=` `|=` `⊻=` `>>>=` `>>=` `<<=` because they are for integers
8183
name = gensym()
82-
dest = :(DiffEqBase.diffeqbc($(expr.args[1])))
84+
dest = :(diffeqbc($(esc(expr.args[1]))))
8385
expr.args[1] = name
84-
return esc(quote
85-
$name = $dest
86-
$expr
87-
end)
86+
return quote
87+
$(esc(name)) = $dest
88+
$(esc(expr))
89+
end
8890
else
8991
return esc(expr)
9092
end

0 commit comments

Comments
 (0)