Skip to content

Commit 04d843f

Browse files
committed
handle *GEES output
1 parent 0222737 commit 04d843f

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

src/stdlib_linalg_schur.fypp

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,46 @@ submodule (stdlib_linalg) stdlib_linalg_schur
1111

1212
contains
1313

14-
elemental subroutine handle_gees_info(info, m, sort, err)
15-
integer(ilp), intent(in) :: info, m
16-
logical, intent(in) :: sort
17-
type(linalg_state_type), intent(out) :: err
14+
!> Wrapper function to handle GEES error codes
15+
elemental subroutine handle_gees_info(info, m, n, ldvs, err)
16+
integer(ilp), intent(in) :: info, m, n, ldvs
17+
type(linalg_state), intent(out) :: err
1818

1919
! Process GEES output
2020
select case (info)
21-
case (0)
21+
case (0_ilp)
2222
! Success
23-
case (-1)
24-
err = linalg_state_type(this, LINALG_VALUE_ERROR, 'invalid matrix size m=', m)
25-
case default
26-
if (sort .and. info > 0) then
27-
err = linalg_state_type(this, LINALG_INTERNAL_ERROR, 'sorting eigenvalues failed at index ', info)
23+
case (-1_ilp)
24+
! Vector not wanted, but task is wrong
25+
err = linalg_state(this, LINALG_INTERNAL_ERROR,'Invalid Schur vector task request')
26+
case (-2_ilp)
27+
! Vector not wanted, but task is wrong
28+
err = linalg_state(this, LINALG_INTERNAL_ERROR,'Invalid sorting task request')
29+
case (-4_ilp,-6_ilp)
30+
! Vector not wanted, but task is wrong
31+
err = linalg_state(this, LINALG_VALUE_ERROR,'Invalid/non-square input matrix size:',[m,n])
32+
case (-11_ilp)
33+
err = linalg_state(this, LINALG_VALUE_ERROR,'Schur vector matrix has insufficient size',[ldvs,n])
34+
case (-13_ilp)
35+
err = linalg_state(this, LINALG_INTERNAL_ERROR,'Insufficient working storage size')
36+
case (1_ilp:)
37+
38+
if (info==n+2) then
39+
err = linalg_state(this, LINALG_ERROR, 'Ill-conditioned problem: could not sort eigenvalues')
40+
elseif (info==n+1) then
41+
err = linalg_state(this, LINALG_ERROR, 'Some selected eigenvalues lost property due to sorting')
42+
elseif (info==n) then
43+
err = linalg_state(this, LINALG_ERROR, 'Convergence failure: no converged eigenvalues')
2844
else
29-
err = linalg_state_type(this, LINALG_INTERNAL_ERROR, 'GEES catastrophic error: info=', info)
45+
err = linalg_state(this, LINALG_ERROR, 'Convergence failure; converged range is',[info,n])
3046
end if
47+
48+
case default
49+
50+
err = linalg_state(this, LINALG_INTERNAL_ERROR, 'GEES catastrophic error: info=', info)
51+
3152
end select
53+
3254
end subroutine handle_gees_info
3355

3456
#:for rk, rt, ri in RC_KINDS_TYPES

0 commit comments

Comments
 (0)