diff --git a/src/offdiagonal.jl b/src/offdiagonal.jl index 32a97baa..ebd08699 100644 --- a/src/offdiagonal.jl +++ b/src/offdiagonal.jl @@ -150,6 +150,9 @@ function _offdiagonal_bcindex(bc::Broadcasted) axes(x) == axes(bc) || return nothing k === nothing || k == x.k || return nothing k = x.k + elseif x isa AbstractArray && ndims(x) > 0 + # other arrays do not reduce to the band, even when the result is zero-preserving + return nothing end end k diff --git a/test/runtests.jl b/test/runtests.jl index 77a9dd3e..26c12445 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -467,7 +467,8 @@ end @test eltype(B) == eltype(BM) end # other operations are dense - for (B, BM) in ((cos.(A), cos.(M)), (A .+ 1, M .+ 1), (A .* M, M .* M), (A .+ M, M .+ M), (A .* (1:size(A,1)), M .* (1:size(A,1)))) + for (B, BM) in ((cos.(A), cos.(M)), (A .+ 1, M .+ 1), (A .* M, M .* M), (A .+ M, M .+ M), (A .* (1:size(A,1)), M .* (1:size(A,1))), + ((1:size(A,1)) .* A, (1:size(A,1)) .* M), (A .* permutedims(1:size(A,2)), M .* permutedims(1:size(A,2)))) @test B isa Matrix @test B == BM end