Skip to content

Commit 3bee50c

Browse files
committed
Make issym/ishermitian a lot faster when tol=0. is requested.
1 parent 99566f1 commit 3bee50c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

base/linalg/generic.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ condskeel{T<:Integer}(A::AbstractMatrix{T}, p::Real=Inf) = norm(abs(inv(float(A)
262262
condskeel(A::AbstractMatrix, x::AbstractVector, p::Real=Inf) = norm(abs(inv(A))*abs(A)*abs(x), p)
263263
condskeel{T<:Integer}(A::AbstractMatrix{T}, x::AbstractVector, p::Real=Inf) = norm(abs(inv(float(A)))*abs(A)*abs(x), p)
264264

265-
function issym(A::AbstractMatrix)
265+
function _issym(A::AbstractMatrix)
266266
m, n = size(A)
267267
m==n || return false
268268
for i = 1:(n-1), j = (i+1):n
@@ -275,7 +275,7 @@ end
275275

276276
issym(x::Number) = true
277277

278-
function ishermitian(A::AbstractMatrix)
278+
function _ishermitian(A::AbstractMatrix)
279279
m, n = size(A)
280280
m==n || return false
281281
for i = 1:n, j = i:n
@@ -286,9 +286,14 @@ function ishermitian(A::AbstractMatrix)
286286
return true
287287
end
288288

289+
ishermitian(A::AbstractMatrix) = _ishermitian(A::AbstractMatrix)
290+
issym(A::AbstractMatrix) = _issym(A::AbstractMatrix)
291+
289292
for (f,t) in ((:ishermitian, :ctranspose),(:issym, :transpose))
290293
eval(quote
291294
function $f{T<:FloatingPoint}(A::Union(AbstractMatrix{Complex{T}}, AbstractMatrix{T}),tol=1e-10)
295+
# This is performed due to if tol==0. _issym/_ishermitian is a lot faster for exact equality.
296+
tol == 0. && return $(symbol("_",:f))(A)
292297
m,n = size(A)
293298
Tnorm = typeof(float(real(zero(T))))
294299
Tsum = promote_type(Float64,Tnorm)

0 commit comments

Comments
 (0)