Blaze  3.6
axpy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_BLAS_AXPY_H_
36 #define _BLAZE_MATH_BLAS_AXPY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
49 #include <blaze/system/BLAS.h>
50 #include <blaze/system/Inline.h>
51 #include <blaze/util/Complex.h>
52 #include <blaze/util/NumericCast.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // BLAS WRAPPER FUNCTIONS (AXPY)
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
67 #if BLAZE_BLAS_MODE
68 
69 BLAZE_ALWAYS_INLINE void axpy( int n, float alpha, const float* x, int incX, float* y, int incY );
70 
71 BLAZE_ALWAYS_INLINE void axpy( int n, double alpha, const double* x, int incX, double* y, int incY );
72 
73 BLAZE_ALWAYS_INLINE void axpy( int n, complex<float> alpha, const complex<float>* x,
74  int incX, complex<float>* y, int incY );
75 
76 BLAZE_ALWAYS_INLINE void axpy( int n, complex<double> alpha, const complex<double>* x,
77  int incX, complex<double>* y, int incY );
78 
79 template< typename VT1, bool TF1, typename VT2, bool TF2, typename ST >
80 BLAZE_ALWAYS_INLINE void axpy( const DenseVector<VT1,TF1>& x, const DenseVector<VT2,TF2>& y, ST alpha );
81 
82 #endif
83 
84 //*************************************************************************************************
85 
86 
87 //*************************************************************************************************
88 #if BLAZE_BLAS_MODE
89 
104 BLAZE_ALWAYS_INLINE void axpy( int n, float alpha, const float* x,
105  int incX, float* y, int incY )
106 {
107  cblas_saxpy( n, alpha, x, incX, y, incY );
108 }
109 #endif
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
114 #if BLAZE_BLAS_MODE
115 
130 BLAZE_ALWAYS_INLINE void axpy( int n, double alpha, const double* x,
131  int incX, double* y, int incY )
132 {
133  cblas_daxpy( n, alpha, x, incX, y, incY );
134 }
135 #endif
136 //*************************************************************************************************
137 
138 
139 //*************************************************************************************************
140 #if BLAZE_BLAS_MODE
141 
156 BLAZE_ALWAYS_INLINE void axpy( int n, complex<float> alpha, const complex<float>* x,
157  int incX, complex<float>* y, int incY )
158 {
159  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
160 
161  cblas_caxpy( n, reinterpret_cast<const float*>( &alpha ),
162  reinterpret_cast<const float*>( x ), incX, reinterpret_cast<float*>( y ), incY );
163 }
164 #endif
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
169 #if BLAZE_BLAS_MODE
170 
185 BLAZE_ALWAYS_INLINE void axpy( int n, complex<double> alpha, const complex<double>* x,
186  int incX, complex<double>* y, int incY )
187 {
188  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
189 
190  cblas_zaxpy( n, reinterpret_cast<const double*>( &alpha ),
191  reinterpret_cast<const double*>( x ), incX, reinterpret_cast<double*>( y ), incY );
192 }
193 #endif
194 //*************************************************************************************************
195 
196 
197 //*************************************************************************************************
198 #if BLAZE_BLAS_MODE
199 
212 template< typename VT1, bool TF1, typename VT2, bool TF2, typename ST >
213 void axpy( DenseVector<VT1,TF1>& y, const DenseVector<VT2,TF2>& x, ST alpha )
214 {
217 
220 
221  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<VT1> );
222  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<VT2> );
223 
224  const int n( numeric_cast<int>( (~x).size() ) );
225 
226  axpy( n, alpha, (~x).data(), 1, (~y).data(), 1 );
227 }
228 #endif
229 //*************************************************************************************************
230 
231 } // namespace blaze
232 
233 #endif
Constraint on the data type.
Header file for auxiliary alias declarations.
#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:61
#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:61
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:170
#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:81
Header file for the DenseVector base class.
Cast operators for numeric types.
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
Constraint on the data type.
System settings for the BLAS mode.
Constraint on the data type.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#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:61
Header file for the complex data type.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
System settings for the inline keywords.