RAPI
|
00001 /* 00002 * R : A Computer Language for Statistical Data Analysis 00003 * Copyright (C) 2003-12 The R Core Team. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as published by 00007 * the Free Software Foundation; either version 2.1 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program; if not, a copy is available at 00017 * https://www.R-project.org/Licenses/ 00018 */ 00019 00020 /* 00021 C declarations of BLAS Fortran subroutines always available in R. 00022 00023 Part of the API. 00024 00025 R packages that use these should have PKG_LIBS in src/Makevars include 00026 $(BLAS_LIBS) $(FLIBS) 00027 */ 00028 00029 /* Part of the API */ 00030 00031 #ifndef R_BLAS_H 00032 #define R_BLAS_H 00033 00034 #include <R_ext/RS.h> /* for F77_... */ 00035 #include <R_ext/Complex.h> /* for Rcomplex */ 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 // never defined in R itself. 00042 #ifndef BLAS_extern 00043 #define BLAS_extern extern 00044 #endif 00045 00046 /* Double Precision Level 1 BLAS */ 00047 00048 BLAS_extern double /* DASUM - sum of absolute values of a one-dimensional array */ 00049 F77_NAME(dasum)(const int *n, const double *dx, const int *incx); 00050 BLAS_extern void /* DAXPY - replace y by alpha*x + y */ 00051 F77_NAME(daxpy)(const int *n, const double *alpha, 00052 const double *dx, const int *incx, 00053 double *dy, const int *incy); 00054 BLAS_extern void /* DCOPY - copy x to y */ 00055 F77_NAME(dcopy)(const int *n, const double *dx, const int *incx, 00056 double *dy, const int *incy); 00057 BLAS_extern double /* DDOT - inner product of x and y */ 00058 F77_NAME(ddot)(const int *n, const double *dx, const int *incx, 00059 const double *dy, const int *incy); 00060 BLAS_extern double /* DNRM2 - 2-norm of a vector */ 00061 F77_NAME(dnrm2)(const int *n, const double *dx, const int *incx); 00062 BLAS_extern void /* DROT - apply a Given's rotation */ 00063 F77_NAME(drot)(const int *n, double *dx, const int *incx, 00064 double *dy, const int *incy, const double *c, const double *s); 00065 BLAS_extern void /* DROTG - generate a Given's rotation */ 00066 F77_NAME(drotg)(const double *a, const double *b, double *c, double *s); 00067 BLAS_extern void /* DROTM - apply a modified Given's rotation */ 00068 F77_NAME(drotm)(const int *n, double *dx, const int *incx, 00069 double *dy, const int *incy, const double *dparam); 00070 BLAS_extern void /* DROTMG - generate a modified Given's rotation */ 00071 F77_NAME(drotmg)(const double *dd1, const double *dd2, const double *dx1, 00072 const double *dy1, double *param); 00073 BLAS_extern void /* DSCAL - scale a one-dimensional array */ 00074 F77_NAME(dscal)(const int *n, const double *alpha, double *dx, const int *incx); 00075 BLAS_extern void /* DSWAP - interchange one-dimensional arrays */ 00076 F77_NAME(dswap)(const int *n, double *dx, const int *incx, 00077 double *dy, const int *incy); 00078 BLAS_extern int /* IDAMAX - return the index of the element with max abs value */ 00079 F77_NAME(idamax)(const int *n, const double *dx, const int *incx); 00080 00081 /* Double Precision Level 2 BLAS */ 00082 00083 /* DGBMV - perform one of the matrix-vector operations */ 00084 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */ 00085 BLAS_extern void 00086 F77_NAME(dgbmv)(const char *trans, const int *m, const int *n, 00087 const int *kl,const int *ku, 00088 const double *alpha, const double *a, const int *lda, 00089 const double *x, const int *incx, 00090 const double *beta, double *y, const int *incy); 00091 /* DGEMV - perform one of the matrix-vector operations */ 00092 /* y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y, */ 00093 BLAS_extern void 00094 F77_NAME(dgemv)(const char *trans, const int *m, const int *n, 00095 const double *alpha, const double *a, const int *lda, 00096 const double *x, const int *incx, const double *beta, 00097 double *y, const int *incy); 00098 /* DSBMV - perform the matrix-vector operation */ 00099 /* y := alpha*A*x + beta*y, */ 00100 BLAS_extern void 00101 F77_NAME(dsbmv)(const char *uplo, const int *n, const int *k, 00102 const double *alpha, const double *a, const int *lda, 00103 const double *x, const int *incx, 00104 const double *beta, double *y, const int *incy); 00105 /* DSPMV - perform the matrix-vector operation */ 00106 /* y := alpha*A*x + beta*y, */ 00107 BLAS_extern void 00108 F77_NAME(dspmv)(const char *uplo, const int *n, 00109 const double *alpha, const double *ap, 00110 const double *x, const int *incx, 00111 const double *beta, double *y, const int *incy); 00112 00113 /* DSYMV - perform the matrix-vector operation */ 00114 /* y := alpha*A*x + beta*y, */ 00115 BLAS_extern void 00116 F77_NAME(dsymv)(const char *uplo, const int *n, const double *alpha, 00117 const double *a, const int *lda, 00118 const double *x, const int *incx, 00119 const double *beta, double *y, const int *incy); 00120 /* DTBMV - perform one of the matrix-vector operations */ 00121 /* x := A*x, or x := A'*x, */ 00122 BLAS_extern void 00123 F77_NAME(dtbmv)(const char *uplo, const char *trans, 00124 const char *diag, const int *n, const int *k, 00125 const double *a, const int *lda, 00126 double *x, const int *incx); 00127 /* DTPMV - perform one of the matrix-vector operations */ 00128 /* x := A*x, or x := A'*x, */ 00129 BLAS_extern void 00130 F77_NAME(dtpmv)(const char *uplo, const char *trans, const char *diag, 00131 const int *n, const double *ap, 00132 double *x, const int *incx); 00133 /* DTRMV - perform one of the matrix-vector operations */ 00134 /* x := A*x, or x := A'*x, */ 00135 BLAS_extern void 00136 F77_NAME(dtrmv)(const char *uplo, const char *trans, const char *diag, 00137 const int *n, const double *a, const int *lda, 00138 double *x, const int *incx); 00139 /* DTBSV - solve one of the systems of equations */ 00140 /* A*x = b, or A'*x = b, */ 00141 BLAS_extern void 00142 F77_NAME(dtbsv)(const char *uplo, const char *trans, 00143 const char *diag, const int *n, const int *k, 00144 const double *a, const int *lda, 00145 double *x, const int *incx); 00146 /* DTPSV - solve one of the systems of equations */ 00147 /* A*x = b, or A'*x = b, */ 00148 BLAS_extern void 00149 F77_NAME(dtpsv)(const char *uplo, const char *trans, 00150 const char *diag, const int *n, 00151 const double *ap, double *x, const int *incx); 00152 /* DTRSV - solve one of the systems of equations */ 00153 /* A*x = b, or A'*x = b, */ 00154 BLAS_extern void 00155 F77_NAME(dtrsv)(const char *uplo, const char *trans, 00156 const char *diag, const int *n, 00157 const double *a, const int *lda, 00158 double *x, const int *incx); 00159 /* DGER - perform the rank 1 operation A := alpha*x*y' + A */ 00160 BLAS_extern void 00161 F77_NAME(dger)(const int *m, const int *n, const double *alpha, 00162 const double *x, const int *incx, 00163 const double *y, const int *incy, 00164 double *a, const int *lda); 00165 /* DSYR - perform the symmetric rank 1 operation A := alpha*x*x' + A */ 00166 BLAS_extern void 00167 F77_NAME(dsyr)(const char *uplo, const int *n, const double *alpha, 00168 const double *x, const int *incx, 00169 double *a, const int *lda); 00170 /* DSPR - perform the symmetric rank 1 operation A := alpha*x*x' + A */ 00171 BLAS_extern void 00172 F77_NAME(dspr)(const char *uplo, const int *n, const double *alpha, 00173 const double *x, const int *incx, double *ap); 00174 /* DSYR2 - perform the symmetric rank 2 operation */ 00175 /* A := alpha*x*y' + alpha*y*x' + A, */ 00176 BLAS_extern void 00177 F77_NAME(dsyr2)(const char *uplo, const int *n, const double *alpha, 00178 const double *x, const int *incx, 00179 const double *y, const int *incy, 00180 double *a, const int *lda); 00181 /* DSPR2 - perform the symmetric rank 2 operation */ 00182 /* A := alpha*x*y' + alpha*y*x' + A, */ 00183 BLAS_extern void 00184 F77_NAME(dspr2)(const char *uplo, const int *n, const double *alpha, 00185 const double *x, const int *incx, 00186 const double *y, const int *incy, double *ap); 00187 00188 /* Double Precision Level 3 BLAS */ 00189 00190 /* DGEMM - perform one of the matrix-matrix operations */ 00191 /* C := alpha*op( A )*op( B ) + beta*C */ 00192 BLAS_extern void 00193 F77_NAME(dgemm)(const char *transa, const char *transb, const int *m, 00194 const int *n, const int *k, const double *alpha, 00195 const double *a, const int *lda, 00196 const double *b, const int *ldb, 00197 const double *beta, double *c, const int *ldc); 00198 /* DTRSM - solve one of the matrix equations */ 00199 /* op(A)*X = alpha*B, or X*op(A) = alpha*B */ 00200 BLAS_extern void 00201 F77_NAME(dtrsm)(const char *side, const char *uplo, 00202 const char *transa, const char *diag, 00203 const int *m, const int *n, const double *alpha, 00204 const double *a, const int *lda, 00205 double *b, const int *ldb); 00206 /* DTRMM - perform one of the matrix-matrix operations */ 00207 /* B := alpha*op( A )*B, or B := alpha*B*op( A ) */ 00208 BLAS_extern void 00209 F77_NAME(dtrmm)(const char *side, const char *uplo, const char *transa, 00210 const char *diag, const int *m, const int *n, 00211 const double *alpha, const double *a, const int *lda, 00212 double *b, const int *ldb); 00213 /* DSYMM - perform one of the matrix-matrix operations */ 00214 /* C := alpha*A*B + beta*C, */ 00215 BLAS_extern void 00216 F77_NAME(dsymm)(const char *side, const char *uplo, const int *m, 00217 const int *n, const double *alpha, 00218 const double *a, const int *lda, 00219 const double *b, const int *ldb, 00220 const double *beta, double *c, const int *ldc); 00221 /* DSYRK - perform one of the symmetric rank k operations */ 00222 /* C := alpha*A*A' + beta*C or C := alpha*A'*A + beta*C */ 00223 BLAS_extern void 00224 F77_NAME(dsyrk)(const char *uplo, const char *trans, 00225 const int *n, const int *k, 00226 const double *alpha, const double *a, const int *lda, 00227 const double *beta, double *c, const int *ldc); 00228 /* DSYR2K - perform one of the symmetric rank 2k operations */ 00229 /* C := alpha*A*B' + alpha*B*A' + beta*C or */ 00230 /* C := alpha*A'*B + alpha*B'*A + beta*C */ 00231 BLAS_extern void 00232 F77_NAME(dsyr2k)(const char *uplo, const char *trans, 00233 const int *n, const int *k, 00234 const double *alpha, const double *a, const int *lda, 00235 const double *b, const int *ldb, 00236 const double *beta, double *c, const int *ldc); 00237 /* 00238 LSAME is a LAPACK support routine, not part of BLAS 00239 */ 00240 00241 /* Double complex BLAS routines added for 2.3.0 */ 00242 /* #ifdef HAVE_FORTRAN_DOUBLE_COMPLEX */ 00243 BLAS_extern double 00244 F77_NAME(dcabs1)(double *z); 00245 BLAS_extern double 00246 F77_NAME(dzasum)(int *n, Rcomplex *zx, int *incx); 00247 BLAS_extern double 00248 F77_NAME(dznrm2)(int *n, Rcomplex *x, int *incx); 00249 BLAS_extern int 00250 F77_NAME(izamax)(int *n, Rcomplex *zx, int *incx); 00251 BLAS_extern void 00252 F77_NAME(zaxpy)(int *n, Rcomplex *za, Rcomplex *zx, 00253 int *incx, Rcomplex *zy, int *incy); 00254 BLAS_extern void 00255 F77_NAME(zcopy)(int *n, Rcomplex *zx, int *incx, 00256 Rcomplex *zy, int *incy); 00257 00258 /* WARNING! The next two return a value that may not be 00259 compatible between C and Fortran, and even if it is, this might 00260 not be the right translation to C. Only use after 00261 configure-testing with your compilers. 00262 */ 00263 BLAS_extern Rcomplex 00264 F77_NAME(zdotc)(int *n, 00265 Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); 00266 BLAS_extern Rcomplex 00267 F77_NAME(zdotu)(int *n, 00268 Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); 00269 00270 BLAS_extern void 00271 F77_NAME(zdrot)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, 00272 int *incy, double *c, double *s); 00273 BLAS_extern void 00274 F77_NAME(zdscal)(int *n, double *da, Rcomplex *zx, int *incx); 00275 BLAS_extern void 00276 F77_NAME(zgbmv)(char *trans, int *m, int *n, int *kl, 00277 int *ku, Rcomplex *alpha, Rcomplex *a, int *lda, 00278 Rcomplex *x, int *incx, Rcomplex *beta, Rcomplex *y, 00279 int *incy); 00280 BLAS_extern void 00281 F77_NAME(zgemm)(const char *transa, const char *transb, const int *m, 00282 const int *n, const int *k, const Rcomplex *alpha, 00283 const Rcomplex *a, const int *lda, 00284 const Rcomplex *b, const int *ldb, 00285 const Rcomplex *beta, Rcomplex *c, const int *ldc); 00286 BLAS_extern void 00287 F77_NAME(zgemv)(char *trans, int *m, int *n, Rcomplex *alpha, 00288 Rcomplex *a, int *lda, Rcomplex *x, int *incx, 00289 Rcomplex *beta, Rcomplex *y, int * incy); 00290 BLAS_extern void 00291 F77_NAME(zgerc)(int *m, int *n, Rcomplex *alpha, Rcomplex *x, 00292 int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda); 00293 BLAS_extern void 00294 F77_NAME(zgeru)(int *m, int *n, Rcomplex *alpha, Rcomplex *x, 00295 int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda); 00296 BLAS_extern void 00297 F77_NAME(zhbmv)(char *uplo, int *n, int *k, Rcomplex *alpha, 00298 Rcomplex *a, int *lda, Rcomplex *x, int *incx, 00299 Rcomplex *beta, Rcomplex *y, int *incy); 00300 BLAS_extern void 00301 F77_NAME(zhemm)(char *side, char *uplo, int *m, int *n, 00302 Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b, 00303 int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc); 00304 BLAS_extern void 00305 F77_NAME(zhemv)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *a, 00306 int *lda, Rcomplex *x, int *incx, Rcomplex *beta, 00307 Rcomplex *y, int *incy); 00308 BLAS_extern void 00309 F77_NAME(zher)(char *uplo, int *n, double *alpha, Rcomplex *x, 00310 int *incx, Rcomplex *a, int *lda); 00311 BLAS_extern void 00312 F77_NAME(zher2)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *x, 00313 int *incx, Rcomplex *y, int *incy, Rcomplex *a, int *lda); 00314 BLAS_extern void 00315 F77_NAME(zher2k)(char *uplo, char *trans, int *n, int *k, 00316 Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b, 00317 int *ldb, double *beta, Rcomplex *c, int *ldc); 00318 BLAS_extern void 00319 F77_NAME(zherk)(char *uplo, char *trans, int *n, int *k, 00320 double *alpha, Rcomplex *a, int *lda, double *beta, 00321 Rcomplex *c, int *ldc); 00322 BLAS_extern void 00323 F77_NAME(zhpmv)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *ap, 00324 Rcomplex *x, int *incx, Rcomplex * beta, Rcomplex *y, 00325 int *incy); 00326 BLAS_extern void 00327 F77_NAME(zhpr)(char *uplo, int *n, double *alpha, 00328 Rcomplex *x, int *incx, Rcomplex *ap); 00329 BLAS_extern void 00330 F77_NAME(zhpr2)(char *uplo, int *n, Rcomplex *alpha, Rcomplex *x, 00331 int *incx, Rcomplex *y, int *incy, Rcomplex *ap); 00332 BLAS_extern void 00333 F77_NAME(zrotg)(Rcomplex *ca, Rcomplex *cb, double *c, Rcomplex *s); 00334 BLAS_extern void 00335 F77_NAME(zscal)(int *n, Rcomplex *za, Rcomplex *zx, int *incx); 00336 BLAS_extern void 00337 F77_NAME(zswap)(int *n, Rcomplex *zx, int *incx, Rcomplex *zy, int *incy); 00338 BLAS_extern void 00339 F77_NAME(zsymm)(char *side, char *uplo, int *m, int *n, 00340 Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b, 00341 int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc); 00342 BLAS_extern void 00343 F77_NAME(zsyr2k)(char *uplo, char *trans, int *n, int *k, 00344 Rcomplex *alpha, Rcomplex *a, int *lda, Rcomplex *b, 00345 int *ldb, Rcomplex *beta, Rcomplex *c, int *ldc); 00346 BLAS_extern void 00347 F77_NAME(zsyrk)(char *uplo, char *trans, int *n, int *k, 00348 Rcomplex *alpha, Rcomplex *a, int *lda, 00349 Rcomplex *beta, Rcomplex *c, int *ldc); 00350 BLAS_extern void 00351 F77_NAME(ztbmv)(char *uplo, char *trans, char *diag, int *n, int *k, 00352 Rcomplex *a, int *lda, Rcomplex *x, int *incx); 00353 BLAS_extern void 00354 F77_NAME(ztbsv)(char *uplo, char *trans, char *diag, int *n, int *k, 00355 Rcomplex *a, int *lda, Rcomplex *x, int *incx); 00356 BLAS_extern void 00357 F77_NAME(ztpmv)(char *uplo, char *trans, char *diag, int *n, 00358 Rcomplex *ap, Rcomplex *x, int *incx); 00359 BLAS_extern void 00360 F77_NAME(ztpsv)(char *uplo, char *trans, char *diag, int *n, 00361 Rcomplex *ap, Rcomplex *x, int *incx); 00362 BLAS_extern void 00363 F77_NAME(ztrmm)(char *side, char *uplo, char *transa, char *diag, 00364 int *m, int *n, Rcomplex *alpha, Rcomplex *a, 00365 int *lda, Rcomplex *b, int *ldb); 00366 BLAS_extern void 00367 F77_NAME(ztrmv)(char *uplo, char *trans, char *diag, int *n, 00368 Rcomplex *a, int *lda, Rcomplex *x, int *incx); 00369 BLAS_extern void 00370 F77_NAME(ztrsm)(char *side, char *uplo, char *transa, char *diag, 00371 int *m, int *n, Rcomplex *alpha, Rcomplex *a, 00372 int *lda, Rcomplex *b, int *ldb); 00373 BLAS_extern void 00374 F77_NAME(ztrsv)(char *uplo, char *trans, char *diag, int *n, 00375 Rcomplex *a, int *lda, Rcomplex *x, int *incx); 00376 /* #endif */ 00377 00378 #ifdef __cplusplus 00379 } 00380 #endif 00381 00382 #endif /* R_BLAS_H */