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 <boost/cast.hpp>
44 #include <blaze/math/Aliases.h>
52 #include <blaze/system/BLAS.h>
53 #include <blaze/system/Inline.h>
54 #include <blaze/util/Assert.h>
55 #include <blaze/util/Complex.h>
56 
57 
58 namespace blaze {
59 
60 //=================================================================================================
61 //
62 // BLAS WRAPPER FUNCTIONS (TRSM)
63 //
64 //=================================================================================================
65 
66 //*************************************************************************************************
69 #if BLAZE_BLAS_MODE
70 
71 BLAZE_ALWAYS_INLINE void trsm( 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 trsm( 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 trsm( 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 trsm( 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 MT, bool SO, typename VT, bool TF, typename ST >
90 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b,
91  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha );
92 
93 template< typename MT1, bool SO1, typename MT2, bool SO2, typename ST >
94 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
95  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha );
96 
97 #endif
98 
99 //*************************************************************************************************
100 
101 
102 //*************************************************************************************************
103 #if BLAZE_BLAS_MODE
104 
126 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
127  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
128  float alpha, const float* A, int lda, float* B, int ldb )
129 {
130  cblas_strsm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
131 }
132 #endif
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
137 #if BLAZE_BLAS_MODE
138 
160 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
161  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
162  double alpha, const double* A, int lda, double* B, int ldb )
163 {
164  cblas_dtrsm( order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb );
165 }
166 #endif
167 //*************************************************************************************************
168 
169 
170 //*************************************************************************************************
171 #if BLAZE_BLAS_MODE
172 
194 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
195  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
196  complex<float> alpha, const complex<float>* A, int lda,
197  complex<float>* B, int ldb )
198 {
199  cblas_ctrsm( order, side, uplo, transA, diag, m, n, &alpha, A, lda, B, ldb );
200 }
201 #endif
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
206 #if BLAZE_BLAS_MODE
207 
229 BLAZE_ALWAYS_INLINE void trsm( CBLAS_ORDER order, CBLAS_SIDE side, CBLAS_UPLO uplo,
230  CBLAS_TRANSPOSE transA, CBLAS_DIAG diag, int m, int n,
231  complex<double> alpha, const complex<double>* A, int lda,
232  complex<double>* B, int ldb )
233 {
234  cblas_ztrsm( order, side, uplo, transA, diag, m, n, &alpha, A, lda, B, ldb );
235 }
236 #endif
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
241 #if BLAZE_BLAS_MODE
242 
260 template< typename MT // Type of the system matrix
261  , bool SO // Storage order of the system matrix
262  , typename VT // Type of the right-hand side matrix
263  , bool TF // Storage order of the right-hand side matrix
264  , typename ST > // Type of the scalar factor
265 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& b,
266  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha )
267 {
268  using boost::numeric_cast;
269 
272 
275 
278 
279  BLAZE_INTERNAL_ASSERT( (~A).rows() == (~A).columns(), "Non-square triangular matrix detected" );
280  BLAZE_INTERNAL_ASSERT( side == CblasLeft || side == CblasRight, "Invalid side argument detected" );
281  BLAZE_INTERNAL_ASSERT( uplo == CblasLower || uplo == CblasUpper, "Invalid uplo argument detected" );
282 
283  const int m ( ( side == CblasLeft )?( numeric_cast<int>( (~b).size() ) ):( 1 ) );
284  const int n ( ( side == CblasRight )?( numeric_cast<int>( (~b).size() ) ):( 1 ) );
285  const int lda( numeric_cast<int>( (~A).spacing() ) );
286  const int ldb( ( IsRowMajorMatrix<MT>::value )?( n ):( m ) );
287 
288  trsm( ( IsRowMajorMatrix<MT>::value )?( CblasRowMajor ):( CblasColMajor ),
289  side,
290  uplo,
291  CblasNoTrans,
292  CblasNonUnit,
293  m, n, alpha, (~A).data(), lda, (~b).data(), ldb );
294 }
295 #endif
296 //*************************************************************************************************
297 
298 
299 //*************************************************************************************************
300 #if BLAZE_BLAS_MODE
301 
319 template< typename MT1 // Type of the system matrix
320  , bool SO1 // Storage order of the system matrix
321  , typename MT2 // Type of the right-hand side matrix
322  , bool SO2 // Storage order of the right-hand side matrix
323  , typename ST > // Type of the scalar factor
324 BLAZE_ALWAYS_INLINE void trsm( const DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
325  CBLAS_SIDE side, CBLAS_UPLO uplo, ST alpha )
326 {
327  using boost::numeric_cast;
328 
331 
334 
337 
338  BLAZE_INTERNAL_ASSERT( (~A).rows() == (~A).columns(), "Non-square triangular matrix detected" );
339  BLAZE_INTERNAL_ASSERT( side == CblasLeft || side == CblasRight, "Invalid side argument detected" );
340  BLAZE_INTERNAL_ASSERT( uplo == CblasLower || uplo == CblasUpper, "Invalid uplo argument detected" );
341 
342  const int m ( numeric_cast<int>( (~B).rows() ) );
343  const int n ( numeric_cast<int>( (~B).columns() ) );
344  const int lda( numeric_cast<int>( (~A).spacing() ) );
345  const int ldb( numeric_cast<int>( (~B).spacing() ) );
346 
347  trsm( ( IsRowMajorMatrix<MT2>::value )?( CblasRowMajor ):( CblasColMajor ),
348  side,
349  ( SO1 == SO2 )?( uplo ):( ( uplo == CblasLower )?( CblasUpper ):( CblasLower ) ),
350  ( SO1 == SO2 )?( CblasNoTrans ):( CblasTrans ),
351  CblasNonUnit,
352  m, n, alpha, (~A).data(), lda, (~B).data(), ldb );
353 }
354 #endif
355 //*************************************************************************************************
356 
357 } // namespace blaze
358 
359 #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
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
#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.
constexpr bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
Constraint on the data type.
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.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
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
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
Header file for the IsRowMajorMatrix type trait.
Header file for the complex data type.
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, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101