The R Project SVN R

Rev

Rev 60253 | Rev 71463 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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