Skip to content

Commit 7b64042

Browse files
authored
Fix issymmetric/ishermitian for block and empty matrices (#377)
1 parent 554ddf4 commit 7b64042

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/FillArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ end
6666
rank(F::AbstractFill) = iszero(getindex_value(F)) ? 0 : 1
6767
IndexStyle(::Type{<:AbstractFill{<:Any,N,<:NTuple{N,Base.OneTo{Int}}}}) where N = IndexLinear()
6868

69-
issymmetric(F::AbstractFillMatrix) = axes(F,1) == axes(F,2)
70-
ishermitian(F::AbstractFillMatrix) = issymmetric(F) && iszero(imag(getindex_value(F)))
69+
issymmetric(F::AbstractFillMatrix) = axes(F,1) == axes(F,2) && (isempty(F) || issymmetric(getindex_value(F)))
70+
ishermitian(F::AbstractFillMatrix) = axes(F,1) == axes(F,2) && (isempty(F) || ishermitian(getindex_value(F)))
7171

7272
Base.IteratorSize(::Type{<:AbstractFill{T,N,Axes}}) where {T,N,Axes} = _IteratorSize(Axes)
7373
_IteratorSize(::Type{Tuple{}}) = Base.HasShape{0}()

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ end
608608
end
609609

610610
@testset "ishermitian" begin
611-
for el in (2, 3+0im, 4+5im), size in [(3,3), (3,4)]
611+
@testset for el in (2, 3+0im, 4+5im, [1 2; 3 4], fill(2, 2, 2)), size in [(3,3), (3,4), (0,0), (0,1)]
612612
@test issymmetric(Fill(el, size...)) == issymmetric(fill(el, size...))
613613
@test ishermitian(Fill(el, size...)) == ishermitian(fill(el, size...))
614614
end

0 commit comments

Comments
 (0)