Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / linearalgebra / gmx_blas.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2008, The GROMACS development team.
6  * Copyright (c) 2012,2013,2014,2019, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 /*! \internal \file
38  * \brief
39  * Header definitions for the standard BLAS library.
40  *
41  * This is the subset of BLAS routines used for the
42  * linear algebra operations in Gromacs.
43  * Do NOT use this for other purposes - we only provide this as a
44  * simple fallback/reference implementation when no optimized BLAS
45  * is present. If you need an implementation for your own code
46  * there are several much faster versions out there.
47  *
48  * All routines are compatible with the BLAS reference implementation,
49  * meaning they assume fortran-style matrix row/column organization.
50  *
51  * There is plenty of documentation for these routines available
52  * at http://www.netlib.org/blas , so there is no point in repeating
53  * it here.
54  */
55 #ifndef GMX_BLAS_H
56 #define GMX_BLAS_H
57
58 /*! \cond */
59
60 #include "config.h"
61
62 /* These are not required by this file, but by the internal BLAS
63  * implementation.  In principle, they could be included in each file
64  * that requires them, but this is simpler.  Since the header is internal
65  * to the linearyalgebra/ module, the added complexity may not be worth it. */
66 #include "gromacs/utility/basedefinitions.h"
67 #include "gromacs/utility/real.h"
68
69 #ifdef __cplusplus
70 extern "C"
71 {
72 #endif
73 #if 0
74 }
75 #endif
76
77     /* Double precision versions */
78     double F77_FUNC(dasum, DASUM)(int* n, double* dx, int* incx);
79
80     void F77_FUNC(daxpy, DAXPY)(int* n, double* da, double* dx, int* incx, double* dy, int* incy);
81
82     void F77_FUNC(dcopy, DCOPY)(int* n, double* dx, int* incx, double* dy, int* incy);
83
84     double F77_FUNC(ddot, DDOT)(int* n, double* dx, int* incx, double* dy, int* incy);
85
86     void F77_FUNC(dgemm, DGEMM)(const char* transa,
87                                 const char* transb,
88                                 int*        m,
89                                 int*        n,
90                                 int*        k,
91                                 double*     alpha,
92                                 double*     a,
93                                 int*        lda,
94                                 double*     b,
95                                 int*        ldb,
96                                 double*     beta,
97                                 double*     c,
98                                 int*        ldc);
99
100     void F77_FUNC(dgemv, DGEMV)(const char* trans,
101                                 int*        m,
102                                 int*        n,
103                                 double*     alpha,
104                                 double*     a,
105                                 int*        lda,
106                                 double*     x,
107                                 int*        incx,
108                                 double*     beta,
109                                 double*     y,
110                                 int*        incy);
111
112     void F77_FUNC(dger,
113                   DGER)(int* m, int* n, double* alpha, double* x, int* incx, double* y, int* incy, double* a, int* lda);
114
115     double F77_FUNC(dnrm2, DNRM2)(int* n, double* x, int* incx);
116
117     void F77_FUNC(drot, DROT)(int* n, double* dx, int* incx, double* dy, int* incy, double* c, double* s);
118
119     void F77_FUNC(dscal, DSCAL)(int* n, double* fact, double* dx, int* incx);
120
121     void F77_FUNC(dswap, DSWAP)(int* n, double* dx, int* incx, double* dy, int* incy);
122
123     void F77_FUNC(dsymv, DSYMV)(const char* uplo,
124                                 int*        n,
125                                 double*     alpha,
126                                 double*     a,
127                                 int*        lda,
128                                 double*     x,
129                                 int*        incx,
130                                 double*     beta,
131                                 double*     y,
132                                 int*        incy);
133
134     void F77_FUNC(dsyr2, DSYR2)(const char* uplo,
135                                 int*        n,
136                                 double*     alpha,
137                                 double*     x,
138                                 int*        incx,
139                                 double*     y,
140                                 int*        incy,
141                                 double*     a,
142                                 int*        lda);
143
144     void F77_FUNC(dsyr2k, DSYR2K)(const char* uplo,
145                                   const char* trans,
146                                   int*        n,
147                                   int*        k,
148                                   double*     alpha,
149                                   double*     a,
150                                   int*        lda,
151                                   double*     b,
152                                   int*        ldb,
153                                   double*     beta,
154                                   double*     c,
155                                   int*        ldc);
156
157     void F77_FUNC(dtrmm, DTRMM)(const char* side,
158                                 const char* uplo,
159                                 const char* transa,
160                                 const char* diag,
161                                 int*        m,
162                                 int*        n,
163                                 double*     alpha,
164                                 double*     a,
165                                 int*        lda,
166                                 double*     b,
167                                 int*        ldb);
168
169     void F77_FUNC(dtrmv, DTRMV)(const char* uplo,
170                                 const char* trans,
171                                 const char* diag,
172                                 int*        n,
173                                 double*     a,
174                                 int*        lda,
175                                 double*     x,
176                                 int*        incx);
177
178     void F77_FUNC(dtrsm, DTRSM)(const char* side,
179                                 const char* uplo,
180                                 const char* transa,
181                                 const char* diag,
182                                 int*        m,
183                                 int*        n,
184                                 double*     alpha,
185                                 double*     a,
186                                 int*        lda,
187                                 double*     b,
188                                 int*        ldb);
189
190     int F77_FUNC(idamax, IDAMAX)(int* n, double* dx, int* incx);
191
192
193     /* Single precision versions */
194     float F77_FUNC(sasum, SASUM)(int* n, float* dx, int* incx);
195
196     void F77_FUNC(saxpy, SAXPY)(int* n, float* da, float* dx, int* incx, float* dy, int* incy);
197
198     void F77_FUNC(scopy, SCOPY)(int* n, float* dx, int* incx, float* dy, int* incy);
199
200     float F77_FUNC(sdot, SDOT)(int* n, float* dx, int* incx, float* dy, int* incy);
201
202     void F77_FUNC(sgemm, SGEMM)(const char* transa,
203                                 const char* transb,
204                                 int*        m,
205                                 int*        n,
206                                 int*        k,
207                                 float*      alpha,
208                                 float*      a,
209                                 int*        lda,
210                                 float*      b,
211                                 int*        ldb,
212                                 float*      beta,
213                                 float*      c,
214                                 int*        ldc);
215
216     void F77_FUNC(sgemv, SGEMV)(const char* trans,
217                                 int*        m,
218                                 int*        n,
219                                 float*      alpha,
220                                 float*      a,
221                                 int*        lda,
222                                 float*      x,
223                                 int*        incx,
224                                 float*      beta,
225                                 float*      y,
226                                 int*        incy);
227
228     void F77_FUNC(sger,
229                   SGER)(int* m, int* n, float* alpha, float* x, int* incx, float* y, int* incy, float* a, int* lda);
230
231     float F77_FUNC(snrm2, SNRM2)(int* n, float* x, int* incx);
232
233     void F77_FUNC(srot, SROT)(int* n, float* dx, int* incx, float* dy, int* incy, float* c, float* s);
234
235     void F77_FUNC(sscal, SSCAL)(int* n, float* fact, float* dx, int* incx);
236
237     void F77_FUNC(sswap, SSWAP)(int* n, float* dx, int* incx, float* dy, int* incy);
238
239     void F77_FUNC(ssymv, SSYMV)(const char* uplo,
240                                 int*        n,
241                                 float*      alpha,
242                                 float*      a,
243                                 int*        lda,
244                                 float*      x,
245                                 int*        incx,
246                                 float*      beta,
247                                 float*      y,
248                                 int*        incy);
249
250     void F77_FUNC(ssyr2, SSYR2)(const char* uplo,
251                                 int*        n,
252                                 float*      alpha,
253                                 float*      x,
254                                 int*        incx,
255                                 float*      y,
256                                 int*        incy,
257                                 float*      a,
258                                 int*        lda);
259
260     void F77_FUNC(ssyr2k, SSYR2K)(const char* uplo,
261                                   const char* trans,
262                                   int*        n,
263                                   int*        k,
264                                   float*      alpha,
265                                   float*      a,
266                                   int*        lda,
267                                   float*      b,
268                                   int*        ldb,
269                                   float*      beta,
270                                   float*      c,
271                                   int*        ldc);
272
273     void F77_FUNC(strmm, STRMM)(const char* side,
274                                 const char* uplo,
275                                 const char* transa,
276                                 const char* diag,
277                                 int*        m,
278                                 int*        n,
279                                 float*      alpha,
280                                 float*      a,
281                                 int*        lda,
282                                 float*      b,
283                                 int*        ldb);
284
285     void F77_FUNC(strmv, STRMV)(const char* uplo,
286                                 const char* trans,
287                                 const char* diag,
288                                 int*        n,
289                                 float*      a,
290                                 int*        lda,
291                                 float*      x,
292                                 int*        incx);
293
294     void F77_FUNC(strsm, STRSM)(const char* side,
295                                 const char* uplo,
296                                 const char* transa,
297                                 const char* diag,
298                                 int*        m,
299                                 int*        n,
300                                 float*      alpha,
301                                 float*      a,
302                                 int*        lda,
303                                 float*      b,
304                                 int*        ldb);
305
306     int F77_FUNC(isamax, ISAMAX)(int* n, float* dx, int* incx);
307
308
309 #ifdef __cplusplus
310 }
311 #endif
312
313 /*! \endcond */
314
315 #endif /* GMX_BLAS_H */