Blaze  3.6
trsm.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_BLAS_TRSM_H_
36 #define _BLAZE_MATH_BLAS_TRSM_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
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 #include <blaze/util/NumericCast.h>
57 
58 
59 namespace blaze {
60 
61 //=================================================================================================
62 //
63 // BLAS WRAPPER FUNCTIONS (TRSM)
64 //
65 //=================================================================================================
66 
67 //*************************************************************************************************
70 #if BLAZE_BLAS_MODE
71 
72 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
73  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
74  float alpha, const float* A, int lda, float* B, int ldb );
75 
76 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
77  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
78  double alpha, const double* A, int lda, double* B, int ldb );
79 
80 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
81  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
82  complex<float> alpha, const complex<float>* A, int lda,
83  complex<float>* B, int ldb );
84 
85 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
86  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
87  complex<double> alpha, const complex<double>* A, int lda,
88  complex<double>* B, int ldb );
89 
90 template< typename MT, bool SO, typename VT, bool TF, typename ST >
91 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b,
92  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha );
93 
94 template< typename MT1, bool SO1, typename MT2, bool SO2, typename ST >
95 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
96  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha );
97 
98 #endif
99 
100 //*************************************************************************************************
101 
102 
103 //*************************************************************************************************
104 #if BLAZE_BLAS_MODE
105 
127 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
128  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
129  float alpha, const float* A, int lda, float* B, int ldb )
130 {
131  cblas_strsm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
132 }
133 #endif
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
138 #if BLAZE_BLAS_MODE
139 
161 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
162  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
163  double alpha, const double* A, int lda, double* B, int ldb )
164 {
165  cblas_dtrsm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
166 }
167 #endif
168 //*************************************************************************************************
169 
170 
171 //*************************************************************************************************
172 #if BLAZE_BLAS_MODE
173 
195 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
196  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
197  complex<float> alpha, const complex<float>* A, int lda,
198  complex<float>* B, int ldb )
199 {
200  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
201 
202  cblas_ctrsm( order, side, uplo, transA, diag, m, n, reinterpret_cast<const float*>( &alpha ),
203  reinterpret_cast<const float*>( A ), lda, reinterpret_cast<float*>( B ), ldb );
204 }
205 #endif
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
210 #if BLAZE_BLAS_MODE
211 
233 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
234  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
235  complex<double> alpha, const complex<double>* A, int lda,
236  complex<double>* B, int ldb )
237 {
238  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
239 
240  cblas_ztrsm( order, side, uplo, transA, diag, m, n, reinterpret_cast<const double*>( &alpha ),
241  reinterpret_cast<const double*>( A ), lda, reinterpret_cast<double*>( B ), ldb );
242 }
243 #endif
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
248 #if BLAZE_BLAS_MODE
249 
267 template< typename MT // Type of the system matrix
268  , bool SO // Storage order of the system matrix
269  , typename VT // Type of the right-hand side matrix
270  , bool TF // Storage order of the right-hand side matrix
271  , typename ST > // Type of the scalar factor
272 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b,
273  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha )
274 {
277 
280 
283 
284  BLAZE_INTERNAL_ASSERT( (~A).rows() == (~A).columns(), "Non-square triangular matrix detected" );
285  BLAZE_INTERNAL_ASSERT( side == CblasLeft || side == CblasRight, "Invalid side argument detected" );
286  BLAZE_INTERNAL_ASSERT( uplo == CblasLower || uplo == CblasUpper, "Invalid uplo argument detected" );
287 
288  const int m ( ( side == CblasLeft )?( numeric_cast<int>( (~b).size() ) ):( 1 ) );
289  const int n ( ( side == CblasRight )?( numeric_cast<int>( (~b).size() ) ):( 1 ) );
290  const int lda( numeric_cast<int>( (~A).spacing() ) );
291  const int ldb( ( IsRowMajorMatrix_v<MT> )?( n ):( m ) );
292 
293  trsm( ( IsRowMajorMatrix_v<MT> )?( CblasRowMajor ):( CblasColMajor ),
294  side,
295  uplo,
296  CblasNoTrans,
297  CblasNonUnit,
298  m, n, alpha, (~A).data(), lda, (~b).data(), ldb );
299 }
300 #endif
301 //*************************************************************************************************
302 
303 
304 //*************************************************************************************************
305 #if BLAZE_BLAS_MODE
306 
324 template< typename MT1 // Type of the system matrix
325  , bool SO1 // Storage order of the system matrix
326  , typename MT2 // Type of the right-hand side matrix
327  , bool SO2 // Storage order of the right-hand side matrix
328  , typename ST > // Type of the scalar factor
329 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
330  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha )
331 {
334 
337 
338  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<MT1> );
339  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<MT2> );
340 
341  BLAZE_INTERNAL_ASSERT( (~A).rows() == (~A).columns(), "Non-square triangular matrix detected" );
342  BLAZE_INTERNAL_ASSERT( side == CblasLeft || side == CblasRight, "Invalid side argument detected" );
343  BLAZE_INTERNAL_ASSERT( uplo == CblasLower || uplo == CblasUpper, "Invalid uplo argument detected" );
344 
345  const int m ( numeric_cast<int>( (~B).rows() ) );
346  const int n ( numeric_cast<int>( (~B).columns() ) );
347  const int lda( numeric_cast<int>( (~A).spacing() ) );
348  const int ldb( numeric_cast<int>( (~B).spacing() ) );
349 
350  trsm( ( IsRowMajorMatrix_v<MT2> )?( CblasRowMajor ):( CblasColMajor ),
351  side,
352  ( SO1 == SO2 )?( uplo ):( ( uplo == CblasLower )?( CblasUpper ):( CblasLower ) ),
353  ( SO1 == SO2 )?( CblasNoTrans ):( CblasTrans ),
354  CblasNonUnit,
355  m, n, alpha, (~A).data(), lda, (~B).data(), ldb );
356 }
357 #endif
358 //*************************************************************************************************
359 
360 } // namespace blaze
361 
362 #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.
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.
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
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