Skip to content

Commit

Permalink
Change more broadcasts over broadcast args to maps (#211)
Browse files Browse the repository at this point in the history
* Change more broadcasts over broadcast args to maps

* Bump version to v0.13.2
  • Loading branch information
jishnub authored Oct 16, 2024
1 parent cfc2e58 commit 4a5d062
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BlockBandedMatrices"
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
version = "0.13.1"
version = "0.13.2"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
26 changes: 21 additions & 5 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ function _broadcast_blockbandwidths((l,u), A::AbstractArray, (ax1,ax2))
end


blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)}) =
min.(_broadcast_blockbandwidths.(Ref(_blockbnds(bc)), bc.args, Ref(axes(bc)))...)
function blockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)})
ax = axes(bc)
blkinds = _blockbnds(bc)
t = map(bc.args) do x
_broadcast_blockbandwidths(blkinds, x, ax)
end
min.(t...)
end

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

subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)}) =
min.(_broadcast_subblockbandwidths.(Ref(_subblockbnds(bc)), bc.args)...)
function subblockbandwidths(bc::Broadcasted{<:Union{Nothing,BroadcastStyle},<:Any,typeof(*)})
subbbw = _subblockbnds(bc)
t = map(bc.args) do x
_broadcast_subblockbandwidths(subbbw, x)
end
min.(t...)
end

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

function subblockbandwidths(bc::Broadcasted)
(a,b) = size(bc)
bnds = (a-1,b-1)
_isweakzero(bc.f, bc.args...) && return min.(bnds, max.(_broadcast_subblockbandwidths.(Ref(bnds), bc.args)...))
if _isweakzero(bc.f, bc.args...)
t = map(bc.args) do x
_broadcast_subblockbandwidths(bnds, x)
end
return min.(bnds, max.(t...))
end
bnds
end

Expand Down

2 comments on commit 4a5d062

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117376

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.2 -m "<description of version>" 4a5d062fed070a74043a0312649b320f09e941f4
git push origin v0.13.2

Please sign in to comment.