|
3 | 3 | submodule (stdlib_linalg) stdlib_linalg_schur |
4 | 4 | use stdlib_linalg_constants |
5 | 5 | use stdlib_linalg_lapack, only: gees |
| 6 | + use stdlib_linalg_lapack_aux, only: handle_gees_info |
6 | 7 | use stdlib_linalg_state, only: linalg_state_type, linalg_error_handling, LINALG_ERROR, & |
7 | 8 | LINALG_INTERNAL_ERROR, LINALG_VALUE_ERROR |
8 | 9 | implicit none |
@@ -35,48 +36,6 @@ submodule (stdlib_linalg) stdlib_linalg_schur |
35 | 36 | gees_sort_eigs = merge(GEES_SORTED_VECTORS,GEES_NOT,sorted) |
36 | 37 | end function gees_sort_eigs |
37 | 38 |
|
38 | | - !> Wrapper function to handle GEES error codes |
39 | | - elemental subroutine handle_gees_info(info, m, n, ldvs, err) |
40 | | - integer(ilp), intent(in) :: info, m, n, ldvs |
41 | | - type(linalg_state_type), intent(out) :: err |
42 | | - |
43 | | - ! Process GEES output |
44 | | - select case (info) |
45 | | - case (0_ilp) |
46 | | - ! Success |
47 | | - case (-1_ilp) |
48 | | - ! Vector not wanted, but task is wrong |
49 | | - err = linalg_state_type(this, LINALG_INTERNAL_ERROR,'Invalid Schur vector task request') |
50 | | - case (-2_ilp) |
51 | | - ! Vector not wanted, but task is wrong |
52 | | - err = linalg_state_type(this, LINALG_INTERNAL_ERROR,'Invalid sorting task request') |
53 | | - case (-4_ilp,-6_ilp) |
54 | | - ! Vector not wanted, but task is wrong |
55 | | - err = linalg_state_type(this, LINALG_VALUE_ERROR,'Invalid/non-square input matrix size:',[m,n]) |
56 | | - case (-11_ilp) |
57 | | - err = linalg_state_type(this, LINALG_VALUE_ERROR,'Schur vector matrix has insufficient size',[ldvs,n]) |
58 | | - case (-13_ilp) |
59 | | - err = linalg_state_type(this, LINALG_INTERNAL_ERROR,'Insufficient working storage size') |
60 | | - case (1_ilp:) |
61 | | - |
62 | | - if (info==n+2) then |
63 | | - err = linalg_state_type(this, LINALG_ERROR, 'Ill-conditioned problem: could not sort eigenvalues') |
64 | | - elseif (info==n+1) then |
65 | | - err = linalg_state_type(this, LINALG_ERROR, 'Some selected eigenvalues lost property due to sorting') |
66 | | - elseif (info==n) then |
67 | | - err = linalg_state_type(this, LINALG_ERROR, 'Convergence failure: no converged eigenvalues') |
68 | | - else |
69 | | - err = linalg_state_type(this, LINALG_ERROR, 'Convergence failure; converged range is',[info,n]) |
70 | | - end if |
71 | | - |
72 | | - case default |
73 | | - |
74 | | - err = linalg_state_type(this, LINALG_INTERNAL_ERROR, 'GEES catastrophic error: info=', info) |
75 | | - |
76 | | - end select |
77 | | - |
78 | | - end subroutine handle_gees_info |
79 | | - |
80 | 39 | #:for rk, rt, ri in RC_KINDS_TYPES |
81 | 40 | !> Workspace query |
82 | 41 | module subroutine get_schur_${ri}$_workspace(a,lwork,err) |
@@ -112,7 +71,7 @@ submodule (stdlib_linalg) stdlib_linalg_schur |
112 | 71 | call gees(jobvs,sort,do_not_select,n,amat,m,sdim,wr_dummy,#{if rt.startswith('r')}#wi_dummy, #{endif}#& |
113 | 72 | vs_dummy,m,work_dummy,lwork,#{if rt.startswith('c')}#rwork_dummy,#{endif}#bwork_dummy,info) |
114 | 73 | if (info==0) lwork = nint(real(work_dummy(1),kind=${rk}$),kind=ilp) |
115 | | - call handle_gees_info(info,m,n,m,err0) |
| 74 | + call handle_gees_info(this,info,m,n,m,err0) |
116 | 75 | call linalg_error_handling(err0,err) |
117 | 76 |
|
118 | 77 | contains |
@@ -275,7 +234,7 @@ submodule (stdlib_linalg) stdlib_linalg_schur |
275 | 234 | ! Compute Schur decomposition |
276 | 235 | call gees(jobvs,sort,eig_select,nt,t,mt,sdim,eigs,#{if rt.startswith('r')}#eigi,#{endif}# & |
277 | 236 | vs,ldvs,work,lwork,#{if rt.startswith('c')}#rwork,#{endif}#bwork,info) |
278 | | - call handle_gees_info(info,m,n,m,err0) |
| 237 | + call handle_gees_info(this,info,m,n,m,err0) |
279 | 238 |
|
280 | 239 |
|
281 | 240 | end if |
|
0 commit comments