Skip to content

Commit c7c34aa

Browse files
authored
Specalize istriu/istril (#326)
* Specalize isdiag and istriu/istril * Remove isdiag specialization
1 parent 1f72917 commit c7c34aa

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "1.9.3"
3+
version = "1.10.0"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/fillalgebra.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,11 @@ function kron(f::AbstractFillVecOrMat, g::AbstractFillVecOrMat)
516516
sz = _kronsize(f, g)
517517
return _kron(f, g, sz)
518518
end
519+
520+
# bandedness
521+
function LinearAlgebra.istriu(A::AbstractFillMatrix, k::Integer = 0)
522+
iszero(A) || k <= -(size(A,1)-1)
523+
end
524+
function LinearAlgebra.istril(A::AbstractFillMatrix, k::Integer = 0)
525+
iszero(A) || k >= size(A,2)-1
526+
end

test/runtests.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,3 +2370,16 @@ end
23702370
@test a.value == first(diag)
23712371
end
23722372
end
2373+
2374+
@testset "isbanded/isdiag" begin
2375+
@testset for A in Any[Zeros(2,3), Zeros(0,1), Zeros(1,1), Zeros(1,2),
2376+
Ones(0,1), Ones(1,1), Ones(3,4), Ones(0,4), Ones(7,0), Ones(7,2), Ones(2,7),
2377+
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)]
2378+
B = Array(A)
2379+
@test isdiag(A) == isdiag(B)
2380+
for k in -5:5
2381+
@test istriu(A, k) == istriu(B, k)
2382+
@test istril(A, k) == istril(B, k)
2383+
end
2384+
end
2385+
end

0 commit comments

Comments
 (0)