Skip to content

Commit

Permalink
Methods for issymmetric & ishermitian (#156)
Browse files Browse the repository at this point in the history
* method for issymmetric + ishermitian

* restric to matrices

* bump version

* Update src/FillArrays.jl

Co-authored-by: Sheehan Olver <[email protected]>

Co-authored-by: Sheehan Olver <[email protected]>
  • Loading branch information
mcabbott and dlfivefifty authored Aug 19, 2021
1 parent 6deeec4 commit 831639c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.12.1"
version = "0.12.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
5 changes: 4 additions & 1 deletion src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
show, view, in, mapreduce

import LinearAlgebra: rank, svdvals!, tril, triu, tril!, triu!, diag, transpose, adjoint, fill!,
dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AbstractTriangular, AdjointAbsVec
dot, norm2, norm1, normInf, normMinusInf, normp, lmul!, rmul!, diagzero, AbstractTriangular, AdjointAbsVec,
issymmetric, ishermitian

import Base.Broadcast: broadcasted, DefaultArrayStyle, broadcast_shape

Expand Down Expand Up @@ -61,6 +62,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::AbstractFill{<:Any, 2}) = axes(F,1) == axes(F,2)
ishermitian(F::AbstractFill{<:Any, 2}) = issymmetric(F) && iszero(imag(getindex_value(F)))

"""
Fill{T, N, Axes}
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ end
@test rank(Eye(2)) == 2
end

@testset "ishermitian" begin
for el in (2, 3+0im, 4+5im), size in [(3,3), (3,4)]
@test issymmetric(Fill(el, size...)) == issymmetric(fill(el, size...))
@test ishermitian(Fill(el, size...)) == ishermitian(fill(el, size...))
end
end

@testset "BigInt indices" begin
for A in (Zeros(BigInt(100)), Ones(BigInt(100)), Fill(2, BigInt(100)))
@test length(A) isa BigInt
Expand Down

2 comments on commit 831639c

@dlfivefifty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43139

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.2 -m "<description of version>" 831639c917b25630f782e9eb72d3175df7166185
git push origin v0.12.2

Please sign in to comment.