CXXR (C++ R)
BLAS.h
1 /*CXXR $Id: BLAS.h 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  * Copyright (C) 2003-5 The R Core Team.
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU Lesser General Public License as published by
23  * the Free Software Foundation; either version 2.1 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU Lesser General Public License
32  * along with this program; if not, a copy is available at
33  * http://www.r-project.org/Licenses/
34  */
35 
36 #ifndef R_BLAS_H
37 #define R_BLAS_H
38 /* C declarations of BLAS routines. R packages that use these should have */
39 /* src/Makevars declare PKG_LIBS = $(BLAS_LIBS) $(FLIBS) */
40 
41 #include <R_ext/RS.h> /* for F77_... */
42 #include <R_ext/Complex.h> /* for Rcomplex */
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #ifndef BLAS_extern
49 #define BLAS_extern extern
50 #endif
51 
52 /* Double Precision Level 1 BLAS */
53 
54 BLAS_extern double /* DASUM - sum of absolute values of a one-dimensional array */
55 F77_NAME(dasum)(const int *n, const double *dx, const int *incx);
56 BLAS_extern void /* DAXPY - replace y by alpha*x + y */
57 F77_NAME(daxpy)(const int *n, const double *alpha,
58  const double *dx, const int *incx,
59  double *dy, const int *incy);
60 BLAS_extern void /* DCOPY - copy x to y */
61 F77_NAME(dcopy)(const int *n, const double *dx, const int *incx,
62  double *dy, const int *incy);
63 BLAS_extern double /* DDOT - inner product of x and y */
64 F77_NAME(ddot)(const int *n, const double *dx, const int *incx,
65  const double *dy, const int *incy);
66 BLAS_extern double /* DNRM2 - 2-norm of a vector */
67 F77_NAME(dnrm2)(const int *n, const double *dx, const int *incx);
68 BLAS_extern void /* DROT - apply a Given's rotation */
69 F77_NAME(drot)(const int *n, double *dx, const int *incx,
70  double *dy, const int *incy, const double *c, const double *s);
71 BLAS_extern void /* DROTG - generate a Given's rotation */
72 F77_NAME(drotg)(const double *a, const double *b, double *c, double *s);
73 BLAS_extern void /* DROTM - apply a modified Given's rotation */
74 F77_NAME(drotm)(const int *n, double *dx, const int *incx,
75  double *dy, const int *incy, const double *dparam);
76 BLAS_extern void /* DROTMG - generate a modified Given's rotation */
77 F77_NAME(drotmg)(const double *dd1, const double *dd2, const double *dx1,
78  const double *dy1, double *param);
79 BLAS_extern void /* DSCAL - scale a one-dimensional array */
80 F77_NAME(dscal)(const int *n, const double *alpha, double *dx, const int *incx);
81 BLAS_extern void /* DSWAP - interchange one-dimensional arrays */
82 F77_NAME(dswap)(const int *n, double *dx, const int *incx,
83  double *dy, const int *incy);
84 BLAS_extern int /* IDAMAX - return the index of the element with max abs value */
85 F77_NAME(idamax)(const int *n, const double *dx, const int *incx);
86 
87 /* Double Precision Level 2 BLAS */
88 
89 /* DGBMV - perform one of the matrix-vector operations */
90 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */
91 BLAS_extern void
92 F77_NAME(dgbmv)(const char *trans, const int *m, const int *n,
93  const int *kl,const int *ku,
94  const double *alpha, const double *a, const int *lda,
95  const double *x, const int *incx,
96  const double *beta, double *y, const int *incy);
97 /* DGEMV - perform one of the matrix-vector operations */
98 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */
99 BLAS_extern void
100 F77_NAME(dgemv)(const char *trans, const int *m, const int *n,
101  const double *alpha, const double *a, const int *lda,
102  const double *x, const int *incx, const double *beta,
103  double *y, const int *incy);
104 /* DSBMV - perform the matrix-vector operation */
105 /* y := alpha*A*x + beta*y, */
106 BLAS_extern void
107 F77_NAME(dsbmv)(const char *uplo, const int *n, const int *k,
108  const double *alpha, const double *a, const int *lda,
109  const double *x, const int *incx,
110  const double *beta, double *y, const int *incy);
111 /* DSPMV - perform the matrix-vector operation */
112 /* y := alpha*A*x + beta*y, */
113 BLAS_extern void
114 F77_NAME(dspmv)(const char *uplo, const int *n,
115  const double *alpha, const double *ap,
116  const double *x, const int *incx,
117  const double *beta, double *y, const int *incy);
118 
119 /* DSYMV - perform the matrix-vector operation */
120 /* y := alpha*A*x + beta*y, */
121 BLAS_extern void
122 F77_NAME(dsymv)(const char *uplo, const int *n, const double *alpha,
123  const double *a, const int *lda,
124  const double *x, const int *incx,
125  const double *beta, double *y, const int *incy);
126 /* DTBMV - perform one of the matrix-vector operations */
127 /* x := A*x, or x := A'*x, */
128 BLAS_extern void
129 F77_NAME(dtbmv)(const char *uplo, const char *trans,
130  const char *diag, const int *n, const int *k,
131  const double *a, const int *lda,
132  double *x, const int *incx);
133 /* DTPMV - perform one of the matrix-vector operations */
134 /* x := A*x, or x := A'*x, */
135 BLAS_extern void
136 F77_NAME(dtpmv)(const char *uplo, const char *trans, const char *diag,
137  const int *n, const double *ap,
138  double *x, const int *incx);
139 /* DTRMV - perform one of the matrix-vector operations */
140 /* x := A*x, or x := A'*x, */
141 BLAS_extern void
142 F77_NAME(dtrmv)(const char *uplo, const char *trans, const char *diag,
143  const int *n, const double *a, const int *lda,
144  double *x, const int *incx);
145 /* DTBSV - solve one of the systems of equations */
146 /* A*x = b, or A'*x = b, */
147 BLAS_extern void
148 F77_NAME(dtbsv)(const char *uplo, const char *trans,
149  const char *diag, const int *n, const int *k,
150  const double *a, const int *lda,
151  double *x, const int *incx);
152 /* DTPSV - solve one of the systems of equations */
153 /* A*x = b, or A'*x = b, */
154 BLAS_extern void
155 F77_NAME(dtpsv)(const char *uplo, const char *trans,
156  const char *diag, const int *n,
157  const double *ap, double *x, const int *incx);
158 /* DTRSV - solve one of the systems of equations */
159 /* A*x = b, or A'*x = b, */
160 BLAS_extern void
161 F77_NAME(dtrsv)(const char *uplo, const char *trans,
162  const char *diag, const int *n,
163  const double *a, const int *lda,
164  double *x, const int *incx);
165 /* DGER - perform the rank 1 operation A := alpha*x*y' + A */
166 BLAS_extern void
167 F77_NAME(dger)(const int *m, const int *n, const double *alpha,
168  const double *x, const int *incx,
169  const double *y, const int *incy,
170  double *a, const int *lda);
171 /* DSYR - perform the symmetric rank 1 operation A := alpha*x*x' + A */
172 BLAS_extern void
173 F77_NAME(dsyr)(const char *uplo, const int *n, const double *alpha,
174  const double *x, const int *incx,
175  double *a, const int *lda);
176 /* DSPR - perform the symmetric rank 1 operation A := alpha*x*x' + A */
177 BLAS_extern void
178 F77_NAME(dspr)(const char *uplo, const int *n, const double *alpha,
179  const double *x, const int *incx, double *ap);
180 /* DSYR2 - perform the symmetric rank 2 operation */
181 /* A := alpha*x*y' + alpha*y*x' + A, */
182 BLAS_extern void
183 F77_NAME(dsyr2)(const char *uplo, const int *n, const double *alpha,
184  const double *x, const int *incx,
185  const double *y, const int *incy,
186  double *a, const int *lda);
187 /* DSPR2 - perform the symmetric rank 2 operation */
188 /* A := alpha*x*y' + alpha*y*x' + A, */
189 BLAS_extern void
190 F77_NAME(dspr2)(const char *uplo, const int *n, const double *alpha,
191  const double *x, const int *incx,
192  const double *y, const int *incy, double *ap);
193 
194 /* Double Precision Level 3 BLAS */
195 
196 /* DGEMM - perform one of the matrix-matrix operations */
197 /* C := alpha*op( A )*op( B ) + beta*C */
198 BLAS_extern void
199 F77_NAME(dgemm)(const char *transa, const char *transb, const int *m,
200  const int *n, const int *k, const double *alpha,
201  const double *a, const int *lda,
202  const double *b, const int *ldb,
203  const double *beta, double *c, const int *ldc);
204 /* DTRSM - solve one of the matrix equations */
205 /* op(A)*X = alpha*B, or X*op(A) = alpha*B */
206 BLAS_extern void
207 F77_NAME(dtrsm)(const char *side, const char *uplo,
208  const char *transa, const char *diag,
209  const int *m, const int *n, const double *alpha,
210  const double *a, const int *lda,
211  double *b, const int *ldb);
212 /* DTRMM - perform one of the matrix-matrix operations */
213 /* B := alpha*op( A )*B, or B := alpha*B*op( A ) */
214 BLAS_extern void
215 F77_NAME(dtrmm)(const char *side, const char *uplo, const char *transa,
216  const char *diag, const int *m, const int *n,
217  const double *alpha, const double *a, const int *lda,
218  double *b, const int *ldb);
219 /* DSYMM - perform one of the matrix-matrix operations */
220 /* C := alpha*A*B + beta*C, */
221 BLAS_extern void
222 F77_NAME(dsymm)(const char *side, const char *uplo, const int *m,
223  const int *n, const double *alpha,
224  const double *a, const int *lda,
225  const double *b, const int *ldb,
226  const double *beta, double *c, const int *ldc);
227 /* DSYRK - perform one of the symmetric rank k operations */
228 /* C := alpha*A*A' + beta*C or C := alpha*A'*A + beta*C */
229 BLAS_extern void
230 F77_NAME(dsyrk)(const char *uplo, const char *trans,
231  const int *n, const int *k,
232  const double *alpha, const double *a, const int *lda,
233  const double *beta, double *c, const int *ldc);
234 /* DSYR2K - perform one of the symmetric rank 2k operations */
235 /* C := alpha*A*B' + alpha*B*A' + beta*C or */
236 /* C := alpha*A'*B + alpha*B'*A + beta*C */
237 BLAS_extern void
238 F77_NAME(dsyr2k)(const char *uplo, const char *trans,
239  const int *n, const int *k,
240  const double *alpha, const double *a, const int *lda,
241  const double *b, const int *ldb,
242  const double *beta, double *c, const int *ldc);
243 /*
244  LSAME is a LAPACK support routine, not part of BLAS
245 */
246 
247 /* Double complex BLAS routines added for 2.3.0 */
248 /* #ifdef HAVE_FORTRAN_DOUBLE_COMPLEX */
249  BLAS_extern double
250  F77_NAME(dcabs1)(double *z);
251  BLAS_extern double
252  F77_NAME(dzasum)(int *n, Rcomplex *zx, int *incx);
253  BLAS_extern double
254  F77_NAME(dznrm2)(int *n, Rcomplex *x, int *incx);
255  BLAS_extern int
256  F77_NAME(izamax)(int *n, Rcomplex *zx, int *incx);
257  BLAS_extern void
258  F77_NAME(zaxpy)(int *n, Rcomplex *za, Rcomplex *zx,
259  int *incx, Rcomplex *zy, int *incy);
260  BLAS_extern void
261  F77_NAME(zcopy)(int *n, Rcomplex *zx, int *incx,
262  Rcomplex *zy, int *incy);
263 
264  /* WARNING! The next two return a value that may not be
265  compatible between C and Fortran, and even if it is, this might
266  not be the right translation to C. Only use after
267  configure-testing with your compilers.
268  */
269  BLAS_extern Rcomplex
270  F77_NAME(zdotc)(int *n,
271  Rcomplex *zx, int *incx, Rcomplex *zy, int *incy);
272  BLAS_extern Rcomplex
273  F77_NAME(zdotu)(int *n,
274  Rcomplex *zx, int *incx, Rcomplex *zy, int *incy);
275 
276  BLAS_extern void
277  F77_NAME(zdrot)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy,
278  int *incy, double *c, double *s);
279  BLAS_extern void
280  F77_NAME(zdscal)(int *n, double *da, Rcomplex *zx, int *incx);
281  BLAS_extern void
282  F77_NAME(zgbmv)(char *trans, int *m, int *n, int *kl,
283  int *ku, Rcomplex *alpha, Rcomplex *a, int *lda,
284  Rcomplex *x, int *incx, Rcomplex *beta, Rcomplex *y,
285  int *incy);
286  BLAS_extern void
287  F77_NAME(zgemm)(const char *transa, const char *transb, const int *m,
288  const int *n, const int *k, const Rcomplex *alpha,
289  const Rcomplex *a, const int *lda,
290  const Rcomplex *b, const int *ldb,
291  const Rcomplex *beta, Rcomplex *c, const int *ldc);
292  BLAS_extern void
293  F77_NAME(zgemv)(char *trans, int *m, int *n, Rcomplex *alpha,
294  Rcomplex *a, int *lda, Rcomplex *x, int *incx,
295  Rcomplex *beta, Rcomplex *y, int * incy);
296  BLAS_extern void
297  F77_NAME(zgerc)(int *m, int *n, Rcomplex *alpha, Rcomplex *x,
298  int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda);
299  BLAS_extern void
300  F77_NAME(zgeru)(int *m, int *n, Rcomplex *alpha, Rcomplex *x,
301  int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda);
302  BLAS_extern void
303  F77_NAME(zhbmv)(char *uplo, int *n, int *k, Rcomplex *alpha,
304  Rcomplex *a, int *lda, Rcomplex *x, int *incx,
305  Rcomplex *beta, Rcomplex *y, int *incy);
306  BLAS_extern void
307  F77_NAME(zhemm)(char *side, char *uplo, int *m, int *n,
308  Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b,
309  int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc);
310  BLAS_extern void
311  F77_NAME(zhemv)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *a,
312  int *lda, Rcomplex *x, int *incx, Rcomplex *beta,
313  Rcomplex *y, int *incy);
314  BLAS_extern void
315  F77_NAME(zher)(char *uplo, int *n, double *alpha, Rcomplex *x,
316  int *incx, Rcomplex *a, int *lda);
317  BLAS_extern void
318  F77_NAME(zher2)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *x,
319  int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda);
320  BLAS_extern void
321  F77_NAME(zher2k)(char *uplo, char *trans, int *n, int *k,
322  Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b,
323  int *ldb, double *beta, Rcomplex *c, int *ldc);
324  BLAS_extern void
325  F77_NAME(zherk)(char *uplo, char *trans, int *n, int *k,
326  double *alpha, Rcomplex *a, int *lda, double *beta,
327  Rcomplex *c, int *ldc);
328  BLAS_extern void
329  F77_NAME(zhpmv)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *ap,
330  Rcomplex *x, int *incx, Rcomplex * beta, Rcomplex *y,
331  int *incy);
332  BLAS_extern void
333  F77_NAME(zhpr)(char *uplo, int *n, double *alpha,
334  Rcomplex *x, int *incx, Rcomplex *ap);
335  BLAS_extern void
336  F77_NAME(zhpr2)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *x,
337  int *incx, Rcomplex *y, int *incy, Rcomplex *ap);
338  BLAS_extern void
339  F77_NAME(zrotg)(Rcomplex *ca, Rcomplex *cb, double *c, Rcomplex *s);
340  BLAS_extern void
341  F77_NAME(zscal)(int *n, Rcomplex *za, Rcomplex *zx, int *incx);
342  BLAS_extern void
343  F77_NAME(zswap)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, int *incy);
344  BLAS_extern void
345  F77_NAME(zsymm)(char *side, char *uplo, int *m, int *n,
346  Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b,
347  int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc);
348  BLAS_extern void
349  F77_NAME(zsyr2k)(char *uplo, char *trans, int *n, int *k,
350  Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b,
351  int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc);
352  BLAS_extern void
353  F77_NAME(zsyrk)(char *uplo, char *trans, int *n, int *k,
354  Rcomplex *alpha, Rcomplex *a, int *lda,
355  Rcomplex *beta, Rcomplex *c, int *ldc);
356  BLAS_extern void
357  F77_NAME(ztbmv)(char *uplo, char *trans, char *diag, int *n, int *k,
358  Rcomplex *a, int *lda, Rcomplex *x, int *incx);
359  BLAS_extern void
360  F77_NAME(ztbsv)(char *uplo, char *trans, char *diag, int *n, int *k,
361  Rcomplex *a, int *lda, Rcomplex *x, int *incx);
362  BLAS_extern void
363  F77_NAME(ztpmv)(char *uplo, char *trans, char *diag, int *n,
364  Rcomplex *ap, Rcomplex *x, int *incx);
365  BLAS_extern void
366  F77_NAME(ztpsv)(char *uplo, char *trans, char *diag, int *n,
367  Rcomplex *ap, Rcomplex *x, int *incx);
368  BLAS_extern void
369  F77_NAME(ztrmm)(char *side, char *uplo, char *transa, char *diag,
370  int *m, int *n, Rcomplex *alpha, Rcomplex *a,
371  int *lda, Rcomplex *b, int *ldb);
372  BLAS_extern void
373  F77_NAME(ztrmv)(char *uplo, char *trans, char *diag, int *n,
374  Rcomplex *a, int *lda, Rcomplex *x, int *incx);
375  BLAS_extern void
376  F77_NAME(ztrsm)(char *side, char *uplo, char *transa, char *diag,
377  int *m, int *n, Rcomplex *alpha, Rcomplex *a,
378  int *lda, Rcomplex *b, int *ldb);
379  BLAS_extern void
380  F77_NAME(ztrsv)(char *uplo, char *trans, char *diag, int *n,
381  Rcomplex *a, int *lda, Rcomplex *x, int *incx);
382 /* #endif */
383 
384 #ifdef __cplusplus
385 }
386 #endif
387 
388 #endif /* R_BLAS_H */