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>
73 #include <blaze/util/Assert.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Exception.h>
80 #include <blaze/util/InvalidType.h>
82 #include <blaze/util/mpl/And.h>
83 #include <blaze/util/SelectType.h>
84 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS SVECSCALARMULTEXPR
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
104 template< typename VT // Type of the left-hand side sparse vector
105  , typename ST // Type of the right-hand side scalar value
106  , bool TF > // Transpose flag
107 class SVecScalarMultExpr : public SparseVector< SVecScalarMultExpr<VT,ST,TF>, TF >
108  , private VecScalarMultExpr
109  , private Computation
110 {
111  private:
112  //**Type definitions****************************************************************************
113  typedef typename VT::ResultType RT;
114  typedef typename VT::ReturnType RN;
115  typedef typename VT::CompositeType CT;
116  //**********************************************************************************************
117 
118  //**Return type evaluation**********************************************************************
120 
125  enum { returnExpr = !IsTemporary<RN>::value };
126 
129  //**********************************************************************************************
130 
131  //**Serial evaluation strategy******************************************************************
133 
139  enum { useAssign = RequiresEvaluation<VT>::value };
140 
142  template< typename VT2 >
144  struct UseAssign {
145  enum { value = useAssign };
146  };
148  //**********************************************************************************************
149 
150  //**Parallel evaluation strategy****************************************************************
152 
158  template< typename VT2 >
159  struct UseSMPAssign {
160  enum { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
161  };
163  //**********************************************************************************************
164 
165  public:
166  //**Type definitions****************************************************************************
171 
174 
177 
179  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type LeftOperand;
180 
182  typedef ST RightOperand;
183  //**********************************************************************************************
184 
185  //**Compilation flags***************************************************************************
187  enum { smpAssignable = 0 };
188  //**********************************************************************************************
189 
190  //**ConstIterator class definition**************************************************************
194  {
195  public:
196  //**Type definitions*************************************************************************
199 
202 
203  typedef std::forward_iterator_tag IteratorCategory;
204  typedef Element ValueType;
205  typedef ValueType* PointerType;
206  typedef ValueType& ReferenceType;
208 
209  // STL iterator requirements
210  typedef IteratorCategory iterator_category;
211  typedef ValueType value_type;
212  typedef PointerType pointer;
213  typedef ReferenceType reference;
214  typedef DifferenceType difference_type;
215  //*******************************************************************************************
216 
217  //**Constructor******************************************************************************
220  inline ConstIterator( IteratorType vector, RightOperand scalar )
221  : vector_( vector ) // Iterator over the elements of the left-hand side sparse vector expression
222  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
223  {}
224  //*******************************************************************************************
225 
226  //**Prefix increment operator****************************************************************
232  ++vector_;
233  return *this;
234  }
235  //*******************************************************************************************
236 
237  //**Element access operator******************************************************************
242  inline const Element operator*() const {
243  return Element( vector_->value() * scalar_, vector_->index() );
244  }
245  //*******************************************************************************************
246 
247  //**Element access operator******************************************************************
252  inline const ConstIterator* operator->() const {
253  return this;
254  }
255  //*******************************************************************************************
256 
257  //**Value function***************************************************************************
262  inline ReturnType value() const {
263  return vector_->value() * scalar_;
264  }
265  //*******************************************************************************************
266 
267  //**Index function***************************************************************************
272  inline size_t index() const {
273  return vector_->index();
274  }
275  //*******************************************************************************************
276 
277  //**Equality operator************************************************************************
283  inline bool operator==( const ConstIterator& rhs ) const {
284  return vector_ == rhs.vector_;
285  }
286  //*******************************************************************************************
287 
288  //**Inequality operator**********************************************************************
294  inline bool operator!=( const ConstIterator& rhs ) const {
295  return vector_ != rhs.vector_;
296  }
297  //*******************************************************************************************
298 
299  //**Subtraction operator*********************************************************************
305  inline DifferenceType operator-( const ConstIterator& rhs ) const {
306  return vector_ - rhs.vector_;
307  }
308  //*******************************************************************************************
309 
310  private:
311  //**Member variables*************************************************************************
312  IteratorType vector_;
313  RightOperand scalar_;
314  //*******************************************************************************************
315  };
316  //**********************************************************************************************
317 
318  //**Constructor*********************************************************************************
324  explicit inline SVecScalarMultExpr( const VT& vector, ST scalar )
325  : vector_( vector ) // Left-hand side sparse vector of the multiplication expression
326  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
327  {}
328  //**********************************************************************************************
329 
330  //**Subscript operator**************************************************************************
336  inline ReturnType operator[]( size_t index ) const {
337  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
338  return vector_[index] * scalar_;
339  }
340  //**********************************************************************************************
341 
342  //**At function*********************************************************************************
349  inline ReturnType at( size_t index ) const {
350  if( index >= vector_.size() ) {
351  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
352  }
353  return (*this)[index];
354  }
355  //**********************************************************************************************
356 
357  //**Begin function******************************************************************************
362  inline ConstIterator begin() const {
363  return ConstIterator( vector_.begin(), scalar_ );
364  }
365  //**********************************************************************************************
366 
367  //**End function********************************************************************************
372  inline ConstIterator end() const {
373  return ConstIterator( vector_.end(), scalar_ );
374  }
375  //**********************************************************************************************
376 
377  //**Size function*******************************************************************************
382  inline size_t size() const {
383  return vector_.size();
384  }
385  //**********************************************************************************************
386 
387  //**NonZeros function***************************************************************************
392  inline size_t nonZeros() const {
393  return vector_.nonZeros();
394  }
395  //**********************************************************************************************
396 
397  //**Find function*******************************************************************************
403  inline ConstIterator find( size_t index ) const {
405  return ConstIterator( vector_.find( index ), scalar_ );
406  }
407  //**********************************************************************************************
408 
409  //**LowerBound function*************************************************************************
415  inline ConstIterator lowerBound( size_t index ) const {
417  return ConstIterator( vector_.lowerBound( index ), scalar_ );
418  }
419  //**********************************************************************************************
420 
421  //**UpperBound function*************************************************************************
427  inline ConstIterator upperBound( size_t index ) const {
429  return ConstIterator( vector_.upperBound( index ), scalar_ );
430  }
431  //**********************************************************************************************
432 
433  //**Left operand access*************************************************************************
438  inline LeftOperand leftOperand() const {
439  return vector_;
440  }
441  //**********************************************************************************************
442 
443  //**Right operand access************************************************************************
448  inline RightOperand rightOperand() const {
449  return scalar_;
450  }
451  //**********************************************************************************************
452 
453  //**********************************************************************************************
459  template< typename T >
460  inline bool canAlias( const T* alias ) const {
461  return vector_.canAlias( alias );
462  }
463  //**********************************************************************************************
464 
465  //**********************************************************************************************
471  template< typename T >
472  inline bool isAliased( const T* alias ) const {
473  return vector_.isAliased( alias );
474  }
475  //**********************************************************************************************
476 
477  private:
478  //**Member variables****************************************************************************
479  LeftOperand vector_;
480  RightOperand scalar_;
481  //**********************************************************************************************
482 
483  //**Assignment to dense vectors*****************************************************************
497  template< typename VT2 > // Type of the target dense vector
498  friend inline typename EnableIf< UseAssign<VT2> >::Type
499  assign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
500  {
502 
503  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
504 
505  assign( ~lhs, rhs.vector_ );
506  (~lhs) *= rhs.scalar_;
507  }
509  //**********************************************************************************************
510 
511  //**Assignment to sparse vectors****************************************************************
525  template< typename VT2 > // Type of the target sparse vector
526  friend inline typename EnableIf< UseAssign<VT2> >::Type
527  assign( SparseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
528  {
530 
531  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
532 
533  assign( ~lhs, rhs.vector_ );
534  (~lhs) *= rhs.scalar_;
535  }
537  //**********************************************************************************************
538 
539  //**Addition assignment to dense vectors********************************************************
553  template< typename VT2 > // Type of the target dense vector
554  friend inline typename EnableIf< UseAssign<VT2> >::Type
555  addAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
556  {
558 
562 
563  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
564 
565  const ResultType tmp( serial( rhs ) );
566  addAssign( ~lhs, tmp );
567  }
569  //**********************************************************************************************
570 
571  //**Addition assignment to sparse vectors*******************************************************
572  // No special implementation for the addition assignment to sparse vectors.
573  //**********************************************************************************************
574 
575  //**Subtraction assignment to dense vectors*****************************************************
589  template< typename VT2 > // Type of the target dense vector
590  friend inline typename EnableIf< UseAssign<VT2> >::Type
591  subAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
592  {
594 
598 
599  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
600 
601  const ResultType tmp( serial( rhs ) );
602  subAssign( ~lhs, tmp );
603  }
605  //**********************************************************************************************
606 
607  //**Subtraction assignment to sparse vectors****************************************************
608  // No special implementation for the subtraction assignment to sparse vectors.
609  //**********************************************************************************************
610 
611  //**Multiplication assignment to dense vectors**************************************************
625  template< typename VT2 > // Type of the target dense vector
626  friend inline typename EnableIf< UseAssign<VT2> >::Type
627  multAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
628  {
630 
634 
635  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
636 
637  const ResultType tmp( serial( rhs ) );
638  multAssign( ~lhs, tmp );
639  }
641  //**********************************************************************************************
642 
643  //**Multiplication assignment to sparse vectors*************************************************
644  // No special implementation for the multiplication assignment to sparse vectors.
645  //**********************************************************************************************
646 
647  //**SMP assignment to dense vectors*************************************************************
648  // No special implementation for the SMP assignment to dense vectors.
649  //**********************************************************************************************
650 
651  //**SMP assignment to sparse vectors************************************************************
652  // No special implementation for the SMP assignment to sparse vectors.
653  //**********************************************************************************************
654 
655  //**SMP addition assignment to dense vectors****************************************************
669  template< typename VT2 > // Type of the target dense vector
670  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
671  smpAddAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
672  {
674 
678 
679  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
680 
681  const ResultType tmp( rhs );
682  smpAddAssign( ~lhs, tmp );
683  }
685  //**********************************************************************************************
686 
687  //**SMP addition assignment to sparse vectors***************************************************
688  // No special implementation for the SMP addition assignment to sparse vectors.
689  //**********************************************************************************************
690 
691  //**SMP subtraction assignment to dense vectors*************************************************
705  template< typename VT2 > // Type of the target dense vector
706  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
707  smpSubAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
708  {
710 
714 
715  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
716 
717  const ResultType tmp( rhs );
718  smpSubAssign( ~lhs, tmp );
719  }
721  //**********************************************************************************************
722 
723  //**SMP subtraction assignment to sparse vectors************************************************
724  // No special implementation for the SMP subtraction assignment to sparse vectors.
725  //**********************************************************************************************
726 
727  //**SMP multiplication assignment to dense vectors**********************************************
741  template< typename VT2 > // Type of the target dense vector
742  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
743  smpMultAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
744  {
746 
750 
751  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
752 
753  const ResultType tmp( rhs );
754  smpMultAssign( ~lhs, tmp );
755  }
757  //**********************************************************************************************
758 
759  //**SMP multiplication assignment to sparse vectors*********************************************
760  // No special implementation for the SMP multiplication assignment to sparse vectors.
761  //**********************************************************************************************
762 
763  //**Compile time checks*************************************************************************
768  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
770  //**********************************************************************************************
771 };
772 //*************************************************************************************************
773 
774 
775 
776 
777 //=================================================================================================
778 //
779 // GLOBAL UNARY ARITHMETIC OPERATORS
780 //
781 //=================================================================================================
782 
783 //*************************************************************************************************
800 template< typename VT // Type of the sparse vector
801  , bool TF > // Transpose flag
802 inline const SVecScalarMultExpr<VT,typename UnderlyingBuiltin<VT>::Type,TF>
804 {
806 
807  typedef typename UnderlyingBuiltin<VT>::Type ElementType;
809 }
810 //*************************************************************************************************
811 
812 
813 
814 
815 //=================================================================================================
816 //
817 // GLOBAL BINARY ARITHMETIC OPERATORS
818 //
819 //=================================================================================================
820 
821 //*************************************************************************************************
842 template< typename T1 // Type of the left-hand side sparse vector
843  , typename T2 // Type of the right-hand side scalar
844  , bool TF > // Transpose flag
845 inline const typename EnableIf< IsNumeric<T2>, typename MultExprTrait<T1,T2>::Type >::Type
846  operator*( const SparseVector<T1,TF>& vec, T2 scalar )
847 {
849 
850  typedef typename MultExprTrait<T1,T2>::Type Type;
851  return Type( ~vec, scalar );
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
877 template< typename T1 // Type of the left-hand side scalar
878  , typename T2 // Type of the right-hand side sparse vector
879  , bool TF > // Transpose flag
880 inline const typename EnableIf< IsNumeric<T1>, typename MultExprTrait<T1,T2>::Type >::Type
881  operator*( T1 scalar, const SparseVector<T2,TF>& vec )
882 {
884 
885  typedef typename MultExprTrait<T1,T2>::Type Type;
886  return Type( ~vec, scalar );
887 }
888 //*************************************************************************************************
889 
890 
891 
892 
893 //=================================================================================================
894 //
895 // GLOBAL FUNCTIONS
896 //
897 //=================================================================================================
898 
899 //*************************************************************************************************
917 template< typename VT // Type of the sparse vector
918  , bool TF > // Transpose flag
919 inline const SVecScalarMultExpr<VT,typename VT::ElementType,TF>
921 {
922  typedef typename VT::ElementType ElementType;
923 
925 
926  const ElementType len ( length( ~vec ) );
927  const ElementType ilen( ( len != ElementType(0) )?( ElementType(1) / len ):( 0 ) );
928 
929  return SVecScalarMultExpr<VT,ElementType,TF>( ~vec, ilen );
930 }
931 //*************************************************************************************************
932 
933 
934 
935 
936 //=================================================================================================
937 //
938 // GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
939 //
940 //=================================================================================================
941 
942 //*************************************************************************************************
954 template< typename VT // Type of the sparse vector
955  , typename ST // Type of the scalar
956  , bool TF > // Transpose flag
957 inline const SVecScalarMultExpr<VT,ST,TF>
958  operator-( const SVecScalarMultExpr<VT,ST,TF>& sv )
959 {
961 
962  return SVecScalarMultExpr<VT,ST,TF>( sv.leftOperand(), -sv.rightOperand() );
963 }
965 //*************************************************************************************************
966 
967 
968 
969 
970 //=================================================================================================
971 //
972 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
973 //
974 //=================================================================================================
975 
976 //*************************************************************************************************
989 template< typename VT // Type of the sparse vector of the left-hand side expression
990  , typename ST1 // Type of the scalar of the left-hand side expression
991  , bool TF // Transpose flag of the sparse vector
992  , typename ST2 > // Type of the right-hand side scalar
993 inline const typename EnableIf< IsNumeric<ST2>
994  , typename MultExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
995  operator*( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
996 {
998 
999  return vec.leftOperand() * ( vec.rightOperand() * scalar );
1000 }
1002 //*************************************************************************************************
1003 
1004 
1005 //*************************************************************************************************
1018 template< typename ST1 // Type of the left-hand side scalar
1019  , typename VT // Type of the sparse vector of the right-hand side expression
1020  , typename ST2 // Type of the scalar of the right-hand side expression
1021  , bool TF > // Transpose flag of the sparse vector
1022 inline const typename EnableIf< IsNumeric<ST1>
1023  , typename MultExprTrait< ST1, SVecScalarMultExpr<VT,ST2,TF> >::Type >::Type
1024  operator*( ST1 scalar, const SVecScalarMultExpr<VT,ST2,TF>& vec )
1025 {
1027 
1028  return vec.leftOperand() * ( scalar * vec.rightOperand() );
1029 }
1031 //*************************************************************************************************
1032 
1033 
1034 //*************************************************************************************************
1047 template< typename VT // Type of the dense vector of the left-hand side expression
1048  , typename ST1 // Type of the scalar of the left-hand side expression
1049  , bool TF // Transpose flag of the dense vector
1050  , typename ST2 > // Type of the right-hand side scalar
1051 inline const typename EnableIf< And< IsNumeric<ST2>, IsInvertible< typename DivTrait<ST1,ST2>::Type > >
1052  , typename DivExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
1053  operator/( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
1054 {
1056 
1057  return vec.leftOperand() * ( vec.rightOperand() / scalar );
1058 }
1060 //*************************************************************************************************
1061 
1062 
1063 //*************************************************************************************************
1077 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1078  , typename ST // Type of the scalar of the left-hand side expression
1079  , bool TF // Transpose flag of the dense vectors
1080  , typename VT2 > // Type of the right-hand side dense vector
1081 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1082  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1083 {
1085 
1086  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1087 }
1089 //*************************************************************************************************
1090 
1091 
1092 //*************************************************************************************************
1106 template< typename VT1 // Type of the left-hand side dense vector
1107  , bool TF // Transpose flag of the dense vectors
1108  , typename VT2 // Type of the sparse vector of the right-hand side expression
1109  , typename ST > // Type of the scalar of the right-hand side expression
1110 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1111  operator*( const DenseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1112 {
1114 
1115  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1116 }
1118 //*************************************************************************************************
1119 
1120 
1121 //*************************************************************************************************
1135 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1136  , typename ST // Type of the scalar of the left-hand side expression
1137  , typename VT2 > // Type of the right-hand side dense vector
1138 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1139  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const DenseVector<VT2,true>& rhs )
1140 {
1142 
1143  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1144 }
1146 //*************************************************************************************************
1147 
1148 
1149 //*************************************************************************************************
1163 template< typename VT1 // Type of the left-hand side dense vector
1164  , typename VT2 // Type of the sparse vector of the right-hand side expression
1165  , typename ST > // Type of the scalar of the right-hand side expression
1166 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1167  operator*( const DenseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1168 {
1170 
1171  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1172 }
1174 //*************************************************************************************************
1175 
1176 
1177 //*************************************************************************************************
1191 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1192  , typename ST // Type of the scalar of the left-hand side expression
1193  , bool TF // Transpose flag of the vectors
1194  , typename VT2 > // Type of the right-hand side sparse vector
1195 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1196  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const SparseVector<VT2,TF>& rhs )
1197 {
1199 
1200  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1201 }
1203 //*************************************************************************************************
1204 
1205 
1206 //*************************************************************************************************
1220 template< typename VT1 // Type of the left-hand side sparse vector
1221  , bool TF // Transpose flag of the vectors
1222  , typename VT2 // Type of the sparse vector of the right-hand side expression
1223  , typename ST > // Type of the scalar of the right-hand side expression
1224 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1225  operator*( const SparseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1226 {
1228 
1229  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1230 }
1232 //*************************************************************************************************
1233 
1234 
1235 //*************************************************************************************************
1249 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1250  , typename ST1 // Type of the scalar of the left-hand side expression
1251  , bool TF // Transpose flag of the sparse vectors
1252  , typename VT2 // Type of the sparse vector of the right-hand side expression
1253  , typename ST2 > // Type of the scalar of the right-hand side expression
1254 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,TF>, SVecScalarMultExpr<VT2,ST2,TF> >::Type
1255  operator*( const SVecScalarMultExpr<VT1,ST1,TF>& lhs, const SVecScalarMultExpr<VT2,ST2,TF>& rhs )
1256 {
1258 
1259  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1260 }
1262 //*************************************************************************************************
1263 
1264 
1265 //*************************************************************************************************
1279 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1280  , typename ST // Type of the scalar of the left-hand side expression
1281  , typename VT2 > // Type of the right-hand side sparse vector
1282 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1283  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const SparseVector<VT2,true>& rhs )
1284 {
1286 
1287  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1288 }
1290 //*************************************************************************************************
1291 
1292 
1293 //*************************************************************************************************
1307 template< typename VT1 // Type of the left-hand side sparse vector
1308  , typename VT2 // Type of the sparse vector of the right-hand side expression
1309  , typename ST > // Type of the scalar of the right-hand side expression
1310 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1311  operator*( const SparseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1312 {
1314 
1315  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1316 }
1318 //*************************************************************************************************
1319 
1320 
1321 //*************************************************************************************************
1335 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1336  , typename ST1 // Type of the scalar of the left-hand side expression
1337  , typename VT2 // Type of the sparse vector of the right-hand side expression
1338  , typename ST2 > // Type of the scalar of the right-hand side expression
1339 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >::Type
1340  operator*( const SVecScalarMultExpr<VT1,ST1,false>& lhs, const SVecScalarMultExpr<VT2,ST2,true>& rhs )
1341 {
1343 
1344  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1345 }
1347 //*************************************************************************************************
1348 
1349 
1350 //*************************************************************************************************
1364 template< typename MT // Type of the left-hand side dense matrix
1365  , bool SO // Storage order of the left-hand side dense matrix
1366  , typename VT // Type of the sparse vector of the right-hand side expression
1367  , typename ST > // Type of the scalar of the right-hand side expression
1368 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1369  operator*( const DenseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1370 {
1372 
1373  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1374 }
1376 //*************************************************************************************************
1377 
1378 
1379 //*************************************************************************************************
1393 template< typename VT // Type of the sparse vector of the left-hand side expression
1394  , typename ST // Type of the scalar of the left-hand side expression
1395  , typename MT // Type of the right-hand side dense matrix
1396  , bool SO > // Storage order of the right-hand side dense matrix
1397 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1398  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const DenseMatrix<MT,SO>& mat )
1399 {
1401 
1402  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1403 }
1405 //*************************************************************************************************
1406 
1407 
1408 //*************************************************************************************************
1422 template< typename MT // Type of the left-hand side sparse matrix
1423  , bool SO // Storage order of the left-hand side sparse matrix
1424  , typename VT // Type of the sparse vector of the right-hand side expression
1425  , typename ST > // Type of the scalar of the right-hand side expression
1426 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1427  operator*( const SparseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1428 {
1430 
1431  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1432 }
1434 //*************************************************************************************************
1435 
1436 
1437 //*************************************************************************************************
1451 template< typename VT // Type of the sparse vector of the left-hand side expression
1452  , typename ST // Type of the scalar of the left-hand side expression
1453  , typename MT // Type of the right-hand side sparse matrix
1454  , bool SO > // Storage order of the right-hand side sparse matrix
1455 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1456  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const SparseMatrix<MT,SO>& mat )
1457 {
1459 
1460  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1461 }
1463 //*************************************************************************************************
1464 
1465 
1466 
1467 
1468 //=================================================================================================
1469 //
1470 // SIZE SPECIALIZATIONS
1471 //
1472 //=================================================================================================
1473 
1474 //*************************************************************************************************
1476 template< typename VT, typename ST, bool TF >
1477 struct Size< SVecScalarMultExpr<VT,ST,TF> > : public Size<VT>
1478 {};
1480 //*************************************************************************************************
1481 
1482 
1483 
1484 
1485 //=================================================================================================
1486 //
1487 // SVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1488 //
1489 //=================================================================================================
1490 
1491 //*************************************************************************************************
1493 template< typename VT, typename ST1, typename ST2 >
1494 struct SVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1495 {
1496  public:
1497  //**********************************************************************************************
1498  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1499  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1500  , typename SVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1501  , INVALID_TYPE >::Type Type;
1502  //**********************************************************************************************
1503 };
1505 //*************************************************************************************************
1506 
1507 
1508 
1509 
1510 //=================================================================================================
1511 //
1512 // TSVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1513 //
1514 //=================================================================================================
1515 
1516 //*************************************************************************************************
1518 template< typename VT, typename ST1, typename ST2 >
1519 struct TSVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1520 {
1521  public:
1522  //**********************************************************************************************
1523  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1524  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1525  , typename TSVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1526  , INVALID_TYPE >::Type Type;
1527  //**********************************************************************************************
1528 };
1530 //*************************************************************************************************
1531 
1532 
1533 
1534 
1535 //=================================================================================================
1536 //
1537 // SVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1538 //
1539 //=================================================================================================
1540 
1541 //*************************************************************************************************
1543 template< typename VT, typename ST1, typename ST2 >
1544 struct SVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1545 {
1546  private:
1547  //**********************************************************************************************
1548  typedef typename DivTrait<ST1,ST2>::Type ScalarType;
1549  //**********************************************************************************************
1550 
1551  //**********************************************************************************************
1552  enum { condition = IsInvertible<ScalarType>::value };
1553  //**********************************************************************************************
1554 
1555  //**********************************************************************************************
1556  typedef typename SVecScalarMultExprTrait<VT,ScalarType>::Type T1;
1557  typedef typename SVecScalarDivExprTrait<VT,ScalarType>::Type T2;
1558  //**********************************************************************************************
1559 
1560  public:
1561  //**********************************************************************************************
1562  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1563  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1564  , typename SelectType<condition,T1,T2>::Type
1565  , INVALID_TYPE >::Type Type;
1566  //**********************************************************************************************
1567 };
1569 //*************************************************************************************************
1570 
1571 
1572 
1573 
1574 //=================================================================================================
1575 //
1576 // TSVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1577 //
1578 //=================================================================================================
1579 
1580 //*************************************************************************************************
1582 template< typename VT, typename ST1, typename ST2 >
1583 struct TSVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1584 {
1585  private:
1586  //**********************************************************************************************
1587  typedef typename DivTrait<ST1,ST2>::Type ScalarType;
1588  //**********************************************************************************************
1589 
1590  //**********************************************************************************************
1591  enum { condition = IsInvertible<ScalarType>::value };
1592  //**********************************************************************************************
1593 
1594  //**********************************************************************************************
1595  typedef typename TSVecScalarMultExprTrait<VT,ScalarType>::Type T1;
1596  typedef typename TSVecScalarDivExprTrait<VT,ScalarType>::Type T2;
1597  //**********************************************************************************************
1598 
1599  public:
1600  //**********************************************************************************************
1601  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1602  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1603  , typename SelectType<condition,T1,T2>::Type
1604  , INVALID_TYPE >::Type Type;
1605  //**********************************************************************************************
1606 };
1608 //*************************************************************************************************
1609 
1610 
1611 
1612 
1613 //=================================================================================================
1614 //
1615 // DVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1616 //
1617 //=================================================================================================
1618 
1619 //*************************************************************************************************
1621 template< typename VT1, typename VT2, typename ST >
1622 struct DVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1623 {
1624  public:
1625  //**********************************************************************************************
1626  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1627  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1628  IsNumeric<ST>::value
1629  , typename SVecScalarMultExprTrait<typename DVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1630  , INVALID_TYPE >::Type Type;
1631  //**********************************************************************************************
1632 };
1634 //*************************************************************************************************
1635 
1636 
1637 
1638 
1639 //=================================================================================================
1640 //
1641 // DVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1642 //
1643 //=================================================================================================
1644 
1645 //*************************************************************************************************
1647 template< typename VT1, typename VT2, typename ST >
1648 struct DVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1649 {
1650  public:
1651  //**********************************************************************************************
1652  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1653  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1654  IsNumeric<ST>::value
1655  , typename SMatScalarMultExprTrait<typename DVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1656  , INVALID_TYPE >::Type Type;
1657  //**********************************************************************************************
1658 };
1660 //*************************************************************************************************
1661 
1662 
1663 
1664 
1665 //=================================================================================================
1666 //
1667 // TDVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1668 //
1669 //=================================================================================================
1670 
1671 //*************************************************************************************************
1673 template< typename VT1, typename VT2, typename ST >
1674 struct TDVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1675 {
1676  public:
1677  //**********************************************************************************************
1678  typedef typename SelectType< IsDenseVector<VT1>::value && IsRowVector<VT1>::value &&
1679  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1680  IsNumeric<ST>::value
1681  , typename TSVecScalarMultExprTrait<typename TDVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1682  , INVALID_TYPE >::Type Type;
1683  //**********************************************************************************************
1684 };
1686 //*************************************************************************************************
1687 
1688 
1689 
1690 
1691 //=================================================================================================
1692 //
1693 // SVECDVECMULTEXPRTRAIT SPECIALIZATIONS
1694 //
1695 //=================================================================================================
1696 
1697 //*************************************************************************************************
1699 template< typename VT1, typename ST, typename VT2 >
1700 struct SVecDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1701 {
1702  public:
1703  //**********************************************************************************************
1704  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1705  IsDenseVector<VT2>::value && IsColumnVector<VT2>::value &&
1706  IsNumeric<ST>::value
1707  , typename SVecScalarMultExprTrait<typename SVecDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1708  , INVALID_TYPE >::Type Type;
1709  //**********************************************************************************************
1710 };
1712 //*************************************************************************************************
1713 
1714 
1715 
1716 
1717 //=================================================================================================
1718 //
1719 // SVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1720 //
1721 //=================================================================================================
1722 
1723 //*************************************************************************************************
1725 template< typename VT1, typename ST, typename VT2 >
1726 struct SVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1727 {
1728  public:
1729  //**********************************************************************************************
1730  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1731  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1732  IsNumeric<ST>::value
1733  , typename TSMatScalarMultExprTrait<typename SVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1734  , INVALID_TYPE >::Type Type;
1735  //**********************************************************************************************
1736 };
1738 //*************************************************************************************************
1739 
1740 
1741 
1742 
1743 //=================================================================================================
1744 //
1745 // TSVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1746 //
1747 //=================================================================================================
1748 
1749 //*************************************************************************************************
1751 template< typename VT1, typename ST, typename VT2 >
1752 struct TSVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1753 {
1754  public:
1755  //**********************************************************************************************
1756  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1757  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1758  IsNumeric<ST>::value
1759  , typename TSVecScalarMultExprTrait<typename TSVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1760  , INVALID_TYPE >::Type Type;
1761  //**********************************************************************************************
1762 };
1764 //*************************************************************************************************
1765 
1766 
1767 
1768 
1769 //=================================================================================================
1770 //
1771 // SVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1772 //
1773 //=================================================================================================
1774 
1775 //*************************************************************************************************
1777 template< typename VT1, typename ST, typename VT2 >
1778 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1779 {
1780  public:
1781  //**********************************************************************************************
1782  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1783  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1784  IsNumeric<ST>::value
1785  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1786  , INVALID_TYPE >::Type Type;
1787  //**********************************************************************************************
1788 };
1790 //*************************************************************************************************
1791 
1792 
1793 //*************************************************************************************************
1795 template< typename VT1, typename VT2, typename ST >
1796 struct SVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1797 {
1798  public:
1799  //**********************************************************************************************
1800  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1801  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1802  IsNumeric<ST>::value
1803  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1804  , INVALID_TYPE >::Type Type;
1805  //**********************************************************************************************
1806 };
1808 //*************************************************************************************************
1809 
1810 
1811 //*************************************************************************************************
1813 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1814 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,false> >
1815 {
1816  public:
1817  //**********************************************************************************************
1818  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1819  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1820  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1821  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1822  , INVALID_TYPE >::Type Type;
1823  //**********************************************************************************************
1824 };
1826 //*************************************************************************************************
1827 
1828 
1829 
1830 
1831 //=================================================================================================
1832 //
1833 // SVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1834 //
1835 //=================================================================================================
1836 
1837 //*************************************************************************************************
1839 template< typename VT1, typename ST, typename VT2 >
1840 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1841 {
1842  public:
1843  //**********************************************************************************************
1844  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1845  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1846  IsNumeric<ST>::value
1847  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1848  , INVALID_TYPE >::Type Type;
1849  //**********************************************************************************************
1850 };
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1857 template< typename VT1, typename VT2, typename ST >
1858 struct SVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1859 {
1860  public:
1861  //**********************************************************************************************
1862  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1863  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1864  IsNumeric<ST>::value
1865  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1866  , INVALID_TYPE >::Type Type;
1867  //**********************************************************************************************
1868 };
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1875 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1876 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1877 {
1878  public:
1879  //**********************************************************************************************
1880  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1881  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1882  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1883  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1884  , INVALID_TYPE >::Type Type;
1885  //**********************************************************************************************
1886 };
1888 //*************************************************************************************************
1889 
1890 
1891 
1892 
1893 //=================================================================================================
1894 //
1895 // TSVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1896 //
1897 //=================================================================================================
1898 
1899 //*************************************************************************************************
1901 template< typename VT1, typename ST, typename VT2 >
1902 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1903 {
1904  public:
1905  //**********************************************************************************************
1906  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1907  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1908  IsNumeric<ST>::value
1909  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1910  , INVALID_TYPE >::Type Type;
1911  //**********************************************************************************************
1912 };
1914 //*************************************************************************************************
1915 
1916 
1917 //*************************************************************************************************
1919 template< typename VT1, typename VT2, typename ST >
1920 struct TSVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1921 {
1922  public:
1923  //**********************************************************************************************
1924  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1925  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1926  IsNumeric<ST>::value
1927  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1928  , INVALID_TYPE >::Type Type;
1929  //**********************************************************************************************
1930 };
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1937 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1938 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,true>, SVecScalarMultExpr<VT2,ST2,true> >
1939 {
1940  public:
1941  //**********************************************************************************************
1942  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1943  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1944  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1945  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1946  , INVALID_TYPE >::Type Type;
1947  //**********************************************************************************************
1948 };
1950 //*************************************************************************************************
1951 
1952 
1953 
1954 
1955 //=================================================================================================
1956 //
1957 // DMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1958 //
1959 //=================================================================================================
1960 
1961 //*************************************************************************************************
1963 template< typename MT, typename VT, typename ST >
1964 struct DMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1965 {
1966  public:
1967  //**********************************************************************************************
1968  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1969  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1970  IsNumeric<ST>::value
1971  , typename DVecScalarMultExprTrait<typename DMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1972  , INVALID_TYPE >::Type Type;
1973  //**********************************************************************************************
1974 };
1976 //*************************************************************************************************
1977 
1978 
1979 
1980 
1981 //=================================================================================================
1982 //
1983 // TDMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1984 //
1985 //=================================================================================================
1986 
1987 //*************************************************************************************************
1989 template< typename MT, typename VT, typename ST >
1990 struct TDMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1991 {
1992  public:
1993  //**********************************************************************************************
1994  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1995  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1996  IsNumeric<ST>::value
1997  , typename DVecScalarMultExprTrait<typename TDMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1998  , INVALID_TYPE >::Type Type;
1999  //**********************************************************************************************
2000 };
2002 //*************************************************************************************************
2003 
2004 
2005 
2006 
2007 //=================================================================================================
2008 //
2009 // TSVECDMATMULTEXPRTRAIT SPECIALIZATIONS
2010 //
2011 //=================================================================================================
2012 
2013 //*************************************************************************************************
2015 template< typename VT, typename ST, typename MT >
2016 struct TSVecDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2017 {
2018  public:
2019  //**********************************************************************************************
2020  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2021  IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2022  IsNumeric<ST>::value
2023  , typename TDVecScalarMultExprTrait<typename TSVecDMatMultExprTrait<VT,MT>::Type,ST>::Type
2024  , INVALID_TYPE >::Type Type;
2025  //**********************************************************************************************
2026 };
2028 //*************************************************************************************************
2029 
2030 
2031 
2032 
2033 //=================================================================================================
2034 //
2035 // TSVECTDMATMULTEXPRTRAIT SPECIALIZATIONS
2036 //
2037 //=================================================================================================
2038 
2039 //*************************************************************************************************
2041 template< typename VT, typename ST, typename MT >
2042 struct TSVecTDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2043 {
2044  public:
2045  //**********************************************************************************************
2046  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2047  IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2048  IsNumeric<ST>::value
2049  , typename TDVecScalarMultExprTrait<typename TSVecTDMatMultExprTrait<VT,MT>::Type,ST>::Type
2050  , INVALID_TYPE >::Type Type;
2051  //**********************************************************************************************
2052 };
2054 //*************************************************************************************************
2055 
2056 
2057 
2058 
2059 //=================================================================================================
2060 //
2061 // SMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2062 //
2063 //=================================================================================================
2064 
2065 //*************************************************************************************************
2067 template< typename MT, typename VT, typename ST >
2068 struct SMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2069 {
2070  public:
2071  //**********************************************************************************************
2072  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2073  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
2074  IsNumeric<ST>::value
2075  , typename SVecScalarMultExprTrait<typename SMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
2076  , INVALID_TYPE >::Type Type;
2077  //**********************************************************************************************
2078 };
2080 //*************************************************************************************************
2081 
2082 
2083 
2084 
2085 //=================================================================================================
2086 //
2087 // TSMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2088 //
2089 //=================================================================================================
2090 
2091 //*************************************************************************************************
2093 template< typename MT, typename VT, typename ST >
2094 struct TSMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2095 {
2096  public:
2097  //**********************************************************************************************
2098  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2099  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
2100  IsNumeric<ST>::value
2101  , typename SVecScalarMultExprTrait<typename TSMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
2102  , INVALID_TYPE >::Type Type;
2103  //**********************************************************************************************
2104 };
2106 //*************************************************************************************************
2107 
2108 
2109 
2110 
2111 //=================================================================================================
2112 //
2113 // TSVECSMATMULTEXPRTRAIT SPECIALIZATIONS
2114 //
2115 //=================================================================================================
2116 
2117 //*************************************************************************************************
2119 template< typename VT, typename ST, typename MT >
2120 struct TSVecSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2121 {
2122  public:
2123  //**********************************************************************************************
2124  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2125  IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2126  IsNumeric<ST>::value
2127  , typename TSVecScalarMultExprTrait<typename TSVecSMatMultExprTrait<VT,MT>::Type,ST>::Type
2128  , INVALID_TYPE >::Type Type;
2129  //**********************************************************************************************
2130 };
2132 //*************************************************************************************************
2133 
2134 
2135 
2136 
2137 //=================================================================================================
2138 //
2139 // TSVECTSMATMULTEXPRTRAIT SPECIALIZATIONS
2140 //
2141 //=================================================================================================
2142 
2143 //*************************************************************************************************
2145 template< typename VT, typename ST, typename MT >
2146 struct TSVecTSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2147 {
2148  public:
2149  //**********************************************************************************************
2150  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2151  IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2152  IsNumeric<ST>::value
2153  , typename TSVecScalarMultExprTrait<typename TSVecTSMatMultExprTrait<VT,MT>::Type,ST>::Type
2154  , INVALID_TYPE >::Type Type;
2155  //**********************************************************************************************
2156 };
2158 //*************************************************************************************************
2159 
2160 
2161 
2162 
2163 //=================================================================================================
2164 //
2165 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2166 //
2167 //=================================================================================================
2168 
2169 //*************************************************************************************************
2171 template< typename VT, typename ST, bool TF, bool AF >
2172 struct SubvectorExprTrait< SVecScalarMultExpr<VT,ST,TF>, AF >
2173 {
2174  public:
2175  //**********************************************************************************************
2176  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT,AF>::Type, ST >::Type Type;
2177  //**********************************************************************************************
2178 };
2180 //*************************************************************************************************
2181 
2182 } // namespace blaze
2183 
2184 #endif
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarMultExpr.h:206
Pointer difference type of the Blaze library.
Data type constraint.
Constraint on the data type.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:182
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:472
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:210
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:7820
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:962
Header file for basic type definitions.
Header file for the SparseVector base class.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:294
VT::ResultType RT
Result type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:113
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
Header file for the IsColumnMajorMatrix type trait.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarMultExpr.h:207
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:242
Header file for the And class template.
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarMultExpr.h:193
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:252
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarMultExpr.h:305
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarMultExpr.h:272
Header file for the VecScalarMultExpr base class.
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarMultExpr.h:231
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarMultExpr.h:392
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:480
Header file for the DivExprTrait class template.
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:448
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarMultExpr.h:415
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:198
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:261
Evaluation of the underlying builtin element type of a given data type.Via this type trait it is poss...
Definition: UnderlyingBuiltin.h:80
Header file for the ValueIndexPair class.
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarMultExpr.h:460
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
SelectType< useAssign, const ResultType, const SVecScalarMultExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SVecScalarMultExpr.h:176
VT::ReturnType RN
Return type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:114
PointerType pointer
Pointer return type.
Definition: SVecScalarMultExpr.h:212
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarMultExpr.h:262
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:313
Header file for the UnderlyingBuiltin type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:169
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#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
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
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
MultExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarMultExpr.h:128
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Constraint on the data type.
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:516
Constraint on the data type.
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
Header file for the serial shim.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:283
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:179
Header file for the IsNumeric type trait.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:372
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarMultExpr.h:403
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:138
Element ValueType
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:204
Header file for the division trait.
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:312
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:382
ReferenceType reference
Reference return type.
Definition: SVecScalarMultExpr.h:213
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition: SVecScalarMultExpr.h:167
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:203
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
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:336
ValueType * PointerType
Pointer return type.
Definition: SVecScalarMultExpr.h:205
DifferenceType difference_type
Difference between two iterators.
Definition: SVecScalarMultExpr.h:214
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
VT::CompositeType CT
Composite type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:115
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
Header file for the IsDenseVector type trait.
ValueType value_type
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:211
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SVecScalarMultExpr.h:173
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:201
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarMultExpr.h:427
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:128
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< 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:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:118
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the SubvectorExprTrait class template.
const DVecScalarMultExpr< VT, typename VT::ElementType, TF > normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1090
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:438
SVecScalarMultExpr(const VT &vector, ST scalar)
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:324
Header file for exception macros.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:362
LeftOperand vector_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecScalarMultExpr.h:479
Header file for the IsColumnVector type trait.
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:170
MultTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: SVecScalarMultExpr.h:168
EnableIf< IsDenseVector< VT1 > >::Type smpMultAssign(Vector< 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:189
Header file for the Size type trait.
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:81
#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
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SVecScalarMultExpr.h:349
#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.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarMultExpr.h:220