2 #include "../gmx_lapack.h"
3 #include "lapack_limits.h"
5 #include "gromacs/utility/real.h"
8 F77_FUNC(sstebz
,SSTEBZ
)(const char *range
,
28 float d__1
, d__2
, d__3
, d__4
, d__5
;
34 int j
, ib
, jb
, ie
, je
, nb
;
44 int iend
, ioff
, iout
, itmp1
, jdisc
;
50 float wkill
, rtoli
, tnorm
;
58 const float safemn
= GMX_FLOAT_MIN
*(1.0+GMX_FLOAT_EPS
);
70 if (*range
=='A' || *range
=='a') {
72 } else if (*range
=='V' || *range
=='v') {
74 } else if (*range
=='I' || *range
=='i') {
80 if (*order
=='B' || *order
=='b') {
82 } else if (*order
=='E' || *order
=='e') {
90 } else if (iorder
<= 0) {
94 } else if (irange
== 2) {
98 } else if (irange
== 3 && (*il
< 1 || *il
> (*n
))) {
100 } else if (irange
== 3 && (*iu
< ((*n
<*il
) ? *n
: *il
) || *iu
> *n
)) {
118 if (irange
== 3 && *il
== 1 && *iu
== *n
) {
122 ulp
= 2*GMX_FLOAT_EPS
;
124 nb
= DSTEBZ_BLOCKSIZE
;
132 if (irange
== 2 && (*vl
>= d__
[1] || *vu
< d__
[1])) {
146 for (j
= 2; j
<= i__1
; ++j
) {
150 if (fabs(d__
[j
] * d__
[j
- 1]) * (d__2
* d__2
) + safemn
152 isplit
[*nsplit
] = j
- 1;
157 pivmin
= (pivmin
>tmp1
) ? pivmin
: tmp1
;
160 isplit
[*nsplit
] = *n
;
170 for (j
= 1; j
<= i__1
; ++j
) {
171 tmp2
= sqrt(work
[j
]);
172 d__1
= gu
, d__2
= d__
[j
] + tmp1
+ tmp2
;
173 gu
= (d__1
>d__2
) ? d__1
: d__2
;
174 d__1
= gl
, d__2
= d__
[j
] - tmp1
- tmp2
;
175 gl
= (d__1
<d__2
) ? d__1
: d__2
;
179 d__1
= gu
, d__2
= d__
[*n
] + tmp1
;
180 gu
= (d__1
>d__2
) ? d__1
: d__2
;
181 d__1
= gl
, d__2
= d__
[*n
] - tmp1
;
182 gl
= (d__1
<d__2
) ? d__1
: d__2
;
185 tnorm
= (d__1
>d__2
) ? d__1
: d__2
;
186 gl
= gl
- tnorm
* 2. * ulp
* *n
- pivmin
* 4.;
187 gu
= gu
+ tnorm
* 2. * ulp
* *n
+ pivmin
* 2.;
189 itmax
= (int) ((log(tnorm
+ pivmin
) - log(pivmin
)) / log(2.)) + 2;
209 F77_FUNC(slaebz
,SLAEBZ
)(&c__3
, &itmax
, n
, &c__2
, &c__2
, &nb
, &atoli
, &rtoli
, &pivmin
,
210 &d__
[1], &e
[1], &work
[1], &iwork
[5], &work
[*n
+ 1], &work
[*n
211 + 5], &iout
, &iwork
[1], &w
[1], &iblock
[1], &iinfo
);
213 if (iwork
[6] == *iu
) {
229 if (nwl
< 0 || nwl
>= *n
|| nwu
< 1 || nwu
> *n
) {
236 /* avoid warnings for high gcc optimization */
239 d__3
= fabs(d__
[1]) + fabs(e
[1]);
240 d__4
= fabs(d__
[*n
]) + fabs(e
[*n
- 1]);
241 tnorm
= (d__3
>d__4
) ? d__3
: d__4
;
244 for (j
= 2; j
<= i__1
; ++j
) {
246 d__5
= fabs(d__
[j
]) + fabs(e
[j
- 1]) + fabs(e
[j
]);
247 tnorm
= (d__4
>d__5
) ? d__4
: d__5
;
272 for (jb
= 1; jb
<= i__1
; ++jb
) {
280 if (irange
== 1 || wl
>= d__
[ibegin
] - pivmin
) {
283 if (irange
== 1 || wu
>= d__
[ibegin
] - pivmin
) {
286 if (irange
== 1 || ((wl
< d__
[ibegin
] - pivmin
) && (wu
>= d__
[ibegin
] - pivmin
))) {
298 for (j
= ibegin
; j
<= i__2
; ++j
) {
300 d__1
= gu
, d__2
= d__
[j
] + tmp1
+ tmp2
;
301 gu
= (d__1
>d__2
) ? d__1
: d__2
;
302 d__1
= gl
, d__2
= d__
[j
] - tmp1
- tmp2
;
303 gl
= (d__1
<d__2
) ? d__1
: d__2
;
307 d__1
= gu
, d__2
= d__
[iend
] + tmp1
;
308 gu
= (d__1
>d__2
) ? d__1
: d__2
;
309 d__1
= gl
, d__2
= d__
[iend
] - tmp1
;
310 gl
= (d__1
<d__2
) ? d__1
: d__2
;
313 bnorm
= (d__1
>d__2
) ? d__1
: d__2
;
314 gl
= gl
- bnorm
* 2. * ulp
* in
- pivmin
* 2.;
315 gu
= gu
+ bnorm
* 2. * ulp
* in
+ pivmin
* 2.;
320 atoli
= ulp
* ((d__1
>d__2
) ? d__1
: d__2
);
330 gl
= (gl
>wl
) ? gl
: wl
;
331 gu
= (gu
<wu
) ? gu
: wu
;
338 work
[*n
+ in
+ 1] = gu
;
339 F77_FUNC(slaebz
,SLAEBZ
)(&c__1
, &c__0
, &in
, &in
, &c__1
, &nb
, &atoli
, &rtoli
, &
340 pivmin
, &d__
[ibegin
], &e
[ibegin
], &work
[ibegin
], idumma
, &
341 work
[*n
+ 1], &work
[*n
+ (in
<< 1) + 1], &im
, &iwork
[1], &
342 w
[*m
+ 1], &iblock
[*m
+ 1], &iinfo
);
345 nwu
+= iwork
[in
+ 1];
346 iwoff
= *m
- iwork
[1];
348 itmax
= (int) ((log(gu
- gl
+ pivmin
) - log(pivmin
)) / log(2.)
350 F77_FUNC(slaebz
,SLAEBZ
)(&c__2
, &itmax
, &in
, &in
, &c__1
, &nb
, &atoli
, &rtoli
, &
351 pivmin
, &d__
[ibegin
], &e
[ibegin
], &work
[ibegin
], idumma
, &
352 work
[*n
+ 1], &work
[*n
+ (in
<< 1) + 1], &iout
, &iwork
[1],
353 &w
[*m
+ 1], &iblock
[*m
+ 1], &iinfo
);
356 for (j
= 1; j
<= i__2
; ++j
) {
357 tmp1
= (work
[j
+ *n
] + work
[j
+ in
+ *n
]) * .5;
359 if (j
> iout
- iinfo
) {
365 i__3
= iwork
[j
+ in
] + iwoff
;
366 for (je
= iwork
[j
] + 1 + iwoff
; je
<= i__3
; ++je
) {
378 idiscl
= *il
- 1 - nwl
;
381 if (idiscl
> 0 || idiscu
> 0) {
383 for (je
= 1; je
<= i__1
; ++je
) {
384 if (w
[je
] <= wlu
&& idiscl
> 0) {
386 } else if (w
[je
] >= wul
&& idiscu
> 0) {
391 iblock
[im
] = iblock
[je
];
396 if (idiscl
> 0 || idiscu
> 0) {
401 for (jdisc
= 1; jdisc
<= i__1
; ++jdisc
) {
404 for (je
= 1; je
<= i__2
; ++je
) {
405 if (iblock
[je
] != 0 && (w
[je
] < wkill
|| iw
== 0)) {
417 for (jdisc
= 1; jdisc
<= i__1
; ++jdisc
) {
420 for (je
= 1; je
<= i__2
; ++je
) {
421 if (iblock
[je
] != 0 && (w
[je
] > wkill
|| iw
== 0)) {
431 for (je
= 1; je
<= i__1
; ++je
) {
432 if (iblock
[je
] != 0) {
435 iblock
[im
] = iblock
[je
];
440 if (idiscl
< 0 || idiscu
< 0) {
445 if (iorder
== 1 && *nsplit
> 1) {
447 for (je
= 1; je
<= i__1
; ++je
) {
451 for (j
= je
+ 1; j
<= i__2
; ++j
) {
461 iblock
[ie
] = iblock
[je
];