comparison armadillo-2.4.4/include/armadillo_bits/blas_wrapper.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14
15 #ifdef ARMA_USE_BLAS
16
17
18 //! \namespace blas namespace for BLAS functions
19 namespace blas
20 {
21
22
23 template<typename eT>
24 inline
25 eT
26 dot(const uword n_elem, const eT* x, const eT* y)
27 {
28 arma_ignore(n_elem);
29 arma_ignore(x);
30 arma_ignore(y);
31
32 return eT(0);
33 }
34
35
36
37 template<>
38 inline
39 float
40 dot(const uword n_elem, const float* x, const float* y)
41 {
42 blas_int n = blas_int(n_elem);
43 blas_int inc = blas_int(1);
44
45 return arma_fortran(arma_sdot)(&n, x, &inc, y, &inc);
46 }
47
48
49
50 template<>
51 inline
52 double
53 dot(const uword n_elem, const double* x, const double* y)
54 {
55 blas_int n = blas_int(n_elem);
56 blas_int inc = blas_int(1);
57
58 return arma_fortran(arma_ddot)(&n, x, &inc, y, &inc);
59 }
60
61
62
63 template<typename eT>
64 inline
65 void
66 gemv(const char* transA, const blas_int* m, const blas_int* n, const eT* alpha, const eT* A, const blas_int* ldA, const eT* x, const blas_int* incx, const eT* beta, eT* y, const blas_int* incy)
67 {
68 arma_type_check((is_supported_blas_type<eT>::value == false));
69
70 if(is_float<eT>::value == true)
71 {
72 typedef float T;
73 arma_fortran(arma_sgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
74 }
75 else
76 if(is_double<eT>::value == true)
77 {
78 typedef double T;
79 arma_fortran(arma_dgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
80 }
81 else
82 if(is_supported_complex_float<eT>::value == true)
83 {
84 typedef std::complex<float> T;
85 arma_fortran(arma_cgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
86 }
87 else
88 if(is_supported_complex_double<eT>::value == true)
89 {
90 typedef std::complex<double> T;
91 arma_fortran(arma_zgemv)(transA, m, n, (const T*)alpha, (const T*)A, ldA, (const T*)x, incx, (const T*)beta, (T*)y, incy);
92 }
93
94 }
95
96
97
98 template<typename eT>
99 inline
100 void
101 gemm(const char* transA, const char* transB, const blas_int* m, const blas_int* n, const blas_int* k, const eT* alpha, const eT* A, const blas_int* ldA, const eT* B, const blas_int* ldB, const eT* beta, eT* C, const blas_int* ldC)
102 {
103 arma_type_check((is_supported_blas_type<eT>::value == false));
104
105 if(is_float<eT>::value == true)
106 {
107 typedef float T;
108 arma_fortran(arma_sgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
109 }
110 else
111 if(is_double<eT>::value == true)
112 {
113 typedef double T;
114 arma_fortran(arma_dgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
115 }
116 else
117 if(is_supported_complex_float<eT>::value == true)
118 {
119 typedef std::complex<float> T;
120 arma_fortran(arma_cgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
121 }
122 else
123 if(is_supported_complex_double<eT>::value == true)
124 {
125 typedef std::complex<double> T;
126 arma_fortran(arma_zgemm)(transA, transB, m, n, k, (const T*)alpha, (const T*)A, ldA, (const T*)B, ldB, (const T*)beta, (T*)C, ldC);
127 }
128
129 }
130
131 }
132
133
134 #endif