Skip to content

Commit c367853

Browse files
authored
Fix broadcast with Zeros (#344)
* Fix broadcast with Zeros * LazyArrays v1 in docs * Update test_broadcasting.jl
1 parent f8766bb commit c367853

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BandedMatrices"
22
uuid = "aae01518-5342-5314-be14-df237901396f"
3-
version = "0.17.18"
3+
version = "0.17.19"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -11,9 +11,9 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1111

1212
[compat]
1313
Aqua = "0.6"
14-
ArrayLayouts = "0.8.14, 1"
14+
ArrayLayouts = "1"
1515
Documenter = "0.27"
16-
FillArrays = "0.13, 1"
16+
FillArrays = "1"
1717
SnoopPrecompile = "1"
1818
julia = "1.6"
1919

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
55

66
[compat]
77
Documenter = "0.27"
8-
LazyArrays = "0.22"
8+
LazyArrays = "1"

src/generic/broadcast.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ axpy!(α, A::AbstractBandedMatrix, dest::AbstractMatrix) = banded_axpy!(α, A, d
10241024

10251025
for op in (:*, :/)
10261026
@eval begin
1027-
broadcasted(::BandedStyle, ::typeof($op), a::Zeros, b::AbstractArray) = _broadcasted_zeros(a, b)
1027+
broadcasted(::BandedStyle, ::typeof($op), a::Zeros, b::AbstractArray) = _broadcasted_zeros($op, a, b)
10281028
function broadcasted(::BandedStyle, ::typeof($op), a::AbstractArray{T}, b::Ones{V}) where {T,V}
10291029
Base.Broadcast.combine_axes(a, b) # dimension check
10301030
_copy_oftype(a, promote_op(*, T, V))
@@ -1034,7 +1034,7 @@ end
10341034

10351035
for op in (:*, :\)
10361036
@eval begin
1037-
broadcasted(::BandedStyle, ::typeof($op), a::AbstractArray, b::Zeros) = _broadcasted_zeros(a, b)
1037+
broadcasted(::BandedStyle, ::typeof($op), a::AbstractArray, b::Zeros) = _broadcasted_zeros($op, a, b)
10381038
function broadcasted(::BandedStyle, ::typeof($op), a::Ones{T}, b::AbstractArray{V}) where {T,V}
10391039
Base.Broadcast.combine_axes(a, b) # dimension check
10401040
_copy_oftype(b, promote_op(*, T, V))

test/test_broadcasting.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,4 +711,11 @@ import BandedMatrices: BandedStyle, BandedRows
711711
b = BandedMatrix(Zeros(0,4), (-1,2))
712712
@test a-b == a
713713
end
714+
715+
@testset "zeros broadcasting" begin
716+
A = brand(5,4,2,1)
717+
Z = Zeros(5,4)
718+
@test Z .* A Z
719+
@test A .* Z Z
720+
end
714721
end

0 commit comments

Comments
 (0)