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  //**Serial 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  //**Parallel evaluation strategy****************************************************************
148 
154  template< typename VT2 >
155  struct UseSMPAssign {
156  enum { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
157  };
159  //**********************************************************************************************
160 
161  public:
162  //**Type definitions****************************************************************************
167 
170 
173 
175  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type LeftOperand;
176 
178  typedef ST RightOperand;
179  //**********************************************************************************************
180 
181  //**Compilation flags***************************************************************************
183  enum { smpAssignable = 0 };
184  //**********************************************************************************************
185 
186  //**ConstIterator class definition**************************************************************
190  {
191  public:
192  //**Type definitions*************************************************************************
195 
198 
199  typedef std::forward_iterator_tag IteratorCategory;
200  typedef Element ValueType;
204 
205  // STL iterator requirements
211  //*******************************************************************************************
212 
213  //**Constructor******************************************************************************
216  inline ConstIterator( IteratorType vector, RightOperand scalar )
217  : vector_( vector ) // Iterator over the elements of the left-hand side sparse vector expression
218  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
219  {}
220  //*******************************************************************************************
221 
222  //**Prefix increment operator****************************************************************
228  ++vector_;
229  return *this;
230  }
231  //*******************************************************************************************
232 
233  //**Element access operator******************************************************************
238  inline const Element operator*() const {
239  return Element( vector_->value() * scalar_, vector_->index() );
240  }
241  //*******************************************************************************************
242 
243  //**Element access operator******************************************************************
248  inline const ConstIterator* operator->() const {
249  return this;
250  }
251  //*******************************************************************************************
252 
253  //**Value function***************************************************************************
258  inline ReturnType value() const {
259  return vector_->value() * scalar_;
260  }
261  //*******************************************************************************************
262 
263  //**Index function***************************************************************************
268  inline size_t index() const {
269  return vector_->index();
270  }
271  //*******************************************************************************************
272 
273  //**Equality operator************************************************************************
279  inline bool operator==( const ConstIterator& rhs ) const {
280  return vector_ == rhs.vector_;
281  }
282  //*******************************************************************************************
283 
284  //**Inequality operator**********************************************************************
290  inline bool operator!=( const ConstIterator& rhs ) const {
291  return vector_ != rhs.vector_;
292  }
293  //*******************************************************************************************
294 
295  //**Subtraction operator*********************************************************************
301  inline DifferenceType operator-( const ConstIterator& rhs ) const {
302  return vector_ - rhs.vector_;
303  }
304  //*******************************************************************************************
305 
306  private:
307  //**Member variables*************************************************************************
310  //*******************************************************************************************
311  };
312  //**********************************************************************************************
313 
314  //**Constructor*********************************************************************************
320  explicit inline SVecScalarMultExpr( const VT& vector, ST scalar )
321  : vector_( vector ) // Left-hand side sparse vector of the multiplication expression
322  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
323  {}
324  //**********************************************************************************************
325 
326  //**Subscript operator**************************************************************************
332  inline ReturnType operator[]( size_t index ) const {
333  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
334  return vector_[index] * scalar_;
335  }
336  //**********************************************************************************************
337 
338  //**Begin function******************************************************************************
343  inline ConstIterator begin() const {
344  return ConstIterator( vector_.begin(), scalar_ );
345  }
346  //**********************************************************************************************
347 
348  //**End function********************************************************************************
353  inline ConstIterator end() const {
354  return ConstIterator( vector_.end(), scalar_ );
355  }
356  //**********************************************************************************************
357 
358  //**Size function*******************************************************************************
363  inline size_t size() const {
364  return vector_.size();
365  }
366  //**********************************************************************************************
367 
368  //**NonZeros function***************************************************************************
373  inline size_t nonZeros() const {
374  return vector_.nonZeros();
375  }
376  //**********************************************************************************************
377 
378  //**Left operand access*************************************************************************
383  inline LeftOperand leftOperand() const {
384  return vector_;
385  }
386  //**********************************************************************************************
387 
388  //**Right operand access************************************************************************
393  inline RightOperand rightOperand() const {
394  return scalar_;
395  }
396  //**********************************************************************************************
397 
398  //**********************************************************************************************
404  template< typename T >
405  inline bool canAlias( const T* alias ) const {
406  return vector_.canAlias( alias );
407  }
408  //**********************************************************************************************
409 
410  //**********************************************************************************************
416  template< typename T >
417  inline bool isAliased( const T* alias ) const {
418  return vector_.isAliased( alias );
419  }
420  //**********************************************************************************************
421 
422  private:
423  //**Member variables****************************************************************************
426  //**********************************************************************************************
427 
428  //**Assignment to dense vectors*****************************************************************
442  template< typename VT2 > // Type of the target dense vector
443  friend inline typename EnableIf< UseAssign<VT2> >::Type
444  assign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
445  {
447 
448  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
449 
450  assign( ~lhs, rhs.vector_ );
451  (~lhs) *= rhs.scalar_;
452  }
454  //**********************************************************************************************
455 
456  //**Assignment to sparse vectors****************************************************************
470  template< typename VT2 > // Type of the target sparse vector
471  friend inline typename EnableIf< UseAssign<VT2> >::Type
473  {
475 
476  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
477 
478  assign( ~lhs, rhs.vector_ );
479  (~lhs) *= rhs.scalar_;
480  }
482  //**********************************************************************************************
483 
484  //**Addition assignment to dense vectors********************************************************
498  template< typename VT2 > // Type of the target dense vector
499  friend inline typename EnableIf< UseAssign<VT2> >::Type
500  addAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
501  {
503 
507 
508  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
509 
510  const ResultType tmp( serial( rhs ) );
511  addAssign( ~lhs, tmp );
512  }
514  //**********************************************************************************************
515 
516  //**Addition assignment to sparse vectors*******************************************************
517  // No special implementation for the addition assignment to sparse vectors.
518  //**********************************************************************************************
519 
520  //**Subtraction assignment to dense vectors*****************************************************
534  template< typename VT2 > // Type of the target dense vector
535  friend inline typename EnableIf< UseAssign<VT2> >::Type
536  subAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
537  {
539 
543 
544  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
545 
546  const ResultType tmp( serial( rhs ) );
547  subAssign( ~lhs, tmp );
548  }
550  //**********************************************************************************************
551 
552  //**Subtraction assignment to sparse vectors****************************************************
553  // No special implementation for the subtraction assignment to sparse vectors.
554  //**********************************************************************************************
555 
556  //**Multiplication assignment to dense vectors**************************************************
570  template< typename VT2 > // Type of the target dense vector
571  friend inline typename EnableIf< UseAssign<VT2> >::Type
572  multAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
573  {
575 
579 
580  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
581 
582  const ResultType tmp( serial( rhs ) );
583  multAssign( ~lhs, tmp );
584  }
586  //**********************************************************************************************
587 
588  //**Multiplication assignment to sparse vectors*************************************************
589  // No special implementation for the multiplication assignment to sparse vectors.
590  //**********************************************************************************************
591 
592  //**SMP assignment to dense vectors*************************************************************
593  // No special implementation for the SMP assignment to dense vectors.
594  //**********************************************************************************************
595 
596  //**SMP assignment to sparse vectors************************************************************
597  // No special implementation for the SMP assignment to sparse vectors.
598  //**********************************************************************************************
599 
600  //**SMP addition assignment to dense vectors****************************************************
614  template< typename VT2 > // Type of the target dense vector
615  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
616  smpAddAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
617  {
619 
623 
624  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
625 
626  const ResultType tmp( rhs );
627  smpAddAssign( ~lhs, tmp );
628  }
630  //**********************************************************************************************
631 
632  //**SMP addition assignment to sparse vectors***************************************************
633  // No special implementation for the SMP addition assignment to sparse vectors.
634  //**********************************************************************************************
635 
636  //**SMP subtraction assignment to dense vectors*************************************************
650  template< typename VT2 > // Type of the target dense vector
651  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
652  smpSubAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
653  {
655 
659 
660  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
661 
662  const ResultType tmp( rhs );
663  smpSubAssign( ~lhs, tmp );
664  }
666  //**********************************************************************************************
667 
668  //**SMP subtraction assignment to sparse vectors************************************************
669  // No special implementation for the SMP subtraction assignment to sparse vectors.
670  //**********************************************************************************************
671 
672  //**SMP multiplication assignment to dense vectors**********************************************
686  template< typename VT2 > // Type of the target dense vector
687  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
688  smpMultAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
689  {
691 
695 
696  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
697 
698  const ResultType tmp( rhs );
699  smpMultAssign( ~lhs, tmp );
700  }
702  //**********************************************************************************************
703 
704  //**SMP multiplication assignment to sparse vectors*********************************************
705  // No special implementation for the SMP multiplication assignment to sparse vectors.
706  //**********************************************************************************************
707 
708  //**Compile time checks*************************************************************************
715  //**********************************************************************************************
716 };
717 //*************************************************************************************************
718 
719 
720 
721 
722 //=================================================================================================
723 //
724 // GLOBAL UNARY ARITHMETIC OPERATORS
725 //
726 //=================================================================================================
727 
728 //*************************************************************************************************
745 template< typename VT // Type of the sparse vector
746  , bool TF > // Transpose flag
747 inline const SVecScalarMultExpr<VT,typename BaseElementType<VT>::Type,TF>
749 {
751 
752  typedef typename BaseElementType<VT>::Type ElementType;
754 }
755 //*************************************************************************************************
756 
757 
758 
759 
760 //=================================================================================================
761 //
762 // GLOBAL BINARY ARITHMETIC OPERATORS
763 //
764 //=================================================================================================
765 
766 //*************************************************************************************************
787 template< typename T1 // Type of the left-hand side sparse vector
788  , typename T2 // Type of the right-hand side scalar
789  , bool TF > // Transpose flag
790 inline const typename EnableIf< IsNumeric<T2>, typename MultExprTrait<T1,T2>::Type >::Type
791  operator*( const SparseVector<T1,TF>& vec, T2 scalar )
792 {
794 
795  typedef typename MultExprTrait<T1,T2>::Type Type;
796  return Type( ~vec, scalar );
797 }
798 //*************************************************************************************************
799 
800 
801 //*************************************************************************************************
822 template< typename T1 // Type of the left-hand side scalar
823  , typename T2 // Type of the right-hand side sparse vector
824  , bool TF > // Transpose flag
825 inline const typename EnableIf< IsNumeric<T1>, typename MultExprTrait<T1,T2>::Type >::Type
826  operator*( T1 scalar, const SparseVector<T2,TF>& vec )
827 {
829 
830  typedef typename MultExprTrait<T1,T2>::Type Type;
831  return Type( ~vec, scalar );
832 }
833 //*************************************************************************************************
834 
835 
836 
837 
838 //=================================================================================================
839 //
840 // GLOBAL FUNCTIONS
841 //
842 //=================================================================================================
843 
844 //*************************************************************************************************
862 template< typename VT // Type of the sparse vector
863  , bool TF > // Transpose flag
864 inline const SVecScalarMultExpr<VT,typename VT::ElementType,TF>
866 {
867  typedef typename VT::ElementType ElementType;
868 
870 
871  const ElementType len ( length( ~vec ) );
872  const ElementType ilen( ( len != ElementType(0) )?( ElementType(1) / len ):( 0 ) );
873 
874  return SVecScalarMultExpr<VT,ElementType,TF>( ~vec, ilen );
875 }
876 //*************************************************************************************************
877 
878 
879 
880 
881 //=================================================================================================
882 //
883 // GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
884 //
885 //=================================================================================================
886 
887 //*************************************************************************************************
899 template< typename VT // Type of the sparse vector
900  , typename ST // Type of the scalar
901  , bool TF > // Transpose flag
902 inline const SVecScalarMultExpr<VT,ST,TF>
903  operator-( const SVecScalarMultExpr<VT,ST,TF>& sv )
904 {
906 
907  return SVecScalarMultExpr<VT,ST,TF>( sv.leftOperand(), -sv.rightOperand() );
908 }
910 //*************************************************************************************************
911 
912 
913 
914 
915 //=================================================================================================
916 //
917 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
918 //
919 //=================================================================================================
920 
921 //*************************************************************************************************
934 template< typename VT // Type of the sparse vector of the left-hand side expression
935  , typename ST1 // Type of the scalar of the left-hand side expression
936  , bool TF // Transpose flag of the sparse vector
937  , typename ST2 > // Type of the right-hand side scalar
938 inline const typename EnableIf< IsNumeric<ST2>
939  , typename MultExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
940  operator*( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
941 {
943 
944  return vec.leftOperand() * ( vec.rightOperand() * scalar );
945 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
963 template< typename ST1 // Type of the left-hand side scalar
964  , typename VT // Type of the sparse vector of the right-hand side expression
965  , typename ST2 // Type of the scalar of the right-hand side expression
966  , bool TF > // Transpose flag of the sparse vector
967 inline const typename EnableIf< IsNumeric<ST1>
968  , typename MultExprTrait< ST1, SVecScalarMultExpr<VT,ST2,TF> >::Type >::Type
969  operator*( ST1 scalar, const SVecScalarMultExpr<VT,ST2,TF>& vec )
970 {
972 
973  return vec.leftOperand() * ( scalar * vec.rightOperand() );
974 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
992 template< typename VT // Type of the dense vector of the left-hand side expression
993  , typename ST1 // Type of the scalar of the left-hand side expression
994  , bool TF // Transpose flag of the dense vector
995  , typename ST2 > // Type of the right-hand side scalar
996 inline const typename EnableIf< IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>
997  , typename DivExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
998  operator/( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
999 {
1001 
1002  return vec.leftOperand() * ( vec.rightOperand() / scalar );
1003 }
1005 //*************************************************************************************************
1006 
1007 
1008 //*************************************************************************************************
1022 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1023  , typename ST // Type of the scalar of the left-hand side expression
1024  , bool TF // Transpose flag of the dense vectors
1025  , typename VT2 > // Type of the right-hand side dense vector
1026 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1027  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1028 {
1030 
1031  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1032 }
1034 //*************************************************************************************************
1035 
1036 
1037 //*************************************************************************************************
1051 template< typename VT1 // Type of the left-hand side dense vector
1052  , bool TF // Transpose flag of the dense vectors
1053  , typename VT2 // Type of the sparse vector of the right-hand side expression
1054  , typename ST > // Type of the scalar of the right-hand side expression
1055 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1056  operator*( const DenseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1057 {
1059 
1060  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1061 }
1063 //*************************************************************************************************
1064 
1065 
1066 //*************************************************************************************************
1080 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1081  , typename ST // Type of the scalar of the left-hand side expression
1082  , typename VT2 > // Type of the right-hand side dense vector
1083 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1084  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const DenseVector<VT2,true>& rhs )
1085 {
1087 
1088  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1108 template< typename VT1 // Type of the left-hand side dense vector
1109  , typename VT2 // Type of the sparse vector of the right-hand side expression
1110  , typename ST > // Type of the scalar of the right-hand side expression
1111 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1112  operator*( const DenseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1113 {
1115 
1116  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1117 }
1119 //*************************************************************************************************
1120 
1121 
1122 //*************************************************************************************************
1136 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1137  , typename ST // Type of the scalar of the left-hand side expression
1138  , bool TF // Transpose flag of the vectors
1139  , typename VT2 > // Type of the right-hand side sparse vector
1140 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1141  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const SparseVector<VT2,TF>& rhs )
1142 {
1144 
1145  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1146 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1165 template< typename VT1 // Type of the left-hand side sparse vector
1166  , bool TF // Transpose flag of the vectors
1167  , typename VT2 // Type of the sparse vector of the right-hand side expression
1168  , typename ST > // Type of the scalar of the right-hand side expression
1169 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1170  operator*( const SparseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1171 {
1173 
1174  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1175 }
1177 //*************************************************************************************************
1178 
1179 
1180 //*************************************************************************************************
1194 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1195  , typename ST1 // Type of the scalar of the left-hand side expression
1196  , bool TF // Transpose flag of the sparse vectors
1197  , typename VT2 // Type of the sparse vector of the right-hand side expression
1198  , typename ST2 > // Type of the scalar of the right-hand side expression
1199 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,TF>, SVecScalarMultExpr<VT2,ST2,TF> >::Type
1200  operator*( const SVecScalarMultExpr<VT1,ST1,TF>& lhs, const SVecScalarMultExpr<VT2,ST2,TF>& rhs )
1201 {
1203 
1204  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1205 }
1207 //*************************************************************************************************
1208 
1209 
1210 //*************************************************************************************************
1224 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1225  , typename ST // Type of the scalar of the left-hand side expression
1226  , typename VT2 > // Type of the right-hand side sparse vector
1227 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1228  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const SparseVector<VT2,true>& rhs )
1229 {
1231 
1232  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1233 }
1235 //*************************************************************************************************
1236 
1237 
1238 //*************************************************************************************************
1252 template< typename VT1 // Type of the left-hand side sparse vector
1253  , typename VT2 // Type of the sparse vector of the right-hand side expression
1254  , typename ST > // Type of the scalar of the right-hand side expression
1255 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1256  operator*( const SparseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1257 {
1259 
1260  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1280 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1281  , typename ST1 // Type of the scalar of the left-hand side expression
1282  , typename VT2 // Type of the sparse vector of the right-hand side expression
1283  , typename ST2 > // Type of the scalar of the right-hand side expression
1284 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >::Type
1285  operator*( const SVecScalarMultExpr<VT1,ST1,false>& lhs, const SVecScalarMultExpr<VT2,ST2,true>& rhs )
1286 {
1288 
1289  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1290 }
1292 //*************************************************************************************************
1293 
1294 
1295 //*************************************************************************************************
1309 template< typename MT // Type of the left-hand side dense matrix
1310  , bool SO // Storage order of the left-hand side dense matrix
1311  , typename VT // Type of the sparse vector of the right-hand side expression
1312  , typename ST > // Type of the scalar of the right-hand side expression
1313 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1314  operator*( const DenseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1315 {
1317 
1318  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1319 }
1321 //*************************************************************************************************
1322 
1323 
1324 //*************************************************************************************************
1338 template< typename VT // Type of the sparse vector of the left-hand side expression
1339  , typename ST // Type of the scalar of the left-hand side expression
1340  , typename MT // Type of the right-hand side dense matrix
1341  , bool SO > // Storage order of the right-hand side dense matrix
1342 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1343  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const DenseMatrix<MT,SO>& mat )
1344 {
1346 
1347  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1348 }
1350 //*************************************************************************************************
1351 
1352 
1353 //*************************************************************************************************
1367 template< typename MT // Type of the left-hand side sparse matrix
1368  , bool SO // Storage order of the left-hand side sparse matrix
1369  , typename VT // Type of the sparse vector of the right-hand side expression
1370  , typename ST > // Type of the scalar of the right-hand side expression
1371 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1372  operator*( const SparseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1373 {
1375 
1376  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1377 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1396 template< typename VT // Type of the sparse vector of the left-hand side expression
1397  , typename ST // Type of the scalar of the left-hand side expression
1398  , typename MT // Type of the right-hand side sparse matrix
1399  , bool SO > // Storage order of the right-hand side sparse matrix
1400 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1401  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const SparseMatrix<MT,SO>& mat )
1402 {
1404 
1405  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1406 }
1408 //*************************************************************************************************
1409 
1410 
1411 
1412 
1413 //=================================================================================================
1414 //
1415 // SVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1416 //
1417 //=================================================================================================
1418 
1419 //*************************************************************************************************
1421 template< typename VT, typename ST1, typename ST2 >
1422 struct SVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1423 {
1424  public:
1425  //**********************************************************************************************
1426  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1427  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1428  , typename SVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1429  , INVALID_TYPE >::Type Type;
1430  //**********************************************************************************************
1431 };
1433 //*************************************************************************************************
1434 
1435 
1436 
1437 
1438 //=================================================================================================
1439 //
1440 // TSVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1441 //
1442 //=================================================================================================
1443 
1444 //*************************************************************************************************
1446 template< typename VT, typename ST1, typename ST2 >
1447 struct TSVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1448 {
1449  public:
1450  //**********************************************************************************************
1451  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1452  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1453  , typename TSVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1454  , INVALID_TYPE >::Type Type;
1455  //**********************************************************************************************
1456 };
1458 //*************************************************************************************************
1459 
1460 
1461 
1462 
1463 //=================================================================================================
1464 //
1465 // SVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1466 //
1467 //=================================================================================================
1468 
1469 //*************************************************************************************************
1471 template< typename VT, typename ST1, typename ST2 >
1472 struct SVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1473 {
1474  private:
1475  //**********************************************************************************************
1476  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1477  //**********************************************************************************************
1478 
1479  //**********************************************************************************************
1480  typedef typename SVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1481  typedef typename SVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1482  //**********************************************************************************************
1483 
1484  public:
1485  //**********************************************************************************************
1486  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1487  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1488  , typename SelectType<condition,T1,T2>::Type
1489  , INVALID_TYPE >::Type Type;
1490  //**********************************************************************************************
1491 };
1493 //*************************************************************************************************
1494 
1495 
1496 
1497 
1498 //=================================================================================================
1499 //
1500 // TSVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1501 //
1502 //=================================================================================================
1503 
1504 //*************************************************************************************************
1506 template< typename VT, typename ST1, typename ST2 >
1507 struct TSVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1508 {
1509  private:
1510  //**********************************************************************************************
1511  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1512  //**********************************************************************************************
1513 
1514  //**********************************************************************************************
1515  typedef typename TSVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1516  typedef typename TSVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1517  //**********************************************************************************************
1518 
1519  public:
1520  //**********************************************************************************************
1521  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1522  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1523  , typename SelectType<condition,T1,T2>::Type
1524  , INVALID_TYPE >::Type Type;
1525  //**********************************************************************************************
1526 };
1528 //*************************************************************************************************
1529 
1530 
1531 
1532 
1533 //=================================================================================================
1534 //
1535 // DVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1536 //
1537 //=================================================================================================
1538 
1539 //*************************************************************************************************
1541 template< typename VT1, typename VT2, typename ST >
1542 struct DVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1543 {
1544  public:
1545  //**********************************************************************************************
1546  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1547  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1548  IsNumeric<ST>::value
1549  , typename SVecScalarMultExprTrait<typename DVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1550  , INVALID_TYPE >::Type Type;
1551  //**********************************************************************************************
1552 };
1554 //*************************************************************************************************
1555 
1556 
1557 
1558 
1559 //=================================================================================================
1560 //
1561 // DVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1562 //
1563 //=================================================================================================
1564 
1565 //*************************************************************************************************
1567 template< typename VT1, typename VT2, typename ST >
1568 struct DVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1569 {
1570  public:
1571  //**********************************************************************************************
1572  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1573  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1574  IsNumeric<ST>::value
1575  , typename SMatScalarMultExprTrait<typename DVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1576  , INVALID_TYPE >::Type Type;
1577  //**********************************************************************************************
1578 };
1580 //*************************************************************************************************
1581 
1582 
1583 
1584 
1585 //=================================================================================================
1586 //
1587 // TDVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1588 //
1589 //=================================================================================================
1590 
1591 //*************************************************************************************************
1593 template< typename VT1, typename VT2, typename ST >
1594 struct TDVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1595 {
1596  public:
1597  //**********************************************************************************************
1598  typedef typename SelectType< IsDenseVector<VT1>::value && IsRowVector<VT1>::value &&
1599  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1600  IsNumeric<ST>::value
1601  , typename TSVecScalarMultExprTrait<typename TDVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1602  , INVALID_TYPE >::Type Type;
1603  //**********************************************************************************************
1604 };
1606 //*************************************************************************************************
1607 
1608 
1609 
1610 
1611 //=================================================================================================
1612 //
1613 // SVECDVECMULTEXPRTRAIT SPECIALIZATIONS
1614 //
1615 //=================================================================================================
1616 
1617 //*************************************************************************************************
1619 template< typename VT1, typename ST, typename VT2 >
1620 struct SVecDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1621 {
1622  public:
1623  //**********************************************************************************************
1624  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1625  IsDenseVector<VT2>::value && IsColumnVector<VT2>::value &&
1626  IsNumeric<ST>::value
1627  , typename SVecScalarMultExprTrait<typename SVecDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1628  , INVALID_TYPE >::Type Type;
1629  //**********************************************************************************************
1630 };
1632 //*************************************************************************************************
1633 
1634 
1635 
1636 
1637 //=================================================================================================
1638 //
1639 // SVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1640 //
1641 //=================================================================================================
1642 
1643 //*************************************************************************************************
1645 template< typename VT1, typename ST, typename VT2 >
1646 struct SVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1647 {
1648  public:
1649  //**********************************************************************************************
1650  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1651  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1652  IsNumeric<ST>::value
1653  , typename TSMatScalarMultExprTrait<typename SVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1654  , INVALID_TYPE >::Type Type;
1655  //**********************************************************************************************
1656 };
1658 //*************************************************************************************************
1659 
1660 
1661 
1662 
1663 //=================================================================================================
1664 //
1665 // TSVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1666 //
1667 //=================================================================================================
1668 
1669 //*************************************************************************************************
1671 template< typename VT1, typename ST, typename VT2 >
1672 struct TSVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1673 {
1674  public:
1675  //**********************************************************************************************
1676  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1677  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1678  IsNumeric<ST>::value
1679  , typename TSVecScalarMultExprTrait<typename TSVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1680  , INVALID_TYPE >::Type Type;
1681  //**********************************************************************************************
1682 };
1684 //*************************************************************************************************
1685 
1686 
1687 
1688 
1689 //=================================================================================================
1690 //
1691 // SVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1692 //
1693 //=================================================================================================
1694 
1695 //*************************************************************************************************
1697 template< typename VT1, typename ST, typename VT2 >
1698 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1699 {
1700  public:
1701  //**********************************************************************************************
1702  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1703  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1704  IsNumeric<ST>::value
1705  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1706  , INVALID_TYPE >::Type Type;
1707  //**********************************************************************************************
1708 };
1710 //*************************************************************************************************
1711 
1712 
1713 //*************************************************************************************************
1715 template< typename VT1, typename VT2, typename ST >
1716 struct SVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1717 {
1718  public:
1719  //**********************************************************************************************
1720  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1721  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1722  IsNumeric<ST>::value
1723  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1724  , INVALID_TYPE >::Type Type;
1725  //**********************************************************************************************
1726 };
1728 //*************************************************************************************************
1729 
1730 
1731 //*************************************************************************************************
1733 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1734 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,false> >
1735 {
1736  public:
1737  //**********************************************************************************************
1738  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1739  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1740  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1741  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1742  , INVALID_TYPE >::Type Type;
1743  //**********************************************************************************************
1744 };
1746 //*************************************************************************************************
1747 
1748 
1749 
1750 
1751 //=================================================================================================
1752 //
1753 // SVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1754 //
1755 //=================================================================================================
1756 
1757 //*************************************************************************************************
1759 template< typename VT1, typename ST, typename VT2 >
1760 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1761 {
1762  public:
1763  //**********************************************************************************************
1764  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1765  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1766  IsNumeric<ST>::value
1767  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1768  , INVALID_TYPE >::Type Type;
1769  //**********************************************************************************************
1770 };
1772 //*************************************************************************************************
1773 
1774 
1775 //*************************************************************************************************
1777 template< typename VT1, typename VT2, typename ST >
1778 struct SVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1779 {
1780  public:
1781  //**********************************************************************************************
1782  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1783  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1784  IsNumeric<ST>::value
1785  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1786  , INVALID_TYPE >::Type Type;
1787  //**********************************************************************************************
1788 };
1790 //*************************************************************************************************
1791 
1792 
1793 //*************************************************************************************************
1795 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1796 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1797 {
1798  public:
1799  //**********************************************************************************************
1800  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1801  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1802  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1803  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1804  , INVALID_TYPE >::Type Type;
1805  //**********************************************************************************************
1806 };
1808 //*************************************************************************************************
1809 
1810 
1811 
1812 
1813 //=================================================================================================
1814 //
1815 // TSVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1816 //
1817 //=================================================================================================
1818 
1819 //*************************************************************************************************
1821 template< typename VT1, typename ST, typename VT2 >
1822 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1823 {
1824  public:
1825  //**********************************************************************************************
1826  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1827  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1828  IsNumeric<ST>::value
1829  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1830  , INVALID_TYPE >::Type Type;
1831  //**********************************************************************************************
1832 };
1834 //*************************************************************************************************
1835 
1836 
1837 //*************************************************************************************************
1839 template< typename VT1, typename VT2, typename ST >
1840 struct TSVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1841 {
1842  public:
1843  //**********************************************************************************************
1844  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1845  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1846  IsNumeric<ST>::value
1847  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1848  , INVALID_TYPE >::Type Type;
1849  //**********************************************************************************************
1850 };
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1857 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1858 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,true>, SVecScalarMultExpr<VT2,ST2,true> >
1859 {
1860  public:
1861  //**********************************************************************************************
1862  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1863  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1864  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1865  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1866  , INVALID_TYPE >::Type Type;
1867  //**********************************************************************************************
1868 };
1870 //*************************************************************************************************
1871 
1872 
1873 
1874 
1875 //=================================================================================================
1876 //
1877 // DMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1878 //
1879 //=================================================================================================
1880 
1881 //*************************************************************************************************
1883 template< typename MT, typename VT, typename ST >
1884 struct DMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1885 {
1886  public:
1887  //**********************************************************************************************
1888  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1889  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1890  IsNumeric<ST>::value
1891  , typename DVecScalarMultExprTrait<typename DMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1892  , INVALID_TYPE >::Type Type;
1893  //**********************************************************************************************
1894 };
1896 //*************************************************************************************************
1897 
1898 
1899 
1900 
1901 //=================================================================================================
1902 //
1903 // TDMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1904 //
1905 //=================================================================================================
1906 
1907 //*************************************************************************************************
1909 template< typename MT, typename VT, typename ST >
1910 struct TDMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1911 {
1912  public:
1913  //**********************************************************************************************
1914  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1915  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1916  IsNumeric<ST>::value
1917  , typename DVecScalarMultExprTrait<typename TDMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1918  , INVALID_TYPE >::Type Type;
1919  //**********************************************************************************************
1920 };
1922 //*************************************************************************************************
1923 
1924 
1925 
1926 
1927 //=================================================================================================
1928 //
1929 // TSVECDMATMULTEXPRTRAIT SPECIALIZATIONS
1930 //
1931 //=================================================================================================
1932 
1933 //*************************************************************************************************
1935 template< typename VT, typename ST, typename MT >
1936 struct TSVecDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1937 {
1938  public:
1939  //**********************************************************************************************
1940  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1941  IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1942  IsNumeric<ST>::value
1943  , typename TDVecScalarMultExprTrait<typename TSVecDMatMultExprTrait<VT,MT>::Type,ST>::Type
1944  , INVALID_TYPE >::Type Type;
1945  //**********************************************************************************************
1946 };
1948 //*************************************************************************************************
1949 
1950 
1951 
1952 
1953 //=================================================================================================
1954 //
1955 // TSVECTDMATMULTEXPRTRAIT SPECIALIZATIONS
1956 //
1957 //=================================================================================================
1958 
1959 //*************************************************************************************************
1961 template< typename VT, typename ST, typename MT >
1962 struct TSVecTDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1963 {
1964  public:
1965  //**********************************************************************************************
1966  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1967  IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1968  IsNumeric<ST>::value
1969  , typename TDVecScalarMultExprTrait<typename TSVecTDMatMultExprTrait<VT,MT>::Type,ST>::Type
1970  , INVALID_TYPE >::Type Type;
1971  //**********************************************************************************************
1972 };
1974 //*************************************************************************************************
1975 
1976 
1977 
1978 
1979 //=================================================================================================
1980 //
1981 // SMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1982 //
1983 //=================================================================================================
1984 
1985 //*************************************************************************************************
1987 template< typename MT, typename VT, typename ST >
1988 struct SMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1989 {
1990  public:
1991  //**********************************************************************************************
1992  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1993  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1994  IsNumeric<ST>::value
1995  , typename SVecScalarMultExprTrait<typename SMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1996  , INVALID_TYPE >::Type Type;
1997  //**********************************************************************************************
1998 };
2000 //*************************************************************************************************
2001 
2002 
2003 
2004 
2005 //=================================================================================================
2006 //
2007 // TSMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2008 //
2009 //=================================================================================================
2010 
2011 //*************************************************************************************************
2013 template< typename MT, typename VT, typename ST >
2014 struct TSMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2015 {
2016  public:
2017  //**********************************************************************************************
2018  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2019  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
2020  IsNumeric<ST>::value
2021  , typename SVecScalarMultExprTrait<typename TSMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
2022  , INVALID_TYPE >::Type Type;
2023  //**********************************************************************************************
2024 };
2026 //*************************************************************************************************
2027 
2028 
2029 
2030 
2031 //=================================================================================================
2032 //
2033 // TSVECSMATMULTEXPRTRAIT SPECIALIZATIONS
2034 //
2035 //=================================================================================================
2036 
2037 //*************************************************************************************************
2039 template< typename VT, typename ST, typename MT >
2040 struct TSVecSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2041 {
2042  public:
2043  //**********************************************************************************************
2044  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2045  IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2046  IsNumeric<ST>::value
2047  , typename TSVecScalarMultExprTrait<typename TSVecSMatMultExprTrait<VT,MT>::Type,ST>::Type
2048  , INVALID_TYPE >::Type Type;
2049  //**********************************************************************************************
2050 };
2052 //*************************************************************************************************
2053 
2054 
2055 
2056 
2057 //=================================================================================================
2058 //
2059 // TSVECTSMATMULTEXPRTRAIT SPECIALIZATIONS
2060 //
2061 //=================================================================================================
2062 
2063 //*************************************************************************************************
2065 template< typename VT, typename ST, typename MT >
2066 struct TSVecTSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2067 {
2068  public:
2069  //**********************************************************************************************
2070  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2071  IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2072  IsNumeric<ST>::value
2073  , typename TSVecScalarMultExprTrait<typename TSVecTSMatMultExprTrait<VT,MT>::Type,ST>::Type
2074  , INVALID_TYPE >::Type Type;
2075  //**********************************************************************************************
2076 };
2078 //*************************************************************************************************
2079 
2080 
2081 
2082 
2083 //=================================================================================================
2084 //
2085 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2086 //
2087 //=================================================================================================
2088 
2089 //*************************************************************************************************
2091 template< typename VT, typename ST, bool TF, bool AF >
2092 struct SubvectorExprTrait< SVecScalarMultExpr<VT,ST,TF>, AF >
2093 {
2094  public:
2095  //**********************************************************************************************
2096  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT,AF>::Type, ST >::Type Type;
2097  //**********************************************************************************************
2098 };
2100 //*************************************************************************************************
2101 
2102 } // namespace blaze
2103 
2104 #endif
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarMultExpr.h:202
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:405
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:4329
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:930
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:353
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:363
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:152
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarMultExpr.h:203
PointerType pointer
Pointer return type.
Definition: SVecScalarMultExpr.h:208
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
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:179
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:417
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:175
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:343
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarMultExpr.h:301
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2408
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:251
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:189
ValueType * PointerType
Pointer return type.
Definition: SVecScalarMultExpr.h:201
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
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:258
Header file for the VecScalarMultExpr base class.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarMultExpr.h:216
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:122
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:253
Header file for the ValueIndexPair class.
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:166
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:309
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:248
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:279
Header file for the IsFloatingPoint type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:206
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:271
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:424
#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:268
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:210
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:165
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:197
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:308
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:361
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:483
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:227
Header file for the serial shim.
Header file for the BaseElementType type trait.
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:425
Header file for the IsNumeric type trait.
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:194
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2407
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:200
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:290
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:207
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:199
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:373
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:301
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:209
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:331
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:238
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:393
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:172
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:115
SVecScalarMultExpr(const VT &vector, ST scalar)
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:320
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
#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:2403
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition: SVecScalarMultExpr.h:163
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:169
const DVecScalarMultExpr< VT, typename VT::ElementType, TF > normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1067
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:383
Header file for the IsColumnVector type trait.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:178
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:164
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:332
#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.