From c14aeab112b0821bf130aef91cbee8be82b277e8 Mon Sep 17 00:00:00 2001 From: Will Kearney Date: Sun, 12 Oct 2014 21:44:56 -0400 Subject: [PATCH] Fix bug in issym(A::BitMatrix) numnz -> countnz backport of 7ba14fe8dc25286df86c03c10f5d3d9260558254 Add issym test for bitarrays backport of 85b015f8dfc089698db3904a89a25b14d49552f7 --- base/linalg/bitarray.jl | 2 +- test/bitarray.jl | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/base/linalg/bitarray.jl b/base/linalg/bitarray.jl index 4b023ce02e0fb..5e9b70ee89fd9 100644 --- a/base/linalg/bitarray.jl +++ b/base/linalg/bitarray.jl @@ -132,7 +132,7 @@ end ## Structure query functions -issym(A::BitMatrix) = size(A, 1)==size(A, 2) && numnz(A - A.')==0 +issym(A::BitMatrix) = size(A, 1)==size(A, 2) && countnz(A - A.')==0 ishermitian(A::BitMatrix) = issym(A) function nonzero_chunks(chunks::Vector{Uint64}, pos0::Int, pos1::Int) diff --git a/test/bitarray.jl b/test/bitarray.jl index c7dd7125474c0..c00df8565e26a 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -975,6 +975,10 @@ b1 = triu(randbool(n1, n2)) b1 = triu(randbool(n2, n1)) @check_bit_operation istriu(b1) Bool +b1 = randbool(n1,n1) +b1 |= b1.' +@check_bit_operation issym(b1) Bool + b1 = randbool(n1) b2 = randbool(n2) @check_bit_operation kron(b1, b2) BitVector