2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012, 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.
36 #include <types/simple.h>
39 #include "gmx_lapack.h"
40 #include "lapack_limits.h"
43 F77_FUNC(slasd7,SLASD7)(int *icompq,
71 int givcol_dim1, givcol_offset, givnum_dim1, givnum_offset, i__1;
78 int nlp1, nlp2, idxi, idxj;
96 givcol_dim1 = *ldgcol;
97 givcol_offset = 1 + givcol_dim1;
98 givcol -= givcol_offset;
99 givnum_dim1 = *ldgnum;
100 givnum_offset = 1 + givnum_dim1;
101 givnum -= givnum_offset;
113 z1 = *alpha * vl[nlp1];
116 for (i__ = *nl; i__ >= 1; --i__) {
117 z__[i__ + 1] = *alpha * vl[i__];
119 vf[i__ + 1] = vf[i__];
120 d__[i__ + 1] = d__[i__];
121 idxq[i__ + 1] = idxq[i__] + 1;
126 for (i__ = nlp2; i__ <= i__1; ++i__) {
127 z__[i__] = *beta * vf[i__];
131 for (i__ = nlp2; i__ <= i__1; ++i__) {
136 for (i__ = 2; i__ <= i__1; ++i__) {
137 dsigma[i__] = d__[idxq[i__]];
138 zw[i__] = z__[idxq[i__]];
139 vfw[i__] = vf[idxq[i__]];
140 vlw[i__] = vl[idxq[i__]];
143 F77_FUNC(slamrg,SLAMRG)(nl, nr, &dsigma[2], &c__1, &c__1, &idx[2]);
146 for (i__ = 2; i__ <= i__1; ++i__) {
148 d__[i__] = dsigma[idxi];
158 tol = (d__1>d__2) ? d__1 : d__2;
160 tol = eps * 64. * ((d__2>tol) ? d__2 : tol);
165 for (j = 2; j <= i__1; ++j) {
166 if (fabs(z__[j]) <= tol) {
185 if (fabs(z__[j]) <= tol) {
191 if (fabs(d__[j] - d__[jprev]) <= tol) {
196 tau = F77_FUNC(slapy2,SLAPY2)(c__, s);
205 idxjp = idxq[idx[jprev] + 1];
206 idxj = idxq[idx[j] + 1];
213 givcol[*givptr + (givcol_dim1 << 1)] = idxjp;
214 givcol[*givptr + givcol_dim1] = idxj;
215 givnum[*givptr + (givnum_dim1 << 1)] = *c__;
216 givnum[*givptr + givnum_dim1] = *s;
218 F77_FUNC(srot,SROT)(&c__1, &vf[jprev], &c__1, &vf[j], &c__1, c__, s);
219 F77_FUNC(srot,SROT)(&c__1, &vl[jprev], &c__1, &vl[j], &c__1, c__, s);
226 dsigma[*k] = d__[jprev];
236 dsigma[*k] = d__[jprev];
242 for (j = 2; j <= i__1; ++j) {
250 for (j = 2; j <= i__1; ++j) {
252 perm[j] = idxq[idx[jp] + 1];
253 if (perm[j] <= nlp1) {
259 F77_FUNC(scopy,SCOPY)(&i__1, &dsigma[*k + 1], &c__1, &d__[*k + 1], &c__1);
263 if (fabs(dsigma[2]) <= hlftol) {
267 z__[1] = F77_FUNC(slapy2,SLAPY2)(&z1, &z__[m]);
274 *s = -z__[m] / z__[1];
276 F77_FUNC(srot,SROT)(&c__1, &vf[m], &c__1, &vf[1], &c__1, c__, s);
277 F77_FUNC(srot,SROT)(&c__1, &vl[m], &c__1, &vl[1], &c__1, c__, s);
279 if (fabs(z1) <= tol) {
287 F77_FUNC(scopy,SCOPY)(&i__1, &zw[2], &c__1, &z__[2], &c__1);
289 F77_FUNC(scopy,SCOPY)(&i__1, &vfw[2], &c__1, &vf[2], &c__1);
291 F77_FUNC(scopy,SCOPY)(&i__1, &vlw[2], &c__1, &vl[2], &c__1);