1 /* 2 * Defines the prototypes for BLAS Fortran functions. 3 * 4 * Also defines a typedef blas_int to be used for all integers passed to BLAS 5 * functions. 6 * 7 * When used in the context of a MATLAB MEX file, you must define MATLAB_MEX_FILE 8 * and MATLAB_VERSION (for version 7.4, define it to 0x0704). 9 * 10 * 11 * Copyright © 2009-2013 Dynare Team 12 * 13 * This file is part of Dynare. 14 * 15 * Dynare is free software: you can redistribute it and/or modify 16 * it under the terms of the GNU General Public License as published by 17 * the Free Software Foundation, either version 3 of the License, or 18 * (at your option) any later version. 19 * 20 * Dynare is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * You should have received a copy of the GNU General Public License 26 * along with Dynare. If not, see <http://www.gnu.org/licenses/>. 27 */ 28 29 #ifndef _DYNBLAS_H 30 #define _DYNBLAS_H 31 32 /* Starting from version 7.8, MATLAB BLAS expects ptrdiff_t arguments for integers */ 33 #if defined(MATLAB_MEX_FILE) && MATLAB_VERSION >= 0x0708 34 # ifdef __cplusplus 35 # include <cstddef> 36 # else 37 # include <stddef.h> 38 # endif 39 typedef ptrdiff_t blas_int; 40 #else 41 typedef int blas_int; 42 #endif 43 44 #if defined(MATLAB_MEX_FILE) && defined(_WIN32) && !defined(_MSC_VER) 45 # define FORTRAN_WRAPPER(x) x 46 #else 47 # define FORTRAN_WRAPPER(x) x ## _ 48 #endif 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 typedef const char *BLCHAR; 55 typedef const blas_int *CONST_BLINT; 56 typedef const double *CONST_BLDOU; 57 typedef const float *CONST_BLFLT; 58 typedef double *BLDOU; 59 typedef float *BLFLT; 60 61 #define dgemm FORTRAN_WRAPPER(dgemm) 62 void dgemm(BLCHAR transa, BLCHAR transb, CONST_BLINT m, CONST_BLINT n, 63 CONST_BLINT k, CONST_BLDOU alpha, CONST_BLDOU a, CONST_BLINT lda, 64 CONST_BLDOU b, CONST_BLINT ldb, CONST_BLDOU beta, 65 BLDOU c, CONST_BLINT ldc); 66 67 #define sgemm FORTRAN_WRAPPER(sgemm) 68 void sgemm(BLCHAR transa, BLCHAR transb, CONST_BLINT m, CONST_BLINT n, 69 CONST_BLINT k, CONST_BLFLT alpha, CONST_BLFLT a, CONST_BLINT lda, 70 CONST_BLFLT b, CONST_BLINT ldb, CONST_BLFLT beta, 71 BLFLT c, CONST_BLINT ldc); 72 73 #define dsymm FORTRAN_WRAPPER(dsymm) 74 void dsymm(BLCHAR side, BLCHAR uplo, CONST_BLINT m, CONST_BLINT n, 75 CONST_BLDOU alpha, CONST_BLDOU a, CONST_BLINT lda, 76 CONST_BLDOU b, CONST_BLINT ldb, CONST_BLDOU beta, 77 BLDOU c, CONST_BLINT ldc); 78 79 #define dgemv FORTRAN_WRAPPER(dgemv) 80 void dgemv(BLCHAR trans, CONST_BLINT m, CONST_BLINT n, CONST_BLDOU alpha, 81 CONST_BLDOU a, CONST_BLINT lda, CONST_BLDOU x, CONST_BLINT incx, 82 CONST_BLDOU beta, BLDOU y, CONST_BLINT incy); 83 84 #define dsymv FORTRAN_WRAPPER(dsymv) 85 void dsymv(BLCHAR uplo, CONST_BLINT m, CONST_BLDOU alpha, CONST_BLDOU a, 86 CONST_BLINT lda, CONST_BLDOU b, CONST_BLINT ldb, CONST_BLDOU beta, 87 BLDOU c, CONST_BLINT ldc); 88 89 #define dtrsv FORTRAN_WRAPPER(dtrsv) 90 void dtrsv(BLCHAR uplo, BLCHAR trans, BLCHAR diag, CONST_BLINT n, 91 CONST_BLDOU a, CONST_BLINT lda, BLDOU x, CONST_BLINT incx); 92 93 #define dtrmv FORTRAN_WRAPPER(dtrmv) 94 void dtrmv(BLCHAR uplo, BLCHAR trans, BLCHAR diag, CONST_BLINT n, 95 CONST_BLDOU a, CONST_BLINT lda, BLDOU x, CONST_BLINT incx); 96 97 #define daxpy FORTRAN_WRAPPER(daxpy) 98 void daxpy(CONST_BLINT n, CONST_BLDOU a, CONST_BLDOU x, CONST_BLINT incx, 99 BLDOU y, CONST_BLINT incy); 100 101 #define saxpy FORTRAN_WRAPPER(saxpy) 102 void saxpy(CONST_BLINT n, CONST_BLFLT a, CONST_BLFLT x, CONST_BLINT incx, 103 BLFLT y, CONST_BLINT incy); 104 105 #define dcopy FORTRAN_WRAPPER(dcopy) 106 void dcopy(CONST_BLINT n, CONST_BLDOU x, CONST_BLINT incx, 107 BLDOU y, CONST_BLINT incy); 108 109 #define zaxpy FORTRAN_WRAPPER(zaxpy) 110 void zaxpy(CONST_BLINT n, CONST_BLDOU a, CONST_BLDOU x, CONST_BLINT incx, 111 BLDOU y, CONST_BLINT incy); 112 113 #define dscal FORTRAN_WRAPPER(dscal) 114 void dscal(CONST_BLINT n, CONST_BLDOU a, BLDOU x, CONST_BLINT incx); 115 116 #define sscal FORTRAN_WRAPPER(sscal) 117 void sscal(CONST_BLINT n, CONST_BLDOU a, BLFLT x, CONST_BLINT incx); 118 119 #define dtrsm FORTRAN_WRAPPER(dtrsm) 120 void dtrsm(BLCHAR side, BLCHAR uplo, BLCHAR transa, BLCHAR diag, CONST_BLINT m, 121 CONST_BLINT n, CONST_BLDOU alpha, CONST_BLDOU a, CONST_BLINT lda, 122 BLDOU b, CONST_BLINT ldb); 123 124 #define ddot FORTRAN_WRAPPER(ddot) 125 double ddot(CONST_BLINT n, CONST_BLDOU x, CONST_BLINT incx, CONST_BLDOU y, 126 CONST_BLINT incy); 127 128 #define dsyr FORTRAN_WRAPPER(dsyr) 129 void dsyr(BLCHAR uplo, CONST_BLINT n, CONST_BLDOU alpha, CONST_BLDOU x, 130 CONST_BLINT incx, BLDOU a, CONST_BLINT lda); 131 132 #define dtrmm FORTRAN_WRAPPER(dtrmm) 133 void dtrmm(BLCHAR side, BLCHAR uplo, BLCHAR transa, BLCHAR diag, CONST_BLINT m, 134 CONST_BLINT n, CONST_BLDOU alpha, CONST_BLDOU a, CONST_BLINT lda, 135 BLDOU b, CONST_BLINT ldb); 136 137 #define strmm FORTRAN_WRAPPER(strmm) 138 void strmm(BLCHAR side, BLCHAR uplo, BLCHAR transa, BLCHAR diag, CONST_BLINT m, 139 CONST_BLINT n, CONST_BLFLT alpha, CONST_BLFLT a, CONST_BLINT lda, 140 BLFLT b, CONST_BLINT ldb); 141 142 #ifdef __cplusplus 143 } /* extern "C" */ 144 #endif 145 146 #endif /* _DYNBLAS_H */ 147