Skip to content

Commit 831639c

Browse files
Methods for issymmetric & ishermitian (#156)
* 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]>
1 parent 6deeec4 commit 831639c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "0.12.1"
3+
version = "0.12.2"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/FillArrays.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import Base: size, getindex, setindex!, IndexStyle, checkbounds, convert,
99
show, view, in, mapreduce
1010

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

1415
import Base.Broadcast: broadcasted, DefaultArrayStyle, broadcast_shape
1516

@@ -61,6 +62,8 @@ end
6162
rank(F::AbstractFill) = iszero(getindex_value(F)) ? 0 : 1
6263
IndexStyle(::Type{<:AbstractFill{<:Any,N,<:NTuple{N,Base.OneTo{Int}}}}) where N = IndexLinear()
6364

65+
issymmetric(F::AbstractFill{<:Any, 2}) = axes(F,1) == axes(F,2)
66+
ishermitian(F::AbstractFill{<:Any, 2}) = issymmetric(F) && iszero(imag(getindex_value(F)))
6467

6568
"""
6669
Fill{T, N, Axes}

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ end
411411
@test rank(Eye(2)) == 2
412412
end
413413

414+
@testset "ishermitian" begin
415+
for el in (2, 3+0im, 4+5im), size in [(3,3), (3,4)]
416+
@test issymmetric(Fill(el, size...)) == issymmetric(fill(el, size...))
417+
@test ishermitian(Fill(el, size...)) == ishermitian(fill(el, size...))
418+
end
419+
end
420+
414421
@testset "BigInt indices" begin
415422
for A in (Zeros(BigInt(100)), Ones(BigInt(100)), Fill(2, BigInt(100)))
416423
@test length(A) isa BigInt

0 commit comments

Comments
 (0)