2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 #include <types/simple.h>
39 #include "gmx_lapack.h"
40 #include "lapack_limits.h"
43 F77_FUNC(dlarrbx,DLARRBX)(int *n,
68 double eps, tmp, left;
69 int nint, prev, next, nleft;
70 double right, width, dplus, error;
88 for (i__ = 1; i__ <= i__1; ++i__) {
95 for (i__ = *ifirst; i__ <= i__1; ++i__) {
99 } else if (i__ == *ilast) {
102 d__1 = wgap[ii - 1], d__2 = wgap[ii];
103 gap = (d__1<d__2) ? d__1 : d__2;
116 if (iwork[(i__ << 1) - 1] == 1) {
118 left = w[ii] - werr[ii];
122 if (i__ > i1 && left <= right) {
129 for (j = 1; j <= i__1; ++j) {
131 s = s * lld[j] / dplus - left;
140 if (! (s > 0. || s < 1.)) {
145 for (j = 1; j <= i__1; ++j) {
150 tmp = lld[j] / dplus;
151 if (fabs(tmp)<GMX_DOUBLE_MIN) {
163 left -= werr[ii] * fac;
169 i1 = (i1<nleft) ? i1 : nleft;
171 right = w[ii] + werr[ii];
176 for (j = 1; j <= i__1; ++j) {
178 s = s * lld[j] / dplus - right;
187 if (! (s > 0. || s < 1.)) {
192 for (j = 1; j <= i__1; ++j) {
197 tmp = lld[j] / dplus;
198 if (fabs(tmp)<GMX_DOUBLE_MIN) {
210 right += werr[ii] * fac;
214 cnt = (cnt<i2) ? cnt : i2;
222 if (prev != nleft - 1) {
227 right = work[i__ * 2];
235 if (i__ <= *n && iwork[(i__ << 1) - 1] != -1) {
236 work[(i__ << 1) - 1] = work[prev * 2];
244 for (p = 1; p <= i__1; ++p) {
250 mid = (left + right) * .5;
254 tmp = (d__1>d__2) ? d__1 : d__2;
258 if (prev > 0 && next <= *n) {
259 d__1 = left - work[k - 2], d__2 = work[k + 1] - right;
260 gap = (d__1<d__2) ? d__1 : d__2;
261 } else if (prev > 0) {
262 gap = left - work[k - 2];
263 } else if (next <= *n) {
264 gap = work[k + 1] - right;
267 d__1 = *rtol1 * gap, d__2 = *rtol2 * tmp;
268 if (width < ((d__1>d__2) ? d__1 : d__2)) {
273 for (j = i__ + 1; j <= i__2; ++j) {
278 wgap[j - 1 - *offset] = 0.;
283 iwork[(prev << 1) - 1] = next;
293 for (j = 1; j <= i__2; ++j) {
295 s = s * lld[j] / dplus - mid;
304 if (! (s > 0. || s < 1.)) {
308 for (j = 1; j <= i__2; ++j) {
313 tmp = lld[j] / dplus;
314 if (fabs(tmp)<GMX_DOUBLE_MIN) {
325 i__2 = i__ - 1, i__3 = (nright<cnt) ? nright : cnt;
326 cnt = (i__2>i__3) ? i__2 : i__3;
327 if (cnt == i__ - 1) {
329 } else if (cnt == nright) {
336 iwork[kk - 1] = next;
345 if (cnt > *ifirst && cnt <= *ilast) {
347 } else if (cnt <= *ifirst) {
357 for (i__ = *ifirst; i__ <= i__1; ++i__) {
360 if (iwork[k - 1] != -1) {
361 w[ii] = (work[k - 1] + work[k]) * .5;
362 werr[ii] = work[k] - w[ii];
364 wgap[ii] = work[k + 1] - work[k];