All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DVecTSVecMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECTSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECTSVECMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
52 #include <blaze/math/Intrinsics.h>
64 #include <blaze/util/Assert.h>
66 #include <blaze/util/EnableIf.h>
68 #include <blaze/util/SelectType.h>
69 #include <blaze/util/Types.h>
72 #include <blaze/util/Unused.h>
73 
74 
75 namespace blaze {
76 
77 //=================================================================================================
78 //
79 // CLASS DVECTSVECMULTEXPR
80 //
81 //=================================================================================================
82 
83 //*************************************************************************************************
90 template< typename VT1 // Type of the left-hand side dense vector
91  , typename VT2 > // Type of the right-hand side sparse vector
92 class DVecTSVecMultExpr : public SparseMatrix< DVecTSVecMultExpr<VT1,VT2>, false >
93  , private VecTVecMultExpr
94  , private Computation
95 {
96  private:
97  //**Type definitions****************************************************************************
98  typedef typename VT1::ResultType RT1;
99  typedef typename VT2::ResultType RT2;
100  typedef typename VT1::ReturnType RN1;
101  typedef typename VT2::ReturnType RN2;
102  typedef typename VT1::CompositeType CT1;
103  typedef typename VT2::CompositeType CT2;
104  typedef typename VT1::ElementType ET1;
105  typedef typename VT2::ElementType ET2;
106  //**********************************************************************************************
107 
108  //**Return type evaluation**********************************************************************
110 
115  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
116 
119  //**********************************************************************************************
120 
121  //**Evaluation strategy*************************************************************************
123 
130  enum { useAssign = ( IsComputation<VT1>::value || !IsNumeric<ET1>::value ||
132 
134  template< typename MT >
136  struct UseAssign {
137  enum { value = useAssign };
138  };
140  //**********************************************************************************************
141 
142  //**********************************************************************************************
144 
147  template< typename T1, typename T2, typename T3 >
148  struct UseVectorizedKernel {
149  enum { value = T1::vectorizable && T2::vectorizable &&
153  };
155  //**********************************************************************************************
156 
157  //**********************************************************************************************
159 
162  template< typename T1, typename T2, typename T3 >
163  struct UseDefaultKernel {
164  enum { value = !UseVectorizedKernel<T1,T2,T3>::value };
165  };
167  //**********************************************************************************************
168 
169  public:
170  //**Type definitions****************************************************************************
176 
179 
182 
184  typedef typename SelectType< IsExpression<VT1>::value, const VT1, const VT1& >::Type LeftOperand;
185 
187  typedef typename SelectType< IsExpression<VT2>::value, const VT2, const VT2& >::Type RightOperand;
188 
190  typedef typename SelectType< IsComputation<VT1>::value, const RT1, CT1 >::Type LT;
191 
193  typedef typename SelectType< IsComputation<VT2>::value, const RT2, CT2 >::Type RT;
194  //**********************************************************************************************
195 
196  //**ConstIterator class definition**************************************************************
200  {
201  public:
202  //**Type definitions*************************************************************************
205 
207  typedef ET1 LeftElement;
208 
211 
212  typedef std::forward_iterator_tag IteratorCategory;
213  typedef Element ValueType;
217 
218  // STL iterator requirements
224  //*******************************************************************************************
225 
226  //**Constructor******************************************************************************
230  : v_ ( v ) // Element of the left-hand side dense vector expression.
231  , it_( it ) // Iterator over the elements of the right-hand side sparse vector expression
232  {}
233  //*******************************************************************************************
234 
235  //**Prefix increment operator****************************************************************
241  ++it_;
242  return *this;
243  }
244  //*******************************************************************************************
245 
246  //**Element access operator******************************************************************
251  inline const Element operator*() const {
252  return Element( v_ * it_->value(), it_->index() );
253  }
254  //*******************************************************************************************
255 
256  //**Element access operator******************************************************************
261  inline const ConstIterator* operator->() const {
262  return this;
263  }
264  //*******************************************************************************************
265 
266  //**Value function***************************************************************************
271  inline ReturnType value() const {
272  return v_ * it_->value();
273  }
274  //*******************************************************************************************
275 
276  //**Index function***************************************************************************
281  inline size_t index() const {
282  return it_->index();
283  }
284  //*******************************************************************************************
285 
286  //**Equality operator************************************************************************
292  inline bool operator==( const ConstIterator& rhs ) const {
293  return it_ == rhs.it_;
294  }
295  //*******************************************************************************************
296 
297  //**Inequality operator**********************************************************************
303  inline bool operator!=( const ConstIterator& rhs ) const {
304  return it_ != rhs.it_;
305  }
306  //*******************************************************************************************
307 
308  //**Subtraction operator*********************************************************************
314  inline DifferenceType operator-( const ConstIterator& rhs ) const {
315  return it_ - rhs.it_;
316  }
317  //*******************************************************************************************
318 
319  private:
320  //**Member variables*************************************************************************
323  //*******************************************************************************************
324  };
325  //**********************************************************************************************
326 
327  //**Constructor*********************************************************************************
333  explicit inline DVecTSVecMultExpr( const VT1& lhs, const VT2& rhs )
334  : lhs_( lhs ) // Left-hand side dense vector of the multiplication expression
335  , rhs_( rhs ) // Right-hand side sparse vector of the multiplication expression
336  {}
337  //**********************************************************************************************
338 
339  //**Access operator*****************************************************************************
346  inline ReturnType operator()( size_t i, size_t j ) const {
347  BLAZE_INTERNAL_ASSERT( i < lhs_.size(), "Invalid row access index" );
348  BLAZE_INTERNAL_ASSERT( j < rhs_.size(), "Invalid column access index" );
349 
350  return lhs_[i] * rhs_[j];
351  }
352  //**********************************************************************************************
353 
354  //**Begin function******************************************************************************
360  inline ConstIterator begin( size_t i ) const {
361  return ConstIterator( lhs_[i], rhs_.begin() );
362  }
363  //**********************************************************************************************
364 
365  //**End function********************************************************************************
371  inline ConstIterator end( size_t i ) const {
372  return ConstIterator( lhs_[i], rhs_.end() );
373  }
374  //**********************************************************************************************
375 
376  //**Rows function*******************************************************************************
381  inline size_t rows() const {
382  return lhs_.size();
383  }
384  //**********************************************************************************************
385 
386  //**Columns function****************************************************************************
391  inline size_t columns() const {
392  return rhs_.size();
393  }
394  //**********************************************************************************************
395 
396  //**NonZeros function***************************************************************************
401  inline size_t nonZeros() const {
402  return lhs_.size() * rhs_.nonZeros();
403  }
404  //**********************************************************************************************
405 
406  //**NonZeros function***************************************************************************
412  inline size_t nonZeros( size_t i ) const {
413  UNUSED_PARAMETER( i );
414  return rhs_.nonZeros();
415  }
416  //**********************************************************************************************
417 
418  //**Left operand access*************************************************************************
423  inline LeftOperand leftOperand() const {
424  return lhs_;
425  }
426  //**********************************************************************************************
427 
428  //**Right operand access************************************************************************
433  inline RightOperand rightOperand() const {
434  return rhs_;
435  }
436  //**********************************************************************************************
437 
438  //**********************************************************************************************
444  template< typename T >
445  inline bool canAlias( const T* alias ) const {
446  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
447  }
448  //**********************************************************************************************
449 
450  //**********************************************************************************************
456  template< typename T >
457  inline bool isAliased( const T* alias ) const {
458  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
459  }
460  //**********************************************************************************************
461 
462  private:
463  //**Member variables****************************************************************************
464  LeftOperand lhs_;
465  RightOperand rhs_;
466  //**********************************************************************************************
467 
468  //**Assignment to row-major dense matrices******************************************************
483  template< typename MT > // Type of the target dense matrix
484  friend inline typename EnableIf< UseAssign<MT> >::Type
486  {
488 
489  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
490  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
491 
493 
494  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
495  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
496 
497  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
498  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
499  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
500  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
501 
502  const ConstIterator begin( y.begin() );
503  const ConstIterator end ( y.end() );
504 
505  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
506  for( ConstIterator element=begin; element!=end; ++element ) {
507  (~lhs)(i,element->index()) = x[i] * element->value();
508  }
509  }
510  }
512  //**********************************************************************************************
513 
514  //**Assignment to column-major dense matrices***************************************************
527  template< typename MT > // Type of the target dense matrix
528  friend inline void assign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
529  {
531 
532  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
533  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
534 
535  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
536  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
537 
538  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
539  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
540  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
541  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
542 
543  DVecTSVecMultExpr::selectAssignKernel( ~lhs, x, y );
544  }
546  //**********************************************************************************************
547 
548  //**Default assignment to column-major dense matrices*******************************************
562  template< typename MT // Type of the left-hand side target matrix
563  , typename VT3 // Type of the left-hand side vector operand
564  , typename VT4 > // Type of the right-hand side vector operand
565  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
566  selectAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
567  {
569 
570  const ConstIterator begin( y.begin() );
571  const ConstIterator end ( y.end() );
572 
573  for( ConstIterator element=begin; element!=end; ++element ) {
574  for( size_t i=0UL; i<(~A).rows(); ++i ) {
575  (~A)(i,element->index()) = x[i] * element->value();
576  }
577  }
578  }
580  //**********************************************************************************************
581 
582  //**Vectorized assignment to column-major dense matrices****************************************
596  template< typename MT // Type of the left-hand side target matrix
597  , typename VT3 // Type of the left-hand side vector operand
598  , typename VT4 > // Type of the right-hand side vector operand
599  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
600  selectAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
601  {
603 
604  typedef IntrinsicTrait<ElementType> IT;
605  typedef typename IT::Type IntrinsicType;
606 
607  const ConstIterator begin( y.begin() );
608  const ConstIterator end ( y.end() );
609 
610  for( ConstIterator element=begin; element!=end; ++element )
611  {
612  const IntrinsicType y1( set( element->value() ) );
613 
614  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
615  (~A).store( i, element->index(), x.load(i) * y1 );
616  }
617  }
618  }
620  //**********************************************************************************************
621 
622  //**Assignment to row-major sparse matrices*****************************************************
637  template< typename MT > // Type of the target sparse matrix
638  friend inline typename EnableIf< UseAssign<MT> >::Type
639  assign( SparseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
640  {
642 
643  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
644  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
645 
647 
648  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
649  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
650 
651  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
652  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
653  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
654  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
655 
656  const ConstIterator begin( y.begin() );
657  const ConstIterator end ( y.end() );
658 
659  for( size_t i=0UL; i<x.size(); ++i ) {
660  if( !isDefault( x[i] ) ) {
661  (~lhs).reserve( i, y.nonZeros() );
662  for( ConstIterator element=begin; element!=end; ++element ) {
663  (~lhs).append( i, element->index(), x[i] * element->value() );
664  }
665  }
666  }
667  }
669  //**********************************************************************************************
670 
671  //**Assignment to column-major sparse matrices*****************************************************
684  template< typename MT > // Type of the target sparse matrix
685  friend inline void assign( SparseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
686  {
688 
689  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
690  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
691 
693 
694  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
695  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
696 
697  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
698  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
699  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
700  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
701 
702  const ConstIterator begin( y.begin() );
703  const ConstIterator end ( y.end() );
704 
705  for( ConstIterator element=begin; element!=end; ++element ) {
706  if( !isDefault( element->value() ) ) {
707  (~lhs).reserve( element->index(), x.size() );
708  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
709  (~lhs).append( i, element->index(), x[i] * element->value() );
710  }
711  }
712  }
713  }
715  //**********************************************************************************************
716 
717  //**Addition assignment to row-major dense matrices*********************************************
733  template< typename MT > // Type of the target dense matrix
734  friend inline typename EnableIf< UseAssign<MT> >::Type
735  addAssign( DenseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
736  {
738 
739  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
740  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
741 
743 
744  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
745  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
746 
747  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
748  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
749  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
750  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
751 
752  const ConstIterator begin( y.begin() );
753  const ConstIterator end ( y.end() );
754 
755  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
756  for( ConstIterator element=begin; element!=end; ++element ) {
757  (~lhs)(i,element->index()) += x[i] * element->value();
758  }
759  }
760  }
762  //**********************************************************************************************
763 
764  //**Addition assignment to column-major dense matrices******************************************
777  template< typename MT > // Type of the target dense matrix
778  friend inline void addAssign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
779  {
781 
782  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
783  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
784 
785  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
786  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
787 
788  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
789  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
790  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
791  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
792 
793  DVecTSVecMultExpr::selectAddAssignKernel( ~lhs, x, y );
794  }
796  //**********************************************************************************************
797 
798  //**Default addition assignment to column dense matrices****************************************
812  template< typename MT // Type of the left-hand side target matrix
813  , typename VT3 // Type of the left-hand side vector operand
814  , typename VT4 > // Type of the right-hand side vector operand
815  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
816  selectAddAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
817  {
819 
820  const ConstIterator begin( y.begin() );
821  const ConstIterator end ( y.end() );
822 
823  for( ConstIterator element=begin; element!=end; ++element ) {
824  for( size_t i=0UL; i<(~A).rows(); ++i ) {
825  (~A)(i,element->index()) += x[i] * element->value();
826  }
827  }
828  }
830  //**********************************************************************************************
831 
832  //**Vectorized addition assignment to column-major dense matrices*******************************
846  template< typename MT // Type of the left-hand side target matrix
847  , typename VT3 // Type of the left-hand side vector operand
848  , typename VT4 > // Type of the right-hand side vector operand
849  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
850  selectAddAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
851  {
853 
854  typedef IntrinsicTrait<ElementType> IT;
855  typedef typename IT::Type IntrinsicType;
856 
857  const ConstIterator begin( y.begin() );
858  const ConstIterator end ( y.end() );
859 
860  for( ConstIterator element=begin; element!=end; ++element )
861  {
862  const IntrinsicType y1( set( element->value() ) );
863 
864  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
865  (~A).store( i, element->index(), (~A).load(i,element->index()) + x.load(i) * y1 );
866  }
867  }
868  }
870  //**********************************************************************************************
871 
872  //**Addition assignment to sparse matrices******************************************************
873  // No special implementation for the addition assignment to sparse matrices.
874  //**********************************************************************************************
875 
876  //**Subtraction assignment to row-major dense matrices******************************************
892  template< typename MT > // Type of the target dense matrix
893  friend inline typename EnableIf< UseAssign<MT> >::Type
894  subAssign( DenseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
895  {
897 
898  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
899  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
900 
902 
903  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
904  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
905 
906  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
907  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
908  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
909  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
910 
911  const ConstIterator begin( y.begin() );
912  const ConstIterator end ( y.end() );
913 
914  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
915  for( ConstIterator element=begin; element!=end; ++element ) {
916  (~lhs)(i,element->index()) -= x[i] * element->value();
917  }
918  }
919  }
921  //**********************************************************************************************
922 
923  //**Subtraction assignment to column-major dense matrices***************************************
936  template< typename MT > // Type of the target dense matrix
937  friend inline void subAssign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
938  {
940 
941  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
942  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
943 
944  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
945  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
946 
947  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
948  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
949  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
950  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
951 
952  DVecTSVecMultExpr::selectSubAssignKernel( ~lhs, x, y );
953  }
955  //**********************************************************************************************
956 
957  //**Default subtraction assignment to column dense matrices*************************************
971  template< typename MT // Type of the left-hand side target matrix
972  , typename VT3 // Type of the left-hand side vector operand
973  , typename VT4 > // Type of the right-hand side vector operand
974  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
975  selectSubAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
976  {
978 
979  const ConstIterator begin( y.begin() );
980  const ConstIterator end ( y.end() );
981 
982  for( ConstIterator element=begin; element!=end; ++element ) {
983  for( size_t i=0UL; i<(~A).rows(); ++i ) {
984  (~A)(i,element->index()) -= x[i] * element->value();
985  }
986  }
987  }
989  //**********************************************************************************************
990 
991  //**Vectorized subtraction assignment to column-major dense matrices****************************
1005  template< typename MT // Type of the left-hand side target matrix
1006  , typename VT3 // Type of the left-hand side vector operand
1007  , typename VT4 > // Type of the right-hand side vector operand
1008  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
1009  selectSubAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
1010  {
1012 
1013  typedef IntrinsicTrait<ElementType> IT;
1014  typedef typename IT::Type IntrinsicType;
1015 
1016  const ConstIterator begin( y.begin() );
1017  const ConstIterator end ( y.end() );
1018 
1019  for( ConstIterator element=begin; element!=end; ++element )
1020  {
1021  const IntrinsicType y1( set( element->value() ) );
1022 
1023  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
1024  (~A).store( i, element->index(), (~A).load(i,element->index()) - x.load(i) * y1 );
1025  }
1026  }
1027  }
1029  //**********************************************************************************************
1030 
1031  //**Subtraction assignment to sparse matrices***************************************************
1032  // No special implementation for the subtraction assignment to sparse matrices.
1033  //**********************************************************************************************
1034 
1035  //**Multiplication assignment to dense matrices*************************************************
1036  // No special implementation for the multiplication assignment to dense matrices.
1037  //**********************************************************************************************
1038 
1039  //**Multiplication assignment to sparse matrices************************************************
1040  // No special implementation for the multiplication assignment to sparse matrices.
1041  //**********************************************************************************************
1042 
1043  //**Compile time checks*************************************************************************
1050  //**********************************************************************************************
1051 };
1052 //*************************************************************************************************
1053 
1054 
1055 
1056 
1057 //=================================================================================================
1058 //
1059 // GLOBAL BINARY ARITHMETIC OPERATORS
1060 //
1061 //=================================================================================================
1062 
1063 //*************************************************************************************************
1092 template< typename T1 // Type of the left-hand side dense vector
1093  , typename T2 > // Type of the right-hand side sparse vector
1094 inline const DVecTSVecMultExpr<T1,T2>
1096 {
1098 
1099  return DVecTSVecMultExpr<T1,T2>( ~lhs, ~rhs );
1100 }
1101 //*************************************************************************************************
1102 
1103 
1104 
1105 
1106 //=================================================================================================
1107 //
1108 // EXPRESSION TRAIT SPECIALIZATIONS
1109 //
1110 //=================================================================================================
1111 
1112 //*************************************************************************************************
1114 template< typename VT1, typename VT2 >
1115 struct SubmatrixExprTrait< DVecTSVecMultExpr<VT1,VT2> >
1116 {
1117  public:
1118  //**********************************************************************************************
1119  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT1>::Type
1120  , typename SubvectorExprTrait<const VT2>::Type >::Type Type;
1121  //**********************************************************************************************
1122 };
1124 //*************************************************************************************************
1125 
1126 
1127 //*************************************************************************************************
1129 template< typename VT1, typename VT2 >
1130 struct RowExprTrait< DVecTSVecMultExpr<VT1,VT2> >
1131 {
1132  public:
1133  //**********************************************************************************************
1134  typedef typename MultExprTrait< typename VT1::ReturnType, VT2 >::Type Type;
1135  //**********************************************************************************************
1136 };
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1143 template< typename VT1, typename VT2 >
1144 struct ColumnExprTrait< DVecTSVecMultExpr<VT1,VT2> >
1145 {
1146  public:
1147  //**********************************************************************************************
1148  typedef typename MultExprTrait< VT1, typename VT2::ReturnType >::Type Type;
1149  //**********************************************************************************************
1150 };
1152 //*************************************************************************************************
1153 
1154 } // namespace blaze
1155 
1156 #endif
ValueType * PointerType
Pointer return type.
Definition: DVecTSVecMultExpr.h:214
Pointer difference type of the Blaze library.
VT1::ReturnType RN1
Return type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:100
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
PointerType pointer
Pointer return type.
Definition: DVecTSVecMultExpr.h:221
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
VT2::ElementType ET2
Element type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:105
ValueType & ReferenceType
Reference return type.
Definition: DVecTSVecMultExpr.h:215
Header file for the UNUSED_PARAMETER function template.
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:3703
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DVecTSVecMultExpr.h:457
SelectType< IsComputation< VT1 >::value, const RT1, CT1 >::Type LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:190
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecTSVecMultExpr.h:216
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DVecTSVecMultExpr.h:381
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: TransposeFlag.h:159
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
Header file for the ColumnExprTrait class template.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:303
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:261
VT1::ElementType ET1
Element type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:104
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:248
IteratorType it_
Iterator over the elements of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:322
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
size_t index() const
Access to the current index of the sparse element.
Definition: DVecTSVecMultExpr.h:281
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: DVecTSVecMultExpr.h:212
Header file for the Computation base class.
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
SelectType< IsExpression< VT2 >::value, const VT2, const VT2 & >::Type RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:187
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DVecTSVecMultExpr.h:346
Element ValueType
Type of the underlying pointers.
Definition: DVecTSVecMultExpr.h:213
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:251
DVecTSVecMultExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the DVecTSVecMultExpr class.
Definition: DVecTSVecMultExpr.h:333
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Constraint on the data type.
MultExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DVecTSVecMultExpr.h:118
Header file for the SparseMatrix base class.
Constraint on the data type.
Header file for the MultExprTrait class template.
ValueType value_type
Type of the underlying pointers.
Definition: DVecTSVecMultExpr.h:220
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DVecTSVecMultExpr.h:360
Header file for the ValueIndexPair class.
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecTSVecMultExpr.h:240
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
LeftOperand lhs_
Left-hand side dense vector of the multiplication expression.
Definition: DVecTSVecMultExpr.h:464
ResultType::ElementType ElementType
Resulting element type.
Definition: DVecTSVecMultExpr.h:175
Expression object for dense vector-sparse vector outer products.The DVecTSVecMultExpr class represent...
Definition: DVecTSVecMultExpr.h:92
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DVecTSVecMultExpr.h:445
ConstIterator(LeftElement v, IteratorType it)
Constructor for the ConstIterator class.
Definition: DVecTSVecMultExpr.h:229
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:292
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
IteratorCategory iterator_category
The iterator category.
Definition: DVecTSVecMultExpr.h:219
#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
Constraint on the data type.
Constraint on the data type.
DifferenceType difference_type
Difference between two iterators.
Definition: DVecTSVecMultExpr.h:223
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the VecTVecMultExpr base class.
VT1::CompositeType CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:102
Header file for the EnableIf class template.
RightOperand rightOperand() const
Returns the right-hand side sparse vector operand.
Definition: DVecTSVecMultExpr.h:433
Header file for the IsNumeric type trait.
LeftOperand leftOperand() const
Returns the left-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:423
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DVecTSVecMultExpr.h:371
Iterator over the elements of the dense vector-sparse vector outer product expression.
Definition: DVecTSVecMultExpr.h:199
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
VT1::ResultType RT1
Result type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:98
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DVecTSVecMultExpr.h:391
Header file for run time assertion macros.
Base template for the MultTrait class.
Definition: MultTrait.h:141
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: DVecTSVecMultExpr.h:465
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:174
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
DVecTSVecMultExpr< VT1, VT2 > This
Type of this DVecTSVecMultExpr instance.
Definition: DVecTSVecMultExpr.h:171
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: DVecTSVecMultExpr.h:204
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: DVecTSVecMultExpr.h:412
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
Header file for the isDefault shim.
ReferenceType reference
Reference return type.
Definition: DVecTSVecMultExpr.h:222
ReturnType value() const
Access to the current value of the sparse element.
Definition: DVecTSVecMultExpr.h:271
Header file for the RemoveReference type trait.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DVecTSVecMultExpr.h:173
Base class for all outer product expression templates.The VecTVecMultExpr class serves as a tag for a...
Definition: VecTVecMultExpr.h:66
ET1 LeftElement
Element type of the dense vector expression.
Definition: DVecTSVecMultExpr.h:207
Header file for all intrinsic functionality.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
VT2::ReturnType RN2
Return type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:101
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
MultTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:172
Header file for the IsComputation type trait class.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DVecTSVecMultExpr.h:178
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
LeftElement v_
Element of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:321
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: DVecTSVecMultExpr.h:314
SelectType< useAssign, const ResultType, const DVecTSVecMultExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: DVecTSVecMultExpr.h:181
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: TransposeFlag.h:81
RemoveReference< RightOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse vector expression.
Definition: DVecTSVecMultExpr.h:210
Header file for the SubvectorExprTrait class template.
VT2::CompositeType CT2
Composite type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:103
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: DVecTSVecMultExpr.h:401
SelectType< IsExpression< VT1 >::value, const VT1, const VT1 & >::Type LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:184
VT2::ResultType RT2
Result type of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:99
Evaluation of the resulting expression type of a multiplication.Via this type trait it is possible to...
Definition: MultExprTrait.h:137
#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
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209
void store(float *address, const sse_float_t &value)
Aligned store of a vector of &#39;float&#39; values.
Definition: Store.h:242
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
SelectType< IsComputation< VT2 >::value, const RT2, CT2 >::Type RT
Type for the assignment of the right-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:193