Skip to content

Commit

Permalink
Avoid warning with empty upper triangular solves (#442)
Browse files Browse the repository at this point in the history
* Avoid warning with empty upper triangular solves

* add seed! to broadcast tests

* Update test_broadcasting.jl
  • Loading branch information
dlfivefifty authored Jun 3, 2024
1 parent 8618b18 commit eb47cc2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "1.7"
version = "1.7.1"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
12 changes: 7 additions & 5 deletions src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ for (fname, elty) in ((:dtbsv_,:Float64),
throw(DimensionMismatch("size of A is $n != length(x) = $(length(x))"))
end
chkstride1(A)
ccall((@blasfunc($fname), libblas), Cvoid,
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
uplo, trans, diag, m, k,
A, max(1,stride(A,2)), x, stride(x, 1))
if n 0 # avoid empty warning message
ccall((@blasfunc($fname), libblas), Cvoid,
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt},
Ptr{$elty}, Ref{BlasInt}, Ptr{$elty}, Ref{BlasInt}),
uplo, trans, diag, m, k,
A, max(1,stride(A,2)), x, stride(x, 1))
end
x
end
function tbsv(uplo::AbstractChar, trans::AbstractChar, diag::AbstractChar,
Expand Down
8 changes: 6 additions & 2 deletions test/test_broadcasting.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module TestBroadcasting

using BandedMatrices, LinearAlgebra, ArrayLayouts, FillArrays, Test
using BandedMatrices, LinearAlgebra, ArrayLayouts, FillArrays, Random, Test
import Base: BroadcastStyle
import Base.Broadcast: broadcasted
import BandedMatrices: BandedStyle, BandedRows, BandError

Random.seed!(0)

@testset "broadcasting" begin
@testset "general" begin
n = 1000
Expand Down Expand Up @@ -40,7 +42,9 @@ import BandedMatrices: BandedStyle, BandedRows, BandError
@test 1 .+ A isa BandedMatrix
@test (1 .+ A) == 1 .+ Matrix(A)

@test 1 .\ A == 1 .\ Matrix(A)
if VERSION v"1.10" # avoid failure on CI with Mac OS Julia v1.6
@test 1 .\ A == 1 .\ Matrix(A)
end
@test 1 .\ A isa BandedMatrix
@test bandwidths(1 .\ A) == bandwidths(A)

Expand Down
5 changes: 5 additions & 0 deletions test/test_tribanded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ import BandedMatrices: BandedColumns, BandedRows, isbanded
@test rot180(LowerTriangular(B)) == rot180(Matrix(LowerTriangular(B)))
@test rot180(UnitLowerTriangular(B)) == rot180(Matrix(UnitLowerTriangular(B)))
end

@testset "empty uppertriangular" begin
B = brand(0,0,2,1)
@test UpperTriangular(B) \ Float64[] == Float64[]
end
end

end # module

2 comments on commit eb47cc2

@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/108121

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 v1.7.1 -m "<description of version>" eb47cc2b537ec5acd981367cea18768afca28d38
git push origin v1.7.1

Please sign in to comment.