Skip to content

Commit 4a5d062

Browse files
authored
Change more broadcasts over broadcast args to maps (#211)
* Change more broadcasts over broadcast args to maps * Bump version to v0.13.2
1 parent cfc2e58 commit 4a5d062

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockBandedMatrices"
22
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
3-
version = "0.13.1"
3+
version = "0.13.2"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/broadcast.jl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ function _broadcast_blockbandwidths((l,u), A::AbstractArray, (ax1,ax2))
5858
end
5959

6060

61-
blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)}) =
62-
min.(_broadcast_blockbandwidths.(Ref(_blockbnds(bc)), bc.args, Ref(axes(bc)))...)
61+
function blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)})
62+
ax = axes(bc)
63+
blkinds = _blockbnds(bc)
64+
t = map(bc.args) do x
65+
_broadcast_blockbandwidths(blkinds, x, ax)
66+
end
67+
min.(t...)
68+
end
6369

6470
blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(/)}) = _broadcast_blockbandwidths(_blockbnds(bc), first(bc.args), axes(bc))
6571
blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(\)}) = _broadcast_blockbandwidths(_blockbnds(bc), last(bc.args), axes(bc))
@@ -76,16 +82,26 @@ function _broadcast_subblockbandwidths((l,u), A::AbstractArray)
7682
subblockbandwidths(A) # need to special case vector broadcasting
7783
end
7884

79-
subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)}) =
80-
min.(_broadcast_subblockbandwidths.(Ref(_subblockbnds(bc)), bc.args)...)
85+
function subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)})
86+
subbbw = _subblockbnds(bc)
87+
t = map(bc.args) do x
88+
_broadcast_subblockbandwidths(subbbw, x)
89+
end
90+
min.(t...)
91+
end
8192

8293
subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(/)}) = _broadcast_subblockbandwidths(_subblockbnds(bc), first(bc.args))
8394
subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(\)}) = _broadcast_subblockbandwidths(_subblockbnds(bc), last(bc.args))
8495

8596
function subblockbandwidths(bc::Broadcasted)
8697
(a,b) = size(bc)
8798
bnds = (a-1,b-1)
88-
_isweakzero(bc.f, bc.args...) && return min.(bnds, max.(_broadcast_subblockbandwidths.(Ref(bnds), bc.args)...))
99+
if _isweakzero(bc.f, bc.args...)
100+
t = map(bc.args) do x
101+
_broadcast_subblockbandwidths(bnds, x)
102+
end
103+
return min.(bnds, max.(t...))
104+
end
89105
bnds
90106
end
91107

0 commit comments

Comments
 (0)