Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/atlas_wrapper.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2012 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 #ifdef ARMA_USE_ATLAS | |
10 | |
11 | |
12 //! \namespace atlas namespace for ATLAS functions (imported from the global namespace) | |
13 namespace atlas | |
14 { | |
15 | |
16 template<typename eT> | |
17 inline static const eT& tmp_real(const eT& X) { return X; } | |
18 | |
19 template<typename T> | |
20 inline static const T tmp_real(const std::complex<T>& X) { return X.real(); } | |
21 | |
22 | |
23 | |
24 template<typename eT> | |
25 arma_inline | |
26 eT | |
27 cblas_dot(const int N, const eT* X, const eT* Y) | |
28 { | |
29 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
30 | |
31 if(is_float<eT>::value == true) | |
32 { | |
33 typedef float T; | |
34 return eT( arma_atlas(cblas_sdot)(N, (const T*)X, 1, (const T*)Y, 1) ); | |
35 } | |
36 else | |
37 if(is_double<eT>::value == true) | |
38 { | |
39 typedef double T; | |
40 return eT( arma_atlas(cblas_ddot)(N, (const T*)X, 1, (const T*)Y, 1) ); | |
41 } | |
42 else | |
43 { | |
44 return eT(0); | |
45 } | |
46 } | |
47 | |
48 | |
49 | |
50 template<typename eT> | |
51 arma_inline | |
52 eT | |
53 cx_cblas_dot(const int N, const eT* X, const eT* Y) | |
54 { | |
55 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
56 | |
57 if(is_supported_complex_float<eT>::value == true) | |
58 { | |
59 typedef typename std::complex<float> T; | |
60 | |
61 T out; | |
62 arma_atlas(cblas_cdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); | |
63 | |
64 return eT(out); | |
65 } | |
66 else | |
67 if(is_supported_complex_double<eT>::value == true) | |
68 { | |
69 typedef typename std::complex<double> T; | |
70 | |
71 T out; | |
72 arma_atlas(cblas_zdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); | |
73 | |
74 return eT(out); | |
75 } | |
76 else | |
77 { | |
78 return eT(0); | |
79 } | |
80 } | |
81 | |
82 | |
83 | |
84 template<typename eT> | |
85 inline | |
86 void | |
87 cblas_gemv | |
88 ( | |
89 const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, | |
90 const int M, const int N, | |
91 const eT alpha, | |
92 const eT *A, const int lda, | |
93 const eT *X, const int incX, | |
94 const eT beta, | |
95 eT *Y, const int incY | |
96 ) | |
97 { | |
98 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
99 | |
100 if(is_float<eT>::value == true) | |
101 { | |
102 typedef float T; | |
103 arma_atlas(cblas_sgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY); | |
104 } | |
105 else | |
106 if(is_double<eT>::value == true) | |
107 { | |
108 typedef double T; | |
109 arma_atlas(cblas_dgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY); | |
110 } | |
111 else | |
112 if(is_supported_complex_float<eT>::value == true) | |
113 { | |
114 typedef std::complex<float> T; | |
115 arma_atlas(cblas_cgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY); | |
116 } | |
117 else | |
118 if(is_supported_complex_double<eT>::value == true) | |
119 { | |
120 typedef std::complex<double> T; | |
121 arma_atlas(cblas_zgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY); | |
122 } | |
123 } | |
124 | |
125 | |
126 | |
127 template<typename eT> | |
128 inline | |
129 void | |
130 cblas_gemm | |
131 ( | |
132 const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, | |
133 const enum CBLAS_TRANSPOSE TransB, const int M, const int N, | |
134 const int K, const eT alpha, const eT *A, | |
135 const int lda, const eT *B, const int ldb, | |
136 const eT beta, eT *C, const int ldc | |
137 ) | |
138 { | |
139 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
140 | |
141 if(is_float<eT>::value == true) | |
142 { | |
143 typedef float T; | |
144 arma_atlas(cblas_sgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc); | |
145 } | |
146 else | |
147 if(is_double<eT>::value == true) | |
148 { | |
149 typedef double T; | |
150 arma_atlas(cblas_dgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc); | |
151 } | |
152 else | |
153 if(is_supported_complex_float<eT>::value == true) | |
154 { | |
155 typedef std::complex<float> T; | |
156 arma_atlas(cblas_cgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc); | |
157 } | |
158 else | |
159 if(is_supported_complex_double<eT>::value == true) | |
160 { | |
161 typedef std::complex<double> T; | |
162 arma_atlas(cblas_zgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc); | |
163 } | |
164 } | |
165 | |
166 | |
167 | |
168 template<typename eT> | |
169 inline | |
170 int | |
171 clapack_getrf | |
172 ( | |
173 const enum CBLAS_ORDER Order, const int M, const int N, | |
174 eT *A, const int lda, int *ipiv | |
175 ) | |
176 { | |
177 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
178 | |
179 if(is_float<eT>::value == true) | |
180 { | |
181 typedef float T; | |
182 return arma_atlas(clapack_sgetrf)(Order, M, N, (T*)A, lda, ipiv); | |
183 } | |
184 else | |
185 if(is_double<eT>::value == true) | |
186 { | |
187 typedef double T; | |
188 return arma_atlas(clapack_dgetrf)(Order, M, N, (T*)A, lda, ipiv); | |
189 } | |
190 else | |
191 if(is_supported_complex_float<eT>::value == true) | |
192 { | |
193 typedef std::complex<float> T; | |
194 return arma_atlas(clapack_cgetrf)(Order, M, N, (T*)A, lda, ipiv); | |
195 } | |
196 else | |
197 if(is_supported_complex_double<eT>::value == true) | |
198 { | |
199 typedef std::complex<double> T; | |
200 return arma_atlas(clapack_zgetrf)(Order, M, N, (T*)A, lda, ipiv); | |
201 } | |
202 else | |
203 { | |
204 return -1; | |
205 } | |
206 } | |
207 | |
208 | |
209 | |
210 template<typename eT> | |
211 inline | |
212 int | |
213 clapack_getri | |
214 ( | |
215 const enum CBLAS_ORDER Order, const int N, eT *A, | |
216 const int lda, const int *ipiv | |
217 ) | |
218 { | |
219 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
220 | |
221 if(is_float<eT>::value == true) | |
222 { | |
223 typedef float T; | |
224 return arma_atlas(clapack_sgetri)(Order, N, (T*)A, lda, ipiv); | |
225 } | |
226 else | |
227 if(is_double<eT>::value == true) | |
228 { | |
229 typedef double T; | |
230 return arma_atlas(clapack_dgetri)(Order, N, (T*)A, lda, ipiv); | |
231 } | |
232 else | |
233 if(is_supported_complex_float<eT>::value == true) | |
234 { | |
235 typedef std::complex<float> T; | |
236 return arma_atlas(clapack_cgetri)(Order, N, (T*)A, lda, ipiv); | |
237 } | |
238 else | |
239 if(is_supported_complex_double<eT>::value == true) | |
240 { | |
241 typedef std::complex<double> T; | |
242 return arma_atlas(clapack_zgetri)(Order, N, (T*)A, lda, ipiv); | |
243 } | |
244 else | |
245 { | |
246 return -1; | |
247 } | |
248 } | |
249 | |
250 | |
251 | |
252 template<typename eT> | |
253 inline | |
254 int | |
255 clapack_gesv | |
256 ( | |
257 const enum CBLAS_ORDER Order, | |
258 const int N, const int NRHS, | |
259 eT* A, const int lda, int* ipiv, | |
260 eT* B, const int ldb | |
261 ) | |
262 { | |
263 arma_type_check((is_supported_blas_type<eT>::value == false)); | |
264 | |
265 if(is_float<eT>::value == true) | |
266 { | |
267 typedef float T; | |
268 return arma_atlas(clapack_sgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); | |
269 } | |
270 else | |
271 if(is_double<eT>::value == true) | |
272 { | |
273 typedef double T; | |
274 return arma_atlas(clapack_dgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); | |
275 } | |
276 else | |
277 if(is_supported_complex_float<eT>::value == true) | |
278 { | |
279 typedef std::complex<float> T; | |
280 return arma_atlas(clapack_cgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); | |
281 } | |
282 else | |
283 if(is_supported_complex_double<eT>::value == true) | |
284 { | |
285 typedef std::complex<double> T; | |
286 return arma_atlas(clapack_zgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); | |
287 } | |
288 else | |
289 { | |
290 return -1; | |
291 } | |
292 } | |
293 | |
294 | |
295 | |
296 } | |
297 | |
298 #endif |