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.
35 #include "gmx_lapack.h"
36 #include "lapack_limits.h"
40 F77_FUNC(sorgqr,SORGQR)(int *m,
50 int a_dim1, a_offset, i__1, i__2, i__3;
52 int i__, j, l, ib, nb, ki, kk, nx, iws, nbmin, iinfo;
57 a_offset = 1 + a_dim1;
64 nb = DORGQR_BLOCKSIZE;
66 work[1] = (float) lwkopt;
67 lquery = *lwork == -1;
70 } else if (*n < 0 || *n > *m) {
72 } else if (*k < 0 || *k > *n) {
74 } else if (*lda < (*m)) {
76 } else if (*lwork < (*n) && ! lquery) {
94 if (nb > 1 && nb < *k) {
96 nx = DORGQR_CROSSOVER;
103 nb = *lwork / ldwork;
104 nbmin = DORGQR_MINBLOCKSIZE;
109 if (nb >= nbmin && nb < *k && nx < *k) {
111 ki = (*k - nx - 1) / nb * nb;
112 i__1 = *k, i__2 = ki + nb;
113 kk = (i__1<i__2) ? i__1 : i__2;
116 for (j = kk + 1; j <= i__1; ++j) {
118 for (i__ = 1; i__ <= i__2; ++i__) {
119 a[i__ + j * a_dim1] = 0.;
130 F77_FUNC(sorg2r,SORG2R)(&i__1, &i__2, &i__3, &a[kk + 1 + (kk + 1) * a_dim1], lda, &
131 tau[kk + 1], &work[1], &iinfo);
137 for (i__ = ki + 1; i__1 < 0 ? i__ >= 1 : i__ <= 1; i__ += i__1) {
138 i__2 = nb, i__3 = *k - i__ + 1;
139 ib = (i__2<i__3) ? i__2 : i__3;
140 if (i__ + ib <= *n) {
143 F77_FUNC(slarft,SLARFT)("Forward", "Columnwise", &i__2, &ib, &a[i__ + i__ *
144 a_dim1], lda, &tau[i__], &work[1], &ldwork);
147 i__3 = *n - i__ - ib + 1;
148 F77_FUNC(slarfb,SLARFB)("Left", "No transpose", "Forward", "Columnwise", &
149 i__2, &i__3, &ib, &a[i__ + i__ * a_dim1], lda, &work[
150 1], &ldwork, &a[i__ + (i__ + ib) * a_dim1], lda, &
151 work[ib + 1], &ldwork);
155 F77_FUNC(sorg2r,SORG2R)(&i__2, &ib, &ib, &a[i__ + i__ * a_dim1], lda, &tau[i__], &
159 for (j = i__; j <= i__2; ++j) {
161 for (l = 1; l <= i__3; ++l) {
162 a[l + j * a_dim1] = 0.;
168 work[1] = (float) iws;