Skip to content

Commit

Permalink
Add (col/row)support for Inv(Triangular)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVandH committed Jul 3, 2024
1 parent 8fc085d commit b19be93
Show file tree
Hide file tree
Showing 3 changed files with 27 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 = "LazyArrays"
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
version = "2.1.2"
version = "2.1.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
10 changes: 10 additions & 0 deletions ext/LazyArraysBandedMatricesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ function rowsupport(::AbstractInvLayout{<:AbstractBandedLayout}, A, k)
1:n
end

function colsupport(lay::AbstractInvLayout{<:TriangularLayout}, A, j)
B, = arguments(lay, A)
return colsupport(B, j)

Check warning on line 92 in ext/LazyArraysBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LazyArraysBandedMatricesExt.jl#L90-L92

Added lines #L90 - L92 were not covered by tests
end

function rowsupport(lay::AbstractInvLayout{<:TriangularLayout}, A, k)
B, = arguments(lay, A)
return rowsupport(B, k)

Check warning on line 97 in ext/LazyArraysBandedMatricesExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LazyArraysBandedMatricesExt.jl#L95-L97

Added lines #L95 - L97 were not covered by tests
end

isbanded(K::Kron{<:Any,2}) = all(isbanded, K.args)

function bandwidths(K::Kron{<:Any,2})
Expand Down
16 changes: 16 additions & 0 deletions test/bandedtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -890,4 +890,20 @@ LinearAlgebra.lmul!(β::Number, A::PseudoBandedMatrix) = (lmul!(β, A.data); A)
end
end

@testset "Issue #329" begin
for op in (UpperTriangular, UnitUpperTriangular)
A = UpperTriangular(ApplyArray(inv, rand(5, 5)))
B = inv(A)
@test colsupport.(Ref(B), 1:5) == Base.OneTo.(1:5)
@test rowsupport.(Ref(B), 1:5) == range.(1:5, 5)
end

for op in (LowerTriangular, UnitLowerTriangular)
A = LowerTriangular(ApplyArray(inv, rand(15, 15)))
B = inv(A)
@test colsupport.(Ref(B), 1:15) == range.(1:15, 15)
@test rowsupport.(Ref(B), 1:15) == Base.OneTo.(1:15)
end
end

end # module

0 comments on commit b19be93

Please sign in to comment.