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.
35 #include "gmx_lapack.h"
37 #define DORGLQ_BLOCKSIZE 32
38 #define DORGLQ_MINBLOCKSIZE 2
39 #define DORGLQ_CROSSOVER 128
43 F77_FUNC(dorglq,DORGLQ)(int *m,
53 int a_dim1, a_offset, i__1, i__2, i__3;
55 int i__, j, l, ib, nb, ki, kk, nx, iws, nbmin, iinfo;
61 a_offset = 1 + a_dim1;
68 nb = DORGLQ_BLOCKSIZE;
70 work[1] = (double) lwkopt;
71 lquery = *lwork == -1;
76 } else if (*k < 0 || *k > *m) {
78 } else if (*lda < (*m)) {
80 } else if (*lwork < (*m) && ! lquery) {
98 if (nb > 1 && nb < *k) {
100 nx = DORGLQ_CROSSOVER;
107 nb = *lwork / ldwork;
108 nbmin = DORGLQ_MINBLOCKSIZE;
113 if (nb >= nbmin && nb < *k && nx < *k) {
115 ki = (*k - nx - 1) / nb * nb;
116 i__1 = *k, i__2 = ki + nb;
117 kk = (i__1<i__2) ? i__1 : i__2;
120 for (j = 1; j <= i__1; ++j) {
122 for (i__ = kk + 1; i__ <= i__2; ++i__) {
123 a[i__ + j * a_dim1] = 0.;
133 F77_FUNC(dorgl2,DORGL2)(&i__1, &i__2, &i__3, &a[kk + 1 + (kk + 1) * a_dim1], lda, &
134 tau[kk + 1], &work[1], &iinfo);
140 for (i__ = ki + 1; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) {
141 i__2 = nb, i__3 = *k - i__ + 1;
142 ib = (i__2<i__3) ? i__2 : i__3;
143 if (i__ + ib <= *m) {
146 F77_FUNC(dlarft,DLARFT)("Forward", "Rowwise", &i__2, &ib, &a[i__ + i__ *
147 a_dim1], lda, &tau[i__], &work[1], &ldwork);
149 i__2 = *m - i__ - ib + 1;
151 F77_FUNC(dlarfb,DLARFB)("Right", "Transpose", "Forward", "Rowwise", &i__2, &
152 i__3, &ib, &a[i__ + i__ * a_dim1], lda, &work[1], &
153 ldwork, &a[i__ + ib + i__ * a_dim1], lda, &work[ib +
158 F77_FUNC(dorgl2,DORGL2)(&ib, &i__2, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &
162 for (j = 1; j <= i__2; ++j) {
164 for (l = i__; l <= i__3; ++l) {
165 a[l + j * a_dim1] = 0.;
171 work[1] = (double) iws;