Blaze 3.9
MatScalarMultExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_MATSCALARMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_MATSCALARMULTEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
49#include <blaze/util/Assert.h>
50#include <blaze/util/EnableIf.h>
52
53
54namespace blaze {
55
56//=================================================================================================
57//
58// CLASS DEFINITION
59//
60//=================================================================================================
61
62//*************************************************************************************************
74template< typename MT > // Matrix base type of the expression
76 : public MultExpr<MT>
77{};
78//*************************************************************************************************
79
80
81
82
83//=================================================================================================
84//
85// GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
86//
87//=================================================================================================
88
89//*************************************************************************************************
101template< typename MT > // Matrix base type of the expression
102inline decltype(auto) operator-( const MatScalarMultExpr<MT>& mat )
103{
105
106 return (*mat).leftOperand() * ( -(*mat).rightOperand() );
107}
109//*************************************************************************************************
110
111
112
113
114//=================================================================================================
115//
116// GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
117//
118//=================================================================================================
119
120//*************************************************************************************************
133template< typename MT // Matrix base type of the expression
134 , typename ST // Type of the right-hand side scalar
135 , EnableIf_t< IsScalar_v<ST> >* = nullptr >
136inline decltype(auto) operator*( const MatScalarMultExpr<MT>& mat, ST scalar )
137{
139
140 return (*mat).leftOperand() * ( (*mat).rightOperand() * scalar );
141}
143//*************************************************************************************************
144
145
146//*************************************************************************************************
159template< typename ST // Type of the left-hand side scalar
160 , typename MT // Matrix base type of the expression
161 , EnableIf_t< IsScalar_v<ST> >* = nullptr >
162inline decltype(auto) operator*( ST scalar, const MatScalarMultExpr<MT>& mat )
163{
165
166 return (*mat).leftOperand() * ( scalar * (*mat).rightOperand() );
167}
169//*************************************************************************************************
170
171
172//*************************************************************************************************
185template< typename MT // Matrix base type of the expression
186 , typename ST // Type of the right-hand side scalar
187 , EnableIf_t< IsScalar_v<ST> &&
188 ( IsInvertible_v<ST> ||
189 IsInvertible_v< RightOperand_t< MatrixType_t<MT> > > ) >* = nullptr >
190inline decltype(auto) operator/( const MatScalarMultExpr<MT>& mat, ST scalar )
191{
193
194 BLAZE_USER_ASSERT( scalar != ST(0), "Division by zero detected" );
195
196 return (*mat).leftOperand() * ( (*mat).rightOperand() / scalar );
197}
199//*************************************************************************************************
200
201
202//*************************************************************************************************
216template< typename MT // Matrix base type of the left-hand side expression
217 , typename VT > // Type of the right-hand side dense vector
218inline decltype(auto)
219 operator*( const MatScalarMultExpr<MT>& mat, const DenseVector<VT,false>& vec )
220{
222
223 return ( (*mat).leftOperand() * (*vec) ) * (*mat).rightOperand();
224}
226//*************************************************************************************************
227
228
229//*************************************************************************************************
243template< typename VT // Type of the left-hand side dense vector
244 , typename MT > // Matrix base type of the right-hand side expression
245inline decltype(auto)
246 operator*( const DenseVector<VT,true>& vec, const MatScalarMultExpr<MT>& mat )
247{
249
250 return ( (*vec) * (*mat).leftOperand() ) * (*mat).rightOperand();
251}
253//*************************************************************************************************
254
255
256//*************************************************************************************************
270template< typename MT // Matrix base type of the left-hand side expression
271 , typename VT > // Type of the right-hand side sparse vector
272inline decltype(auto)
273 operator*( const MatScalarMultExpr<MT>& mat, const SparseVector<VT,false>& vec )
274{
276
277 return ( (*mat).leftOperand() * (*vec) ) * (*mat).rightOperand();
278}
280//*************************************************************************************************
281
282
283//*************************************************************************************************
297template< typename VT // Type of the left-hand side sparse vector
298 , typename MT > // Matrix base type of the right-hand side expression
299inline decltype(auto)
300 operator*( const SparseVector<VT,true>& vec, const MatScalarMultExpr<MT>& mat )
301{
303
304 return ( (*vec) * (*mat).leftOperand() ) * (*mat).rightOperand();
305}
307//*************************************************************************************************
308
309
310//*************************************************************************************************
325template< typename MT // Matrix base type of the left-hand side expression
326 , typename VT > // Vector base type of the right-hand side expression
327inline decltype(auto)
328 operator*( const MatScalarMultExpr<MT>& mat, const VecScalarMultExpr<VT>& vec )
329{
331
332 return ( (*mat).leftOperand() * (*vec).leftOperand() ) * ( (*mat).rightOperand() * (*vec).rightOperand() );
333}
335//*************************************************************************************************
336
337
338//*************************************************************************************************
353template< typename VT // Vector base type of the left-hand side expression
354 , typename MT > // Matrix base type of the right-hand side expression
355inline decltype(auto)
356 operator*( const VecScalarMultExpr<VT>& vec, const MatScalarMultExpr<MT>& mat )
357{
359
360 return ( (*vec).leftOperand() * (*mat).leftOperand() ) * ( (*vec).rightOperand() * (*mat).rightOperand() );
361}
363//*************************************************************************************************
364
365
366//*************************************************************************************************
380template< typename MT1 // Matrix base type of the left-hand side expression
381 , typename MT2 // Type of the right-hand side dense matrix
382 , bool SO > // Storage order of the right-hand side dense matrix
383inline decltype(auto)
384 operator*( const MatScalarMultExpr<MT1>& lhs, const DenseMatrix<MT2,SO>& rhs )
385{
387
388 return ( (*lhs).leftOperand() * (*rhs) ) * (*lhs).rightOperand();
389}
391//*************************************************************************************************
392
393
394//*************************************************************************************************
408template< typename MT1 // Type of the left-hand side dense matrix
409 , bool SO // Storage order of the left-hand side dense matrix
410 , typename MT2 > // Matrix base type of the right-hand side expression
411inline decltype(auto)
412 operator*( const DenseMatrix<MT1,SO>& lhs, const MatScalarMultExpr<MT2>& rhs )
413{
415
416 return ( (*lhs) * (*rhs).leftOperand() ) * (*rhs).rightOperand();
417}
419//*************************************************************************************************
420
421
422//*************************************************************************************************
436template< typename MT1 // Matrix base type of the left-hand side expression
437 , typename MT2 // Type of the right-hand side sparse matrix
438 , bool SO > // Storage order of the right-hand side sparse matrix
439inline decltype(auto)
440 operator*( const MatScalarMultExpr<MT1>& lhs, const SparseMatrix<MT2,SO>& rhs )
441{
443
444 return ( (*lhs).leftOperand() * (*rhs) ) * (*lhs).rightOperand();
445}
447//*************************************************************************************************
448
449
450//*************************************************************************************************
464template< typename MT1 // Type of the left-hand side sparse matrix
465 , bool SO // Storage order of the left-hand side sparse matrix
466 , typename MT2 > // Matrix base type of the right-hand side expression
467inline decltype(auto)
468 operator*( const SparseMatrix<MT1,SO>& lhs, const MatScalarMultExpr<MT2>& rhs )
469{
471
472 return ( (*lhs) * (*rhs).leftOperand() ) * (*rhs).rightOperand();
473}
475//*************************************************************************************************
476
477
478//*************************************************************************************************
492template< typename MT1 // Matrix base type of the left-hand side expression
493 , typename MT2 > // Matrix base type of the right-hand side expression
494inline decltype(auto)
495 operator*( const MatScalarMultExpr<MT1>& lhs, const MatScalarMultExpr<MT2>& rhs )
496{
498
499 return ( (*lhs).leftOperand() * (*rhs).leftOperand() ) * ( (*lhs).rightOperand() * (*rhs).rightOperand() );
500}
502//*************************************************************************************************
503
504
505
506
507//=================================================================================================
508//
509// GLOBAL RESTRUCTURING FUNCTIONS
510//
511//=================================================================================================
512
513//*************************************************************************************************
525template< typename MT > // Matrix base type of the expression
526inline decltype(auto) trans( const MatScalarMultExpr<MT>& matrix )
527{
529
530 return trans( (*matrix).leftOperand() ) * (*matrix).rightOperand();
531}
533//*************************************************************************************************
534
535
536//*************************************************************************************************
548template< typename MT > // Matrix base type of the expression
549inline decltype(auto) conj( const MatScalarMultExpr<MT>& matrix )
550{
552
553 return conj( (*matrix).leftOperand() ) * (*matrix).rightOperand();
554}
556//*************************************************************************************************
557
558} // namespace blaze
559
560#endif
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the IsInvertible type trait.
Header file for the IsScalar type trait.
Header file for the MultExpr base class.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1464
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Base class for all matrix/scalar multiplication expression templates.
Definition: MatScalarMultExpr.h:77
Base class for all multiplication expression templates.
Definition: MultExpr.h:70