blas_wrapper.hpp
Go to the documentation of this file.
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 
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  {
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
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
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  {
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
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
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
int blas_int
arma_inline arma_warn_unused T1::elem_type dot(const Base< typename T1::elem_type, T1 > &A, const Base< typename T1::elem_type, T2 > &B)
Definition: fn_dot.hpp:23
Wrapper for ATLAS/BLAS gemv function, using template arguments to control the arguments passed to gem...
u32 uword
Definition: typedef.hpp:85
#define arma_type_check(condition)
#define arma_fortran(function)
Wrapper for ATLAS/BLAS dgemm function, using template arguments to control the arguments passed to dg...
#define arma_ignore(variable)


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:56