839d56a5d0fe94ca0e57a00b770378fe7603b7d2
[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, 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 #ifdef HAVE_CONFIG_H
61 #include "config.h"
62 #endif
63
64 /* These are not required by this file, but by the internal BLAS
65  * implementation.  In principle, they could be included in each file
66  * that requires them, but this is simpler.  Since the header is internal
67  * to the linearyalgebra/ module, the added complexity may not be worth it. */
68 #include "gromacs/utility/basedefinitions.h"
69 #include "gromacs/utility/real.h"
70
71 /* Suppress Cygwin compiler warnings from using newlib version of
72  * ctype.h */
73 #ifdef GMX_CYGWIN
74 #undef toupper
75 #endif
76
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 #if 0
81 }
82 #endif
83
84 /* Double precision versions */
85 double
86     F77_FUNC(dasum, DASUM) (int *n, double *dx, int *incx);
87
88 void
89     F77_FUNC(daxpy, DAXPY) (int *n, double *da, double *dx, int *incx, double *dy, int *incy);
90
91 void
92     F77_FUNC(dcopy, DCOPY) (int *n, double *dx, int *incx, double *dy, int *incy);
93
94 double
95     F77_FUNC(ddot, DDOT) (int *n, double *dx, int *incx, double *dy, int *incy);
96
97 void
98     F77_FUNC(dgemm, DGEMM) (const char *transa, const char *transb, int *m, int *n, int *k,
99                             double *alpha, double *a, int *lda, double *b, int *ldb,
100                             double *beta, double *c, int *ldc);
101
102 void
103     F77_FUNC(dgemv, DGEMV) (const char *trans, int *m, int *n, double *alpha, double *a, int *lda,
104                             double *x, int *incx, double *beta, double *y, int *incy);
105
106 void
107     F77_FUNC(dger, DGER) (int *m, int *n, double *alpha, double *x, int *incx,
108                           double *y, int *incy, double *a, int *lda);
109
110 double
111     F77_FUNC(dnrm2, DNRM2) (int  *n, double *x, int *incx);
112
113 void
114     F77_FUNC(drot, DROT) (int *n, double *dx, int *incx,
115                           double *dy, int *incy, double *c, double *s);
116
117 void
118     F77_FUNC(dscal, DSCAL) (int *n, double *fact, double *dx, int *incx);
119
120 void
121     F77_FUNC(dswap, DSWAP) (int *n, double *dx, int *incx, double *dy, int *incy);
122
123 void
124     F77_FUNC(dsymv, DSYMV) (const char *uplo, int *n, double *alpha, double *a, int *lda,
125                             double *x, int *incx, double *beta, double *y, int *incy);
126
127 void
128     F77_FUNC(dsyr2, DSYR2) (const char *uplo, int *n, double *alpha, double *x, int *incx,
129                             double *y, int *incy, double *a, int *lda);
130
131 void
132     F77_FUNC(dsyr2k, DSYR2K) (const char *uplo, const char *trans, int *n, int *k, double *alpha, double *a,
133                               int *lda, double *b, int *ldb, double *beta, double *c, int *ldc);
134
135 void
136     F77_FUNC(dtrmm, DTRMM) (const char *side, const char *uplo, const char *transa, const char *diag, int *m, int *n,
137                             double *alpha, double *a, int *lda, double *b, int *ldb);
138
139 void
140     F77_FUNC(dtrmv, DTRMV) (const char *uplo, const char *trans, const char *diag, int *n,
141                             double *a, int *lda, double *x, int *incx);
142
143 void
144     F77_FUNC(dtrsm, DTRSM) (const char *side, const char *uplo, const char *transa, const char *diag, int *m, int *n,
145                             double *alpha, double *a, int *lda, double *b, int *ldb);
146
147 int
148     F77_FUNC(idamax, IDAMAX) (int *n, double *dx, int *incx);
149
150
151
152 /* Single precision versions */
153 float
154     F77_FUNC(sasum, SASUM) (int *n, float *dx, int *incx);
155
156 void
157     F77_FUNC(saxpy, SAXPY) (int *n, float *da, float *dx, int *incx, float *dy, int *incy);
158
159 void
160     F77_FUNC(scopy, SCOPY) (int *n, float *dx, int *incx, float *dy, int *incy);
161
162 float
163     F77_FUNC(sdot, SDOT) (int *n, float *dx, int *incx, float *dy, int *incy);
164
165 void
166     F77_FUNC(sgemm, SGEMM) (const char *transa, const char *transb, int *m, int *n, int *k,
167                             float *alpha, float *a, int *lda, float *b, int *ldb,
168                             float *beta, float *c, int *ldc);
169
170 void
171     F77_FUNC(sgemv, SGEMV) (const char *trans, int *m, int *n, float *alpha, float *a, int *lda,
172                             float *x, int *incx, float *beta, float *y, int *incy);
173
174 void
175     F77_FUNC(sger, SGER) (int *m, int *n, float *alpha, float *x, int *incx,
176                           float *y, int *incy, float *a, int *lda);
177
178 float
179     F77_FUNC(snrm2, SNRM2) (int  *n, float *x, int *incx);
180
181 void
182     F77_FUNC(srot, SROT) (int *n, float *dx, int *incx,
183                           float *dy, int *incy, float *c, float *s);
184
185 void
186     F77_FUNC(sscal, SSCAL) (int *n, float *fact, float *dx, int *incx);
187
188 void
189     F77_FUNC(sswap, SSWAP) (int *n, float *dx, int *incx, float *dy, int *incy);
190
191 void
192     F77_FUNC(ssymv, SSYMV) (const char *uplo, int *n, float *alpha, float *a, int *lda,
193                             float *x, int *incx, float *beta, float *y, int *incy);
194
195 void
196     F77_FUNC(ssyr2, SSYR2) (const char *uplo, int *n, float *alpha, float *x, int *incx,
197                             float *y, int *incy, float *a, int *lda);
198
199 void
200     F77_FUNC(ssyr2k, SSYR2K) (const char *uplo, const char *trans, int *n, int *k, float *alpha, float *a,
201                               int *lda, float *b, int *ldb, float *beta, float *c, int *ldc);
202
203 void
204     F77_FUNC(strmm, STRMM) (const char *side, const char *uplo, const char *transa, const char *diag, int *m, int *n,
205                             float *alpha, float *a, int *lda, float *b, int *ldb);
206
207 void
208     F77_FUNC(strmv, STRMV) (const char *uplo, const char *trans, const char *diag, int *n,
209                             float *a, int *lda, float *x, int *incx);
210
211 void
212     F77_FUNC(strsm, STRSM) (const char *side, const char *uplo, const char *transa, const char *diag, int *m, int *n,
213                             float *alpha, float *a, int *lda, float *b, int *ldb);
214
215 int
216     F77_FUNC(isamax, ISAMAX) (int *n, float *dx, int *incx);
217
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223 /*! \endcond */
224
225 #endif /* GMX_BLAS_H */