1 #ifndef HEADER_myblas 2 #define HEADER_myblas 3 4 /* ************************************************************************ */ 5 /* BLAS function interface with local and external loadable versions */ 6 /* Author: Kjell Eikland */ 7 /* Version: Initial version spring 2004 */ 8 /* Licence: LGPL */ 9 /* ************************************************************************ */ 10 /* Changes: 19 September 2004 Moved function pointer variable */ 11 /* declarations from myblas.h to myblas.c */ 12 /* to avoid linker problems with the Mac. */ 13 /* 20 April 2005 Modified all double types to REAL to self- */ 14 /* adjust to global settings. Note that BLAS */ 15 /* as of now does not have double double. */ 16 /* 15 December 2005 Added idamin() */ 17 /* ************************************************************************ */ 18 19 #define BLAS_BASE 1 20 #define UseMacroVector 21 #define LoadableBlasLib 22 23 24 /* ************************************************************************ */ 25 /* Include necessary libraries */ 26 /* ************************************************************************ */ 27 #include "commonlib.h" 28 #ifdef LoadableBlasLib 29 #if (defined WIN32) || (defined WIN64) 30 #include <windows.h> 31 #else 32 #include <dlfcn.h> 33 #endif 34 #endif 35 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 42 /* ************************************************************************ */ 43 /* BLAS functions */ 44 /* ************************************************************************ */ 45 46 #ifndef BLAS_CALLMODEL 47 #if (defined WIN32) || (defined WIN64) 48 #define BLAS_CALLMODEL _cdecl 49 #else 50 #define BLAS_CALLMODEL 51 #endif 52 #endif 53 54 typedef void (BLAS_CALLMODEL BLAS_dscal_func) (int *n, REAL *da, REAL *dx, int *incx); 55 typedef void (BLAS_CALLMODEL BLAS_dcopy_func) (int *n, REAL *dx, int *incx, REAL *dy, int *incy); 56 typedef void (BLAS_CALLMODEL BLAS_daxpy_func) (int *n, REAL *da, REAL *dx, int *incx, REAL *dy, int *incy); 57 typedef void (BLAS_CALLMODEL BLAS_dswap_func) (int *n, REAL *dx, int *incx, REAL *dy, int *incy); 58 typedef double (BLAS_CALLMODEL BLAS_ddot_func) (int *n, REAL *dx, int *incx, REAL *dy, int *incy); 59 typedef int (BLAS_CALLMODEL BLAS_idamax_func)(int *n, REAL *x, int *is); 60 typedef int (BLAS_CALLMODEL BLAS_idamin_func)(int *n, REAL *x, int *is); 61 typedef void (BLAS_CALLMODEL BLAS_dload_func) (int *n, REAL *da, REAL *dx, int *incx); 62 typedef double (BLAS_CALLMODEL BLAS_dnormi_func)(int *n, REAL *x); 63 64 #ifndef __WINAPI 65 #if (defined WIN32) || (defined WIN64) 66 #define __WINAPI WINAPI 67 #else 68 #define __WINAPI 69 #endif 70 #endif 71 72 void init_BLAS(void); 73 MYBOOL is_nativeBLAS(void); 74 MYBOOL load_BLAS(char *libname); 75 MYBOOL unload_BLAS(void); 76 77 /* ************************************************************************ */ 78 /* User-callable BLAS definitions (C base 1) */ 79 /* ************************************************************************ */ 80 void dscallpsolve ( int n, REAL da, REAL *dx, int incx ); 81 void dcopylpsolve ( int n, REAL *dx, int incx, REAL *dy, int incy ); 82 void daxpylpsolve ( int n, REAL da, REAL *dx, int incx, REAL *dy, int incy ); 83 void dswaplpsolve ( int n, REAL *dx, int incx, REAL *dy, int incy ); 84 REAL ddotlpsolve ( int n, REAL *dx, int incx, REAL *dy, int incy ); 85 int idamaxlpsolve( int n, REAL *x, int is ); 86 int idaminlpsolve( int n, REAL *x, int is ); 87 void dload ( int n, REAL da, REAL *dx, int incx ); 88 REAL dnormi( int n, REAL *x ); 89 90 91 /* ************************************************************************ */ 92 /* Locally implemented BLAS functions (C base 0) */ 93 /* ************************************************************************ */ 94 void BLAS_CALLMODEL my_dscal ( int *n, REAL *da, REAL *dx, int *incx ); 95 void BLAS_CALLMODEL my_dcopy ( int *n, REAL *dx, int *incx, REAL *dy, int *incy ); 96 void BLAS_CALLMODEL my_daxpy ( int *n, REAL *da, REAL *dx, int *incx, REAL *dy, int *incy ); 97 void BLAS_CALLMODEL my_dswap ( int *n, REAL *dx, int *incx, REAL *dy, int *incy ); 98 REAL BLAS_CALLMODEL my_ddot ( int *n, REAL *dx, int *incx, REAL *dy, int *incy ); 99 int BLAS_CALLMODEL my_idamax( int *n, REAL *x, int *is ); 100 int BLAS_CALLMODEL my_idamin( int *n, REAL *x, int *is ); 101 void BLAS_CALLMODEL my_dload ( int *n, REAL *da, REAL *dx, int *incx ); 102 REAL BLAS_CALLMODEL my_dnormi( int *n, REAL *x ); 103 104 105 /* ************************************************************************ */ 106 /* Subvector and submatrix access routines (Fortran compatibility) */ 107 /* ************************************************************************ */ 108 #ifdef UseMacroVector 109 #define subvec(item) (item - 1) 110 #else 111 int subvec( int item ); 112 #endif 113 114 int submat( int nrowb, int row, int col ); 115 int posmat( int nrowb, int row, int col ); 116 117 118 /* ************************************************************************ */ 119 /* Randomization functions */ 120 /* ************************************************************************ */ 121 void randomseed(int *seeds); 122 void randomdens( int n, REAL *x, REAL r1, REAL r2, REAL densty, int *seeds); 123 void ddrand( int n, REAL *x, int incx, int *seeds ); 124 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif 131