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>
44 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
75 #include <blaze/util/Assert.h>
80 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/InvalidType.h>
83 #include <blaze/util/mpl/And.h>
84 #include <blaze/util/mpl/If.h>
85 #include <blaze/util/mpl/Or.h>
86 #include <blaze/util/Types.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS SVECSCALARMULTEXPR
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
106 template< typename VT // Type of the left-hand side sparse vector
107  , typename ST // Type of the right-hand side scalar value
108  , bool TF > // Transpose flag
109 class SVecScalarMultExpr : public SparseVector< SVecScalarMultExpr<VT,ST,TF>, TF >
110  , private VecScalarMultExpr
111  , private Computation
112 {
113  private:
114  //**Type definitions****************************************************************************
115  typedef ResultType_<VT> RT;
116  typedef ReturnType_<VT> RN;
118  //**********************************************************************************************
119 
120  //**Return type evaluation**********************************************************************
122 
127  enum : bool { returnExpr = !IsTemporary<RN>::value };
128 
131  //**********************************************************************************************
132 
133  //**Serial evaluation strategy******************************************************************
135 
141  enum : bool { useAssign = RequiresEvaluation<VT>::value };
142 
144  template< typename VT2 >
146  struct UseAssign {
147  enum : bool { value = useAssign };
148  };
150  //**********************************************************************************************
151 
152  //**Parallel evaluation strategy****************************************************************
154 
160  template< typename VT2 >
161  struct UseSMPAssign {
162  enum : bool { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
163  };
165  //**********************************************************************************************
166 
167  public:
168  //**Type definitions****************************************************************************
173 
176 
179 
181  typedef If_< IsExpression<VT>, const VT, const VT& > LeftOperand;
182 
184  typedef ST RightOperand;
185  //**********************************************************************************************
186 
187  //**Compilation flags***************************************************************************
189  enum : bool { smpAssignable = false };
190  //**********************************************************************************************
191 
192  //**ConstIterator class definition**************************************************************
196  {
197  public:
198  //**Type definitions*************************************************************************
201 
204 
205  typedef std::forward_iterator_tag IteratorCategory;
206  typedef Element ValueType;
207  typedef ValueType* PointerType;
208  typedef ValueType& ReferenceType;
210 
211  // STL iterator requirements
212  typedef IteratorCategory iterator_category;
213  typedef ValueType value_type;
214  typedef PointerType pointer;
215  typedef ReferenceType reference;
216  typedef DifferenceType difference_type;
217  //*******************************************************************************************
218 
219  //**Constructor******************************************************************************
222  inline ConstIterator( IteratorType vector, RightOperand scalar )
223  : vector_( vector ) // Iterator over the elements of the left-hand side sparse vector expression
224  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
225  {}
226  //*******************************************************************************************
227 
228  //**Prefix increment operator****************************************************************
234  ++vector_;
235  return *this;
236  }
237  //*******************************************************************************************
238 
239  //**Element access operator******************************************************************
244  inline const Element operator*() const {
245  return Element( vector_->value() * scalar_, vector_->index() );
246  }
247  //*******************************************************************************************
248 
249  //**Element access operator******************************************************************
254  inline const ConstIterator* operator->() const {
255  return this;
256  }
257  //*******************************************************************************************
258 
259  //**Value function***************************************************************************
264  inline ReturnType value() const {
265  return vector_->value() * scalar_;
266  }
267  //*******************************************************************************************
268 
269  //**Index function***************************************************************************
274  inline size_t index() const {
275  return vector_->index();
276  }
277  //*******************************************************************************************
278 
279  //**Equality operator************************************************************************
285  inline bool operator==( const ConstIterator& rhs ) const {
286  return vector_ == rhs.vector_;
287  }
288  //*******************************************************************************************
289 
290  //**Inequality operator**********************************************************************
296  inline bool operator!=( const ConstIterator& rhs ) const {
297  return vector_ != rhs.vector_;
298  }
299  //*******************************************************************************************
300 
301  //**Subtraction operator*********************************************************************
307  inline DifferenceType operator-( const ConstIterator& rhs ) const {
308  return vector_ - rhs.vector_;
309  }
310  //*******************************************************************************************
311 
312  private:
313  //**Member variables*************************************************************************
314  IteratorType vector_;
315  RightOperand scalar_;
316  //*******************************************************************************************
317  };
318  //**********************************************************************************************
319 
320  //**Constructor*********************************************************************************
326  explicit inline SVecScalarMultExpr( const VT& vector, ST scalar ) noexcept
327  : vector_( vector ) // Left-hand side sparse vector of the multiplication expression
328  , scalar_( scalar ) // Right-hand side scalar of the multiplication expression
329  {}
330  //**********************************************************************************************
331 
332  //**Subscript operator**************************************************************************
338  inline ReturnType operator[]( size_t index ) const {
339  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
340  return vector_[index] * scalar_;
341  }
342  //**********************************************************************************************
343 
344  //**At function*********************************************************************************
351  inline ReturnType at( size_t index ) const {
352  if( index >= vector_.size() ) {
353  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
354  }
355  return (*this)[index];
356  }
357  //**********************************************************************************************
358 
359  //**Begin function******************************************************************************
364  inline ConstIterator begin() const {
365  return ConstIterator( vector_.begin(), scalar_ );
366  }
367  //**********************************************************************************************
368 
369  //**End function********************************************************************************
374  inline ConstIterator end() const {
375  return ConstIterator( vector_.end(), scalar_ );
376  }
377  //**********************************************************************************************
378 
379  //**Size function*******************************************************************************
384  inline size_t size() const noexcept {
385  return vector_.size();
386  }
387  //**********************************************************************************************
388 
389  //**NonZeros function***************************************************************************
394  inline size_t nonZeros() const {
395  return vector_.nonZeros();
396  }
397  //**********************************************************************************************
398 
399  //**Find function*******************************************************************************
405  inline ConstIterator find( size_t index ) const {
407  return ConstIterator( vector_.find( index ), scalar_ );
408  }
409  //**********************************************************************************************
410 
411  //**LowerBound function*************************************************************************
417  inline ConstIterator lowerBound( size_t index ) const {
419  return ConstIterator( vector_.lowerBound( index ), scalar_ );
420  }
421  //**********************************************************************************************
422 
423  //**UpperBound function*************************************************************************
429  inline ConstIterator upperBound( size_t index ) const {
431  return ConstIterator( vector_.upperBound( index ), scalar_ );
432  }
433  //**********************************************************************************************
434 
435  //**Left operand access*************************************************************************
440  inline LeftOperand leftOperand() const noexcept {
441  return vector_;
442  }
443  //**********************************************************************************************
444 
445  //**Right operand access************************************************************************
450  inline RightOperand rightOperand() const noexcept {
451  return scalar_;
452  }
453  //**********************************************************************************************
454 
455  //**********************************************************************************************
461  template< typename T >
462  inline bool canAlias( const T* alias ) const noexcept {
463  return vector_.canAlias( alias );
464  }
465  //**********************************************************************************************
466 
467  //**********************************************************************************************
473  template< typename T >
474  inline bool isAliased( const T* alias ) const noexcept {
475  return vector_.isAliased( alias );
476  }
477  //**********************************************************************************************
478 
479  private:
480  //**Member variables****************************************************************************
481  LeftOperand vector_;
482  RightOperand scalar_;
483  //**********************************************************************************************
484 
485  //**Assignment to dense vectors*****************************************************************
499  template< typename VT2 > // Type of the target dense vector
500  friend inline EnableIf_< UseAssign<VT2> >
501  assign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
502  {
504 
505  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
506 
507  assign( ~lhs, rhs.vector_ );
508  (~lhs) *= rhs.scalar_;
509  }
511  //**********************************************************************************************
512 
513  //**Assignment to sparse vectors****************************************************************
527  template< typename VT2 > // Type of the target sparse vector
528  friend inline EnableIf_< UseAssign<VT2> >
529  assign( SparseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
530  {
532 
533  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
534 
535  assign( ~lhs, rhs.vector_ );
536  (~lhs) *= rhs.scalar_;
537  }
539  //**********************************************************************************************
540 
541  //**Addition assignment to dense vectors********************************************************
555  template< typename VT2 > // Type of the target dense vector
556  friend inline EnableIf_< UseAssign<VT2> >
557  addAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
558  {
560 
563  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
564 
565  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
566 
567  const ResultType tmp( serial( rhs ) );
568  addAssign( ~lhs, tmp );
569  }
571  //**********************************************************************************************
572 
573  //**Addition assignment to sparse vectors*******************************************************
574  // No special implementation for the addition assignment to sparse vectors.
575  //**********************************************************************************************
576 
577  //**Subtraction assignment to dense vectors*****************************************************
591  template< typename VT2 > // Type of the target dense vector
592  friend inline EnableIf_< UseAssign<VT2> >
593  subAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
594  {
596 
599  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
600 
601  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
602 
603  const ResultType tmp( serial( rhs ) );
604  subAssign( ~lhs, tmp );
605  }
607  //**********************************************************************************************
608 
609  //**Subtraction assignment to sparse vectors****************************************************
610  // No special implementation for the subtraction assignment to sparse vectors.
611  //**********************************************************************************************
612 
613  //**Multiplication assignment to dense vectors**************************************************
627  template< typename VT2 > // Type of the target dense vector
628  friend inline EnableIf_< UseAssign<VT2> >
629  multAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
630  {
632 
635  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
636 
637  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
638 
639  const ResultType tmp( serial( rhs ) );
640  multAssign( ~lhs, tmp );
641  }
643  //**********************************************************************************************
644 
645  //**Multiplication assignment to sparse vectors*************************************************
646  // No special implementation for the multiplication assignment to sparse vectors.
647  //**********************************************************************************************
648 
649  //**SMP assignment to dense vectors*************************************************************
650  // No special implementation for the SMP assignment to dense vectors.
651  //**********************************************************************************************
652 
653  //**SMP assignment to sparse vectors************************************************************
654  // No special implementation for the SMP assignment to sparse vectors.
655  //**********************************************************************************************
656 
657  //**SMP addition assignment to dense vectors****************************************************
671  template< typename VT2 > // Type of the target dense vector
672  friend inline EnableIf_< UseSMPAssign<VT2> >
673  smpAddAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
674  {
676 
679  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
680 
681  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
682 
683  const ResultType tmp( rhs );
684  smpAddAssign( ~lhs, tmp );
685  }
687  //**********************************************************************************************
688 
689  //**SMP addition assignment to sparse vectors***************************************************
690  // No special implementation for the SMP addition assignment to sparse vectors.
691  //**********************************************************************************************
692 
693  //**SMP subtraction assignment to dense vectors*************************************************
707  template< typename VT2 > // Type of the target dense vector
708  friend inline EnableIf_< UseSMPAssign<VT2> >
709  smpSubAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
710  {
712 
715  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
716 
717  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
718 
719  const ResultType tmp( rhs );
720  smpSubAssign( ~lhs, tmp );
721  }
723  //**********************************************************************************************
724 
725  //**SMP subtraction assignment to sparse vectors************************************************
726  // No special implementation for the SMP subtraction assignment to sparse vectors.
727  //**********************************************************************************************
728 
729  //**SMP multiplication assignment to dense vectors**********************************************
743  template< typename VT2 > // Type of the target dense vector
744  friend inline EnableIf_< UseSMPAssign<VT2> >
745  smpMultAssign( DenseVector<VT2,TF>& lhs, const SVecScalarMultExpr& rhs )
746  {
748 
751  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
752 
753  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
754 
755  const ResultType tmp( rhs );
756  smpMultAssign( ~lhs, tmp );
757  }
759  //**********************************************************************************************
760 
761  //**SMP multiplication assignment to sparse vectors*********************************************
762  // No special implementation for the SMP multiplication assignment to sparse vectors.
763  //**********************************************************************************************
764 
765  //**Compile time checks*************************************************************************
770  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
772  //**********************************************************************************************
773 };
774 //*************************************************************************************************
775 
776 
777 
778 
779 //=================================================================================================
780 //
781 // GLOBAL UNARY ARITHMETIC OPERATORS
782 //
783 //=================================================================================================
784 
785 //*************************************************************************************************
802 template< typename VT // Type of the sparse vector
803  , bool TF > // Transpose flag
804 inline const SVecScalarMultExpr<VT,UnderlyingBuiltin_<VT>,TF>
806 {
808 
811 }
812 //*************************************************************************************************
813 
814 
815 
816 
817 //=================================================================================================
818 //
819 // GLOBAL BINARY ARITHMETIC OPERATORS
820 //
821 //=================================================================================================
822 
823 //*************************************************************************************************
844 template< typename T1 // Type of the left-hand side sparse vector
845  , typename T2 // Type of the right-hand side scalar
846  , bool TF > // Transpose flag
847 inline const EnableIf_< IsNumeric<T2>, MultExprTrait_<T1,T2> >
848  operator*( const SparseVector<T1,TF>& vec, T2 scalar )
849 {
851 
852  return MultExprTrait_<T1,T2>( ~vec, scalar );
853 }
854 //*************************************************************************************************
855 
856 
857 //*************************************************************************************************
878 template< typename T1 // Type of the left-hand side scalar
879  , typename T2 // Type of the right-hand side sparse vector
880  , bool TF > // Transpose flag
881 inline const EnableIf_< IsNumeric<T1>, MultExprTrait_<T1,T2> >
882  operator*( T1 scalar, const SparseVector<T2,TF>& vec )
883 {
885 
886  return MultExprTrait_<T1,T2>( ~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,ElementType_<VT>,TF>
921 {
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 EnableIf_< IsNumeric<ST2>, MultExprTrait_< SVecScalarMultExpr<VT,ST1,TF>, ST2 > >
994  operator*( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
995 {
997 
998  return vec.leftOperand() * ( vec.rightOperand() * scalar );
999 }
1001 //*************************************************************************************************
1002 
1003 
1004 //*************************************************************************************************
1017 template< typename ST1 // Type of the left-hand side scalar
1018  , typename VT // Type of the sparse vector of the right-hand side expression
1019  , typename ST2 // Type of the scalar of the right-hand side expression
1020  , bool TF > // Transpose flag of the sparse vector
1021 inline const EnableIf_< IsNumeric<ST1>, MultExprTrait_< ST1, SVecScalarMultExpr<VT,ST2,TF> > >
1022  operator*( ST1 scalar, const SVecScalarMultExpr<VT,ST2,TF>& vec )
1023 {
1025 
1026  return vec.leftOperand() * ( scalar * vec.rightOperand() );
1027 }
1029 //*************************************************************************************************
1030 
1031 
1032 //*************************************************************************************************
1045 template< typename VT // Type of the dense vector of the left-hand side expression
1046  , typename ST1 // Type of the scalar of the left-hand side expression
1047  , bool TF // Transpose flag of the dense vector
1048  , typename ST2 > // Type of the right-hand side scalar
1049 inline const EnableIf_< And< IsNumeric<ST2>, Or< IsInvertible<ST1>, IsInvertible<ST2> > >
1050  , DivExprTrait_< SVecScalarMultExpr<VT,ST1,TF>, ST2 > >
1051  operator/( const SVecScalarMultExpr<VT,ST1,TF>& vec, ST2 scalar )
1052 {
1054 
1055  return vec.leftOperand() * ( vec.rightOperand() / scalar );
1056 }
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1075 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1076  , typename ST // Type of the scalar of the left-hand side expression
1077  , bool TF // Transpose flag of the dense vectors
1078  , typename VT2 > // Type of the right-hand side dense vector
1079 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST,TF>, VT2 >
1080  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1081 {
1083 
1084  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1085 }
1087 //*************************************************************************************************
1088 
1089 
1090 //*************************************************************************************************
1104 template< typename VT1 // Type of the left-hand side dense vector
1105  , bool TF // Transpose flag of the dense vectors
1106  , typename VT2 // Type of the sparse vector of the right-hand side expression
1107  , typename ST > // Type of the scalar of the right-hand side expression
1108 inline const MultExprTrait_< VT1, SVecScalarMultExpr<VT2,ST,TF> >
1109  operator*( const DenseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1110 {
1112 
1113  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1114 }
1116 //*************************************************************************************************
1117 
1118 
1119 //*************************************************************************************************
1133 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1134  , typename ST // Type of the scalar of the left-hand side expression
1135  , typename VT2 > // Type of the right-hand side dense vector
1136 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1137  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const DenseVector<VT2,true>& rhs )
1138 {
1140 
1141  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1142 }
1144 //*************************************************************************************************
1145 
1146 
1147 //*************************************************************************************************
1161 template< typename VT1 // Type of the left-hand side dense vector
1162  , typename VT2 // Type of the sparse vector of the right-hand side expression
1163  , typename ST > // Type of the scalar of the right-hand side expression
1164 inline const MultExprTrait_< VT1, SVecScalarMultExpr<VT2,ST,true> >
1165  operator*( const DenseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1166 {
1168 
1169  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1170 }
1172 //*************************************************************************************************
1173 
1174 
1175 //*************************************************************************************************
1189 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1190  , typename ST // Type of the scalar of the left-hand side expression
1191  , bool TF // Transpose flag of the vectors
1192  , typename VT2 > // Type of the right-hand side sparse vector
1193 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST,TF>, VT2 >
1194  operator*( const SVecScalarMultExpr<VT1,ST,TF>& lhs, const SparseVector<VT2,TF>& rhs )
1195 {
1197 
1198  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1199 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1218 template< typename VT1 // Type of the left-hand side sparse vector
1219  , bool TF // Transpose flag of the vectors
1220  , typename VT2 // Type of the sparse vector of the right-hand side expression
1221  , typename ST > // Type of the scalar of the right-hand side expression
1222 inline const MultExprTrait_< VT1, SVecScalarMultExpr<VT2,ST,TF> >
1223  operator*( const SparseVector<VT1,TF>& lhs, const SVecScalarMultExpr<VT2,ST,TF>& rhs )
1224 {
1226 
1227  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1228 }
1230 //*************************************************************************************************
1231 
1232 
1233 //*************************************************************************************************
1247 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1248  , typename ST1 // Type of the scalar of the left-hand side expression
1249  , bool TF // Transpose flag of the sparse vectors
1250  , typename VT2 // Type of the sparse vector of the right-hand side expression
1251  , typename ST2 > // Type of the scalar of the right-hand side expression
1252 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST1,TF>, SVecScalarMultExpr<VT2,ST2,TF> >
1253  operator*( const SVecScalarMultExpr<VT1,ST1,TF>& lhs, const SVecScalarMultExpr<VT2,ST2,TF>& rhs )
1254 {
1256 
1257  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1258 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1277 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1278  , typename ST // Type of the scalar of the left-hand side expression
1279  , typename VT2 > // Type of the right-hand side sparse vector
1280 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1281  operator*( const SVecScalarMultExpr<VT1,ST,false>& lhs, const SparseVector<VT2,true>& rhs )
1282 {
1284 
1285  return ( lhs.leftOperand() * (~rhs) ) * lhs.rightOperand();
1286 }
1288 //*************************************************************************************************
1289 
1290 
1291 //*************************************************************************************************
1305 template< typename VT1 // Type of the left-hand side sparse vector
1306  , typename VT2 // Type of the sparse vector of the right-hand side expression
1307  , typename ST > // Type of the scalar of the right-hand side expression
1308 inline const MultExprTrait_< VT1, SVecScalarMultExpr<VT2,ST,true> >
1309  operator*( const SparseVector<VT1,false>& lhs, const SVecScalarMultExpr<VT2,ST,true>& rhs )
1310 {
1312 
1313  return ( (~lhs) * rhs.leftOperand() ) * rhs.rightOperand();
1314 }
1316 //*************************************************************************************************
1317 
1318 
1319 //*************************************************************************************************
1333 template< typename VT1 // Type of the sparse vector of the left-hand side expression
1334  , typename ST1 // Type of the scalar of the left-hand side expression
1335  , typename VT2 // Type of the sparse vector of the right-hand side expression
1336  , typename ST2 > // Type of the scalar of the right-hand side expression
1337 inline const MultExprTrait_< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1338  operator*( const SVecScalarMultExpr<VT1,ST1,false>& lhs, const SVecScalarMultExpr<VT2,ST2,true>& rhs )
1339 {
1341 
1342  return ( lhs.leftOperand() * rhs.leftOperand() ) * ( lhs.rightOperand() * rhs.rightOperand() );
1343 }
1345 //*************************************************************************************************
1346 
1347 
1348 //*************************************************************************************************
1362 template< typename MT // Type of the left-hand side dense matrix
1363  , bool SO // Storage order of the left-hand side dense matrix
1364  , typename VT // Type of the sparse vector of the right-hand side expression
1365  , typename ST > // Type of the scalar of the right-hand side expression
1366 inline const MultExprTrait_< MT, SVecScalarMultExpr<VT,ST,false> >
1367  operator*( const DenseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1368 {
1370 
1371  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1372 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1391 template< typename VT // Type of the sparse vector of the left-hand side expression
1392  , typename ST // Type of the scalar of the left-hand side expression
1393  , typename MT // Type of the right-hand side dense matrix
1394  , bool SO > // Storage order of the right-hand side dense matrix
1395 inline const MultExprTrait_< SVecScalarMultExpr<VT,ST,true>, MT >
1396  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const DenseMatrix<MT,SO>& mat )
1397 {
1399 
1400  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1401 }
1403 //*************************************************************************************************
1404 
1405 
1406 //*************************************************************************************************
1420 template< typename MT // Type of the left-hand side sparse matrix
1421  , bool SO // Storage order of the left-hand side sparse matrix
1422  , typename VT // Type of the sparse vector of the right-hand side expression
1423  , typename ST > // Type of the scalar of the right-hand side expression
1424 inline const MultExprTrait_< MT, SVecScalarMultExpr<VT,ST,false> >
1425  operator*( const SparseMatrix<MT,SO>& mat, const SVecScalarMultExpr<VT,ST,false>& vec )
1426 {
1428 
1429  return ( (~mat) * vec.leftOperand() ) * vec.rightOperand();
1430 }
1432 //*************************************************************************************************
1433 
1434 
1435 //*************************************************************************************************
1449 template< typename VT // Type of the sparse vector of the left-hand side expression
1450  , typename ST // Type of the scalar of the left-hand side expression
1451  , typename MT // Type of the right-hand side sparse matrix
1452  , bool SO > // Storage order of the right-hand side sparse matrix
1453 inline const MultExprTrait_< SVecScalarMultExpr<VT,ST,true>, MT >
1454  operator*( const SVecScalarMultExpr<VT,ST,true>& vec, const SparseMatrix<MT,SO>& mat )
1455 {
1457 
1458  return ( vec.leftOperand() * (~mat) ) * vec.rightOperand();
1459 }
1461 //*************************************************************************************************
1462 
1463 
1464 
1465 
1466 //=================================================================================================
1467 //
1468 // SIZE SPECIALIZATIONS
1469 //
1470 //=================================================================================================
1471 
1472 //*************************************************************************************************
1474 template< typename VT, typename ST, bool TF >
1475 struct Size< SVecScalarMultExpr<VT,ST,TF> > : public Size<VT>
1476 {};
1478 //*************************************************************************************************
1479 
1480 
1481 
1482 
1483 //=================================================================================================
1484 //
1485 // SVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1486 //
1487 //=================================================================================================
1488 
1489 //*************************************************************************************************
1491 template< typename VT, typename ST1, typename ST2 >
1492 struct SVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1493 {
1494  public:
1495  //**********************************************************************************************
1496  typedef If_< And< IsSparseVector<VT>, IsColumnVector<VT>
1497  , IsNumeric<ST1>, IsNumeric<ST2> >
1498  , SVecScalarMultExprTrait_< VT, MultTrait_<ST1,ST2> >
1499  , INVALID_TYPE > Type;
1500  //**********************************************************************************************
1501 };
1503 //*************************************************************************************************
1504 
1505 
1506 
1507 
1508 //=================================================================================================
1509 //
1510 // TSVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1511 //
1512 //=================================================================================================
1513 
1514 //*************************************************************************************************
1516 template< typename VT, typename ST1, typename ST2 >
1517 struct TSVecScalarMultExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1518 {
1519  public:
1520  //**********************************************************************************************
1521  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
1522  , IsNumeric<ST1>, IsNumeric<ST2> >
1523  , TSVecScalarMultExprTrait_< VT, MultTrait_<ST1,ST2> >
1524  , INVALID_TYPE >;
1525  //**********************************************************************************************
1526 };
1528 //*************************************************************************************************
1529 
1530 
1531 
1532 
1533 //=================================================================================================
1534 //
1535 // SVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1536 //
1537 //=================================================================================================
1538 
1539 //*************************************************************************************************
1541 template< typename VT, typename ST1, typename ST2 >
1542 struct SVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,false>, ST2 >
1543 {
1544  private:
1545  //**********************************************************************************************
1546  using ScalarType = DivTrait_<ST1,ST2>;
1547  //**********************************************************************************************
1548 
1549  public:
1550  //**********************************************************************************************
1551  using Type = If_< And< IsSparseVector<VT>, IsColumnVector<VT>
1552  , IsNumeric<ST1>, IsNumeric<ST2> >
1553  , If_< IsInvertible<ScalarType>
1554  , SVecScalarMultExprTrait_<VT,ScalarType>
1555  , SVecScalarDivExprTrait_<VT,ScalarType> >
1556  , INVALID_TYPE >;
1557  //**********************************************************************************************
1558 };
1560 //*************************************************************************************************
1561 
1562 
1563 
1564 
1565 //=================================================================================================
1566 //
1567 // TSVECSCALARDIVEXPRTRAIT SPECIALIZATIONS
1568 //
1569 //=================================================================================================
1570 
1571 //*************************************************************************************************
1573 template< typename VT, typename ST1, typename ST2 >
1574 struct TSVecScalarDivExprTrait< SVecScalarMultExpr<VT,ST1,true>, ST2 >
1575 {
1576  private:
1577  //**********************************************************************************************
1578  using ScalarType = DivTrait_<ST1,ST2>;
1579  //**********************************************************************************************
1580 
1581  public:
1582  //**********************************************************************************************
1583  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
1584  , IsNumeric<ST1>, IsNumeric<ST2> >
1585  , If_< IsInvertible<ScalarType>
1586  , TSVecScalarMultExprTrait_<VT,ScalarType>
1587  , TSVecScalarDivExprTrait_<VT,ScalarType> >
1588  , INVALID_TYPE >;
1589  //**********************************************************************************************
1590 };
1592 //*************************************************************************************************
1593 
1594 
1595 
1596 
1597 //=================================================================================================
1598 //
1599 // DVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1600 //
1601 //=================================================================================================
1602 
1603 //*************************************************************************************************
1605 template< typename VT1, typename VT2, typename ST >
1606 struct DVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1607 {
1608  public:
1609  //**********************************************************************************************
1610  using Type = If_< And< IsDenseVector<VT1>, IsColumnVector<VT1>
1611  , IsSparseVector<VT2>, IsColumnVector<VT2>
1612  , IsNumeric<ST> >
1613  , SVecScalarMultExprTrait_< DVecSVecMultExprTrait_<VT1,VT2>, ST >
1614  , INVALID_TYPE >;
1615  //**********************************************************************************************
1616 };
1618 //*************************************************************************************************
1619 
1620 
1621 
1622 
1623 //=================================================================================================
1624 //
1625 // DVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1626 //
1627 //=================================================================================================
1628 
1629 //*************************************************************************************************
1631 template< typename VT1, typename VT2, typename ST >
1632 struct DVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1633 {
1634  public:
1635  //**********************************************************************************************
1636  using Type = If_< And< IsDenseVector<VT1>, IsColumnVector<VT1>
1637  , IsSparseVector<VT2>, IsRowVector<VT2>
1638  , IsNumeric<ST> >
1639  , SMatScalarMultExprTrait_< DVecTSVecMultExprTrait_<VT1,VT2>, ST >
1640  , INVALID_TYPE >;
1641  //**********************************************************************************************
1642 };
1644 //*************************************************************************************************
1645 
1646 
1647 
1648 
1649 //=================================================================================================
1650 //
1651 // TDVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1652 //
1653 //=================================================================================================
1654 
1655 //*************************************************************************************************
1657 template< typename VT1, typename VT2, typename ST >
1658 struct TDVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1659 {
1660  public:
1661  //**********************************************************************************************
1662  using Type = If_< And< IsDenseVector<VT1>, IsRowVector<VT1>
1663  , IsSparseVector<VT2>, IsRowVector<VT2>
1664  , IsNumeric<ST> >
1665  , TSVecScalarMultExprTrait_< TDVecTSVecMultExprTrait_<VT1,VT2>, ST >
1666  , INVALID_TYPE >;
1667  //**********************************************************************************************
1668 };
1670 //*************************************************************************************************
1671 
1672 
1673 
1674 
1675 //=================================================================================================
1676 //
1677 // SVECDVECMULTEXPRTRAIT SPECIALIZATIONS
1678 //
1679 //=================================================================================================
1680 
1681 //*************************************************************************************************
1683 template< typename VT1, typename ST, typename VT2 >
1684 struct SVecDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1685 {
1686  public:
1687  //**********************************************************************************************
1688  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1689  , IsDenseVector<VT2>, IsColumnVector<VT2>
1690  , IsNumeric<ST> >
1691  , SVecScalarMultExprTrait_< SVecDVecMultExprTrait_<VT1,VT2>, ST >
1692  , INVALID_TYPE >;
1693  //**********************************************************************************************
1694 };
1696 //*************************************************************************************************
1697 
1698 
1699 
1700 
1701 //=================================================================================================
1702 //
1703 // SVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1704 //
1705 //=================================================================================================
1706 
1707 //*************************************************************************************************
1709 template< typename VT1, typename ST, typename VT2 >
1710 struct SVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1711 {
1712  public:
1713  //**********************************************************************************************
1714  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1715  , IsDenseVector<VT2>, IsRowVector<VT2>
1716  , IsNumeric<ST> >
1717  , TSMatScalarMultExprTrait_< SVecTDVecMultExprTrait_<VT1,VT2>, ST >
1718  , INVALID_TYPE >;
1719  //**********************************************************************************************
1720 };
1722 //*************************************************************************************************
1723 
1724 
1725 
1726 
1727 //=================================================================================================
1728 //
1729 // TSVECTDVECMULTEXPRTRAIT SPECIALIZATIONS
1730 //
1731 //=================================================================================================
1732 
1733 //*************************************************************************************************
1735 template< typename VT1, typename ST, typename VT2 >
1736 struct TSVecTDVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1737 {
1738  public:
1739  //**********************************************************************************************
1740  using Type = If_< And< IsSparseVector<VT1>, IsRowVector<VT1>
1741  , IsDenseVector<VT2>, IsRowVector<VT2>
1742  , IsNumeric<ST> >
1743  , TSVecScalarMultExprTrait_< TSVecTDVecMultExprTrait_<VT1,VT2>, ST >
1744  , INVALID_TYPE >;
1745  //**********************************************************************************************
1746 };
1748 //*************************************************************************************************
1749 
1750 
1751 
1752 
1753 //=================================================================================================
1754 //
1755 // SVECSVECMULTEXPRTRAIT SPECIALIZATIONS
1756 //
1757 //=================================================================================================
1758 
1759 //*************************************************************************************************
1761 template< typename VT1, typename ST, typename VT2 >
1762 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1763 {
1764  public:
1765  //**********************************************************************************************
1766  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1767  , IsSparseVector<VT2>, IsColumnVector<VT2>
1768  , IsNumeric<ST> >
1769  , SVecScalarMultExprTrait_< SVecSVecMultExprTrait_<VT1,VT2>, ST >
1770  , INVALID_TYPE >;
1771  //**********************************************************************************************
1772 };
1774 //*************************************************************************************************
1775 
1776 
1777 //*************************************************************************************************
1779 template< typename VT1, typename VT2, typename ST >
1780 struct SVecSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,false> >
1781 {
1782  public:
1783  //**********************************************************************************************
1784  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1785  , IsSparseVector<VT2>, IsColumnVector<VT2>
1786  , IsNumeric<ST> >
1787  , SVecScalarMultExprTrait_< SVecSVecMultExprTrait_<VT1,VT2>, ST >
1788  , INVALID_TYPE >;
1789  //**********************************************************************************************
1790 };
1792 //*************************************************************************************************
1793 
1794 
1795 //*************************************************************************************************
1797 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1798 struct SVecSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,false> >
1799 {
1800  public:
1801  //**********************************************************************************************
1802  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1803  , IsSparseVector<VT2>, IsColumnVector<VT2>
1804  , IsNumeric<ST1>, IsNumeric<ST2> >
1805  , SVecScalarMultExprTrait_< SVecSVecMultExprTrait_<VT1,VT2>, MultTrait_<ST1,ST2> >
1806  , INVALID_TYPE >;
1807  //**********************************************************************************************
1808 };
1810 //*************************************************************************************************
1811 
1812 
1813 
1814 
1815 //=================================================================================================
1816 //
1817 // SVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1818 //
1819 //=================================================================================================
1820 
1821 //*************************************************************************************************
1823 template< typename VT1, typename ST, typename VT2 >
1824 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,false>, VT2 >
1825 {
1826  public:
1827  //**********************************************************************************************
1828  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1829  , IsSparseVector<VT2>, IsRowVector<VT2>
1830  , IsNumeric<ST> >
1831  , SMatScalarMultExprTrait_< SVecTSVecMultExprTrait_<VT1,VT2>, ST >
1832  , INVALID_TYPE >;
1833  //**********************************************************************************************
1834 };
1836 //*************************************************************************************************
1837 
1838 
1839 //*************************************************************************************************
1841 template< typename VT1, typename VT2, typename ST >
1842 struct SVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1843 {
1844  public:
1845  //**********************************************************************************************
1846  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1847  , IsSparseVector<VT2>, IsRowVector<VT2>
1848  , IsNumeric<ST> >
1849  , SMatScalarMultExprTrait_< SVecTSVecMultExprTrait_<VT1,VT2>, ST >
1850  , INVALID_TYPE >;
1851  //**********************************************************************************************
1852 };
1854 //*************************************************************************************************
1855 
1856 
1857 //*************************************************************************************************
1859 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1860 struct SVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,false>, SVecScalarMultExpr<VT2,ST2,true> >
1861 {
1862  public:
1863  //**********************************************************************************************
1864  using Type = If_< And< IsSparseVector<VT1>, IsColumnVector<VT1>
1865  , IsSparseVector<VT2>, IsRowVector<VT2>
1866  , IsNumeric<ST1>, IsNumeric<ST2> >
1867  , SMatScalarMultExprTrait_< SVecTSVecMultExprTrait_<VT1,VT2>, MultTrait_<ST1,ST2> >
1868  , INVALID_TYPE >;
1869  //**********************************************************************************************
1870 };
1872 //*************************************************************************************************
1873 
1874 
1875 
1876 
1877 //=================================================================================================
1878 //
1879 // TSVECTSVECMULTEXPRTRAIT SPECIALIZATIONS
1880 //
1881 //=================================================================================================
1882 
1883 //*************************************************************************************************
1885 template< typename VT1, typename ST, typename VT2 >
1886 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST,true>, VT2 >
1887 {
1888  public:
1889  //**********************************************************************************************
1890  using Type = If_< And< IsSparseVector<VT1>, IsRowVector<VT1>
1891  , IsSparseVector<VT2>, IsRowVector<VT2>
1892  , IsNumeric<ST> >
1893  , TSVecScalarMultExprTrait_< TSVecTSVecMultExprTrait_<VT1,VT2>, ST >
1894  , INVALID_TYPE >;
1895  //**********************************************************************************************
1896 };
1898 //*************************************************************************************************
1899 
1900 
1901 //*************************************************************************************************
1903 template< typename VT1, typename VT2, typename ST >
1904 struct TSVecTSVecMultExprTrait< VT1, SVecScalarMultExpr<VT2,ST,true> >
1905 {
1906  public:
1907  //**********************************************************************************************
1908  using Type = If_< And< IsSparseVector<VT1>, IsRowVector<VT1>
1909  , IsSparseVector<VT2>, IsRowVector<VT2>
1910  , IsNumeric<ST> >
1911  , TSVecScalarMultExprTrait_< TSVecTSVecMultExprTrait_<VT1,VT2>, ST >
1912  , INVALID_TYPE >;
1913  //**********************************************************************************************
1914 };
1916 //*************************************************************************************************
1917 
1918 
1919 //*************************************************************************************************
1921 template< typename VT1, typename ST1, typename VT2, typename ST2 >
1922 struct TSVecTSVecMultExprTrait< SVecScalarMultExpr<VT1,ST1,true>, SVecScalarMultExpr<VT2,ST2,true> >
1923 {
1924  public:
1925  //**********************************************************************************************
1926  using Type = If_< And< IsSparseVector<VT1>, IsRowVector<VT1>
1927  , IsSparseVector<VT2>, IsRowVector<VT2>
1928  , IsNumeric<ST1>, IsNumeric<ST2> >
1929  , TSVecScalarMultExprTrait_< TSVecTSVecMultExprTrait_<VT1,VT2>, MultTrait_<ST1,ST2> >
1930  , INVALID_TYPE >;
1931  //**********************************************************************************************
1932 };
1934 //*************************************************************************************************
1935 
1936 
1937 
1938 
1939 //=================================================================================================
1940 //
1941 // DMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1942 //
1943 //=================================================================================================
1944 
1945 //*************************************************************************************************
1947 template< typename MT, typename VT, typename ST >
1948 struct DMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1949 {
1950  public:
1951  //**********************************************************************************************
1952  using Type = If_< And< IsDenseMatrix<MT>, IsRowMajorMatrix<MT>
1953  , IsSparseVector<VT>, IsColumnVector<VT>
1954  , IsNumeric<ST> >
1955  , DVecScalarMultExprTrait_< DMatSVecMultExprTrait_<MT,VT>, ST >
1956  , INVALID_TYPE >;
1957  //**********************************************************************************************
1958 };
1960 //*************************************************************************************************
1961 
1962 
1963 
1964 
1965 //=================================================================================================
1966 //
1967 // TDMATSVECMULTEXPRTRAIT SPECIALIZATIONS
1968 //
1969 //=================================================================================================
1970 
1971 //*************************************************************************************************
1973 template< typename MT, typename VT, typename ST >
1974 struct TDMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
1975 {
1976  public:
1977  //**********************************************************************************************
1978  using Type = If_< And< IsDenseMatrix<MT>, IsColumnMajorMatrix<MT>
1979  , IsSparseVector<VT>, IsColumnVector<VT>
1980  , IsNumeric<ST> >
1981  , DVecScalarMultExprTrait_< TDMatSVecMultExprTrait_<MT,VT>, ST >
1982  , INVALID_TYPE >;
1983  //**********************************************************************************************
1984 };
1986 //*************************************************************************************************
1987 
1988 
1989 
1990 
1991 //=================================================================================================
1992 //
1993 // TSVECDMATMULTEXPRTRAIT SPECIALIZATIONS
1994 //
1995 //=================================================================================================
1996 
1997 //*************************************************************************************************
1999 template< typename VT, typename ST, typename MT >
2000 struct TSVecDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2001 {
2002  public:
2003  //**********************************************************************************************
2004  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
2005  , IsDenseMatrix<MT>, IsRowMajorMatrix<MT>
2006  , IsNumeric<ST> >
2007  , TDVecScalarMultExprTrait_< TSVecDMatMultExprTrait_<VT,MT>, ST >
2008  , INVALID_TYPE >;
2009  //**********************************************************************************************
2010 };
2012 //*************************************************************************************************
2013 
2014 
2015 
2016 
2017 //=================================================================================================
2018 //
2019 // TSVECTDMATMULTEXPRTRAIT SPECIALIZATIONS
2020 //
2021 //=================================================================================================
2022 
2023 //*************************************************************************************************
2025 template< typename VT, typename ST, typename MT >
2026 struct TSVecTDMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2027 {
2028  public:
2029  //**********************************************************************************************
2030  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
2031  , IsDenseMatrix<MT>, IsColumnMajorMatrix<MT>
2032  , IsNumeric<ST> >
2033  , TDVecScalarMultExprTrait_< TSVecTDMatMultExprTrait_<VT,MT>, ST >
2034  , INVALID_TYPE >;
2035  //**********************************************************************************************
2036 };
2038 //*************************************************************************************************
2039 
2040 
2041 
2042 
2043 //=================================================================================================
2044 //
2045 // SMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2046 //
2047 //=================================================================================================
2048 
2049 //*************************************************************************************************
2051 template< typename MT, typename VT, typename ST >
2052 struct SMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2053 {
2054  public:
2055  //**********************************************************************************************
2056  using Type = If_< And< IsSparseMatrix<MT>, IsRowMajorMatrix<MT>
2057  , IsSparseVector<VT>, IsColumnVector<VT>
2058  , IsNumeric<ST> >
2059  , SVecScalarMultExprTrait_< SMatSVecMultExprTrait_<MT,VT>, ST >
2060  , INVALID_TYPE >;
2061  //**********************************************************************************************
2062 };
2064 //*************************************************************************************************
2065 
2066 
2067 
2068 
2069 //=================================================================================================
2070 //
2071 // TSMATSVECMULTEXPRTRAIT SPECIALIZATIONS
2072 //
2073 //=================================================================================================
2074 
2075 //*************************************************************************************************
2077 template< typename MT, typename VT, typename ST >
2078 struct TSMatSVecMultExprTrait< MT, SVecScalarMultExpr<VT,ST,false> >
2079 {
2080  public:
2081  //**********************************************************************************************
2082  using Type = If_< And< IsSparseMatrix<MT>, IsColumnMajorMatrix<MT>
2083  , IsSparseVector<VT>, IsColumnVector<VT>
2084  , IsNumeric<ST> >
2085  , SVecScalarMultExprTrait_< TSMatSVecMultExprTrait_<MT,VT>, ST >
2086  , INVALID_TYPE >;
2087  //**********************************************************************************************
2088 };
2090 //*************************************************************************************************
2091 
2092 
2093 
2094 
2095 //=================================================================================================
2096 //
2097 // TSVECSMATMULTEXPRTRAIT SPECIALIZATIONS
2098 //
2099 //=================================================================================================
2100 
2101 //*************************************************************************************************
2103 template< typename VT, typename ST, typename MT >
2104 struct TSVecSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2105 {
2106  public:
2107  //**********************************************************************************************
2108  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
2109  , IsSparseMatrix<MT>, IsRowMajorMatrix<MT>
2110  , IsNumeric<ST> >
2111  , TSVecScalarMultExprTrait_< TSVecSMatMultExprTrait_<VT,MT>, ST >
2112  , INVALID_TYPE >;
2113  //**********************************************************************************************
2114 };
2116 //*************************************************************************************************
2117 
2118 
2119 
2120 
2121 //=================================================================================================
2122 //
2123 // TSVECTSMATMULTEXPRTRAIT SPECIALIZATIONS
2124 //
2125 //=================================================================================================
2126 
2127 //*************************************************************************************************
2129 template< typename VT, typename ST, typename MT >
2130 struct TSVecTSMatMultExprTrait< SVecScalarMultExpr<VT,ST,true>, MT >
2131 {
2132  public:
2133  //**********************************************************************************************
2134  using Type = If_< And< IsSparseVector<VT>, IsRowVector<VT>
2135  , IsSparseMatrix<MT>, IsColumnMajorMatrix<MT>
2136  , IsNumeric<ST> >
2137  , TSVecScalarMultExprTrait_< TSVecTSMatMultExprTrait_<VT,MT>, ST >
2138  , INVALID_TYPE >;
2139  //**********************************************************************************************
2140 };
2142 //*************************************************************************************************
2143 
2144 
2145 
2146 
2147 //=================================================================================================
2148 //
2149 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
2150 //
2151 //=================================================================================================
2152 
2153 //*************************************************************************************************
2155 template< typename VT, typename ST, bool TF, bool AF >
2156 struct SubvectorExprTrait< SVecScalarMultExpr<VT,ST,TF>, AF >
2157 {
2158  public:
2159  //**********************************************************************************************
2160  using Type = MultExprTrait_< SubvectorExprTrait_<const VT,AF>, ST >;
2161  //**********************************************************************************************
2162 };
2164 //*************************************************************************************************
2165 
2166 } // namespace blaze
2167 
2168 #endif
ValueType & ReferenceType
Reference return type.
Definition: SVecScalarMultExpr.h:208
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Data type constraint.
Constraint on the data type.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SVecScalarMultExpr.h:184
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecScalarMultExpr.h:462
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
IteratorCategory iterator_category
The iterator category.
Definition: SVecScalarMultExpr.h:212
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:7800
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:296
EnableIf_< IsDenseMatrix< MT1 > > 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 IsSparseMatrix type trait.
Header file for the serial shim.
Header file for the IsColumnMajorMatrix type trait.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SVecScalarMultExpr.h:209
Header file for the IsRowVector type trait.
EnableIf_< IsDenseVector< VT1 > > 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:193
const Element operator*() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:244
Header file for the And class template.
Iterator over the elements of the sparse vector/scalar multiplication expression. ...
Definition: SVecScalarMultExpr.h:195
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SVecScalarMultExpr.h:450
ConstIterator_< RemoveReference_< LeftOperand > > IteratorType
Iterator type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:203
const ConstIterator * operator->() const
Direct access to the sparse vector element at the current iterator position.
Definition: SVecScalarMultExpr.h:254
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
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:307
size_t index() const
Access to the current index of the sparse element.
Definition: SVecScalarMultExpr.h:274
Header file for the VecScalarMultExpr base class.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > 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
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_
Auxiliary alias declaration for the UnderlyingBuiltin type trait.The UnderlyingBuiltin_ alias declara...
Definition: UnderlyingBuiltin.h:133
ConstIterator & operator++()
Pre-increment operator.
Definition: SVecScalarMultExpr.h:233
Constraint on the data type.
auto length(const DenseVector< VT, TF > &dv) -> decltype(sqrt(sqrLength(~dv)))
Calculation of the dense vector length .
Definition: DenseVector.h:574
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
size_t nonZeros() const
Returns the number of non-zero elements in the sparse vector.
Definition: SVecScalarMultExpr.h:394
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:482
Header file for the DivExprTrait class template.
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: SVecScalarMultExpr.h:417
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:344
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:72
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
ValueIndexPair< ElementType > Element
Element type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:200
const EnableIf_< IsNumeric< T2 >, DivExprTrait_< T1, T2 > > operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:966
Header file for the ValueIndexPair class.
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
PointerType pointer
Pointer return type.
Definition: SVecScalarMultExpr.h:214
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SVecScalarMultExpr.h:264
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SVecScalarMultExpr.h:315
Header file for the UnderlyingBuiltin type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecScalarMultExpr.h:175
Header file for the Or class template.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SVecScalarMultExpr.h:384
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
If_< IsExpression< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:181
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
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:71
#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:61
CompositeType_< VT > CT
Composite type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:117
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:60
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the IsDenseMatrix type trait.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecScalarMultExpr.h:474
Header file for the EnableIf class template.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecScalarMultExpr.h:440
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SVecScalarMultExpr.h:285
Header file for the IsNumeric type trait.
IfTrue_< useAssign, const ResultType, const SVecScalarMultExpr & > CompositeType
Data type for composite expression templates.
Definition: SVecScalarMultExpr.h:178
ConstIterator end() const
Returns an iterator just past the last non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:374
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: SVecScalarMultExpr.h:405
Header file for the IsSparseVector type trait.
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecScalarMultExpr.h:172
ResultType_< VT > RT
Result type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:115
Header file for run time assertion macros.
Utility type for generic codes.
Element ValueType
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:206
Header file for the division trait.
IteratorType vector_
Iterator over the elements of the left-hand side sparse vector expression.
Definition: SVecScalarMultExpr.h:314
ReferenceType reference
Reference return type.
Definition: SVecScalarMultExpr.h:215
SVecScalarMultExpr< VT, ST, TF > This
Type of this SVecScalarMultExpr instance.
Definition: SVecScalarMultExpr.h:169
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SVecScalarMultExpr.h:205
MultTrait_< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SVecScalarMultExpr.h:170
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:61
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SVecScalarMultExpr.h:338
ValueType * PointerType
Pointer return type.
Definition: SVecScalarMultExpr.h:207
DifferenceType difference_type
Difference between two iterators.
Definition: SVecScalarMultExpr.h:216
#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:81
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the IsDenseVector type trait.
ValueType value_type
Type of the underlying pointers.
Definition: SVecScalarMultExpr.h:213
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
ReturnType_< VT > RN
Return type of the sparse vector expression.
Definition: SVecScalarMultExpr.h:116
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
const DVecScalarMultExpr< VT, ElementType_< VT >, TF > normalize(const DenseVector< VT, TF > &vec)
Normalization of the dense vector ( ).
Definition: DVecScalarMultExpr.h:1164
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: SVecScalarMultExpr.h:429
Header file for the IsRowMajorMatrix type trait.
MultExprTrait_< RN, ST > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecScalarMultExpr.h:130
Header file for the IsComputation type trait class.
Expression object for sparse vector-scalar multiplications.The SVecScalarMultExpr class represents th...
Definition: Forward.h:118
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
#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
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecScalarMultExpr.h:171
SVecScalarMultExpr(const VT &vector, ST scalar) noexcept
Constructor for the SVecScalarMultExpr class.
Definition: SVecScalarMultExpr.h:326
Header file for the SubvectorExprTrait class template.
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
ConstIterator begin() const
Returns an iterator to the first non-zero element of the sparse vector.
Definition: SVecScalarMultExpr.h:364
LeftOperand vector_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecScalarMultExpr.h:481
Header file for the IsColumnVector type trait.
Header file for the Size type trait.
#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:63
#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:351
#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:61
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:222