COPASI API  4.16.103
blaswrap.h
Go to the documentation of this file.
1 // Copyright (C) 2013 - 2015 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 #ifndef COPASI_blaswrap
7 #define COPASI_blaswrap
8 
9 #ifdef min
10 # undef min
11 #endif // min
12 
13 #ifdef max
14 # undef max
15 #endif // max
16 
17 extern "C"
18 {
19 #ifdef HAVE_BLASWRAP_H
20 # include <blaswrap.h>
21 #else
22 # ifdef USE_MKL
23 # include "mkl_blas.h"
24 # define daxpy_ daxpy
25 # define dcopy_ dcopy
26 # define ddot_ ddot
27 # define dgemm_ dgemm
28 # define dnrm2_ dnrm2
29 # define dscal_ dscal
30 # define idamax_ idamax
31 # endif // USE_MKL
32 
33 # if (defined HAVE_CLAPACK_H || defined HAVE_LAPACK_H)
34 # if (defined WIN32 && defined HAVE_LAPACK_H)
35 # define daxpy_ DAXPY
36 # define dcopy_ DCOPY
37 # define ddot_ DDOT
38 # define dgemm_ DGEMM
39 # define dnrm2_ DNRM2
40 # define dscal_ DSCAL
41 # define idamax_ IDAMAX
42 # endif // (defined WIN32 && defined HAVE_LAPACK_H)
43 
44 # if (defined HAVE_CLAPACK_H && !defined NO_BLAS_WRAP && !defined HAVE_APPLE)
45 # define daxpy_ f2c_daxpy
46 # define dcopy_ f2c_dcopy
47 # define ddot_ f2c_ddot
48 # define dgemm_ f2c_dgemm
49 # define dnrm2_ f2c_dnrm2
50 # define dscal_ f2c_dscal
51 # define idamax_ f2c_idamax
52 # endif // (defined HAVE_CLAPACK_H && !defined NO_BLAS_WRAP && !defined HAVE_APPLE)
53 
54 # endif // (defined HAVE_CLAPACK_H || defined HAVE_LAPACK_H)
55 #endif // HAVE_BLASWRAP_H
56 
57 # ifdef HAVE_F2C_H
58 # include <f2c.h>
59 # else
60 # include "lapack/f2c.h"
61 # endif
62 # undef abs
63 
64 # ifdef HAVE_BLAS_H
65 # include <blas.h>
66 # else
67 # include "lapack/blas.h"
68 # endif
69 
70 #ifdef USE_SUNPERF
71 # include "sunperf.h"
72 #endif // USE_SUNPERF
73 }
74 
75 #ifdef HAVE_APPLE
76 # undef abs
77 # undef max
78 # undef min
79 # include <Accelerate/Accelerate.h>
80 # define daxpy_(N, ALPHA, X, INCX, Y, INCY) \
81  cblas_daxpy(*N, *ALPHA, X, *INCX, Y, *INCY)
82 # define dcopy_(N, X, INCX, Y, INCY) \
83  cblas_dcopy(*N, X, *INCX, Y, *INCY)
84 # define ddot_(N, X, INCX, Y, INCY) \
85  cblas_ddot(*N, X, *INCX, Y, *INCY)
86 # define dgemm_(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC) \
87  cblas_dgemm(CblasColMajor, \
88  (*TRANSA == 'N' ? CblasNoTrans: CblasTrans), \
89  (*TRANSB == 'N' ? CblasNoTrans: CblasTrans), \
90  *M, *N, *K, *ALPHA, A, *LDA, B, *LDB, *BETA, C, *LDC)
91 # define dscal_(N, ALPHA, X, INCX) cblas_dscal(*N, *ALPHA, X *INCX)
92 # define dnrm2_(N, X, INCX) cblas_dnrm2(*N, X, *INCX)
93 # define idamax_(N, X, INCX) \
94  cblas_idamax(*N, X, *INCX)
95 # include <cmath>
96 using std::isnan;
97 #endif // HAVE_APPLE
98 
99 #ifdef min
100 # undef min
101 #endif // min
102 
103 #ifdef max
104 # undef max
105 #endif // max
106 
107 #ifdef WIN32
108 # if _MSC_VER < 1600
109 # define min _cpp_min
110 # define max _cpp_max
111 # endif
112 #endif
113 
114 #endif // COPASI_blaswrap