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.
36 #include "gmx_lapack.h"
37 #include "lapack_limits.h"
40 F77_FUNC(sgetri,SGETRI)(int *n,
48 int a_dim1, a_offset, i__1, i__2, i__3;
50 int i__, j, jb, nb, jj, jp, nn, iws;
59 a_offset = 1 + a_dim1;
65 nb = DGETRI_BLOCKSIZE;
67 work[1] = (float) lwkopt;
71 } else if (*lda < (*n)) {
73 } else if (*lwork < (*n) && *lwork!=-1) {
79 } else if (*lwork == -1) {
87 F77_FUNC(strtri,STRTRI)("Upper", "Non-unit", n, &a[a_offset], lda, info);
94 if (nb > 1 && nb < *n) {
96 iws = (i__1>1) ? i__1 : 1;
99 nbmin = DGETRI_MINBLOCKSIZE;
105 if (nb < nbmin || nb >= *n) {
107 for (j = *n; j >= 1; --j) {
110 for (i__ = j + 1; i__ <= i__1; ++i__) {
111 work[i__] = a[i__ + j * a_dim1];
112 a[i__ + j * a_dim1] = 0.;
117 F77_FUNC(sgemv,SGEMV)("No transpose", n, &i__1, &c_b20, &a[(j + 1) * a_dim1
118 + 1], lda, &work[j + 1], &c__1, &c_b22, &a[j * a_dim1
124 nn = (*n - 1) / nb * nb + 1;
126 for (j = nn; i__1 < 0 ? j >= 1 : j <= 1; j += i__1) {
127 i__2 = nb, i__3 = *n - j + 1;
128 jb = (i__2<i__3) ? i__2 : i__3;
131 for (jj = j; jj <= i__2; ++jj) {
133 for (i__ = jj + 1; i__ <= i__3; ++i__) {
134 work[i__ + (jj - j) * ldwork] = a[i__ + jj * a_dim1];
135 a[i__ + jj * a_dim1] = 0.;
140 i__2 = *n - j - jb + 1;
141 F77_FUNC(sgemm,SGEMM)("No transpose", "No transpose", n, &jb, &i__2, &c_b20,
142 &a[(j + jb) * a_dim1 + 1], lda, &work[j + jb], &
143 ldwork, &c_b22, &a[j * a_dim1 + 1], lda);
145 F77_FUNC(strsm,STRSM)("Right", "Lower", "No transpose", "Unit", n, &jb, &c_b22, &
146 work[j], &ldwork, &a[j * a_dim1 + 1], lda);
150 for (j = *n - 1; j >= 1; --j) {
153 F77_FUNC(sswap,SSWAP)(n, &a[j * a_dim1 + 1], &c__1, &a[jp * a_dim1 + 1], &c__1);
157 work[1] = (float) iws;