gemv.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_BLAS_GEMV_H_
36 #define _BLAZE_MATH_BLAS_GEMV_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <boost/cast.hpp>
51 #include <blaze/system/BLAS.h>
52 #include <blaze/system/Inline.h>
53 #include <blaze/util/Assert.h>
54 #include <blaze/util/Complex.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // BLAS WRAPPER FUNCTIONS (GEMV)
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
68 #if BLAZE_BLAS_MODE
69 
70 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER layout, CBLAS_TRANSPOSE transA, int m, int n,
71  float alpha, const float* A, int lda, const float* x, int incX,
72  float beta, float* y, int incY );
73 
74 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER layout, CBLAS_TRANSPOSE transA, int m, int n,
75  double alpha, const double* A, int lda, const double* x, int incX,
76  double beta, double* y, int incY );
77 
78 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER layout, CBLAS_TRANSPOSE transA, int m, int n,
79  complex<float> alpha, const complex<float>* A, int lda,
80  const complex<float>* x, int incX, complex<float> beta,
81  complex<float>* y, int incY );
82 
83 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER layout, CBLAS_TRANSPOSE transA, int m, int n,
84  complex<double> alpha, const complex<double>* A, int lda,
85  const complex<double>* x, int incX, complex<double> beta,
86  complex<double>* y, int incY );
87 
88 template< typename VT1, typename MT1, bool SO, typename VT2, typename ST >
89 BLAZE_ALWAYS_INLINE void gemv( DenseVector<VT1,false>& y, const DenseMatrix<MT1,SO>& A,
90  const DenseVector<VT2,false>& x, ST alpha, ST beta );
91 
92 template< typename VT1, typename VT2, typename MT1, bool SO, typename ST >
93 BLAZE_ALWAYS_INLINE void gemv( DenseVector<VT1,true>& y, const DenseVector<VT2,true>& x,
94  const DenseMatrix<MT1,SO>& A, ST alpha, ST beta );
95 
96 #endif
97 
98 //*************************************************************************************************
99 
100 
101 //*************************************************************************************************
102 #if BLAZE_BLAS_MODE
103 
124 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int m, int n,
125  float alpha, const float* A, int lda, const float* x, int incX,
126  float beta, float* y, int incY )
127 {
128  cblas_sgemv( order, transA, m, n, alpha, A, lda, x, incX, beta, y, incY );
129 }
130 #endif
131 //*************************************************************************************************
132 
133 
134 //*************************************************************************************************
135 #if BLAZE_BLAS_MODE
136 
157 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int m, int n,
158  double alpha, const double* A, int lda, const double* x, int incX,
159  double beta, double* y, int incY )
160 {
161  cblas_dgemv( order, transA, m, n, alpha, A, lda, x, incX, beta, y, incY );
162 }
163 #endif
164 //*************************************************************************************************
165 
166 
167 //*************************************************************************************************
168 #if BLAZE_BLAS_MODE
169 
190 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int m, int n,
191  complex<float> alpha, const complex<float>* A, int lda,
192  const complex<float>* x, int incX, complex<float> beta,
193  complex<float>* y, int incY )
194 {
195  cblas_cgemv( order, transA, m, n, &alpha, A, lda, x, incX, &beta, y, incY );
196 }
197 #endif
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
202 #if BLAZE_BLAS_MODE
203 
224 BLAZE_ALWAYS_INLINE void gemv( CBLAS_ORDER order, CBLAS_TRANSPOSE transA, int m, int n,
225  complex<double> alpha, const complex<double>* A, int lda,
226  const complex<double>* x, int incX, complex<double> beta,
227  complex<double>* y, int incY )
228 {
229  cblas_zgemv( order, transA, m, n, &alpha, A, lda, x, incX, &beta, y, incY );
230 }
231 #endif
232 //*************************************************************************************************
233 
234 
235 //*************************************************************************************************
236 #if BLAZE_BLAS_MODE
237 
253 template< typename VT1 // Type of the left-hand side target vector
254  , typename MT1 // Type of the left-hand side matrix operand
255  , bool SO // Storage order of the left-hand side matrix operand
256  , typename VT2 // Type of the right-hand side vector operand
257  , typename ST > // Type of the scalar factors
258 BLAZE_ALWAYS_INLINE void gemv( DenseVector<VT1,false>& y, const DenseMatrix<MT1,SO>& A,
259  const DenseVector<VT2,false>& x, ST alpha, ST beta )
260 {
261  using boost::numeric_cast;
262 
266 
270 
274 
275  const int m ( numeric_cast<int>( (~A).rows() ) );
276  const int n ( numeric_cast<int>( (~A).columns() ) );
277  const int lda( numeric_cast<int>( (~A).spacing() ) );
278 
279  gemv( ( SO )?( CblasColMajor ):( CblasRowMajor ), CblasNoTrans, m, n, alpha,
280  (~A).data(), lda, (~x).data(), 1, beta, (~y).data(), 1 );
281 }
282 #endif
283 //*************************************************************************************************
284 
285 
286 //*************************************************************************************************
287 #if BLAZE_BLAS_MODE
288 
304 template< typename VT1 // Type of the left-hand side target vector
305  , typename VT2 // Type of the left-hand side vector operand
306  , typename MT1 // Type of the right-hand side matrix operand
307  , bool SO // Storage order of the right-hand side matrix operand
308  , typename ST > // Type of the scalar factors
309 BLAZE_ALWAYS_INLINE void gemv( DenseVector<VT1,true>& y, const DenseVector<VT2,true>& x,
310  const DenseMatrix<MT1,SO>& A, ST alpha, ST beta )
311 {
312  using boost::numeric_cast;
313 
317 
321 
325 
326  const int m ( numeric_cast<int>( (~A).rows() ) );
327  const int n ( numeric_cast<int>( (~A).columns() ) );
328  const int lda( numeric_cast<int>( (~A).spacing() ) );
329 
330  gemv( ( SO )?( CblasColMajor ):( CblasRowMajor ), CblasTrans, m, n, alpha,
331  (~A).data(), lda, (~x).data(), 1, beta, (~y).data(), 1 );
332 }
333 #endif
334 //*************************************************************************************************
335 
336 } // namespace blaze
337 
338 #endif
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to m...
Definition: MutableDataAccess.h:79
#define BLAZE_CONSTRAINT_MUST_HAVE_CONST_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to c...
Definition: ConstDataAccess.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
Header file for the DenseVector base class.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the DenseMatrix base class.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Constraint on the data type.
Constraint on the data type.
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
System settings for the BLAS mode.
Header file for run time assertion macros.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i...
Definition: BlasCompatible.h:79
Header file for the IsRowMajorMatrix type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
Header file for the complex data type.
System settings for the inline keywords.