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 "gmx_lapack.h"
40 F77_FUNC(dlasd3,DLASD3)(int *nl,
61 int q_dim1, q_offset, u_dim1, u_offset, u2_dim1, u2_offset, vt_dim1,
62 vt_offset, vt2_dim1, vt2_offset, i__1, i__2;
82 q_offset = 1 + q_dim1;
86 u_offset = 1 + u_dim1;
89 u2_offset = 1 + u2_dim1;
92 vt_offset = 1 + vt_dim1;
95 vt2_offset = 1 + vt2_dim1;
106 } else if (*nr < 1) {
108 } else if (*sqre != 1 && *sqre != 0) {
118 d__[1] = fabs(z__[1]);
119 F77_FUNC(dcopy,DCOPY)(&m, &vt2[vt2_dim1 + 1], ldvt2, &vt[vt_dim1 + 1], ldvt);
121 F77_FUNC(dcopy,DCOPY)(&n, &u2[u2_dim1 + 1], &c__1, &u[u_dim1 + 1], &c__1);
124 for (i__ = 1; i__ <= i__1; ++i__) {
125 u[i__ + u_dim1] = -u2[i__ + u2_dim1];
132 for (i__ = 1; i__ <= i__1; ++i__) {
135 /* force store and reload from memory */
136 t1 = (*p1) + (*p2) - dsigma[i__];
141 F77_FUNC(dcopy,DCOPY)(k, &z__[1], &c__1, &q[q_offset], &c__1);
143 rho = F77_FUNC(dnrm2,DNRM2)(k, &z__[1], &c__1);
144 F77_FUNC(dlascl,DLASCL)("G", &c__0, &c__0, &rho, &one, k, &c__1, &z__[1], k, info);
149 for (j = 1; j <= i__1; ++j) {
150 F77_FUNC(dlasd4,DLASD4)(k, &j, &dsigma[1], &z__[1], &u[j * u_dim1 + 1], &rho, &d__[j],
151 &vt[j * vt_dim1 + 1], info);
159 for (i__ = 1; i__ <= i__1; ++i__) {
160 z__[i__] = u[i__ + *k * u_dim1] * vt[i__ + *k * vt_dim1];
162 for (j = 1; j <= i__2; ++j) {
163 z__[i__] *= u[i__ + j * u_dim1] * vt[i__ + j * vt_dim1] / (dsigma[
164 i__] - dsigma[j]) / (dsigma[i__] + dsigma[j]);
167 for (j = i__; j <= i__2; ++j) {
168 z__[i__] *= u[i__ + j * u_dim1] * vt[i__ + j * vt_dim1] / (dsigma[
169 i__] - dsigma[j + 1]) / (dsigma[i__] + dsigma[j + 1]);
171 d__2 = sqrt(fabs(z__[i__]));
172 z__[i__] = (q[i__ + q_dim1] > 0) ? d__2 : -d__2;
176 for (i__ = 1; i__ <= i__1; ++i__) {
177 vt[i__ * vt_dim1 + 1] = z__[1] / u[i__ * u_dim1 + 1] / vt[i__ *
179 u[i__ * u_dim1 + 1] = -1.;
181 for (j = 2; j <= i__2; ++j) {
182 vt[j + i__ * vt_dim1] = z__[j] / u[j + i__ * u_dim1] / vt[j + i__
184 u[j + i__ * u_dim1] = dsigma[j] * vt[j + i__ * vt_dim1];
186 temp = F77_FUNC(dnrm2,DNRM2)(k, &u[i__ * u_dim1 + 1], &c__1);
187 q[i__ * q_dim1 + 1] = u[i__ * u_dim1 + 1] / temp;
189 for (j = 2; j <= i__2; ++j) {
191 q[j + i__ * q_dim1] = u[jc + i__ * u_dim1] / temp;
196 F77_FUNC(dgemm,DGEMM)("N", "N", &n, k, k, &one, &u2[u2_offset], ldu2, &q[q_offset],
197 ldq, &zero, &u[u_offset], ldu);
201 F77_FUNC(dgemm,DGEMM)("N", "N", nl, k, &ctot[1], &one, &u2[(u2_dim1 << 1) + 1],
202 ldu2, &q[q_dim1 + 2], ldq, &zero, &u[u_dim1 + 1], ldu);
204 ktemp = ctot[1] + 2 + ctot[2];
205 F77_FUNC(dgemm,DGEMM)("N", "N", nl, k, &ctot[3], &one, &u2[ktemp * u2_dim1 + 1]
206 , ldu2, &q[ktemp + q_dim1], ldq, &one, &u[u_dim1 + 1],
209 } else if (ctot[3] > 0) {
210 ktemp = ctot[1] + 2 + ctot[2];
211 F77_FUNC(dgemm,DGEMM)("N", "N", nl, k, &ctot[3], &one, &u2[ktemp * u2_dim1 + 1],
212 ldu2, &q[ktemp + q_dim1], ldq, &zero, &u[u_dim1 + 1], ldu);
214 F77_FUNC(dlacpy,DLACPY)("F", nl, k, &u2[u2_offset], ldu2, &u[u_offset], ldu);
216 F77_FUNC(dcopy,DCOPY)(k, &q[q_dim1 + 1], ldq, &u[nlp1 + u_dim1], ldu);
218 ctemp = ctot[2] + ctot[3];
219 F77_FUNC(dgemm,DGEMM)("N", "N", nr, k, &ctemp, &one, &u2[nlp2 + ktemp * u2_dim1], ldu2,
220 &q[ktemp + q_dim1], ldq, &zero, &u[nlp2 + u_dim1], ldu);
224 for (i__ = 1; i__ <= i__1; ++i__) {
225 temp = F77_FUNC(dnrm2,DNRM2)(k, &vt[i__ * vt_dim1 + 1], &c__1);
226 q[i__ + q_dim1] = vt[i__ * vt_dim1 + 1] / temp;
228 for (j = 2; j <= i__2; ++j) {
230 q[i__ + j * q_dim1] = vt[jc + i__ * vt_dim1] / temp;
235 F77_FUNC(dgemm,DGEMM)("N", "N", k, &m, k, &one, &q[q_offset], ldq, &vt2[vt2_offset]
236 , ldvt2, &zero, &vt[vt_offset], ldvt);
240 F77_FUNC(dgemm,DGEMM)("N", "N", k, &nlp1, &ktemp, &one, &q[q_dim1 + 1], ldq, &vt2[
241 vt2_dim1 + 1], ldvt2, &zero, &vt[vt_dim1 + 1], ldvt);
242 ktemp = ctot[1] + 2 + ctot[2];
243 if (ktemp <= *ldvt2) {
244 F77_FUNC(dgemm,DGEMM)("N", "N", k, &nlp1, &ctot[3], &one, &q[ktemp * q_dim1 + 1],
245 ldq, &vt2[ktemp + vt2_dim1], ldvt2, &one, &vt[vt_dim1 + 1],
253 for (i__ = 1; i__ <= i__1; ++i__) {
254 q[i__ + ktemp * q_dim1] = q[i__ + q_dim1];
257 for (i__ = nlp2; i__ <= i__1; ++i__) {
258 vt2[ktemp + i__ * vt2_dim1] = vt2[i__ * vt2_dim1 + 1];
261 ctemp = ctot[2] + 1 + ctot[3];
262 F77_FUNC(dgemm,DGEMM)("N", "N", k, &nrp1, &ctemp, &one, &q[ktemp * q_dim1 + 1], ldq, &
263 vt2[ktemp + nlp2 * vt2_dim1], ldvt2, &zero, &vt[nlp2 * vt_dim1 +