Skip to content

Commit

Permalink
Fix issymmetric/ishermitian for block and empty matrices (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Aug 27, 2024
1 parent 554ddf4 commit 7b64042
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ end
rank(F::AbstractFill) = iszero(getindex_value(F)) ? 0 : 1
IndexStyle(::Type{<:AbstractFill{<:Any,N,<:NTuple{N,Base.OneTo{Int}}}}) where N = IndexLinear()

issymmetric(F::AbstractFillMatrix) = axes(F,1) == axes(F,2)
ishermitian(F::AbstractFillMatrix) = issymmetric(F) && iszero(imag(getindex_value(F)))
issymmetric(F::AbstractFillMatrix) = axes(F,1) == axes(F,2) && (isempty(F) || issymmetric(getindex_value(F)))
ishermitian(F::AbstractFillMatrix) = axes(F,1) == axes(F,2) && (isempty(F) || ishermitian(getindex_value(F)))

Base.IteratorSize(::Type{<:AbstractFill{T,N,Axes}}) where {T,N,Axes} = _IteratorSize(Axes)
_IteratorSize(::Type{Tuple{}}) = Base.HasShape{0}()
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ end
end

@testset "ishermitian" begin
for el in (2, 3+0im, 4+5im), size in [(3,3), (3,4)]
@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)]
@test issymmetric(Fill(el, size...)) == issymmetric(fill(el, size...))
@test ishermitian(Fill(el, size...)) == ishermitian(fill(el, size...))
end
Expand Down

0 comments on commit 7b64042

Please sign in to comment.