Skip to content

Commit

Permalink
LAPACK: validate input parameters to throw informative errors (#53631)
Browse files Browse the repository at this point in the history
This PR validates the input parameters to the Julia LAPACK wrappers, so
that the error messages are more informative.
On nightly
```julia
julia> using LinearAlgebra

julia> LAPACK.geev!('X', 'X', rand(2,2))
 ** On entry to DGEEV  parameter number  1 had an illegal value
ERROR: ArgumentError: invalid argument #1 to LAPACK call
```
This PR
```julia
julia> using LinearAlgebra

julia> LAPACK.geev!('X', 'X', rand(2,2))
ERROR: ArgumentError: argument #1: jobvl must be one of ('N', 'V'), but 'X' was passed
```

Secondly, moved certain allocations (e.g. in `geevx`) below the
validation checks, so that these only happen for valid parameter values.

Thirdly, added `require_one_based_indexing` checks to functions where
these were missing.
  • Loading branch information
jishnub authored Mar 12, 2024
1 parent dcfad21 commit dcd1fb2
Show file tree
Hide file tree
Showing 3 changed files with 344 additions and 82 deletions.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ end
"Check that upper/lower (for special matrices) is correctly specified"
function chkuplo(uplo::AbstractChar)
if !(uplo == 'U' || uplo == 'L')
throw(ArgumentError(lazy"uplo argument must be 'U' (upper) or 'L' (lower), got $uplo"))
throw(ArgumentError(lazy"uplo argument must be 'U' (upper) or 'L' (lower), got '$uplo'"))
end
uplo
end
Expand Down
Loading

0 comments on commit dcd1fb2

Please sign in to comment.