All Classes Namespaces Functions Typedefs Enumerations Pages
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 #include <complex>
61 
62 typedef std::complex<double> doublecomplex;
63 
64 #if defined(HAVE_LIBBLAS)
65 namespace fmatvec {
66  void dscal(const int N, const double alpha, double *X, const int incX) ;
67  void dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA,
68  const CBLAS_TRANSPOSE TransB, const int M, const int N,
69  const int K, const double alpha, const double *A,
70  const int lda, const double *B, const int ldb,
71  const double beta, double *C, const int ldc);
72  void dsymm(const CBLAS_ORDER Order, const CBLAS_SIDE Side,
73  const CBLAS_UPLO Uplo, const int M, const int N,
74  const double alpha, const double *A, const int lda,
75  const double *B, const int ldb, const double beta,
76  double *C, const int ldc);
77  void daxpy(const int N, const double alpha, const double *X,
78  const int incX, double *Y, const int incY);
79  void dcopy(const int N, const double *X, const int incX,
80  double *Y, const int incY);
81  void dgemv(const CBLAS_ORDER Order,
82  const CBLAS_TRANSPOSE TransA, const int M, const int N,
83  const double alpha, const double *A, const int lda,
84  const double *X, const int incX, const double beta,
85  double *Y, const int incY);
86  void dsymv(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
87  const int N, const double alpha, const double *A,
88  const int lda, const double *X, const int incX,
89  const double beta, double *Y, const int incY);
90  double ddot(const int N, const double *X, const int incX,
91  const double *Y, const int incY);
92  double dasum(const int N, const double *X, const int incX);
93  CBLAS_INDEX idamax(const int N, const double *X, const int incX);
94  double dnrm2(const int N, const double *X, const int incX);
95  int dgesv(const CBLAS_ORDER Order, const int N, const int NRHS,
96  double *A, const int lda, int *ipiv,
97  double *B, const int ldb);
98  int zgesv(const CBLAS_ORDER Order, const int N, const int NRHS,
99  doublecomplex *A, const int lda, int *ipiv,
100  doublecomplex *B, const int ldb);
101  int dgetrs(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE Trans,
102  const int N, const int NRHS, const double *A, const int lda,
103  const int *ipiv, double *B, const int ldb);
104  int dgetrf(const CBLAS_ORDER Order, const int M, const int N,
105  double *A, const int lda, int *ipiv);
106  int dgetri(const CBLAS_ORDER Order, const int N, double *A,
107  const int lda, const int *ipiv);
108  int dpotrf(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo, const int N, double *A, const int lda);
109  int dpotri(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
110  const int N, double *A, const int lda);
111  int dposv(const ATLAS_ORDER Order, const ATLAS_UPLO Uplo,
112  const int N, const int NRHS, double *A, const int lda,
113  double *B, const int ldb);
114  int dpotrs(const CBLAS_ORDER Order, const CBLAS_UPLO Uplo,
115  const int N, const int NRHS, const double *A, const int lda,
116  double *B, const int ldb);
117 }
118 #endif
119 
120 #if defined(HAVE_LIBATLAS)
121 namespace fmatvec {
122 
123 extern "C" {
124 #include "cblas.h"
125 #include "clapack.h"
126 }
127 
128 #define dscal cblas_dscal
129 #define dcopy cblas_dcopy
130 #define ddot cblas_ddot
131 #define dnrm2 cblas_dnrm2
132 #define dasum cblas_dasum
133 #define idamax cblas_idamax
134 #define daxpy cblas_daxpy
135 #define dgemv cblas_dgemv
136 #define dsymv cblas_dsymv
137 #define dgemm cblas_dgemm
138 #define dsymm cblas_dsymm
139 
140 #define dgesv clapack_dgesv
141 #define zgesv clapack_zgesv
142 #define dgetrs clapack_dgetrs
143 #define dgetrf clapack_dgetrf
144 #define dgetri clapack_dgetri
145 #define dpotrf clapack_dpotrf
146 #define dpotri clapack_dpotri
147 #define dpotrs clapack_dpotrs
148 #define dposv clapack_dposv
149 
150 }
151 #endif
152 
153 #if defined(HAVE_LIBMKL_INTEL_LP64)
154 extern "C" {
155 #include "mkl_cblas.h"
156 #include "mkl_lapacke.h"
157 #include "mkl_lapack.h"
158 }
159 
160 #define dscal cblas_dscal
161 #define dcopy cblas_dcopy
162 #define ddot cblas_ddot
163 #define dnrm2 cblas_dnrm2
164 #define dasum cblas_dasum
165 #define idamax cblas_idamax
166 #define daxpy cblas_daxpy
167 #define dgemv cblas_dgemv
168 #define dsymv cblas_dsymv
169 #define dgemm cblas_dgemm
170 #define dsymm cblas_dsymm
171 
172 #define dgesv LAPACKE_dgesv
173 #define zgesv LAPACKE_zgesv
174 #define dgetrs LAPACKE_dgetrs
175 #define dgetrf LAPACKE_dgetrf
176 #define dgetri LAPACKE_dgetri
177 #define dpotrf LAPACKE_dpotrf
178 #define dpotri LAPACKE_dpotri
179 #define dpotrs LAPACKE_dpotrs
180 #define dposv LAPACKE_dposv
181 
182 #endif
183 
184 namespace fmatvec {
185 
186 #ifndef HAVE_LIBMKL_INTEL_LP64
187  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);
188 #else
189  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);
190 #endif
191 
192  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);
193 
194  int dgelss(const int m, const int n, const int nrhs, double *a, const int lda, double *b, const int ldb, const double rcond);
195 
196  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);
197 
198  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);
199 
200  int dgesvd(const char jobu, const char jobvt, const int m, const int n, double *a, const int lda, double *s, double *u, const int ldu, double *vt, const int ldvt);
201 
202  int dsyev(const char jobz, const char ul, const int n, double *a, const int lda, double *w);
203 
204  double dlange(const char norm, const int m, const int n, const double* a, const int lda);
205 
206  double dlansy(const char norm, const char uplo, const int n, const double* a, const int lda);
207 }
208 #endif

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML