Blaze  3.6
dotu.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_BLAS_DOTU_H_
36 #define _BLAZE_MATH_BLAS_DOTU_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
48 #include <blaze/system/BLAS.h>
49 #include <blaze/system/Inline.h>
50 #include <blaze/util/Assert.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 (DOTU)
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
67 #if BLAZE_BLAS_MODE
68 
69 BLAZE_ALWAYS_INLINE float dotu( int n, const float* x, int incX, const float* y, int incY );
70 
71 BLAZE_ALWAYS_INLINE double dotu( int n, const double* x, int incX, const double* y, int incY );
72 
73 BLAZE_ALWAYS_INLINE complex<float> dotu( int n, const complex<float>* x, int incX,
74  const complex<float>* y, int incY );
75 
76 BLAZE_ALWAYS_INLINE complex<double> dotu( int n, const complex<double>* x, int incX,
77  const complex<double>* y, int incY );
78 
79 template< typename VT1, bool TF1, typename VT2, bool TF2 >
80 BLAZE_ALWAYS_INLINE ElementType_t<VT1> dotu( const DenseVector<VT1,TF1>& x, const DenseVector<VT2,TF2>& y );
81 
82 #endif
83 
84 //*************************************************************************************************
85 
86 
87 //*************************************************************************************************
88 #if BLAZE_BLAS_MODE
89 
103 BLAZE_ALWAYS_INLINE float dotu( int n, const float* x, int incX, const float* y, int incY )
104 {
105  return cblas_sdot( n, x, incX, y, incY );
106 }
107 #endif
108 //*************************************************************************************************
109 
110 
111 //*************************************************************************************************
112 #if BLAZE_BLAS_MODE
113 
127 BLAZE_ALWAYS_INLINE double dotu( int n, const double* x, int incX, const double* y, int incY )
128 {
129  return cblas_ddot( n, x, incX, y, incY );
130 }
131 #endif
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
136 #if BLAZE_BLAS_MODE
137 
151 BLAZE_ALWAYS_INLINE complex<float> dotu( int n, const complex<float>* x, int incX,
152  const complex<float>* y, int incY )
153 {
154  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
155 
156  complex<float> tmp;
157 
158 #ifdef OPENBLAS_VERSION
159  cblas_cdotu_sub( n, reinterpret_cast<const float*>( x ), incX,
160  reinterpret_cast<const float*>( y ), incY,
161  reinterpret_cast<openblas_complex_float*>( &tmp ) );
162 #else
163  cblas_cdotu_sub( n, reinterpret_cast<const float*>( x ), incX,
164  reinterpret_cast<const float*>( y ), incY, &tmp );
165 #endif
166 
167  return tmp;
168 }
169 #endif
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
174 #if BLAZE_BLAS_MODE
175 
189 BLAZE_ALWAYS_INLINE complex<double> dotu( int n, const complex<double>* x, int incX,
190  const complex<double>* y, int incY )
191 {
192  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
193 
194  complex<double> tmp;
195 
196 #ifdef OPENBLAS_VERSION
197  cblas_zdotu_sub( n, reinterpret_cast<const double*>( x ), incX,
198  reinterpret_cast<const double*>( y ), incY,
199  reinterpret_cast<openblas_complex_double*>( &tmp ) );
200 #else
201  cblas_zdotu_sub( n, reinterpret_cast<const double*>( x ), incX,
202  reinterpret_cast<const double*>( y ), incY, &tmp );
203 #endif
204 
205  return tmp;
206 }
207 #endif
208 //*************************************************************************************************
209 
210 
211 //*************************************************************************************************
212 #if BLAZE_BLAS_MODE
213 
225 template< typename VT1, bool TF1, typename VT2, bool TF2 >
226 ElementType_t<VT1> dotu( const DenseVector<VT1,TF1>& x, const DenseVector<VT2,TF2>& y )
227 {
230 
233 
234  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<VT1> );
235  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<VT2> );
236 
237  const int n( numeric_cast<int>( (~x).size() ) );
238 
239  return dotu( n, (~x).data(), 1, (~y).data(), 1 );
240 }
241 #endif
242 //*************************************************************************************************
243 
244 } // namespace blaze
245 
246 #endif
Constraint on the data type.
Header file for auxiliary alias declarations.
#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.
System settings for the BLAS mode.
Header file for run time assertion macros.
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.