All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SVecScalarMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECSCALARMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
70 #include <blaze/util/Assert.h>
75 #include <blaze/util/EnableIf.h>
76 #include <blaze/util/InvalidType.h>
78 #include <blaze/util/SelectType.h>
79 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS SVECSCALARMULTEXPR
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
100 template< typename VT // Type of the left-hand side sparse vector
101  , typename ST // Type of the right-hand side scalar value
102  , bool TF > // Transpose flag
103 class SVecScalarMultExpr : public SparseVector< SVecScalarMultExpr<VT,ST,TF>, TF >
104  , private VecScalarMultExpr
105  , private Computation
106 {
107  private:
108  //**Type definitions****************************************************************************
109  typedef typename VT::ResultType RT;
110  typedef typename VT::ReturnType RN;
111  typedef typename VT::CompositeType CT;
112  //**********************************************************************************************
113 
114  //**Return type evaluation**********************************************************************
116 
121  enum { returnExpr = !IsTemporary<RN>::value };
122 
125  //**********************************************************************************************
126 
127  //**Evaluation strategy*************************************************************************
129 
135  enum { useAssign = RequiresEvaluation<VT>::value };
136 
138  template< typename VT2 >
140  struct UseAssign {
141  enum { value = useAssign };
142  };
144  //**********************************************************************************************
145 
146  public:
147  //**Type definitions****************************************************************************
152 
155 
158 
160  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type LeftOperand;
161 
163  typedef ST RightOperand;
164  //**********************************************************************************************
165 
166  //**Compilation flags***************************************************************************
168  enum { smpAssignable = 0 };
169  //**********************************************************************************************
170 
171  //**ConstIterator class definition**************************************************************
175  {
176  public:
177  //**Type definitions*************************************************************************
180 
183 
184  typedef std::forward_iterator_tag IteratorCategory;
185  typedef Element ValueType;
189 
190  // STL iterator requirements
196  //*******************************************************************************************
197 
198  //**Constructor******************************************************************************
201  inline ConstIterator( IteratorType vector, RightOperand scalar )
202  : vector_( vector ) // Iterator over the elements of the left-hand side sparse vector expression
203  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
204  {}
205  //*******************************************************************************************
206 
207  //**Prefix increment operator****************************************************************
213  ++vector_;
214  return *this;
215  }
216  //*******************************************************************************************
217 
218  //**Element access operator******************************************************************
223  inline const Element operator*() const {
224  return Element( vector_->value() * scalar_, vector_->index() );
225  }
226  //*******************************************************************************************
227 
228  //**Element access operator******************************************************************
233  inline const ConstIterator* operator->() const {
234  return this;
235  }
236  //*******************************************************************************************
237 
238  //**Value function***************************************************************************
243  inline ReturnType value() const {
244  return vector_->value() * scalar_;
245  }
246  //*******************************************************************************************
247 
248  //**Index function***************************************************************************
253  inline size_t index() const {
254  return vector_->index();
255  }
256  //*******************************************************************************************
257 
258  //**Equality operator************************************************************************
264  inline bool operator==( const ConstIterator& rhs ) const {
265  return vector_ == rhs.vector_;
266  }
267  //*******************************************************************************************
268 
269  //**Inequality operator**********************************************************************
275  inline bool operator!=( const ConstIterator& rhs ) const {
276  return vector_ != rhs.vector_;
277  }
278  //*******************************************************************************************
279 
280  //**Subtraction operator*********************************************************************
286  inline DifferenceType operator-( const ConstIterator& rhs ) const {
287  return vector_ - rhs.vector_;
288  }
289  //*******************************************************************************************
290 
291  private:
292  //**Member variables*************************************************************************
295  //*******************************************************************************************
296  };
297  //**********************************************************************************************
298 
299  //**Constructor*********************************************************************************
305  explicit inline SVecScalarMultExpr( const VT& vector, ST scalar )
306  : vector_( vector ) // Left-hand side sparse vector of the multiplication expression
307  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
308  {}
309  //**********************************************************************************************
310 
311  //**Subscript operator**************************************************************************
317  inline ReturnType operator[]( size_t index ) const {
318  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
319  return vector_[index] * scalar_;
320  }
321  //**********************************************************************************************
322 
323  //**Begin function******************************************************************************
328  inline ConstIterator begin() const {
329  return ConstIterator( vector_.begin(), scalar_ );
330  }
331  //**********************************************************************************************
332 
333  //**End function********************************************************************************
338  inline ConstIterator end() const {
339  return ConstIterator( vector_.end(), scalar_ );
340  }
341  //**********************************************************************************************
342 
343  //**Size function*******************************************************************************
348  inline size_t size() const {
349  return vector_.size();
350  }
351  //**********************************************************************************************
352 
353  //**NonZeros function***************************************************************************
358  inline size_t nonZeros() const {
359  return vector_.nonZeros();
360  }
361  //**********************************************************************************************
362 
363  //**Left operand access*************************************************************************
368  inline LeftOperand leftOperand() const {
369  return vector_;
370  }
371  //**********************************************************************************************
372 
373  //**Right operand access************************************************************************
378  inline RightOperand rightOperand() const {
379  return scalar_;
380  }
381  //**********************************************************************************************
382 
383  //**********************************************************************************************
389  template< typename T >
390  inline bool canAlias( const T* alias ) const {
391  return vector_.canAlias( alias );
392  }
393  //**********************************************************************************************
394 
395  //**********************************************************************************************
401  template< typename T >
402  inline bool isAliased( const T* alias ) const {
403  return vector_.isAliased( alias );
404  }
405  //**********************************************************************************************
406 
407  private:
408  //**Member variables****************************************************************************
411  //**********************************************************************************************
412 
413  //**Assignment to dense vectors*****************************************************************
427  template< typename VT2 > // Type of the target dense vector
428  friend inline typename EnableIf< UseAssign<VT2> >::Type
429  assign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
430  {
432 
433  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
434 
435  assign( ~lhs, rhs.vector_ );
436  (~lhs) *= rhs.scalar_;
437  }
439  //**********************************************************************************************
440 
441  //**Assignment to sparse vectors****************************************************************
455  template< typename VT2 > // Type of the target sparse vector
456  friend inline typename EnableIf< UseAssign<VT2> >::Type
458  {
460 
461  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
462 
463  assign( ~lhs, rhs.vector_ );
464  (~lhs) *= rhs.scalar_;
465  }
467  //**********************************************************************************************
468 
469  //**Addition assignment to dense vectors********************************************************
483  template< typename VT2 > // Type of the target dense vector
484  friend inline typename EnableIf< UseAssign<VT2> >::Type
485  addAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
486  {
488 
492 
493  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
494 
495  const ResultType tmp( rhs );
496  smpAddAssign( ~lhs, tmp );
497  }
499  //**********************************************************************************************
500 
501  //**Addition assignment to sparse vectors*******************************************************
502  // No special implementation for the addition assignment to sparse vectors.
503  //**********************************************************************************************
504 
505  //**Subtraction assignment to dense vectors*****************************************************
519  template< typename VT2 > // Type of the target dense vector
520  friend inline typename EnableIf< UseAssign<VT2> >::Type
521  subAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
522  {
524 
528 
529  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
530 
531  const ResultType tmp( rhs );
532  smpSubAssign( ~lhs, tmp );
533  }
535  //**********************************************************************************************
536 
537  //**Subtraction assignment to sparse vectors****************************************************
538  // No special implementation for the subtraction assignment to sparse vectors.
539  //**********************************************************************************************
540 
541  //**Multiplication assignment to dense vectors**************************************************
555  template< typename VT2 > // Type of the target dense vector
556  friend inline typename EnableIf< UseAssign<VT2> >::Type
557  multAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
558  {
560 
564 
565  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
566 
567  const ResultType tmp( rhs );
568  smpMultAssign( ~lhs, tmp );
569  }
571  //**********************************************************************************************
572 
573  //**Multiplication assignment to sparse vectors*************************************************
574  // No special implementation for the multiplication assignment to sparse vectors.
575  //**********************************************************************************************
576 
577  //**Compile time checks*************************************************************************
584  //**********************************************************************************************
585 };
586 //*************************************************************************************************
587 
588 
589 
590 
591 //=================================================================================================
592 //
593 // GLOBAL UNARY ARITHMETIC OPERATORS
594 //
595 //=================================================================================================
596 
597 //*************************************************************************************************
614 template< typename VT // Type of the sparse vector
615  , bool TF > // Transpose flag
616 inline const SVecScalarMultExpr<VT,typename BaseElementType<VT>::Type,TF>
618 {
620 
621  typedef typename BaseElementType<VT>::Type ElementType;
623 }
624 //*************************************************************************************************
625 
626 
627 
628 
629 //=================================================================================================
630 //
631 // GLOBAL BINARY ARITHMETIC OPERATORS
632 //
633 //=================================================================================================
634 
635 //*************************************************************************************************
656 template< typename T1 // Type of the left-hand side sparse vector
657  , typename T2 // Type of the right-hand side scalar
658  , bool TF > // Transpose flag
659 inline const typename EnableIf< IsNumeric<T2>, typename MultExprTrait<T1,T2>::Type >::Type
660  operator*( const SparseVector<T1,TF>& vec, T2 scalar )
661 {
663 
664  typedef typename MultExprTrait<T1,T2>::Type Type;
665  return Type( ~vec, scalar );
666 }
667 //*************************************************************************************************
668 
669 
670 //*************************************************************************************************
691 template< typename T1 // Type of the left-hand side scalar
692  , typename T2 // Type of the right-hand side sparse vector
693  , bool TF > // Transpose flag
694 inline const typename EnableIf< IsNumeric<T1>, typename MultExprTrait<T1,T2>::Type >::Type
695  operator*( T1 scalar, const SparseVector<T2,TF>& vec )
696 {
698 
699  typedef typename MultExprTrait<T1,T2>::Type Type;
700  return Type( ~vec, scalar );
701 }
702 //*************************************************************************************************
703 
704 
705 
706 
707 //=================================================================================================
708 //
709 // GLOBAL FUNCTIONS
710 //
711 //=================================================================================================
712 
713 //*************************************************************************************************
731 template< typename VT // Type of the sparse vector
732  , bool TF > // Transpose flag
733 inline const SVecScalarMultExpr<VT,typename VT::ElementType,TF>
735 {
736  typedef typename VT::ElementType ElementType;
737 
739 
740  const ElementType len ( length( ~vec ) );
741  const ElementType ilen( ( len != ElementType(0) )?( ElementType(1) / len ):( 0 ) );
742 
743  return SVecScalarMultExpr<VT,ElementType,TF>( ~vec, ilen );
744 }
745 //*************************************************************************************************
746 
747 
748 
749 
750 //=================================================================================================
751 //
752 // GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
753 //
754 //=================================================================================================
755 
756 //*************************************************************************************************
768 template< typename VT // Type of the sparse vector
769  , typename ST // Type of the scalar
770  , bool TF > // Transpose flag
771 inline const SVecScalarMultExpr<VT,ST,TF>
772  operator-( const SVecScalarMultExpr<VT,ST,TF>& sv )
773 {
775 
776  return SVecScalarMultExpr<VT,ST,TF>( sv.leftOperand(), -sv.rightOperand() );
777 }
779 //*************************************************************************************************
780 
781 
782 
783 
784 //=================================================================================================
785 //
786 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
787 //
788 //=================================================================================================
789 
790 //*************************************************************************************************
803 template< typename VT // Type of the sparse vector of the left-hand side expression
804  , typename ST1 // Type of the scalar of the left-hand side expression
805  , bool TF // Transpose flag of the sparse vector
806  , typename ST2 > // Type of the right-hand side scalar
807 inline const typename EnableIf< IsNumeric<ST2>
808  , typename MultExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
809  operator*( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
810 {
812 
813  return vec.leftOperand() * ( vec.rightOperand() * scalar );
814 }
816 //*************************************************************************************************
817 
818 
819 //*************************************************************************************************
832 template< typename ST1 // Type of the left-hand side scalar
833  , typename VT // Type of the sparse vector of the right-hand side expression
834  , typename ST2 // Type of the scalar of the right-hand side expression
835  , bool TF > // Transpose flag of the sparse vector
836 inline const typename EnableIf< IsNumeric<ST1>
837  , typename MultExprTrait< ST1, SVecScalarMultExpr<VT,ST2,TF> >::Type >::Type
838  operator*( ST1 scalar, const SVecScalarMultExpr<VT,ST2,TF>& vec )
839 {
841 
842  return vec.leftOperand() * ( scalar * vec.rightOperand() );
843 }
845 //*************************************************************************************************
846 
847 
848 //*************************************************************************************************
861 template< typename VT // Type of the dense vector of the left-hand side expression
862  , typename ST1 // Type of the scalar of the left-hand side expression
863  , bool TF // Transpose flag of the dense vector
864  , typename ST2 > // Type of the right-hand side scalar
865 inline const typename EnableIf< IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>
866  , typename DivExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
867  operator/( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
868 {
870 
871  return vec.leftOperand() * ( vec.rightOperand() / scalar );
872 }
874 //*************************************************************************************************
875 
876 
877 //*************************************************************************************************
891 template< typename VT1 // Type of the sparse vector of the left-hand side expression
892  , typename ST // Type of the scalar of the left-hand side expression
893  , bool TF // Transpose flag of the dense vectors
894  , typename VT2 > // Type of the right-hand side dense vector
895 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
896  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const DenseVector<VT2,TF>& rhs )
897 {
899 
900  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
901 }
903 //*************************************************************************************************
904 
905 
906 //*************************************************************************************************
920 template< typename VT1 // Type of the left-hand side dense vector
921  , bool TF // Transpose flag of the dense vectors
922  , typename VT2 // Type of the sparse vector of the right-hand side expression
923  , typename ST > // Type of the scalar of the right-hand side expression
924 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
925  operator*( const DenseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
926 {
928 
929  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
930 }
932 //*************************************************************************************************
933 
934 
935 //*************************************************************************************************
949 template< typename VT1 // Type of the sparse vector of the left-hand side expression
950  , typename ST // Type of the scalar of the left-hand side expression
951  , typename VT2 > // Type of the right-hand side dense vector
952 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
953  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const DenseVector<VT2,true>& rhs )
954 {
956 
957  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
958 }
960 //*************************************************************************************************
961 
962 
963 //*************************************************************************************************
977 template< typename VT1 // Type of the left-hand side dense vector
978  , typename VT2 // Type of the sparse vector of the right-hand side expression
979  , typename ST > // Type of the scalar of the right-hand side expression
980 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
981  operator*( const DenseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
982 {
984 
985  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
986 }
988 //*************************************************************************************************
989 
990 
991 //*************************************************************************************************
1005 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1006  , typename ST // Type of the scalar of the left-hand side expression
1007  , bool TF // Transpose flag of the vectors
1008  , typename VT2 > // Type of the right-hand side sparse vector
1009 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1010  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const SparseVector<VT2,TF>& rhs )
1011 {
1013 
1014  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1015 }
1017 //*************************************************************************************************
1018 
1019 
1020 //*************************************************************************************************
1034 template< typename VT1 // Type of the left-hand side sparse vector
1035  , bool TF // Transpose flag of the vectors
1036  , typename VT2 // Type of the sparse vector of the right-hand side expression
1037  , typename ST > // Type of the scalar of the right-hand side expression
1038 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1039  operator*( const SparseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1040 {
1042 
1043  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1044 }
1046 //*************************************************************************************************
1047 
1048 
1049 //*************************************************************************************************
1063 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1064  , typename ST1 // Type of the scalar of the left-hand side expression
1065  , bool TF // Transpose flag of the sparse vectors
1066  , typename VT2 // Type of the sparse vector of the right-hand side expression
1067  , typename ST2 > // Type of the scalar of the right-hand side expression
1068 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,TF>, SVecScalarMultExpr<VT2,ST2,TF> >::Type
1069  operator*( const SVecScalarMultExpr<VT1,ST1,TF>& lhs, const SVecScalarMultExpr<VT2,ST2,TF>& rhs )
1070 {
1072 
1073  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1074 }
1076 //*************************************************************************************************
1077 
1078 
1079 //*************************************************************************************************
1093 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1094  , typename ST // Type of the scalar of the left-hand side expression
1095  , typename VT2 > // Type of the right-hand side sparse vector
1096 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1097  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const SparseVector<VT2,true>& rhs )
1098 {
1100 
1101  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1102 }
1104 //*************************************************************************************************
1105 
1106 
1107 //*************************************************************************************************
1121 template< typename VT1 // Type of the left-hand side sparse vector
1122  , typename VT2 // Type of the sparse vector of the right-hand side expression
1123  , typename ST > // Type of the scalar of the right-hand side expression
1124 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1125  operator*( const SparseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1126 {
1128 
1129  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1130 }
1132 //*************************************************************************************************
1133 
1134 
1135 //*************************************************************************************************
1149 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1150  , typename ST1 // Type of the scalar of the left-hand side expression
1151  , typename VT2 // Type of the sparse vector of the right-hand side expression
1152  , typename ST2 > // Type of the scalar of the right-hand side expression
1153 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >::Type
1154  operator*( const SVecScalarMultExpr<VT1,ST1,false>& lhs, const SVecScalarMultExpr<VT2,ST2,true>& rhs )
1155 {
1157 
1158  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1159 }
1161 //*************************************************************************************************
1162 
1163 
1164 //*************************************************************************************************
1178 template< typename MT // Type of the left-hand side dense matrix
1179  , bool SO // Storage order of the left-hand side dense matrix
1180  , typename VT // Type of the sparse vector of the right-hand side expression
1181  , typename ST > // Type of the scalar of the right-hand side expression
1182 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1183  operator*( const DenseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1184 {
1186 
1187  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1188 }
1190 //*************************************************************************************************
1191 
1192 
1193 //*************************************************************************************************
1207 template< typename VT // Type of the sparse vector of the left-hand side expression
1208  , typename ST // Type of the scalar of the left-hand side expression
1209  , typename MT // Type of the right-hand side dense matrix
1210  , bool SO > // Storage order of the right-hand side dense matrix
1211 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1212  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const DenseMatrix<MT,SO>& mat )
1213 {
1215 
1216  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1217 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1236 template< typename MT // Type of the left-hand side sparse matrix
1237  , bool SO // Storage order of the left-hand side sparse matrix
1238  , typename VT // Type of the sparse vector of the right-hand side expression
1239  , typename ST > // Type of the scalar of the right-hand side expression
1240 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1241  operator*( const SparseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1242 {
1244 
1245  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1246 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1265 template< typename VT // Type of the sparse vector of the left-hand side expression
1266  , typename ST // Type of the scalar of the left-hand side expression
1267  , typename MT // Type of the right-hand side sparse matrix
1268  , bool SO > // Storage order of the right-hand side sparse matrix
1269 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1270  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const SparseMatrix<MT,SO>& mat )
1271 {
1273 
1274  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1275 }
1277 //*************************************************************************************************
1278 
1279 
1280 
1281 
1282 //=================================================================================================
1283 //
1284 // SVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1285 //
1286 //=================================================================================================
1287 
1288 //*************************************************************************************************
1290 template< typename VT, typename ST1, typename ST2 >
1291 struct SVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1292 {
1293  public:
1294  //**********************************************************************************************
1295  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1296  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1297  , typename SVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1298  , INVALID_TYPE >::Type Type;
1299  //**********************************************************************************************
1300 };
1302 //*************************************************************************************************
1303 
1304 
1305 
1306 
1307 //=================================================================================================
1308 //
1309 // TSVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1310 //
1311 //=================================================================================================
1312 
1313 //*************************************************************************************************
1315 template< typename VT, typename ST1, typename ST2 >
1316 struct TSVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1317 {
1318  public:
1319  //**********************************************************************************************
1320  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1321  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1322  , typename TSVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1323  , INVALID_TYPE >::Type Type;
1324  //**********************************************************************************************
1325 };
1327 //*************************************************************************************************
1328 
1329 
1330 
1331 
1332 //=================================================================================================
1333 //
1334 // SVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1335 //
1336 //=================================================================================================
1337 
1338 //*************************************************************************************************
1340 template< typename VT, typename ST1, typename ST2 >
1341 struct SVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1342 {
1343  private:
1344  //**********************************************************************************************
1345  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1346  //**********************************************************************************************
1347 
1348  //**********************************************************************************************
1349  typedef typename SVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1350  typedef typename SVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1351  //**********************************************************************************************
1352 
1353  public:
1354  //**********************************************************************************************
1355  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1356  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1357  , typename SelectType<condition,T1,T2>::Type
1358  , INVALID_TYPE >::Type Type;
1359  //**********************************************************************************************
1360 };
1362 //*************************************************************************************************
1363 
1364 
1365 
1366 
1367 //=================================================================================================
1368 //
1369 // TSVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1370 //
1371 //=================================================================================================
1372 
1373 //*************************************************************************************************
1375 template< typename VT, typename ST1, typename ST2 >
1376 struct TSVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1377 {
1378  private:
1379  //**********************************************************************************************
1380  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1381  //**********************************************************************************************
1382 
1383  //**********************************************************************************************
1384  typedef typename TSVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1385  typedef typename TSVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1386  //**********************************************************************************************
1387 
1388  public:
1389  //**********************************************************************************************
1390  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1391  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1392  , typename SelectType<condition,T1,T2>::Type
1393  , INVALID_TYPE >::Type Type;
1394  //**********************************************************************************************
1395 };
1397 //*************************************************************************************************
1398 
1399 
1400 
1401 
1402 //=================================================================================================
1403 //
1404 // DVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1405 //
1406 //=================================================================================================
1407 
1408 //*************************************************************************************************
1410 template< typename VT1, typename VT2, typename ST >
1411 struct DVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1412 {
1413  public:
1414  //**********************************************************************************************
1415  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1416  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1417  IsNumeric<ST>::value
1418  , typename SVecScalarMultExprTrait<typename DVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1419  , INVALID_TYPE >::Type Type;
1420  //**********************************************************************************************
1421 };
1423 //*************************************************************************************************
1424 
1425 
1426 
1427 
1428 //=================================================================================================
1429 //
1430 // DVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1431 //
1432 //=================================================================================================
1433 
1434 //*************************************************************************************************
1436 template< typename VT1, typename VT2, typename ST >
1437 struct DVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1438 {
1439  public:
1440  //**********************************************************************************************
1441  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1442  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1443  IsNumeric<ST>::value
1444  , typename SMatScalarMultExprTrait<typename DVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1445  , INVALID_TYPE >::Type Type;
1446  //**********************************************************************************************
1447 };
1449 //*************************************************************************************************
1450 
1451 
1452 
1453 
1454 //=================================================================================================
1455 //
1456 // TDVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1457 //
1458 //=================================================================================================
1459 
1460 //*************************************************************************************************
1462 template< typename VT1, typename VT2, typename ST >
1463 struct TDVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1464 {
1465  public:
1466  //**********************************************************************************************
1467  typedef typename SelectType< IsDenseVector<VT1>::value && IsRowVector<VT1>::value &&
1468  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1469  IsNumeric<ST>::value
1470  , typename TSVecScalarMultExprTrait<typename TDVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1471  , INVALID_TYPE >::Type Type;
1472  //**********************************************************************************************
1473 };
1475 //*************************************************************************************************
1476 
1477 
1478 
1479 
1480 //=================================================================================================
1481 //
1482 // SVECDVECMULTEXPRTRAIT SPECIALIZATIONS
1483 //
1484 //=================================================================================================
1485 
1486 //*************************************************************************************************
1488 template< typename VT1, typename ST, typename VT2 >
1489 struct SVecDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1490 {
1491  public:
1492  //**********************************************************************************************
1493  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1494  IsDenseVector<VT2>::value && IsColumnVector<VT2>::value &&
1495  IsNumeric<ST>::value
1496  , typename SVecScalarMultExprTrait<typename SVecDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1497  , INVALID_TYPE >::Type Type;
1498  //**********************************************************************************************
1499 };
1501 //*************************************************************************************************
1502 
1503 
1504 
1505 
1506 //=================================================================================================
1507 //
1508 // SVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1509 //
1510 //=================================================================================================
1511 
1512 //*************************************************************************************************
1514 template< typename VT1, typename ST, typename VT2 >
1515 struct SVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1516 {
1517  public:
1518  //**********************************************************************************************
1519  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1520  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1521  IsNumeric<ST>::value
1522  , typename TSMatScalarMultExprTrait<typename SVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1523  , INVALID_TYPE >::Type Type;
1524  //**********************************************************************************************
1525 };
1527 //*************************************************************************************************
1528 
1529 
1530 
1531 
1532 //=================================================================================================
1533 //
1534 // TSVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1535 //
1536 //=================================================================================================
1537 
1538 //*************************************************************************************************
1540 template< typename VT1, typename ST, typename VT2 >
1541 struct TSVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1542 {
1543  public:
1544  //**********************************************************************************************
1545  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1546  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1547  IsNumeric<ST>::value
1548  , typename TSVecScalarMultExprTrait<typename TSVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1549  , INVALID_TYPE >::Type Type;
1550  //**********************************************************************************************
1551 };
1553 //*************************************************************************************************
1554 
1555 
1556 
1557 
1558 //=================================================================================================
1559 //
1560 // SVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1561 //
1562 //=================================================================================================
1563 
1564 //*************************************************************************************************
1566 template< typename VT1, typename ST, typename VT2 >
1567 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1568 {
1569  public:
1570  //**********************************************************************************************
1571  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1572  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1573  IsNumeric<ST>::value
1574  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1575  , INVALID_TYPE >::Type Type;
1576  //**********************************************************************************************
1577 };
1579 //*************************************************************************************************
1580 
1581 
1582 //*************************************************************************************************
1584 template< typename VT1, typename VT2, typename ST >
1585 struct SVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1586 {
1587  public:
1588  //**********************************************************************************************
1589  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1590  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1591  IsNumeric<ST>::value
1592  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1593  , INVALID_TYPE >::Type Type;
1594  //**********************************************************************************************
1595 };
1597 //*************************************************************************************************
1598 
1599 
1600 //*************************************************************************************************
1602 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1603 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,false> >
1604 {
1605  public:
1606  //**********************************************************************************************
1607  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1608  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1609  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1610  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1611  , INVALID_TYPE >::Type Type;
1612  //**********************************************************************************************
1613 };
1615 //*************************************************************************************************
1616 
1617 
1618 
1619 
1620 //=================================================================================================
1621 //
1622 // SVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1623 //
1624 //=================================================================================================
1625 
1626 //*************************************************************************************************
1628 template< typename VT1, typename ST, typename VT2 >
1629 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1630 {
1631  public:
1632  //**********************************************************************************************
1633  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1634  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1635  IsNumeric<ST>::value
1636  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1637  , INVALID_TYPE >::Type Type;
1638  //**********************************************************************************************
1639 };
1641 //*************************************************************************************************
1642 
1643 
1644 //*************************************************************************************************
1646 template< typename VT1, typename VT2, typename ST >
1647 struct SVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1648 {
1649  public:
1650  //**********************************************************************************************
1651  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1652  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1653  IsNumeric<ST>::value
1654  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1655  , INVALID_TYPE >::Type Type;
1656  //**********************************************************************************************
1657 };
1659 //*************************************************************************************************
1660 
1661 
1662 //*************************************************************************************************
1664 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1665 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1666 {
1667  public:
1668  //**********************************************************************************************
1669  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1670  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1671  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1672  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1673  , INVALID_TYPE >::Type Type;
1674  //**********************************************************************************************
1675 };
1677 //*************************************************************************************************
1678 
1679 
1680 
1681 
1682 //=================================================================================================
1683 //
1684 // TSVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1685 //
1686 //=================================================================================================
1687 
1688 //*************************************************************************************************
1690 template< typename VT1, typename ST, typename VT2 >
1691 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1692 {
1693  public:
1694  //**********************************************************************************************
1695  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1696  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1697  IsNumeric<ST>::value
1698  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1699  , INVALID_TYPE >::Type Type;
1700  //**********************************************************************************************
1701 };
1703 //*************************************************************************************************
1704 
1705 
1706 //*************************************************************************************************
1708 template< typename VT1, typename VT2, typename ST >
1709 struct TSVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1710 {
1711  public:
1712  //**********************************************************************************************
1713  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1714  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1715  IsNumeric<ST>::value
1716  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1717  , INVALID_TYPE >::Type Type;
1718  //**********************************************************************************************
1719 };
1721 //*************************************************************************************************
1722 
1723 
1724 //*************************************************************************************************
1726 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1727 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,true>, SVecScalarMultExpr<VT2,ST2,true> >
1728 {
1729  public:
1730  //**********************************************************************************************
1731  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1732  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1733  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1734  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1735  , INVALID_TYPE >::Type Type;
1736  //**********************************************************************************************
1737 };
1739 //*************************************************************************************************
1740 
1741 
1742 
1743 
1744 //=================================================================================================
1745 //
1746 // DMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1747 //
1748 //=================================================================================================
1749 
1750 //*************************************************************************************************
1752 template< typename MT, typename VT, typename ST >
1753 struct DMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1754 {
1755  public:
1756  //**********************************************************************************************
1757  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1758  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1759  IsNumeric<ST>::value
1760  , typename DVecScalarMultExprTrait<typename DMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1761  , INVALID_TYPE >::Type Type;
1762  //**********************************************************************************************
1763 };
1765 //*************************************************************************************************
1766 
1767 
1768 
1769 
1770 //=================================================================================================
1771 //
1772 // TDMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1773 //
1774 //=================================================================================================
1775 
1776 //*************************************************************************************************
1778 template< typename MT, typename VT, typename ST >
1779 struct TDMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1780 {
1781  public:
1782  //**********************************************************************************************
1783  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1784  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1785  IsNumeric<ST>::value
1786  , typename DVecScalarMultExprTrait<typename TDMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1787  , INVALID_TYPE >::Type Type;
1788  //**********************************************************************************************
1789 };
1791 //*************************************************************************************************
1792 
1793 
1794 
1795 
1796 //=================================================================================================
1797 //
1798 // TSVECDMATMULTEXPRTRAIT SPECIALIZATIONS
1799 //
1800 //=================================================================================================
1801 
1802 //*************************************************************************************************
1804 template< typename VT, typename ST, typename MT >
1805 struct TSVecDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1806 {
1807  public:
1808  //**********************************************************************************************
1809  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1810  IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1811  IsNumeric<ST>::value
1812  , typename TDVecScalarMultExprTrait<typename TSVecDMatMultExprTrait<VT,MT>::Type,ST>::Type
1813  , INVALID_TYPE >::Type Type;
1814  //**********************************************************************************************
1815 };
1817 //*************************************************************************************************
1818 
1819 
1820 
1821 
1822 //=================================================================================================
1823 //
1824 // TSVECTDMATMULTEXPRTRAIT SPECIALIZATIONS
1825 //
1826 //=================================================================================================
1827 
1828 //*************************************************************************************************
1830 template< typename VT, typename ST, typename MT >
1831 struct TSVecTDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1832 {
1833  public:
1834  //**********************************************************************************************
1835  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1836  IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1837  IsNumeric<ST>::value
1838  , typename TDVecScalarMultExprTrait<typename TSVecTDMatMultExprTrait<VT,MT>::Type,ST>::Type
1839  , INVALID_TYPE >::Type Type;
1840  //**********************************************************************************************
1841 };
1843 //*************************************************************************************************
1844 
1845 
1846 
1847 
1848 //=================================================================================================
1849 //
1850 // SMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1851 //
1852 //=================================================================================================
1853 
1854 //*************************************************************************************************
1856 template< typename MT, typename VT, typename ST >
1857 struct SMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1858 {
1859  public:
1860  //**********************************************************************************************
1861  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1862  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1863  IsNumeric<ST>::value
1864  , typename SVecScalarMultExprTrait<typename SMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1865  , INVALID_TYPE >::Type Type;
1866  //**********************************************************************************************
1867 };
1869 //*************************************************************************************************
1870 
1871 
1872 
1873 
1874 //=================================================================================================
1875 //
1876 // TSMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1877 //
1878 //=================================================================================================
1879 
1880 //*************************************************************************************************
1882 template< typename MT, typename VT, typename ST >
1883 struct TSMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1884 {
1885  public:
1886  //**********************************************************************************************
1887  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1888  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1889  IsNumeric<ST>::value
1890  , typename SVecScalarMultExprTrait<typename TSMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1891  , INVALID_TYPE >::Type Type;
1892  //**********************************************************************************************
1893 };
1895 //*************************************************************************************************
1896 
1897 
1898 
1899 
1900 //=================================================================================================
1901 //
1902 // TSVECSMATMULTEXPRTRAIT SPECIALIZATIONS
1903 //
1904 //=================================================================================================
1905 
1906 //*************************************************************************************************
1908 template< typename VT, typename ST, typename MT >
1909 struct TSVecSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1910 {
1911  public:
1912  //**********************************************************************************************
1913  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1914  IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1915  IsNumeric<ST>::value
1916  , typename TSVecScalarMultExprTrait<typename TSVecSMatMultExprTrait<VT,MT>::Type,ST>::Type
1917  , INVALID_TYPE >::Type Type;
1918  //**********************************************************************************************
1919 };
1921 //*************************************************************************************************
1922 
1923 
1924 
1925 
1926 //=================================================================================================
1927 //
1928 // TSVECTSMATMULTEXPRTRAIT SPECIALIZATIONS
1929 //
1930 //=================================================================================================
1931 
1932 //*************************************************************************************************
1934 template< typename VT, typename ST, typename MT >
1935 struct TSVecTSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1936 {
1937  public:
1938  //**********************************************************************************************
1939  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1940  IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1941  IsNumeric<ST>::value
1942  , typename TSVecScalarMultExprTrait<typename TSVecTSMatMultExprTrait<VT,MT>::Type,ST>::Type
1943  , INVALID_TYPE >::Type Type;
1944  //**********************************************************************************************
1945 };
1947 //*************************************************************************************************
1948 
1949 
1950 
1951 
1952 //=================================================================================================
1953 //
1954 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
1955 //
1956 //=================================================================================================
1957 
1958 //*************************************************************************************************
1960 template< typename VT, typename ST, bool TF, bool AF >
1961 struct SubvectorExprTrait< SVecScalarMultExpr<VT,ST,TF>, AF >
1962 {
1963  public:
1964  //**********************************************************************************************
1965  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT,AF>::Type, ST >::Type Type;
1966  //**********************************************************************************************
1967 };
1969 //*************************************************************************************************
1970 
1971 } // namespace blaze
1972 
1973 #endif
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarMultExpr.h:187
Pointer difference type of the Blaze library.
Data type constraint.
Constraint on the data type.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarMultExpr.h:390
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:4075
const EnableIf< IsNumeric< T2 >, typename DivExprTrait< T1, T2 >::Type >::Type operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:772
Header file for the SparseVector base class.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:338
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:348
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:151
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarMultExpr.h:188
PointerType pointer
Pointer return type.
Definition: SVecScalarMultExpr.h:193
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:197
void smpMultAssign(DenseVector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:178
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:402
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:160
Header file for the IsColumnMajorMatrix type trait.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:328
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarMultExpr.h:286
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2384
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:249
MultExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarMultExpr.h:124
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarMultExpr.h:174
ValueType * PointerType
Pointer return type.
Definition: SVecScalarMultExpr.h:186
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarMultExpr.h:243
Header file for the VecScalarMultExpr base class.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarMultExpr.h:201
Constraint on the data type.
Header file for the DivExprTrait class template.
Header file for the MultExprTrait class template.
void smpAddAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:121
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:251
Header file for the ValueIndexPair class.
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:151
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:294
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:233
Header file for the dense vector SMP implementation.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:264
Header file for the IsFloatingPoint type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:191
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
LeftOperand vector_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecScalarMultExpr.h:409
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.In case the two types A and B are not the same (ignoring all cv-qualifiers of bo...
Definition: SameType.h:89
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:79
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarMultExpr.h:253
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:78
DifferenceType difference_type
Difference between two iterators.
Definition: SVecScalarMultExpr.h:195
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:150
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:182
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:293
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:269
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
CMathTrait< typename VT::ElementType >::Type length(const DenseVector< VT, TF > &dv)
Calculation of the dense vector length .
Definition: DenseVector.h:480
Constraint on the data type.
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarMultExpr.h:212
Header file for the BaseElementType type trait.
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:410
Header file for the IsNumeric type trait.
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:179
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2383
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Element ValueType
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:185
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:275
Header file for run time assertion macros.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:141
ValueType value_type
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:192
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:184
VT::CompositeType CT
Composite type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:111
Header file for the division trait.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarMultExpr.h:358
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
ReferenceType reference
Reference return type.
Definition: SVecScalarMultExpr.h:194
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:223
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:378
Evaluation of the base element type of a given data type.Via this type trait it is possible to evalua...
Definition: BaseElementType.h:75
Header file for the RemoveReference type trait.
Header file for the IsDenseVector type trait.
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
SelectType< useAssign, const ResultType, const SVecScalarMultExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SVecScalarMultExpr.h:157
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:112
SVecScalarMultExpr(const VT &vector, ST scalar)
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:305
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
VT::ResultType RT
Result type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:109
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2379
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition: SVecScalarMultExpr.h:148
Header file for basic type definitions.
Header file for the SubvectorExprTrait class template.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecScalarMultExpr.h:154
const DVecScalarMultExpr< VT, typename VT::ElementType, TF > normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:889
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:368
Header file for the IsColumnVector type trait.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:163
Evaluation of the resulting expression type of a multiplication.Via this type trait it is possible to...
Definition: MultExprTrait.h:137
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:238
#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
VT::ReturnType RN
Return type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:110
MultTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: SVecScalarMultExpr.h:149
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:317
#define BLAZE_CONSTRAINT_MUST_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is not a floating point data type...
Definition: FloatingPoint.h:79
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.