Skip to content

Commit

Permalink
Specalize istriu/istril (#326)
Browse files Browse the repository at this point in the history
* Specalize isdiag and istriu/istril

* Remove isdiag specialization
  • Loading branch information
jishnub authored Dec 12, 2023
1 parent 1f72917 commit c7c34aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "1.9.3"
version = "1.10.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
8 changes: 8 additions & 0 deletions src/fillalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -516,3 +516,11 @@ function kron(f::AbstractFillVecOrMat, g::AbstractFillVecOrMat)
sz = _kronsize(f, g)
return _kron(f, g, sz)
end

# bandedness
function LinearAlgebra.istriu(A::AbstractFillMatrix, k::Integer = 0)
iszero(A) || k <= -(size(A,1)-1)
end
function LinearAlgebra.istril(A::AbstractFillMatrix, k::Integer = 0)
iszero(A) || k >= size(A,2)-1
end
13 changes: 13 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2370,3 +2370,16 @@ end
@test a.value == first(diag)
end
end

@testset "isbanded/isdiag" begin
@testset for A in Any[Zeros(2,3), Zeros(0,1), Zeros(1,1), Zeros(1,2),
Ones(0,1), Ones(1,1), Ones(3,4), Ones(0,4), Ones(7,0), Ones(7,2), Ones(2,7),
Fill(3, 0,1), Fill(3, 1,1), Fill(3, 2,4), Fill(0, 3, 4), Fill(2, 0, 4), Fill(2, 6, 0), Fill(0, 8, 8)]
B = Array(A)
@test isdiag(A) == isdiag(B)
for k in -5:5
@test istriu(A, k) == istriu(B, k)
@test istril(A, k) == istril(B, k)
end
end
end

0 comments on commit c7c34aa

Please sign in to comment.