Skip to content

Commit

Permalink
Don't error in lmul!/rmul! with non-zero entries (#171)
Browse files Browse the repository at this point in the history
* Don't error in lmul!/rmul! with non-zero entries

* add tests
  • Loading branch information
dlfivefifty authored Sep 18, 2023
1 parent 821853b commit 6e8049b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 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.12.5"
version = "0.12.6"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
4 changes: 0 additions & 4 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,13 @@ end


function blockbanded_rmul!(B::AbstractMatrix{T}, x::Number) where T
x == zero(T) || throw(BandError(B))

for J = blockaxes(B,2), K = blockcolsupport(B,J)
rmul!(view(B,K,J), x)
end
B
end

function blockbanded_lmul!(x::Number, B::AbstractMatrix{T}) where T
x == zero(T) || throw(BandError(B))

for J = blockaxes(B,2), K = blockcolsupport(B,J)
lmul!(x, view(B,K,J))
end
Expand Down
10 changes: 10 additions & 0 deletions test/test_linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ import BlockBandedMatrices: _BandedBlockBandedMatrix, MemoryLayout, mul!,
C.data .= NaN
rmul!(C, 0.0)
norm(C) == 0.0

C.data .= 1
@test lmul!(2, C) == fill(2,3,3)

A = BlockBandedMatrix{Float64}(undef, 1:2,1:2, (1,1))
A.data .= 1
lmul!(2, A)
@test A == fill(2,3,3)
rmul!(A, 2)
@test A == fill(4,3,3)
end

@testset "BlockBandedMatrix linear algebra" begin
Expand Down

2 comments on commit 6e8049b

@dlfivefifty
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/91637

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.12.6 -m "<description of version>" 6e8049bc12e06c614091a706eb2e3c86abb44823
git push origin v0.12.6

Please sign in to comment.