Skip to content

Commit

Permalink
18267 1x1 NaN matrix eigenvalue (#18526)
Browse files Browse the repository at this point in the history
* updated tests so that all of NaN, NaN16, and NaN32 are tested

* changed the indicies of the loop in issymmetric to include the diagonal.
  • Loading branch information
mcognetta authored and andreasnoack committed Sep 27, 2016
1 parent bfb1f79 commit 2042ee6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/linalg/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ isposdef(A::Union{Eigen,GeneralizedEigen}) = isreal(A.values) && all(A.values .>

function eigfact!{T<:BlasReal}(A::StridedMatrix{T}; permute::Bool=true, scale::Bool=true)
n = size(A, 2)
n==0 && return Eigen(zeros(T, 0), zeros(T, 0, 0))
n == 0 && return Eigen(zeros(T, 0), zeros(T, 0, 0))
issymmetric(A) && return eigfact!(Symmetric(A))
A, WR, WI, VL, VR, _ = LAPACK.geevx!(permute ? (scale ? 'B' : 'P') : (scale ? 'S' : 'N'), 'N', 'V', 'N', A)
all(WI .== 0.) && return Eigen(WR, VR)
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ function issymmetric(A::AbstractMatrix)
if indsm != indsn
return false
end
for i = first(indsn):last(indsn)-1, j = (i+1):last(indsn)
for i = first(indsn):last(indsn), j = (i):last(indsn)
if A[i,j] != transpose(A[j,i])
return false
end
Expand Down
10 changes: 10 additions & 0 deletions test/linalg/eigen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ for eltya in (Float32, Float64, Complex64, Complex128, Int)
@test v == f[:vectors]
end
end

#test eigenvalue computations with NaNs
for eltya in (NaN16, NaN32, NaN)
@test_throws(ArgumentError, eig(fill(eltya, 1, 1)))
@test_throws(ArgumentError, eig(fill(eltya, 2, 2)))
test_matrix = rand(typeof(eltya),3,3)
test_matrix[2,2] = eltya
@test_throws(ArgumentError, eig(test_matrix))
end

# test a matrix larger than 140-by-140 for #14174
let aa = rand(200, 200)
for atype in ("Array", "SubArray")
Expand Down

2 comments on commit 2042ee6

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.