2 #include "../gmx_blas.h"
3 #include "../gmx_lapack.h"
4 #include "lapack_limits.h"
6 #include "gromacs/utility/real.h"
9 F77_FUNC(sstegr
,SSTEGR
)(const char *jobz
,
30 int z_dim1
, z_offset
, i__1
, i__2
;
36 float eps
, tol
, tmp
, rmin
, rmax
;
44 int valeig
,alleig
,indeig
;
49 int iinspl
, indwrk
, liwmin
, nsplit
;
58 z_offset
= 1 + z_dim1
;
64 wantz
= (*jobz
=='V' || *jobz
=='v');
65 alleig
= (*range
=='A' || *range
=='a');
66 valeig
= (*range
=='V' || *range
=='v');
67 indeig
= (*range
=='I' || *range
=='i');
69 lquery
= *lwork
== -1 || *liwork
== -1;
74 if (! (wantz
|| (*jobz
=='N' || *jobz
=='n'))) {
76 } else if (! (alleig
|| valeig
|| indeig
)) {
80 } else if (valeig
&& *n
> 0 && *vu
<= *vl
) {
82 } else if (indeig
&& (*il
< 1 || *il
> *n
)) {
84 } else if (indeig
&& (*iu
< *il
|| *iu
> *n
)) {
86 } else if (*ldz
< 1 || (wantz
&& *ldz
< *n
)) {
88 } else if (*lwork
< lwmin
&& ! lquery
) {
90 } else if (*liwork
< liwmin
&& ! lquery
) {
94 work
[1] = (float) lwmin
;
111 if (alleig
|| indeig
) {
115 if (*vl
< d__
[1] && *vu
>= d__
[1]) {
121 z__
[z_dim1
+ 1] = 1.;
126 minval
= GMX_FLOAT_MIN
;
127 safmin
= minval
*(1.0+GMX_FLOAT_EPS
);
129 smlnum
= safmin
/ eps
;
130 bignum
= 1. / smlnum
;
132 d__1
= sqrt(bignum
), d__2
= 1. / sqrt(sqrt(safmin
));
133 rmax
= (d__1
<d__2
) ? d__1
: d__2
;
135 tnrm
= F77_FUNC(slanst
,SLANST
)("M", n
, &d__
[1], &e
[1]);
136 if (tnrm
> 0. && tnrm
< rmin
) {
138 } else if (tnrm
> rmax
) {
141 if ( fabs(scale
-1.0)>GMX_FLOAT_EPS
) {
142 F77_FUNC(sscal
,SSCAL
)(n
, &scale
, &d__
[1], &c__1
);
144 F77_FUNC(sscal
,SSCAL
)(&i__1
, &scale
, &e
[1], &c__1
);
148 indwrk
= (*n
<< 1) + 1;
152 iindw
= (*n
<< 1) + 1;
156 F77_FUNC(slarrex
,SLARREX
)(range
, n
, vl
, vu
, il
, iu
, &d__
[1], &e
[1], &thresh
, &nsplit
, &
157 iwork
[iinspl
], m
, &w
[1], &iwork
[iindbl
], &iwork
[iindw
], &work
[
158 indgrs
], &work
[indwrk
], &iwork
[iindwk
], &iinfo
);
166 d__1
= *abstol
, d__2
= (float) (*n
) * eps
;
167 tol
= (d__1
>d__2
) ? d__1
: d__2
;
168 F77_FUNC(slarrvx
,SLARRVX
)(n
, &d__
[1], &e
[1], &iwork
[iinspl
], m
, &w
[1], &iwork
[iindbl
], &
169 iwork
[iindw
], &work
[indgrs
], &tol
, &z__
[z_offset
], ldz
, &
170 isuppz
[1], &work
[indwrk
], &iwork
[iindwk
], &iinfo
);
178 for (j
= 1; j
<= i__1
; ++j
) {
179 itmp
= iwork
[iindbl
+ j
- 1];
180 w
[j
] += e
[iwork
[iinspl
+ itmp
- 1]];
183 if (fabs(scale
-1.0)>GMX_FLOAT_EPS
) {
185 F77_FUNC(sscal
,SSCAL
)(m
, &d__1
, &w
[1], &c__1
);
189 for (j
= 1; j
<= i__1
; ++j
) {
193 for (jj
= j
+ 1; jj
<= i__2
; ++jj
) {
203 F77_FUNC(sswap
,SSWAP
)(n
, &z__
[i__
* z_dim1
+ 1], &c__1
, &z__
[j
* z_dim1
205 itmp
= isuppz
[(i__
<< 1) - 1];
206 isuppz
[(i__
<< 1) - 1] = isuppz
[(j
<< 1) - 1];
207 isuppz
[(j
<< 1) - 1] = itmp
;
208 itmp
= isuppz
[i__
* 2];
209 isuppz
[i__
* 2] = isuppz
[j
* 2];
210 isuppz
[j
* 2] = itmp
;
216 work
[1] = (float) lwmin
;