Blaze 3.9
VecScalarMultExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_VECSCALARMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_VECSCALARMULTEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
48#include <blaze/util/Assert.h>
49#include <blaze/util/EnableIf.h>
51
52
53namespace blaze {
54
55//=================================================================================================
56//
57// CLASS DEFINITION
58//
59//=================================================================================================
60
61//*************************************************************************************************
73template< typename VT > // Vector base type of the expression
75 : public MultExpr<VT>
76{};
77//*************************************************************************************************
78
79
80
81
82//=================================================================================================
83//
84// GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
85//
86//=================================================================================================
87
88//*************************************************************************************************
100template< typename VT > // Vector base type of the expression
101inline decltype(auto) operator-( const VecScalarMultExpr<VT>& vec )
102{
104
105 return (*vec).leftOperand() * ( -(*vec).rightOperand() );
106}
108//*************************************************************************************************
109
110
111
112
113//=================================================================================================
114//
115// GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
116//
117//=================================================================================================
118
119//*************************************************************************************************
132template< typename VT // Vector base type of the expression
133 , typename ST // Type of the right-hand side scalar
134 , EnableIf_t< IsScalar_v<ST> >* = nullptr >
135inline decltype(auto) operator*( const VecScalarMultExpr<VT>& vec, ST scalar )
136{
138
139 return (*vec).leftOperand() * ( (*vec).rightOperand() * scalar );
140}
142//*************************************************************************************************
143
144
145//*************************************************************************************************
158template< typename ST // Type of the left-hand side scalar
159 , typename VT // Vector base type of the expression
160 , EnableIf_t< IsScalar_v<ST> >* = nullptr >
161inline decltype(auto) operator*( ST scalar, const VecScalarMultExpr<VT>& vec )
162{
164
165 return (*vec).leftOperand() * ( scalar * (*vec).rightOperand() );
166}
168//*************************************************************************************************
169
170
171//*************************************************************************************************
184template< typename VT // Vector base type of the expression
185 , typename ST // Type of the right-hand side scalar
186 , EnableIf_t< IsScalar_v<ST> &&
187 ( IsInvertible_v<ST> ||
188 IsInvertible_v< RightOperand_t< VectorType_t<VT> > > ) >* = nullptr >
189inline decltype(auto) operator/( const VecScalarMultExpr<VT>& vec, ST scalar )
190{
192
193 BLAZE_USER_ASSERT( scalar != ST(0), "Division by zero detected" );
194
195 return (*vec).leftOperand() * ( (*vec).rightOperand() / scalar );
196}
198//*************************************************************************************************
199
200
201//*************************************************************************************************
215template< typename VT1 // Vector base type of the left-hand side expression
216 , typename VT2 // Type of the right-hand side dense vector
217 , bool TF > // Transpose flag of the right-hand side dense vector
218inline decltype(auto)
219 operator*( const VecScalarMultExpr<VT1>& lhs, const DenseVector<VT2,TF>& rhs )
220{
222
223 return ( (*lhs).leftOperand() * (*rhs) ) * (*lhs).rightOperand();
224}
226//*************************************************************************************************
227
228
229//*************************************************************************************************
243template< typename VT1 // Type of the left-hand side dense vector
244 , bool TF // Transpose flag of the left-hand side dense vector
245 , typename VT2 > // Vector base type of the right-hand side expression
246inline decltype(auto)
247 operator*( const DenseVector<VT1,TF>& lhs, const VecScalarMultExpr<VT2>& rhs )
248{
250
251 return ( (*lhs) * (*rhs).leftOperand() ) * (*rhs).rightOperand();
252}
254//*************************************************************************************************
255
256
257//*************************************************************************************************
271template< typename VT1 // Vector base type of the left-hand side expression
272 , typename VT2 // Type of the right-hand side sparse vector
273 , bool TF > // Transpose flag of the left-hand side sparse vector
274inline decltype(auto)
275 operator*( const VecScalarMultExpr<VT1>& lhs, const SparseVector<VT2,TF>& rhs )
276{
278
279 return ( (*lhs).leftOperand() * (*rhs) ) * (*lhs).rightOperand();
280}
282//*************************************************************************************************
283
284
285//*************************************************************************************************
299template< typename VT1 // Type of the left-hand side sparse vector
300 , bool TF // Transpose flag of the left-hand side sparse vector
301 , typename VT2 > // Vector base type of the right-hand side expression
302inline decltype(auto)
303 operator*( const SparseVector<VT1,TF>& lhs, const VecScalarMultExpr<VT2>& rhs )
304{
306
307 return ( (*lhs) * (*rhs).leftOperand() ) * (*rhs).rightOperand();
308}
310//*************************************************************************************************
311
312
313//*************************************************************************************************
327template< typename VT1 // Vector base type of the left-hand side expression
328 , typename VT2 > // Vector base type of the right-hand side expression
329inline decltype(auto)
330 operator*( const VecScalarMultExpr<VT1>& lhs, const VecScalarMultExpr<VT2>& rhs )
331{
333
334 return ( (*lhs).leftOperand() * (*rhs).leftOperand() ) * ( (*lhs).rightOperand() * (*rhs).rightOperand() );
335}
337//*************************************************************************************************
338
339
340//*************************************************************************************************
354template< typename MT // Type of the left-hand side dense matrix
355 , bool SO // Storage order of the left-hand side dense matrix
356 , typename VT > // Vector base type of the right-hand side expression
357inline decltype(auto)
358 operator*( const DenseMatrix<MT,SO>& mat, const VecScalarMultExpr<VT>& vec )
359{
361
362 return ( (*mat) * (*vec).leftOperand() ) * (*vec).rightOperand();
363}
365//*************************************************************************************************
366
367
368//*************************************************************************************************
382template< typename VT // Vector base type of the left-hand side expression
383 , typename MT // Type of the right-hand side dense matrix
384 , bool SO > // Storage order of the right-hand side dense matrix
385inline decltype(auto)
386 operator*( const VecScalarMultExpr<VT>& vec, const DenseMatrix<MT,SO>& mat )
387{
389
390 return ( (*vec).leftOperand() * (*mat) ) * (*vec).rightOperand();
391}
393//*************************************************************************************************
394
395
396//*************************************************************************************************
410template< typename MT // Type of the left-hand side sparse matrix
411 , bool SO // Storage order of the left-hand side sparse matrix
412 , typename VT > // Vector base type of the right-hand side expression
413inline decltype(auto)
414 operator*( const SparseMatrix<MT,SO>& mat, const VecScalarMultExpr<VT>& vec )
415{
417
418 return ( (*mat) * (*vec).leftOperand() ) * (*vec).rightOperand();
419}
421//*************************************************************************************************
422
423
424//*************************************************************************************************
438template< typename VT // Vector base type of the left-hand side expression
439 , typename MT // Type of the right-hand side sparse matrix
440 , bool SO > // Storage order of the right-hand side sparse matrix
441inline decltype(auto)
442 operator*( const VecScalarMultExpr<VT>& vec, const SparseMatrix<MT,SO>& mat )
443{
445
446 return ( (*vec).leftOperand() * (*mat) ) * (*vec).rightOperand();
447}
449//*************************************************************************************************
450
451
452
453
454//=================================================================================================
455//
456// GLOBAL RESTRUCTURING FUNCTIONS
457//
458//=================================================================================================
459
460//*************************************************************************************************
472template< typename VT > // Vector base type of the expression
473inline decltype(auto) trans( const VecScalarMultExpr<VT>& vector )
474{
476
477 return trans( (*vector).leftOperand() ) * (*vector).rightOperand();
478}
480//*************************************************************************************************
481
482
483//*************************************************************************************************
495template< typename VT > // Vector base type of the expression
496inline decltype(auto) conj( const VecScalarMultExpr<VT>& vector )
497{
499
500 return conj( (*vector).leftOperand() ) * (*vector).rightOperand();
501}
503//*************************************************************************************************
504
505} // namespace blaze
506
507#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 all forward declarations for expression class templates.
Base class for all multiplication expression templates.
Definition: MultExpr.h:70
Base class for all vector/scalar multiplication expression templates.
Definition: VecScalarMultExpr.h:76