fmatvec 0.0.0

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 using doublecomplex = std::complex<double>;
63
64 #if defined(HAVE_LIBBLAS)
65 namespace fmatvec {
66 void dscal(int N, double alpha, double *X, int incX) ;
67 void dgemm(CBLAS_ORDER Order, CBLAS_TRANSPOSE TransA,
68 CBLAS_TRANSPOSE TransB, int M, int N,
69 int K, double alpha, const double *A,
70 int lda, const double *B, int ldb,
71 double beta, double *C, int ldc);
72 void dsymm(CBLAS_ORDER Order, CBLAS_SIDE Side,
73 CBLAS_UPLO Uplo, int M, int N,
74 double alpha, const double *A, int lda,
75 const double *B, int ldb, double beta,
76 double *C, int ldc);
77 void daxpy(int N, double alpha, const double *X,
78 int incX, double *Y, int incY);
79 void dcopy(int N, const double *X, int incX,
80 double *Y, int incY);
81 void dgemv(CBLAS_ORDER Order,
82 CBLAS_TRANSPOSE TransA, int M, int N,
83 double alpha, const double *A, int lda,
84 const double *X, int incX, double beta,
85 double *Y, int incY);
86 void dsymv(CBLAS_ORDER Order, CBLAS_UPLO Uplo,
87 int N, double alpha, const double *A,
88 int lda, const double *X, int incX,
89 double beta, double *Y, int incY);
90 double ddot(int N, const double *X, int incX,
91 const double *Y, int incY);
92 double dasum(int N, const double *X, int incX);
93 CBLAS_INDEX idamax(int N, const double *X, int incX);
94 double dnrm2(int N, const double *X, int incX);
95 int dgesv(CBLAS_ORDER Order, int N, int NRHS,
96 double *A, int lda, int *ipiv,
97 double *B, int ldb);
98 int zgesv(CBLAS_ORDER Order, int N, int NRHS,
99 doublecomplex *A, int lda, int *ipiv,
100 doublecomplex *B, int ldb);
101 int dgetrs(CBLAS_ORDER Order, CBLAS_TRANSPOSE Trans,
102 int N, int NRHS, const double *A, int lda,
103 const int *ipiv, double *B, int ldb);
104 int dgetrf(CBLAS_ORDER Order, int M, int N,
105 double *A, int lda, int *ipiv);
106 int dgetri(CBLAS_ORDER Order, int N, double *A,
107 int lda, const int *ipiv);
108 int dpotrf(ATLAS_ORDER Order, ATLAS_UPLO Uplo, int N, double *A, int lda);
109 int dpotri(ATLAS_ORDER Order, ATLAS_UPLO Uplo,
110 int N, double *A, int lda);
111 int dposv(ATLAS_ORDER Order, ATLAS_UPLO Uplo,
112 int N, int NRHS, double *A, int lda,
113 double *B, int ldb);
114 int dpotrs(CBLAS_ORDER Order, CBLAS_UPLO Uplo,
115 int N, int NRHS, const double *A, int lda,
116 double *B, 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(char jobz, char range, CBLAS_UPLO cuplo, int n, double *a, int lda, double vl, double vu, int il, int iu, double abstol, int *m, double *w, double *z, 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( CBLAS_TRANSPOSE ctr, int m, int n, int nrhs, double* a, int lda, double* b, int ldb);
193
194 int dgelss(int m, int n, int nrhs, double *a, int lda, double *b, int ldb, double rcond);
195
196 int dgeev(char jobvl, char jobvr, int n, double *a, int lda, double *wr, double *wi, double *vl, int ldvl, double *vr, int ldvr);
197
198 int dsygv(int itype, char jobz, char uplo, int n, double *a, int lda, double *b, int ldb, double *w);
199
200 int dgesvd(char jobu, char jobvt, int m, int n, double *a, int lda, double *s, double *u, int ldu, double *vt, int ldvt);
201
202 int dsyev(char jobz, char ul, int n, double *a, int lda, double *w);
203
204 double dlange(char norm, int m, int n, const double* a, int lda);
205
206 double dlansy(char norm, char uplo, int n, const double* a, int lda);
207 }
208 #endif
fmatvec
Namespace fmatvec.
Definition: _memory.cc:28