wrapper.h
1 /* Copyright (C) 2007 Martin Förg, Jan Clauberg
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * martin.o.foerg@googlemail.com
19  *
20  */
21 
22 #ifndef wrapper_h
23 #define wrapper_h
24 
25 #ifndef HAVE_LIBMKL_INTEL_LP64
26 #ifndef CBLAS_ENUM_DEFINED_H
27  #define CBLAS_ENUM_DEFINED_H
28  enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
29  enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113,
30  AtlasConj=114};
31  enum CBLAS_UPLO {CblasUpper=121, CblasLower=122};
32  enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132};
33  enum CBLAS_SIDE {CblasLeft=141, CblasRight=142};
34 #endif
35 #define CBLAS_INDEX int
36 
37 #ifndef ATLAS_ENUM_H
38  #define ATLAS_ENUM_H
39  #define ATLAS_ORDER CBLAS_ORDER
40  #define AtlasRowMajor CblasRowMajor
41  #define AtlasColMajor CblasColMajor
42  #define ATLAS_TRANS CBLAS_TRANSPOSE
43  #define AtlasNoTrans CblasNoTrans
44  #define AtlasTrans CblasTrans
45  #define AtlasConjTrans CblasConjTrans
46  #define ATLAS_UPLO CBLAS_UPLO
47  #define AtlasUpper CblasUpper
48  #define AtlasLower CblasLower
49  #define ATLAS_DIAG CBLAS_DIAG
50  #define AtlasNonUnit CblasNonUnit
51  #define AtlasUnit CblasUnit
52  #define ATLAS_SIDE CBLAS_SIDE
53  #define AtlasLeft CblasLeft
54  #define AtlasRight CblasRight
55 #endif
56 #else
57 #include "mkl_cblas.h"
58 #endif
59 
60 #if defined(HAVE_LIBBLAS)
61 namespace fmatvec {
62  void dscal(const int N, const double alpha, double *X, const int incX) ;
63  void dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA,
64  const CBLAS_TRANSPOSE TransB, const int M, const int N,
65  const int K, const double alpha, const double *A,
66  const int lda, const double *B, const int ldb,
67  const double beta, double *C, const int ldc);
68  void dsymm(const CBLAS_ORDER Order, const CBLAS_SIDE Side,
69  const CBLAS_UPLO Uplo, const int M, const int N,
70  const double alpha, const double *A, const int lda,
71  const double *B, const int ldb, const double beta,
72  double *C, const int ldc);
73  void daxpy(const int N, const double alpha, const double *X,
74  const int incX, double *Y, const int incY);
75  void dcopy(const int N, const double *X, const int incX,
76  double *Y, const int incY);
77  void dgemv(const CBLAS_ORDER Order,
78  const CBLAS_TRANSPOSE TransA, const int M, const int N,
79  const double alpha, const double *A, const int lda,
80  const double *X, const int incX, const double beta,
81  double *Y, const int incY);
82  void dsymv(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
83  const int N, const double alpha, const double *A,
84  const int lda, const double *X, const int incX,
85  const double beta, double *Y, const int incY);
86  double ddot(const int N, const double *X, const int incX,
87  const double *Y, const int incY);
88  double dasum(const int N, const double *X, const int incX);
89  CBLAS_INDEX idamax(const int N, const double *X, const int incX);
90  double dnrm2(const int N, const double *X, const int incX);
91  int dgesv(const CBLAS_ORDER Order, const int N, const int NRHS,
92  double *A, const int lda, int *ipiv,
93  double *B, const int ldb);
94  int dgetrs(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE Trans,
95  const int N, const int NRHS, const double *A, const int lda,
96  const int *ipiv, double *B, const int ldb);
97  int dgetrf(const CBLAS_ORDER Order, const int M, const int N,
98  double *A, const int lda, int *ipiv);
99  int dgetri(const CBLAS_ORDER Order, const int N, double *A,
100  const int lda, const int *ipiv);
101  int dpotrf(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo, const int N, double *A, const int lda);
102  int dpotri(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
103  const int N, double *A, const int lda);
104  int dposv(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
105  const int N, const int NRHS, double *A, const int lda,
106  double *B, const int ldb);
107  int dpotrs(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
108  const int N, const int NRHS, const double *A, const int lda,
109  double *B, const int ldb);
110 }
111 #endif
112 
113 #if defined(HAVE_LIBATLAS)
114 namespace fmatvec {
115 
116 extern "C" {
117 #include "cblas.h"
118 #include "clapack.h"
119 }
120 
121 #define dscal cblas_dscal
122 #define dcopy cblas_dcopy
123 #define ddot cblas_ddot
124 #define dnrm2 cblas_dnrm2
125 #define dasum cblas_dasum
126 #define idamax cblas_idamax
127 #define daxpy cblas_daxpy
128 #define dgemv cblas_dgemv
129 #define dsymv cblas_dsymv
130 #define dgemm cblas_dgemm
131 #define dsymm cblas_dsymm
132 
133 #define dgesv clapack_dgesv
134 #define dgetrs clapack_dgetrs
135 #define dgetrf clapack_dgetrf
136 #define dgetri clapack_dgetri
137 #define dpotrf clapack_dpotrf
138 #define dpotri clapack_dpotri
139 #define dpotrs clapack_dpotrs
140 #define dposv clapack_dposv
141 
142 }
143 #endif
144 
145 #if defined(HAVE_LIBMKL_INTEL_LP64)
146 extern "C" {
147 #include "mkl_cblas.h"
148 #include "mkl_lapacke.h"
149 #include "mkl_lapack.h"
150 }
151 
152 #define dscal cblas_dscal
153 #define dcopy cblas_dcopy
154 #define ddot cblas_ddot
155 #define dnrm2 cblas_dnrm2
156 #define dasum cblas_dasum
157 #define idamax cblas_idamax
158 #define daxpy cblas_daxpy
159 #define dgemv cblas_dgemv
160 #define dsymv cblas_dsymv
161 #define dgemm cblas_dgemm
162 #define dsymm cblas_dsymm
163 
164 #define dgesv LAPACKE_dgesv
165 #define dgetrs LAPACKE_dgetrs
166 #define dgetrf LAPACKE_dgetrf
167 #define dgetri LAPACKE_dgetri
168 #define dpotrf LAPACKE_dpotrf
169 #define dpotri LAPACKE_dpotri
170 #define dpotrs LAPACKE_dpotrs
171 #define dposv LAPACKE_dposv
172 
173 #endif
174 
175 namespace fmatvec {
176 
177 #ifndef HAVE_LIBMKL_INTEL_LP64
178  int dsyevx(const char jobz, const char range, const CBLAS_UPLO cuplo, const int n, double *a, const int lda, const double vl, const double vu, const int il, const int iu, const double abstol, const int *m, double *w, double *z, const int ldz);
179 #else
180  int dsyevx(const char jobz, const char range, const CBLAS_UPLO cuplo, const int n, double *a, const int lda, const double vl, const double vu, const int il, const int iu, const double abstol, int *m, double *w, double *z, const int ldz);
181 #endif
182 
183  int dgels( const CBLAS_TRANSPOSE ctr, const int m, const int n, const int nhrs, double* a, const int lda, double* b, const int ldb);
184 
185  int dgelss(const int m, const int n, const int nrhs, double *a, const int lda, double *b, const int ldb, const double rcond);
186 
187  int dgeev(const char jobvl, const char jobvr, const int n, double *a, const int lda, double *wr, double *wi, double *vl, const int ldvl, double *vr, const int ldvr);
188 
189  int dsygv(const int itype, const char jobz, const char uplo, const int n, double *a, const int lda, double *b, const int ldb, double *w);
190 
191  int dsyev(const char jobz, const char ul, const int n, double *a, const int lda, double *w);
192 
193  double dlange(const char norm , const int m, const int n, const double* a, const int lda);
194 }
195 #endif