Blaze  3.6
trmm.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_BLAS_TRMM_H_
36 #define _BLAZE_MATH_BLAS_TRMM_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/system/BLAS.h>
51 #include <blaze/system/Inline.h>
52 #include <blaze/util/Assert.h>
53 #include <blaze/util/Complex.h>
54 #include <blaze/util/NumericCast.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // BLAS WRAPPER FUNCTIONS (TRMM)
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
69 #if BLAZE_BLAS_MODE
70 
71 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
72  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
73  float alpha, const float* A, int lda, float* B, int ldb );
74 
75 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
76  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
77  double alpha, const double* A, int lda, double* B, int ldb );
78 
79 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
80  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
81  complex<float> alpha, const complex<float>* A, int lda,
82  complex<float>* B, int ldb );
83 
84 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
85  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
86  complex<double> alpha, const complex<double>* A, int lda,
87  complex<double>* B, int ldb );
88 
89 template< typename MT1, bool SO1, typename MT2, bool SO2, typename ST >
90 BLAZE_ALWAYS_INLINE void trmm( DenseMatrix<MT1,SO1>& B, const DenseMatrix<MT2,SO2>& A,
91  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha );
92 
93 #endif
94 
95 //*************************************************************************************************
96 
97 
98 //*************************************************************************************************
99 #if BLAZE_BLAS_MODE
100 
121 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
122  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
123  float alpha, const float* A, int lda, float* B, int ldb )
124 {
125  cblas_strmm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
126 }
127 #endif
128 //*************************************************************************************************
129 
130 
131 //*************************************************************************************************
132 #if BLAZE_BLAS_MODE
133 
154 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
155  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
156  double alpha, const double* A, int lda, double* B, int ldb )
157 {
158  cblas_dtrmm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
159 }
160 #endif
161 //*************************************************************************************************
162 
163 
164 //*************************************************************************************************
165 #if BLAZE_BLAS_MODE
166 
187 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
188  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
189  complex<float> alpha, const complex<float>* A, int lda,
190  complex<float>* B, int ldb )
191 {
192  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
193 
194  cblas_ctrmm( order, side, uplo, transA, diag, m, n, reinterpret_cast<const float*>( &alpha ),
195  reinterpret_cast<const float*>( A ), lda, reinterpret_cast<float*>( B ), ldb );
196 }
197 #endif
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
202 #if BLAZE_BLAS_MODE
203 
224 BLAZE_ALWAYS_INLINE void trmm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
225  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
226  complex<double> alpha, const complex<double>* A, int lda,
227  complex<double>* B, int ldb )
228 {
229  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
230 
231  cblas_ztrmm( order, side, uplo, transA, diag, m, n, reinterpret_cast<const double*>( &alpha ),
232  reinterpret_cast<const double*>( A ), lda, reinterpret_cast<double*>( B ), ldb );
233 }
234 #endif
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
239 #if BLAZE_BLAS_MODE
240 
257 template< typename MT1 // Type of the left-hand side target matrix
258  , bool SO1 // Storage order of the left-hand side target matrix
259  , typename MT2 // Type of the left-hand side matrix operand
260  , bool SO2 // Storage order of the left-hand side matrix operand
261  , typename ST > // Type of the scalar factor
262 BLAZE_ALWAYS_INLINE void trmm( DenseMatrix<MT1,SO1>& B, const DenseMatrix<MT2,SO2>& A,
263  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha )
264 {
267 
270 
271  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<MT1> );
272  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<MT2> );
273 
274  BLAZE_INTERNAL_ASSERT( (~A).rows() == (~A).columns(), "Non-square triangular matrix detected" );
275  BLAZE_INTERNAL_ASSERT( side == CblasLeft || side == CblasRight, "Invalid side argument detected" );
276  BLAZE_INTERNAL_ASSERT( uplo == CblasLower || uplo == CblasUpper, "Invalid uplo argument detected" );
277 
278  const int m ( numeric_cast<int>( (~B).rows() ) );
279  const int n ( numeric_cast<int>( (~B).columns() ) );
280  const int lda( numeric_cast<int>( (~A).spacing() ) );
281  const int ldb( numeric_cast<int>( (~B).spacing() ) );
282 
283  trmm( ( IsRowMajorMatrix_v<MT1> )?( CblasRowMajor ):( CblasColMajor ),
284  side,
285  ( SO1 == SO2 )?( uplo ):( ( uplo == CblasLower )?( CblasUpper ):( CblasLower ) ),
286  ( SO1 == SO2 )?( CblasNoTrans ):( CblasTrans ),
287  CblasNonUnit,
288  m, n, alpha, (~A).data(), lda, (~B).data(), ldb );
289 }
290 #endif
291 //*************************************************************************************************
292 
293 } // namespace blaze
294 
295 #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
Cast operators for numeric types.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:253
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.
Header file for the DenseMatrix base class.
Constraint on the data type.
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:61
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the IsRowMajorMatrix type trait.
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.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101