Skip to content

Commit 6eb9d9d

Browse files
authored
Overload axes for Symmetric/Triangular of a LayoutArray (#95)
* Overload axes for Symmetric/Triangular of a LayoutArray * Update test_layoutarray.jl * Update ArrayLayouts.jl * Revert "Update ArrayLayouts.jl" This reverts commit 34640fb.
1 parent 6d5d5ef commit 6eb9d9d

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.8.5"
4+
version = "0.8.6"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/diagonal.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
###
32
# Lmul
43
####

src/memorylayout.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,3 +693,23 @@ function colsupport(::HermitianLayout, A, j)
693693
end
694694
rowsupport(::Union{SymmetricLayout,HermitianLayout}, A, j) = colsupport(A, j)
695695

696+
697+
698+
function _sym_axes(A)
699+
ax = axes(parent(A),2)
700+
(ax, ax)
701+
end
702+
703+
###
704+
# axes overloads to support block indexing
705+
###
706+
707+
axes(A::HermOrSym{<:Any,<:LayoutMatrix}) = _sym_axes(A)
708+
axes(A::HermOrSym{<:Any,<:SubArray{<:Any,2,<:LayoutMatrix}}) = _sym_axes(A)
709+
axes(A::AbstractTriangular{<:Any,<:LayoutMatrix}) = axes(parent(A))
710+
axes(A::AbstractTriangular{<:Any,<:SubArray{<:Any,2,<:LayoutMatrix}}) = axes(parent(A))
711+
712+
function axes(D::Diagonal{<:Any,<:LayoutVector})
713+
a = axes(parent(D),1)
714+
(a,a)
715+
end

test/test_layoutarray.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor()
327327
@test A[6] == ArrayLayouts.layout_getindex(A,6) == A[1,2]
328328
@test A[1,2] == A[CartesianIndex(1,2)] == ArrayLayouts.layout_getindex(A,CartesianIndex(1,2))
329329
end
330+
331+
@testset "structured axes" begin
332+
A = MyMatrix(rand(5,5))
333+
x = MyVector(rand(5))
334+
@test axes(Symmetric(A)) == axes(Symmetric(view(A,1:5,1:5))) == axes(A)
335+
@test axes(UpperTriangular(A)) == axes(UpperTriangular(view(A,1:5,1:5))) == axes(A)
336+
@test axes(Diagonal(x)) == axes(Diagonal(Vector(x)))
337+
end
330338
end
331339

332340
struct MyUpperTriangular{T} <: AbstractMatrix{T}

0 commit comments

Comments
 (0)