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>
72 #include <blaze/util/Assert.h>
77 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/InvalidType.h>
80 #include <blaze/util/SelectType.h>
81 #include <blaze/util/Types.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS SVECSCALARMULTEXPR
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
102 template< typename VT // Type of the left-hand side sparse vector
103  , typename ST // Type of the right-hand side scalar value
104  , bool TF > // Transpose flag
105 class SVecScalarMultExpr : public SparseVector< SVecScalarMultExpr<VT,ST,TF>, TF >
106  , private VecScalarMultExpr
107  , private Computation
108 {
109  private:
110  //**Type definitions****************************************************************************
111  typedef typename VT::ResultType RT;
112  typedef typename VT::ReturnType RN;
113  typedef typename VT::CompositeType CT;
114  //**********************************************************************************************
115 
116  //**Return type evaluation**********************************************************************
118 
123  enum { returnExpr = !IsTemporary<RN>::value };
124 
127  //**********************************************************************************************
128 
129  //**Serial evaluation strategy******************************************************************
131 
137  enum { useAssign = RequiresEvaluation<VT>::value };
138 
140  template< typename VT2 >
142  struct UseAssign {
143  enum { value = useAssign };
144  };
146  //**********************************************************************************************
147 
148  //**Parallel evaluation strategy****************************************************************
150 
156  template< typename VT2 >
157  struct UseSMPAssign {
158  enum { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
159  };
161  //**********************************************************************************************
162 
163  public:
164  //**Type definitions****************************************************************************
169 
172 
175 
177  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type LeftOperand;
178 
180  typedef ST RightOperand;
181  //**********************************************************************************************
182 
183  //**Compilation flags***************************************************************************
185  enum { smpAssignable = 0 };
186  //**********************************************************************************************
187 
188  //**ConstIterator class definition**************************************************************
192  {
193  public:
194  //**Type definitions*************************************************************************
197 
200 
201  typedef std::forward_iterator_tag IteratorCategory;
202  typedef Element ValueType;
206 
207  // STL iterator requirements
213  //*******************************************************************************************
214 
215  //**Constructor******************************************************************************
218  inline ConstIterator( IteratorType vector, RightOperand scalar )
219  : vector_( vector ) // Iterator over the elements of the left-hand side sparse vector expression
220  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
221  {}
222  //*******************************************************************************************
223 
224  //**Prefix increment operator****************************************************************
230  ++vector_;
231  return *this;
232  }
233  //*******************************************************************************************
234 
235  //**Element access operator******************************************************************
240  inline const Element operator*() const {
241  return Element( vector_->value() * scalar_, vector_->index() );
242  }
243  //*******************************************************************************************
244 
245  //**Element access operator******************************************************************
250  inline const ConstIterator* operator->() const {
251  return this;
252  }
253  //*******************************************************************************************
254 
255  //**Value function***************************************************************************
260  inline ReturnType value() const {
261  return vector_->value() * scalar_;
262  }
263  //*******************************************************************************************
264 
265  //**Index function***************************************************************************
270  inline size_t index() const {
271  return vector_->index();
272  }
273  //*******************************************************************************************
274 
275  //**Equality operator************************************************************************
281  inline bool operator==( const ConstIterator& rhs ) const {
282  return vector_ == rhs.vector_;
283  }
284  //*******************************************************************************************
285 
286  //**Inequality operator**********************************************************************
292  inline bool operator!=( const ConstIterator& rhs ) const {
293  return vector_ != rhs.vector_;
294  }
295  //*******************************************************************************************
296 
297  //**Subtraction operator*********************************************************************
303  inline DifferenceType operator-( const ConstIterator& rhs ) const {
304  return vector_ - rhs.vector_;
305  }
306  //*******************************************************************************************
307 
308  private:
309  //**Member variables*************************************************************************
312  //*******************************************************************************************
313  };
314  //**********************************************************************************************
315 
316  //**Constructor*********************************************************************************
322  explicit inline SVecScalarMultExpr( const VT& vector, ST scalar )
323  : vector_( vector ) // Left-hand side sparse vector of the multiplication expression
324  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
325  {}
326  //**********************************************************************************************
327 
328  //**Subscript operator**************************************************************************
334  inline ReturnType operator[]( size_t index ) const {
335  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
336  return vector_[index] * scalar_;
337  }
338  //**********************************************************************************************
339 
340  //**Begin function******************************************************************************
345  inline ConstIterator begin() const {
346  return ConstIterator( vector_.begin(), scalar_ );
347  }
348  //**********************************************************************************************
349 
350  //**End function********************************************************************************
355  inline ConstIterator end() const {
356  return ConstIterator( vector_.end(), scalar_ );
357  }
358  //**********************************************************************************************
359 
360  //**Size function*******************************************************************************
365  inline size_t size() const {
366  return vector_.size();
367  }
368  //**********************************************************************************************
369 
370  //**NonZeros function***************************************************************************
375  inline size_t nonZeros() const {
376  return vector_.nonZeros();
377  }
378  //**********************************************************************************************
379 
380  //**Find function*******************************************************************************
386  inline ConstIterator find( size_t index ) const {
388  return ConstIterator( vector_.find( index ) );
389  }
390  //**********************************************************************************************
391 
392  //**LowerBound function*************************************************************************
398  inline ConstIterator lowerBound( size_t index ) const {
400  return ConstIterator( vector_.lowerBound( index ) );
401  }
402  //**********************************************************************************************
403 
404  //**UpperBound function*************************************************************************
410  inline ConstIterator upperBound( size_t index ) const {
412  return ConstIterator( vector_.upperBound( index ) );
413  }
414  //**********************************************************************************************
415 
416  //**Left operand access*************************************************************************
421  inline LeftOperand leftOperand() const {
422  return vector_;
423  }
424  //**********************************************************************************************
425 
426  //**Right operand access************************************************************************
431  inline RightOperand rightOperand() const {
432  return scalar_;
433  }
434  //**********************************************************************************************
435 
436  //**********************************************************************************************
442  template< typename T >
443  inline bool canAlias( const T* alias ) const {
444  return vector_.canAlias( alias );
445  }
446  //**********************************************************************************************
447 
448  //**********************************************************************************************
454  template< typename T >
455  inline bool isAliased( const T* alias ) const {
456  return vector_.isAliased( alias );
457  }
458  //**********************************************************************************************
459 
460  private:
461  //**Member variables****************************************************************************
464  //**********************************************************************************************
465 
466  //**Assignment to dense vectors*****************************************************************
480  template< typename VT2 > // Type of the target dense vector
481  friend inline typename EnableIf< UseAssign<VT2> >::Type
482  assign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
483  {
485 
486  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
487 
488  assign( ~lhs, rhs.vector_ );
489  (~lhs) *= rhs.scalar_;
490  }
492  //**********************************************************************************************
493 
494  //**Assignment to sparse vectors****************************************************************
508  template< typename VT2 > // Type of the target sparse vector
509  friend inline typename EnableIf< UseAssign<VT2> >::Type
511  {
513 
514  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
515 
516  assign( ~lhs, rhs.vector_ );
517  (~lhs) *= rhs.scalar_;
518  }
520  //**********************************************************************************************
521 
522  //**Addition assignment to dense vectors********************************************************
536  template< typename VT2 > // Type of the target dense vector
537  friend inline typename EnableIf< UseAssign<VT2> >::Type
538  addAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
539  {
541 
545 
546  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
547 
548  const ResultType tmp( serial( rhs ) );
549  addAssign( ~lhs, tmp );
550  }
552  //**********************************************************************************************
553 
554  //**Addition assignment to sparse vectors*******************************************************
555  // No special implementation for the addition assignment to sparse vectors.
556  //**********************************************************************************************
557 
558  //**Subtraction assignment to dense vectors*****************************************************
572  template< typename VT2 > // Type of the target dense vector
573  friend inline typename EnableIf< UseAssign<VT2> >::Type
574  subAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
575  {
577 
581 
582  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
583 
584  const ResultType tmp( serial( rhs ) );
585  subAssign( ~lhs, tmp );
586  }
588  //**********************************************************************************************
589 
590  //**Subtraction assignment to sparse vectors****************************************************
591  // No special implementation for the subtraction assignment to sparse vectors.
592  //**********************************************************************************************
593 
594  //**Multiplication assignment to dense vectors**************************************************
608  template< typename VT2 > // Type of the target dense vector
609  friend inline typename EnableIf< UseAssign<VT2> >::Type
610  multAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
611  {
613 
617 
618  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
619 
620  const ResultType tmp( serial( rhs ) );
621  multAssign( ~lhs, tmp );
622  }
624  //**********************************************************************************************
625 
626  //**Multiplication assignment to sparse vectors*************************************************
627  // No special implementation for the multiplication assignment to sparse vectors.
628  //**********************************************************************************************
629 
630  //**SMP assignment to dense vectors*************************************************************
631  // No special implementation for the SMP assignment to dense vectors.
632  //**********************************************************************************************
633 
634  //**SMP assignment to sparse vectors************************************************************
635  // No special implementation for the SMP assignment to sparse vectors.
636  //**********************************************************************************************
637 
638  //**SMP addition assignment to dense vectors****************************************************
652  template< typename VT2 > // Type of the target dense vector
653  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
654  smpAddAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
655  {
657 
661 
662  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
663 
664  const ResultType tmp( rhs );
665  smpAddAssign( ~lhs, tmp );
666  }
668  //**********************************************************************************************
669 
670  //**SMP addition assignment to sparse vectors***************************************************
671  // No special implementation for the SMP addition assignment to sparse vectors.
672  //**********************************************************************************************
673 
674  //**SMP subtraction assignment to dense vectors*************************************************
688  template< typename VT2 > // Type of the target dense vector
689  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
690  smpSubAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
691  {
693 
697 
698  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
699 
700  const ResultType tmp( rhs );
701  smpSubAssign( ~lhs, tmp );
702  }
704  //**********************************************************************************************
705 
706  //**SMP subtraction assignment to sparse vectors************************************************
707  // No special implementation for the SMP subtraction assignment to sparse vectors.
708  //**********************************************************************************************
709 
710  //**SMP multiplication assignment to dense vectors**********************************************
724  template< typename VT2 > // Type of the target dense vector
725  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
726  smpMultAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
727  {
729 
733 
734  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
735 
736  const ResultType tmp( rhs );
737  smpMultAssign( ~lhs, tmp );
738  }
740  //**********************************************************************************************
741 
742  //**SMP multiplication assignment to sparse vectors*********************************************
743  // No special implementation for the SMP multiplication assignment to sparse vectors.
744  //**********************************************************************************************
745 
746  //**Compile time checks*************************************************************************
753  //**********************************************************************************************
754 };
755 //*************************************************************************************************
756 
757 
758 
759 
760 //=================================================================================================
761 //
762 // GLOBAL UNARY ARITHMETIC OPERATORS
763 //
764 //=================================================================================================
765 
766 //*************************************************************************************************
783 template< typename VT // Type of the sparse vector
784  , bool TF > // Transpose flag
785 inline const SVecScalarMultExpr<VT,typename BaseElementType<VT>::Type,TF>
787 {
789 
790  typedef typename BaseElementType<VT>::Type ElementType;
792 }
793 //*************************************************************************************************
794 
795 
796 
797 
798 //=================================================================================================
799 //
800 // GLOBAL BINARY ARITHMETIC OPERATORS
801 //
802 //=================================================================================================
803 
804 //*************************************************************************************************
825 template< typename T1 // Type of the left-hand side sparse vector
826  , typename T2 // Type of the right-hand side scalar
827  , bool TF > // Transpose flag
828 inline const typename EnableIf< IsNumeric<T2>, typename MultExprTrait<T1,T2>::Type >::Type
829  operator*( const SparseVector<T1,TF>& vec, T2 scalar )
830 {
832 
833  typedef typename MultExprTrait<T1,T2>::Type Type;
834  return Type( ~vec, scalar );
835 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
860 template< typename T1 // Type of the left-hand side scalar
861  , typename T2 // Type of the right-hand side sparse vector
862  , bool TF > // Transpose flag
863 inline const typename EnableIf< IsNumeric<T1>, typename MultExprTrait<T1,T2>::Type >::Type
864  operator*( T1 scalar, const SparseVector<T2,TF>& vec )
865 {
867 
868  typedef typename MultExprTrait<T1,T2>::Type Type;
869  return Type( ~vec, scalar );
870 }
871 //*************************************************************************************************
872 
873 
874 
875 
876 //=================================================================================================
877 //
878 // GLOBAL FUNCTIONS
879 //
880 //=================================================================================================
881 
882 //*************************************************************************************************
900 template< typename VT // Type of the sparse vector
901  , bool TF > // Transpose flag
902 inline const SVecScalarMultExpr<VT,typename VT::ElementType,TF>
904 {
905  typedef typename VT::ElementType ElementType;
906 
908 
909  const ElementType len ( length( ~vec ) );
910  const ElementType ilen( ( len != ElementType(0) )?( ElementType(1) / len ):( 0 ) );
911 
912  return SVecScalarMultExpr<VT,ElementType,TF>( ~vec, ilen );
913 }
914 //*************************************************************************************************
915 
916 
917 
918 
919 //=================================================================================================
920 //
921 // GLOBAL RESTRUCTURING UNARY ARITHMETIC OPERATORS
922 //
923 //=================================================================================================
924 
925 //*************************************************************************************************
937 template< typename VT // Type of the sparse vector
938  , typename ST // Type of the scalar
939  , bool TF > // Transpose flag
940 inline const SVecScalarMultExpr<VT,ST,TF>
941  operator-( const SVecScalarMultExpr<VT,ST,TF>& sv )
942 {
944 
945  return SVecScalarMultExpr<VT,ST,TF>( sv.leftOperand(), -sv.rightOperand() );
946 }
948 //*************************************************************************************************
949 
950 
951 
952 
953 //=================================================================================================
954 //
955 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
956 //
957 //=================================================================================================
958 
959 //*************************************************************************************************
972 template< typename VT // Type of the sparse vector of the left-hand side expression
973  , typename ST1 // Type of the scalar of the left-hand side expression
974  , bool TF // Transpose flag of the sparse vector
975  , typename ST2 > // Type of the right-hand side scalar
976 inline const typename EnableIf< IsNumeric<ST2>
977  , typename MultExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
978  operator*( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
979 {
981 
982  return vec.leftOperand() * ( vec.rightOperand() * scalar );
983 }
985 //*************************************************************************************************
986 
987 
988 //*************************************************************************************************
1001 template< typename ST1 // Type of the left-hand side scalar
1002  , typename VT // Type of the sparse vector of the right-hand side expression
1003  , typename ST2 // Type of the scalar of the right-hand side expression
1004  , bool TF > // Transpose flag of the sparse vector
1005 inline const typename EnableIf< IsNumeric<ST1>
1006  , typename MultExprTrait< ST1, SVecScalarMultExpr<VT,ST2,TF> >::Type >::Type
1007  operator*( ST1 scalar, const SVecScalarMultExpr<VT,ST2,TF>& vec )
1008 {
1010 
1011  return vec.leftOperand() * ( scalar * vec.rightOperand() );
1012 }
1014 //*************************************************************************************************
1015 
1016 
1017 //*************************************************************************************************
1030 template< typename VT // Type of the dense vector of the left-hand side expression
1031  , typename ST1 // Type of the scalar of the left-hand side expression
1032  , bool TF // Transpose flag of the dense vector
1033  , typename ST2 > // Type of the right-hand side scalar
1034 inline const typename EnableIf< IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>
1035  , typename DivExprTrait< SVecScalarMultExpr<VT,ST1,TF>, ST2 >::Type >::Type
1036  operator/( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
1037 {
1039 
1040  return vec.leftOperand() * ( vec.rightOperand() / scalar );
1041 }
1043 //*************************************************************************************************
1044 
1045 
1046 //*************************************************************************************************
1060 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1061  , typename ST // Type of the scalar of the left-hand side expression
1062  , bool TF // Transpose flag of the dense vectors
1063  , typename VT2 > // Type of the right-hand side dense vector
1064 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1065  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1066 {
1068 
1069  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1070 }
1072 //*************************************************************************************************
1073 
1074 
1075 //*************************************************************************************************
1089 template< typename VT1 // Type of the left-hand side dense vector
1090  , bool TF // Transpose flag of the dense vectors
1091  , typename VT2 // Type of the sparse vector of the right-hand side expression
1092  , typename ST > // Type of the scalar of the right-hand side expression
1093 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1094  operator*( const DenseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1095 {
1097 
1098  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1099 }
1101 //*************************************************************************************************
1102 
1103 
1104 //*************************************************************************************************
1118 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1119  , typename ST // Type of the scalar of the left-hand side expression
1120  , typename VT2 > // Type of the right-hand side dense vector
1121 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1122  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const DenseVector<VT2,true>& rhs )
1123 {
1125 
1126  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1127 }
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1146 template< typename VT1 // Type of the left-hand side dense vector
1147  , typename VT2 // Type of the sparse vector of the right-hand side expression
1148  , typename ST > // Type of the scalar of the right-hand side expression
1149 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1150  operator*( const DenseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1151 {
1153 
1154  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1155 }
1157 //*************************************************************************************************
1158 
1159 
1160 //*************************************************************************************************
1174 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1175  , typename ST // Type of the scalar of the left-hand side expression
1176  , bool TF // Transpose flag of the vectors
1177  , typename VT2 > // Type of the right-hand side sparse vector
1178 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,TF>, VT2 >::Type
1179  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const SparseVector<VT2,TF>& rhs )
1180 {
1182 
1183  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1184 }
1186 //*************************************************************************************************
1187 
1188 
1189 //*************************************************************************************************
1203 template< typename VT1 // Type of the left-hand side sparse vector
1204  , bool TF // Transpose flag of the vectors
1205  , typename VT2 // Type of the sparse vector of the right-hand side expression
1206  , typename ST > // Type of the scalar of the right-hand side expression
1207 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,TF> >::Type
1208  operator*( const SparseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1209 {
1211 
1212  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1213 }
1215 //*************************************************************************************************
1216 
1217 
1218 //*************************************************************************************************
1232 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1233  , typename ST1 // Type of the scalar of the left-hand side expression
1234  , bool TF // Transpose flag of the sparse vectors
1235  , typename VT2 // Type of the sparse vector of the right-hand side expression
1236  , typename ST2 > // Type of the scalar of the right-hand side expression
1237 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,TF>, SVecScalarMultExpr<VT2,ST2,TF> >::Type
1238  operator*( const SVecScalarMultExpr<VT1,ST1,TF>& lhs, const SVecScalarMultExpr<VT2,ST2,TF>& rhs )
1239 {
1241 
1242  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1243 }
1245 //*************************************************************************************************
1246 
1247 
1248 //*************************************************************************************************
1262 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1263  , typename ST // Type of the scalar of the left-hand side expression
1264  , typename VT2 > // Type of the right-hand side sparse vector
1265 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >::Type
1266  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const SparseVector<VT2,true>& rhs )
1267 {
1269 
1270  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1271 }
1273 //*************************************************************************************************
1274 
1275 
1276 //*************************************************************************************************
1290 template< typename VT1 // Type of the left-hand side sparse vector
1291  , typename VT2 // Type of the sparse vector of the right-hand side expression
1292  , typename ST > // Type of the scalar of the right-hand side expression
1293 inline const typename MultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >::Type
1294  operator*( const SparseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1295 {
1297 
1298  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1299 }
1301 //*************************************************************************************************
1302 
1303 
1304 //*************************************************************************************************
1318 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1319  , typename ST1 // Type of the scalar of the left-hand side expression
1320  , typename VT2 // Type of the sparse vector of the right-hand side expression
1321  , typename ST2 > // Type of the scalar of the right-hand side expression
1322 inline const typename MultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >::Type
1323  operator*( const SVecScalarMultExpr<VT1,ST1,false>& lhs, const SVecScalarMultExpr<VT2,ST2,true>& rhs )
1324 {
1326 
1327  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1328 }
1330 //*************************************************************************************************
1331 
1332 
1333 //*************************************************************************************************
1347 template< typename MT // Type of the left-hand side dense matrix
1348  , bool SO // Storage order of the left-hand side dense matrix
1349  , typename VT // Type of the sparse vector of the right-hand side expression
1350  , typename ST > // Type of the scalar of the right-hand side expression
1351 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1352  operator*( const DenseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1353 {
1355 
1356  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1357 }
1359 //*************************************************************************************************
1360 
1361 
1362 //*************************************************************************************************
1376 template< typename VT // Type of the sparse vector of the left-hand side expression
1377  , typename ST // Type of the scalar of the left-hand side expression
1378  , typename MT // Type of the right-hand side dense matrix
1379  , bool SO > // Storage order of the right-hand side dense matrix
1380 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1381  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const DenseMatrix<MT,SO>& mat )
1382 {
1384 
1385  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1386 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1405 template< typename MT // Type of the left-hand side sparse matrix
1406  , bool SO // Storage order of the left-hand side sparse matrix
1407  , typename VT // Type of the sparse vector of the right-hand side expression
1408  , typename ST > // Type of the scalar of the right-hand side expression
1409 inline const typename MultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >::Type
1410  operator*( const SparseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1411 {
1413 
1414  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1415 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1434 template< typename VT // Type of the sparse vector of the left-hand side expression
1435  , typename ST // Type of the scalar of the left-hand side expression
1436  , typename MT // Type of the right-hand side sparse matrix
1437  , bool SO > // Storage order of the right-hand side sparse matrix
1438 inline const typename MultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >::Type
1439  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const SparseMatrix<MT,SO>& mat )
1440 {
1442 
1443  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 
1450 
1451 //=================================================================================================
1452 //
1453 // SIZE SPECIALIZATIONS
1454 //
1455 //=================================================================================================
1456 
1457 //*************************************************************************************************
1459 template< typename VT, typename ST, bool TF >
1460 struct Size< SVecScalarMultExpr<VT,ST,TF> >
1461  : public Size<VT>
1462 {};
1464 //*************************************************************************************************
1465 
1466 
1467 
1468 
1469 //=================================================================================================
1470 //
1471 // SVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1472 //
1473 //=================================================================================================
1474 
1475 //*************************************************************************************************
1477 template< typename VT, typename ST1, typename ST2 >
1478 struct SVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1479 {
1480  public:
1481  //**********************************************************************************************
1482  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1483  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1484  , typename SVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1485  , INVALID_TYPE >::Type Type;
1486  //**********************************************************************************************
1487 };
1489 //*************************************************************************************************
1490 
1491 
1492 
1493 
1494 //=================================================================================================
1495 //
1496 // TSVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1497 //
1498 //=================================================================================================
1499 
1500 //*************************************************************************************************
1502 template< typename VT, typename ST1, typename ST2 >
1503 struct TSVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1504 {
1505  public:
1506  //**********************************************************************************************
1507  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1508  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1509  , typename TSVecScalarMultExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type
1510  , INVALID_TYPE >::Type Type;
1511  //**********************************************************************************************
1512 };
1514 //*************************************************************************************************
1515 
1516 
1517 
1518 
1519 //=================================================================================================
1520 //
1521 // SVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1522 //
1523 //=================================================================================================
1524 
1525 //*************************************************************************************************
1527 template< typename VT, typename ST1, typename ST2 >
1528 struct SVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1529 {
1530  private:
1531  //**********************************************************************************************
1532  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1533  //**********************************************************************************************
1534 
1535  //**********************************************************************************************
1536  typedef typename SVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1537  typedef typename SVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1538  //**********************************************************************************************
1539 
1540  public:
1541  //**********************************************************************************************
1542  typedef typename SelectType< IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1543  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1544  , typename SelectType<condition,T1,T2>::Type
1545  , INVALID_TYPE >::Type Type;
1546  //**********************************************************************************************
1547 };
1549 //*************************************************************************************************
1550 
1551 
1552 
1553 
1554 //=================================================================================================
1555 //
1556 // TSVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1557 //
1558 //=================================================================================================
1559 
1560 //*************************************************************************************************
1562 template< typename VT, typename ST1, typename ST2 >
1563 struct TSVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1564 {
1565  private:
1566  //**********************************************************************************************
1567  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1568  //**********************************************************************************************
1569 
1570  //**********************************************************************************************
1571  typedef typename TSVecScalarMultExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1572  typedef typename TSVecScalarDivExprTrait<VT,typename DivTrait<ST1,ST2>::Type>::Type T2;
1573  //**********************************************************************************************
1574 
1575  public:
1576  //**********************************************************************************************
1577  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1578  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1579  , typename SelectType<condition,T1,T2>::Type
1580  , INVALID_TYPE >::Type Type;
1581  //**********************************************************************************************
1582 };
1584 //*************************************************************************************************
1585 
1586 
1587 
1588 
1589 //=================================================================================================
1590 //
1591 // DVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1592 //
1593 //=================================================================================================
1594 
1595 //*************************************************************************************************
1597 template< typename VT1, typename VT2, typename ST >
1598 struct DVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1599 {
1600  public:
1601  //**********************************************************************************************
1602  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1603  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1604  IsNumeric<ST>::value
1605  , typename SVecScalarMultExprTrait<typename DVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1606  , INVALID_TYPE >::Type Type;
1607  //**********************************************************************************************
1608 };
1610 //*************************************************************************************************
1611 
1612 
1613 
1614 
1615 //=================================================================================================
1616 //
1617 // DVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1618 //
1619 //=================================================================================================
1620 
1621 //*************************************************************************************************
1623 template< typename VT1, typename VT2, typename ST >
1624 struct DVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1625 {
1626  public:
1627  //**********************************************************************************************
1628  typedef typename SelectType< IsDenseVector<VT1>::value && IsColumnVector<VT1>::value &&
1629  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1630  IsNumeric<ST>::value
1631  , typename SMatScalarMultExprTrait<typename DVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1632  , INVALID_TYPE >::Type Type;
1633  //**********************************************************************************************
1634 };
1636 //*************************************************************************************************
1637 
1638 
1639 
1640 
1641 //=================================================================================================
1642 //
1643 // TDVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1644 //
1645 //=================================================================================================
1646 
1647 //*************************************************************************************************
1649 template< typename VT1, typename VT2, typename ST >
1650 struct TDVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1651 {
1652  public:
1653  //**********************************************************************************************
1654  typedef typename SelectType< IsDenseVector<VT1>::value && IsRowVector<VT1>::value &&
1655  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1656  IsNumeric<ST>::value
1657  , typename TSVecScalarMultExprTrait<typename TDVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1658  , INVALID_TYPE >::Type Type;
1659  //**********************************************************************************************
1660 };
1662 //*************************************************************************************************
1663 
1664 
1665 
1666 
1667 //=================================================================================================
1668 //
1669 // SVECDVECMULTEXPRTRAIT SPECIALIZATIONS
1670 //
1671 //=================================================================================================
1672 
1673 //*************************************************************************************************
1675 template< typename VT1, typename ST, typename VT2 >
1676 struct SVecDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1677 {
1678  public:
1679  //**********************************************************************************************
1680  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1681  IsDenseVector<VT2>::value && IsColumnVector<VT2>::value &&
1682  IsNumeric<ST>::value
1683  , typename SVecScalarMultExprTrait<typename SVecDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1684  , INVALID_TYPE >::Type Type;
1685  //**********************************************************************************************
1686 };
1688 //*************************************************************************************************
1689 
1690 
1691 
1692 
1693 //=================================================================================================
1694 //
1695 // SVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1696 //
1697 //=================================================================================================
1698 
1699 //*************************************************************************************************
1701 template< typename VT1, typename ST, typename VT2 >
1702 struct SVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1703 {
1704  public:
1705  //**********************************************************************************************
1706  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1707  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1708  IsNumeric<ST>::value
1709  , typename TSMatScalarMultExprTrait<typename SVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1710  , INVALID_TYPE >::Type Type;
1711  //**********************************************************************************************
1712 };
1714 //*************************************************************************************************
1715 
1716 
1717 
1718 
1719 //=================================================================================================
1720 //
1721 // TSVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1722 //
1723 //=================================================================================================
1724 
1725 //*************************************************************************************************
1727 template< typename VT1, typename ST, typename VT2 >
1728 struct TSVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1729 {
1730  public:
1731  //**********************************************************************************************
1732  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1733  IsDenseVector<VT2>::value && IsRowVector<VT2>::value &&
1734  IsNumeric<ST>::value
1735  , typename TSVecScalarMultExprTrait<typename TSVecTDVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1736  , INVALID_TYPE >::Type Type;
1737  //**********************************************************************************************
1738 };
1740 //*************************************************************************************************
1741 
1742 
1743 
1744 
1745 //=================================================================================================
1746 //
1747 // SVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1748 //
1749 //=================================================================================================
1750 
1751 //*************************************************************************************************
1753 template< typename VT1, typename ST, typename VT2 >
1754 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1755 {
1756  public:
1757  //**********************************************************************************************
1758  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1759  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1760  IsNumeric<ST>::value
1761  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1762  , INVALID_TYPE >::Type Type;
1763  //**********************************************************************************************
1764 };
1766 //*************************************************************************************************
1767 
1768 
1769 //*************************************************************************************************
1771 template< typename VT1, typename VT2, typename ST >
1772 struct SVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1773 {
1774  public:
1775  //**********************************************************************************************
1776  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1777  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1778  IsNumeric<ST>::value
1779  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1780  , INVALID_TYPE >::Type Type;
1781  //**********************************************************************************************
1782 };
1784 //*************************************************************************************************
1785 
1786 
1787 //*************************************************************************************************
1789 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1790 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,false> >
1791 {
1792  public:
1793  //**********************************************************************************************
1794  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1795  IsSparseVector<VT2>::value && IsColumnVector<VT2>::value &&
1796  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1797  , typename SVecScalarMultExprTrait<typename SVecSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1798  , INVALID_TYPE >::Type Type;
1799  //**********************************************************************************************
1800 };
1802 //*************************************************************************************************
1803 
1804 
1805 
1806 
1807 //=================================================================================================
1808 //
1809 // SVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1810 //
1811 //=================================================================================================
1812 
1813 //*************************************************************************************************
1815 template< typename VT1, typename ST, typename VT2 >
1816 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1817 {
1818  public:
1819  //**********************************************************************************************
1820  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1821  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1822  IsNumeric<ST>::value
1823  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1824  , INVALID_TYPE >::Type Type;
1825  //**********************************************************************************************
1826 };
1828 //*************************************************************************************************
1829 
1830 
1831 //*************************************************************************************************
1833 template< typename VT1, typename VT2, typename ST >
1834 struct SVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1835 {
1836  public:
1837  //**********************************************************************************************
1838  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1839  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1840  IsNumeric<ST>::value
1841  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1842  , INVALID_TYPE >::Type Type;
1843  //**********************************************************************************************
1844 };
1846 //*************************************************************************************************
1847 
1848 
1849 //*************************************************************************************************
1851 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1852 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1853 {
1854  public:
1855  //**********************************************************************************************
1856  typedef typename SelectType< IsSparseVector<VT1>::value && IsColumnVector<VT1>::value &&
1857  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1858  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1859  , typename SMatScalarMultExprTrait<typename SVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1860  , INVALID_TYPE >::Type Type;
1861  //**********************************************************************************************
1862 };
1864 //*************************************************************************************************
1865 
1866 
1867 
1868 
1869 //=================================================================================================
1870 //
1871 // TSVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1872 //
1873 //=================================================================================================
1874 
1875 //*************************************************************************************************
1877 template< typename VT1, typename ST, typename VT2 >
1878 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1879 {
1880  public:
1881  //**********************************************************************************************
1882  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1883  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1884  IsNumeric<ST>::value
1885  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1886  , INVALID_TYPE >::Type Type;
1887  //**********************************************************************************************
1888 };
1890 //*************************************************************************************************
1891 
1892 
1893 //*************************************************************************************************
1895 template< typename VT1, typename VT2, typename ST >
1896 struct TSVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1897 {
1898  public:
1899  //**********************************************************************************************
1900  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1901  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1902  IsNumeric<ST>::value
1903  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,ST>::Type
1904  , INVALID_TYPE >::Type Type;
1905  //**********************************************************************************************
1906 };
1908 //*************************************************************************************************
1909 
1910 
1911 //*************************************************************************************************
1913 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1914 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,true>, SVecScalarMultExpr<VT2,ST2,true> >
1915 {
1916  public:
1917  //**********************************************************************************************
1918  typedef typename SelectType< IsSparseVector<VT1>::value && IsRowVector<VT1>::value &&
1919  IsSparseVector<VT2>::value && IsRowVector<VT2>::value &&
1920  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1921  , typename TSVecScalarMultExprTrait<typename TSVecTSVecMultExprTrait<VT1,VT2>::Type,typename MultTrait<ST1,ST2>::Type>::Type
1922  , INVALID_TYPE >::Type Type;
1923  //**********************************************************************************************
1924 };
1926 //*************************************************************************************************
1927 
1928 
1929 
1930 
1931 //=================================================================================================
1932 //
1933 // DMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1934 //
1935 //=================================================================================================
1936 
1937 //*************************************************************************************************
1939 template< typename MT, typename VT, typename ST >
1940 struct DMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1941 {
1942  public:
1943  //**********************************************************************************************
1944  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1945  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1946  IsNumeric<ST>::value
1947  , typename DVecScalarMultExprTrait<typename DMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1948  , INVALID_TYPE >::Type Type;
1949  //**********************************************************************************************
1950 };
1952 //*************************************************************************************************
1953 
1954 
1955 
1956 
1957 //=================================================================================================
1958 //
1959 // TDMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1960 //
1961 //=================================================================================================
1962 
1963 //*************************************************************************************************
1965 template< typename MT, typename VT, typename ST >
1966 struct TDMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1967 {
1968  public:
1969  //**********************************************************************************************
1970  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1971  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
1972  IsNumeric<ST>::value
1973  , typename DVecScalarMultExprTrait<typename TDMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
1974  , INVALID_TYPE >::Type Type;
1975  //**********************************************************************************************
1976 };
1978 //*************************************************************************************************
1979 
1980 
1981 
1982 
1983 //=================================================================================================
1984 //
1985 // TSVECDMATMULTEXPRTRAIT SPECIALIZATIONS
1986 //
1987 //=================================================================================================
1988 
1989 //*************************************************************************************************
1991 template< typename VT, typename ST, typename MT >
1992 struct TSVecDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
1993 {
1994  public:
1995  //**********************************************************************************************
1996  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
1997  IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1998  IsNumeric<ST>::value
1999  , typename TDVecScalarMultExprTrait<typename TSVecDMatMultExprTrait<VT,MT>::Type,ST>::Type
2000  , INVALID_TYPE >::Type Type;
2001  //**********************************************************************************************
2002 };
2004 //*************************************************************************************************
2005 
2006 
2007 
2008 
2009 //=================================================================================================
2010 //
2011 // TSVECTDMATMULTEXPRTRAIT SPECIALIZATIONS
2012 //
2013 //=================================================================================================
2014 
2015 //*************************************************************************************************
2017 template< typename VT, typename ST, typename MT >
2018 struct TSVecTDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2019 {
2020  public:
2021  //**********************************************************************************************
2022  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2023  IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2024  IsNumeric<ST>::value
2025  , typename TDVecScalarMultExprTrait<typename TSVecTDMatMultExprTrait<VT,MT>::Type,ST>::Type
2026  , INVALID_TYPE >::Type Type;
2027  //**********************************************************************************************
2028 };
2030 //*************************************************************************************************
2031 
2032 
2033 
2034 
2035 //=================================================================================================
2036 //
2037 // SMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2038 //
2039 //=================================================================================================
2040 
2041 //*************************************************************************************************
2043 template< typename MT, typename VT, typename ST >
2044 struct SMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2045 {
2046  public:
2047  //**********************************************************************************************
2048  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2049  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
2050  IsNumeric<ST>::value
2051  , typename SVecScalarMultExprTrait<typename SMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
2052  , INVALID_TYPE >::Type Type;
2053  //**********************************************************************************************
2054 };
2056 //*************************************************************************************************
2057 
2058 
2059 
2060 
2061 //=================================================================================================
2062 //
2063 // TSMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2064 //
2065 //=================================================================================================
2066 
2067 //*************************************************************************************************
2069 template< typename MT, typename VT, typename ST >
2070 struct TSMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2071 {
2072  public:
2073  //**********************************************************************************************
2074  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2075  IsSparseVector<VT>::value && IsColumnVector<VT>::value &&
2076  IsNumeric<ST>::value
2077  , typename SVecScalarMultExprTrait<typename TSMatSVecMultExprTrait<MT,VT>::Type,ST>::Type
2078  , INVALID_TYPE >::Type Type;
2079  //**********************************************************************************************
2080 };
2082 //*************************************************************************************************
2083 
2084 
2085 
2086 
2087 //=================================================================================================
2088 //
2089 // TSVECSMATMULTEXPRTRAIT SPECIALIZATIONS
2090 //
2091 //=================================================================================================
2092 
2093 //*************************************************************************************************
2095 template< typename VT, typename ST, typename MT >
2096 struct TSVecSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2097 {
2098  public:
2099  //**********************************************************************************************
2100  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2101  IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
2102  IsNumeric<ST>::value
2103  , typename TSVecScalarMultExprTrait<typename TSVecSMatMultExprTrait<VT,MT>::Type,ST>::Type
2104  , INVALID_TYPE >::Type Type;
2105  //**********************************************************************************************
2106 };
2108 //*************************************************************************************************
2109 
2110 
2111 
2112 
2113 //=================================================================================================
2114 //
2115 // TSVECTSMATMULTEXPRTRAIT SPECIALIZATIONS
2116 //
2117 //=================================================================================================
2118 
2119 //*************************************************************************************************
2121 template< typename VT, typename ST, typename MT >
2122 struct TSVecTSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2123 {
2124  public:
2125  //**********************************************************************************************
2126  typedef typename SelectType< IsSparseVector<VT>::value && IsRowVector<VT>::value &&
2127  IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
2128  IsNumeric<ST>::value
2129  , typename TSVecScalarMultExprTrait<typename TSVecTSMatMultExprTrait<VT,MT>::Type,ST>::Type
2130  , INVALID_TYPE >::Type Type;
2131  //**********************************************************************************************
2132 };
2134 //*************************************************************************************************
2135 
2136 
2137 
2138 
2139 //=================================================================================================
2140 //
2141 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2142 //
2143 //=================================================================================================
2144 
2145 //*************************************************************************************************
2147 template< typename VT, typename ST, bool TF, bool AF >
2148 struct SubvectorExprTrait< SVecScalarMultExpr<VT,ST,TF>, AF >
2149 {
2150  public:
2151  //**********************************************************************************************
2152  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT,AF>::Type, ST >::Type Type;
2153  //**********************************************************************************************
2154 };
2156 //*************************************************************************************************
2157 
2158 } // namespace blaze
2159 
2160 #endif
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarMultExpr.h:204
Pointer difference type of the Blaze library.
Data type constraint.
Constraint on the data type.
BLAZE_ALWAYS_INLINE 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:879
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:443
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:4838
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:936
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:355
size_t size() const
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:365
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarMultExpr.h:205
PointerType pointer
Pointer return type.
Definition: SVecScalarMultExpr.h:210
Header file for the IsSparseMatrix type trait.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:455
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:177
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarMultExpr.h:398
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:345
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarMultExpr.h:386
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SVecScalarMultExpr.h:303
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Header file for the IsRowVector type trait.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
MultExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarMultExpr.h:126
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarMultExpr.h:191
ValueType * PointerType
Pointer return type.
Definition: SVecScalarMultExpr.h:203
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
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:260
Header file for the VecScalarMultExpr base class.
ConstIterator(IteratorType vector, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SVecScalarMultExpr.h:218
Constraint on the data type.
Header file for the DivExprTrait class template.
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
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:259
Header file for the ValueIndexPair class.
ResultType::ElementType ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:168
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:311
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:250
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:281
Header file for the IsFloatingPoint type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
BLAZE_ALWAYS_INLINE 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:635
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:208
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:462
#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:270
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:212
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:167
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:199
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:310
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:463
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:229
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:463
Header file for the IsNumeric type trait.
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:196
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:2477
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:202
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarMultExpr.h:410
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:292
Header file for run time assertion macros.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:142
ValueType value_type
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:209
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:201
BLAZE_ALWAYS_INLINE 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:742
VT::CompositeType CT
Composite type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:113
Header file for the division trait.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarMultExpr.h:375
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:211
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:240
#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
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:431
Evaluation of the base element type of a given data type.Via this type trait it is possible to evalua...
Definition: BaseElementType.h:80
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:70
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:174
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:115
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
SVecScalarMultExpr(const VT &vector, ST scalar)
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:322
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:111
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition: SVecScalarMultExpr.h:165
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:171
const DVecScalarMultExpr< VT, typename VT::ElementType, TF > normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1068
LeftOperand leftOperand() const
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:421
Header file for the IsColumnVector type trait.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:180
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: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:112
MultTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: SVecScalarMultExpr.h:166
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:334
#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.
BLAZE_ALWAYS_INLINE 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:849