From e03700a8b2b4b7afc3b33735c966c0227d688981 Mon Sep 17 00:00:00 2001 From: Andreas Noack Jensen Date: Tue, 19 Aug 2014 16:22:31 -0400 Subject: [PATCH] Check arguments in wrapper for xheevr. Add tests for errors reported in #8057 and #8058 --- base/linalg/lapack.jl | 6 ++++++ test/linalg4.jl | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/base/linalg/lapack.jl b/base/linalg/lapack.jl index 595a65ad87363..adc594c26abe7 100644 --- a/base/linalg/lapack.jl +++ b/base/linalg/lapack.jl @@ -2985,6 +2985,12 @@ for (syev, syevr, sygvd, elty, relty) in function syevr!(jobz::BlasChar, range::BlasChar, uplo::BlasChar, A::StridedMatrix{$elty}, vl::FloatingPoint, vu::FloatingPoint, il::Integer, iu::Integer, abstol::FloatingPoint) chkstride1(A) n = chksquare(A) + if range == 'I' + 1 <= il <= iu <= n || throw(ArgumentError("illegal choise of eigenvalue indices")) + end + if range == 'V' + vl < vu || throw(ArgumentError("lower boundary must be less than upper boundary")) + end lda = max(1,stride(A,2)) m = Array(BlasInt, 1) w = similar(A, $relty, n) diff --git a/test/linalg4.jl b/test/linalg4.jl index 1a9f6a9898c57..8a5f26ed12c4f 100644 --- a/test/linalg4.jl +++ b/test/linalg4.jl @@ -354,3 +354,11 @@ A7933 = [1 2; 3 4] B7933 = copy(A7933) C7933 = full(Symmetric(A7933)) @test A7933 == B7933 + +# Issues #8057 and #8058 +for f in (eigfact, eigvals) + for A in (Symmetric(randn(2,2)), Hermitian(complex(randn(2,2), randn(2,2)))) + @test_throws ArgumentError f(A, 3, 2) + @test_throws ArgumentError f(A, 1:4) + end +end