From aba1879e0d4f7b53b86d7670953ea0fd9cf73a86 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <44583944+putianyi889@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:08:28 +0000 Subject: [PATCH 1/2] Update memorylayout.jl --- src/memorylayout.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/memorylayout.jl b/src/memorylayout.jl index f7b9e46..4004c7d 100644 --- a/src/memorylayout.jl +++ b/src/memorylayout.jl @@ -645,6 +645,7 @@ gives an iterator containing the possible non-zero entries in the k-th row of A. """ rowsupport(A, k) = rowsupport(MemoryLayout(A), A, k) rowsupport(A) = rowsupport(A, axes(A,1)) +rowsupport(A, k::CartesianIndex{2}) = rowsupport(A, k[1]) colsupport(_, A, j) = axes(A,1) @@ -656,6 +657,7 @@ gives an iterator containing the possible non-zero entries in the j-th column of """ colsupport(A, j) = colsupport(MemoryLayout(A), A, j) colsupport(A) = colsupport(A, axes(A,2)) +colsupport(A, k::CartesianIndex{2}) = rowsupport(A, k[2]) # TODO: generalise to other subarrays function colsupport(A::SubArray{<:Any,N,<:Any,<:Tuple{Slice,AbstractVector}}, j) where N From a707be0a939532b14bcbd51a7c771ba8bba5c0fb Mon Sep 17 00:00:00 2001 From: Tianyi Pu <44583944+putianyi889@users.noreply.github.com> Date: Mon, 27 Nov 2023 09:12:50 +0000 Subject: [PATCH 2/2] add tests --- test/test_layouts.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_layouts.jl b/test/test_layouts.jl index 19e186b..64ddd06 100644 --- a/test/test_layouts.jl +++ b/test/test_layouts.jl @@ -134,7 +134,7 @@ struct FooNumber <: Number end subdiagonaldata(Bl) == supdiagonaldata(Adjoint(Bl)) == supdiagonaldata(Transpose(Bl)) == T.dl - @test colsupport(T,3) == rowsupport(T,3) == colsupport(S,3) == rowsupport(S,3) == 2:4 + @test colsupport(T,3) == rowsupport(T,3) == colsupport(S,3) == rowsupport(S,3) == rowsupport(T,CartesianIndex(3,2)) == colsupport(T,CartesianIndex(2,3)) == 2:4 @test colsupport(T,3:6) == rowsupport(T,3:6) == colsupport(S,3:6) == rowsupport(S,3:6) == 2:6 @test colsupport(Bl,3) == rowsupport(Bu,3) == rowsupport(Adjoint(Bl),3) == 3:4 @test rowsupport(Bl,3) == colsupport(Bu,3) == colsupport(Adjoint(Bl),3) == 2:3