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.

(cherry picked from commit dcd1fb2)
  • Loading branch information
jishnub authored and KristofferC committed Mar 15, 2024
1 parent 641ae2c commit 0087a11
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 @@ -169,7 +169,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 0087a11

Please sign in to comment.