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  //**Compilation flags***************************************************************************
198  enum { smpAssignable = 0 };
199  //**********************************************************************************************
200 
201  //**ConstIterator class definition**************************************************************
205  {
206  public:
207  //**Type definitions*************************************************************************
210 
212  typedef ET1 LeftElement;
213 
216 
217  typedef std::forward_iterator_tag IteratorCategory;
218  typedef Element ValueType;
222 
223  // STL iterator requirements
229  //*******************************************************************************************
230 
231  //**Constructor******************************************************************************
235  : v_ ( v ) // Element of the left-hand side dense vector expression.
236  , it_( it ) // Iterator over the elements of the right-hand side sparse vector expression
237  {}
238  //*******************************************************************************************
239 
240  //**Prefix increment operator****************************************************************
246  ++it_;
247  return *this;
248  }
249  //*******************************************************************************************
250 
251  //**Element access operator******************************************************************
256  inline const Element operator*() const {
257  return Element( v_ * it_->value(), it_->index() );
258  }
259  //*******************************************************************************************
260 
261  //**Element access operator******************************************************************
266  inline const ConstIterator* operator->() const {
267  return this;
268  }
269  //*******************************************************************************************
270 
271  //**Value function***************************************************************************
276  inline ReturnType value() const {
277  return v_ * it_->value();
278  }
279  //*******************************************************************************************
280 
281  //**Index function***************************************************************************
286  inline size_t index() const {
287  return it_->index();
288  }
289  //*******************************************************************************************
290 
291  //**Equality operator************************************************************************
297  inline bool operator==( const ConstIterator& rhs ) const {
298  return it_ == rhs.it_;
299  }
300  //*******************************************************************************************
301 
302  //**Inequality operator**********************************************************************
308  inline bool operator!=( const ConstIterator& rhs ) const {
309  return it_ != rhs.it_;
310  }
311  //*******************************************************************************************
312 
313  //**Subtraction operator*********************************************************************
319  inline DifferenceType operator-( const ConstIterator& rhs ) const {
320  return it_ - rhs.it_;
321  }
322  //*******************************************************************************************
323 
324  private:
325  //**Member variables*************************************************************************
328  //*******************************************************************************************
329  };
330  //**********************************************************************************************
331 
332  //**Constructor*********************************************************************************
338  explicit inline DVecTSVecMultExpr( const VT1& lhs, const VT2& rhs )
339  : lhs_( lhs ) // Left-hand side dense vector of the multiplication expression
340  , rhs_( rhs ) // Right-hand side sparse vector of the multiplication expression
341  {}
342  //**********************************************************************************************
343 
344  //**Access operator*****************************************************************************
351  inline ReturnType operator()( size_t i, size_t j ) const {
352  BLAZE_INTERNAL_ASSERT( i < lhs_.size(), "Invalid row access index" );
353  BLAZE_INTERNAL_ASSERT( j < rhs_.size(), "Invalid column access index" );
354 
355  return lhs_[i] * rhs_[j];
356  }
357  //**********************************************************************************************
358 
359  //**Begin function******************************************************************************
365  inline ConstIterator begin( size_t i ) const {
366  return ConstIterator( lhs_[i], rhs_.begin() );
367  }
368  //**********************************************************************************************
369 
370  //**End function********************************************************************************
376  inline ConstIterator end( size_t i ) const {
377  return ConstIterator( lhs_[i], rhs_.end() );
378  }
379  //**********************************************************************************************
380 
381  //**Rows function*******************************************************************************
386  inline size_t rows() const {
387  return lhs_.size();
388  }
389  //**********************************************************************************************
390 
391  //**Columns function****************************************************************************
396  inline size_t columns() const {
397  return rhs_.size();
398  }
399  //**********************************************************************************************
400 
401  //**NonZeros function***************************************************************************
406  inline size_t nonZeros() const {
407  return lhs_.size() * rhs_.nonZeros();
408  }
409  //**********************************************************************************************
410 
411  //**NonZeros function***************************************************************************
417  inline size_t nonZeros( size_t i ) const {
418  UNUSED_PARAMETER( i );
419  return rhs_.nonZeros();
420  }
421  //**********************************************************************************************
422 
423  //**Left operand access*************************************************************************
428  inline LeftOperand leftOperand() const {
429  return lhs_;
430  }
431  //**********************************************************************************************
432 
433  //**Right operand access************************************************************************
438  inline RightOperand rightOperand() const {
439  return rhs_;
440  }
441  //**********************************************************************************************
442 
443  //**********************************************************************************************
449  template< typename T >
450  inline bool canAlias( const T* alias ) const {
451  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
452  }
453  //**********************************************************************************************
454 
455  //**********************************************************************************************
461  template< typename T >
462  inline bool isAliased( const T* alias ) const {
463  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
464  }
465  //**********************************************************************************************
466 
467  private:
468  //**Member variables****************************************************************************
469  LeftOperand lhs_;
470  RightOperand rhs_;
471  //**********************************************************************************************
472 
473  //**Assignment to row-major dense matrices******************************************************
488  template< typename MT > // Type of the target dense matrix
489  friend inline typename EnableIf< UseAssign<MT> >::Type
491  {
493 
494  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
495  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
496 
498 
499  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
500  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
501 
502  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
503  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
504  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
505  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
506 
507  const ConstIterator begin( y.begin() );
508  const ConstIterator end ( y.end() );
509 
510  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
511  for( ConstIterator element=begin; element!=end; ++element ) {
512  (~lhs)(i,element->index()) = x[i] * element->value();
513  }
514  }
515  }
517  //**********************************************************************************************
518 
519  //**Assignment to column-major dense matrices***************************************************
532  template< typename MT > // Type of the target dense matrix
533  friend inline void assign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
534  {
536 
537  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
538  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
539 
540  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
541  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
542 
543  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
544  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
545  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
546  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
547 
548  DVecTSVecMultExpr::selectAssignKernel( ~lhs, x, y );
549  }
551  //**********************************************************************************************
552 
553  //**Default assignment to column-major dense matrices*******************************************
567  template< typename MT // Type of the left-hand side target matrix
568  , typename VT3 // Type of the left-hand side vector operand
569  , typename VT4 > // Type of the right-hand side vector operand
570  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
571  selectAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
572  {
574 
575  const ConstIterator begin( y.begin() );
576  const ConstIterator end ( y.end() );
577 
578  for( ConstIterator element=begin; element!=end; ++element ) {
579  for( size_t i=0UL; i<(~A).rows(); ++i ) {
580  (~A)(i,element->index()) = x[i] * element->value();
581  }
582  }
583  }
585  //**********************************************************************************************
586 
587  //**Vectorized assignment to column-major dense matrices****************************************
601  template< typename MT // Type of the left-hand side target matrix
602  , typename VT3 // Type of the left-hand side vector operand
603  , typename VT4 > // Type of the right-hand side vector operand
604  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
605  selectAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
606  {
608 
609  typedef IntrinsicTrait<ElementType> IT;
610  typedef typename IT::Type IntrinsicType;
611 
612  const ConstIterator begin( y.begin() );
613  const ConstIterator end ( y.end() );
614 
615  for( ConstIterator element=begin; element!=end; ++element )
616  {
617  const IntrinsicType y1( set( element->value() ) );
618 
619  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
620  (~A).store( i, element->index(), x.load(i) * y1 );
621  }
622  }
623  }
625  //**********************************************************************************************
626 
627  //**Assignment to row-major sparse matrices*****************************************************
642  template< typename MT > // Type of the target sparse matrix
643  friend inline typename EnableIf< UseAssign<MT> >::Type
644  assign( SparseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
645  {
647 
648  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
649  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
650 
652 
653  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
654  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
655 
656  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
657  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
658  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
659  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
660 
661  const ConstIterator begin( y.begin() );
662  const ConstIterator end ( y.end() );
663 
664  for( size_t i=0UL; i<x.size(); ++i ) {
665  if( !isDefault( x[i] ) ) {
666  (~lhs).reserve( i, y.nonZeros() );
667  for( ConstIterator element=begin; element!=end; ++element ) {
668  (~lhs).append( i, element->index(), x[i] * element->value() );
669  }
670  }
671  }
672  }
674  //**********************************************************************************************
675 
676  //**Assignment to column-major sparse matrices*****************************************************
689  template< typename MT > // Type of the target sparse matrix
690  friend inline void assign( SparseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
691  {
693 
694  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
695  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
696 
698 
699  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
700  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
701 
702  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
703  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
704  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
705  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
706 
707  const ConstIterator begin( y.begin() );
708  const ConstIterator end ( y.end() );
709 
710  for( ConstIterator element=begin; element!=end; ++element ) {
711  if( !isDefault( element->value() ) ) {
712  (~lhs).reserve( element->index(), x.size() );
713  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
714  (~lhs).append( i, element->index(), x[i] * element->value() );
715  }
716  }
717  }
718  }
720  //**********************************************************************************************
721 
722  //**Addition assignment to row-major dense matrices*********************************************
738  template< typename MT > // Type of the target dense matrix
739  friend inline typename EnableIf< UseAssign<MT> >::Type
740  addAssign( DenseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
741  {
743 
744  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
745  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
746 
748 
749  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
750  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
751 
752  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
753  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
754  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
755  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
756 
757  const ConstIterator begin( y.begin() );
758  const ConstIterator end ( y.end() );
759 
760  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
761  for( ConstIterator element=begin; element!=end; ++element ) {
762  (~lhs)(i,element->index()) += x[i] * element->value();
763  }
764  }
765  }
767  //**********************************************************************************************
768 
769  //**Addition assignment to column-major dense matrices******************************************
782  template< typename MT > // Type of the target dense matrix
783  friend inline void addAssign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
784  {
786 
787  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
788  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
789 
790  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
791  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
792 
793  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
794  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
795  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
796  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
797 
798  DVecTSVecMultExpr::selectAddAssignKernel( ~lhs, x, y );
799  }
801  //**********************************************************************************************
802 
803  //**Default addition assignment to column dense matrices****************************************
817  template< typename MT // Type of the left-hand side target matrix
818  , typename VT3 // Type of the left-hand side vector operand
819  , typename VT4 > // Type of the right-hand side vector operand
820  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
821  selectAddAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
822  {
824 
825  const ConstIterator begin( y.begin() );
826  const ConstIterator end ( y.end() );
827 
828  for( ConstIterator element=begin; element!=end; ++element ) {
829  for( size_t i=0UL; i<(~A).rows(); ++i ) {
830  (~A)(i,element->index()) += x[i] * element->value();
831  }
832  }
833  }
835  //**********************************************************************************************
836 
837  //**Vectorized addition assignment to column-major dense matrices*******************************
851  template< typename MT // Type of the left-hand side target matrix
852  , typename VT3 // Type of the left-hand side vector operand
853  , typename VT4 > // Type of the right-hand side vector operand
854  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
855  selectAddAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
856  {
858 
859  typedef IntrinsicTrait<ElementType> IT;
860  typedef typename IT::Type IntrinsicType;
861 
862  const ConstIterator begin( y.begin() );
863  const ConstIterator end ( y.end() );
864 
865  for( ConstIterator element=begin; element!=end; ++element )
866  {
867  const IntrinsicType y1( set( element->value() ) );
868 
869  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
870  (~A).store( i, element->index(), (~A).load(i,element->index()) + x.load(i) * y1 );
871  }
872  }
873  }
875  //**********************************************************************************************
876 
877  //**Addition assignment to sparse matrices******************************************************
878  // No special implementation for the addition assignment to sparse matrices.
879  //**********************************************************************************************
880 
881  //**Subtraction assignment to row-major dense matrices******************************************
897  template< typename MT > // Type of the target dense matrix
898  friend inline typename EnableIf< UseAssign<MT> >::Type
899  subAssign( DenseMatrix<MT,false>& lhs, const DVecTSVecMultExpr& rhs )
900  {
902 
903  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
904  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
905 
907 
908  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
909  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
910 
911  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
912  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
913  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
914  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
915 
916  const ConstIterator begin( y.begin() );
917  const ConstIterator end ( y.end() );
918 
919  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
920  for( ConstIterator element=begin; element!=end; ++element ) {
921  (~lhs)(i,element->index()) -= x[i] * element->value();
922  }
923  }
924  }
926  //**********************************************************************************************
927 
928  //**Subtraction assignment to column-major dense matrices***************************************
941  template< typename MT > // Type of the target dense matrix
942  friend inline void subAssign( DenseMatrix<MT,true>& lhs, const DVecTSVecMultExpr& rhs )
943  {
945 
946  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
947  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
948 
949  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
950  RT y( rhs.rhs_ ); // Evaluation of the right-hand side sparse vector operand
951 
952  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
953  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
954  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
955  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
956 
957  DVecTSVecMultExpr::selectSubAssignKernel( ~lhs, x, y );
958  }
960  //**********************************************************************************************
961 
962  //**Default subtraction assignment to column dense matrices*************************************
976  template< typename MT // Type of the left-hand side target matrix
977  , typename VT3 // Type of the left-hand side vector operand
978  , typename VT4 > // Type of the right-hand side vector operand
979  static inline typename EnableIf< UseDefaultKernel<MT,VT3,VT4> >::Type
980  selectSubAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
981  {
983 
984  const ConstIterator begin( y.begin() );
985  const ConstIterator end ( y.end() );
986 
987  for( ConstIterator element=begin; element!=end; ++element ) {
988  for( size_t i=0UL; i<(~A).rows(); ++i ) {
989  (~A)(i,element->index()) -= x[i] * element->value();
990  }
991  }
992  }
994  //**********************************************************************************************
995 
996  //**Vectorized subtraction assignment to column-major dense matrices****************************
1010  template< typename MT // Type of the left-hand side target matrix
1011  , typename VT3 // Type of the left-hand side vector operand
1012  , typename VT4 > // Type of the right-hand side vector operand
1013  static inline typename EnableIf< UseVectorizedKernel<MT,VT3,VT4> >::Type
1014  selectSubAssignKernel( DenseMatrix<MT,true>& A, const VT3& x, const VT4& y )
1015  {
1017 
1018  typedef IntrinsicTrait<ElementType> IT;
1019  typedef typename IT::Type IntrinsicType;
1020 
1021  const ConstIterator begin( y.begin() );
1022  const ConstIterator end ( y.end() );
1023 
1024  for( ConstIterator element=begin; element!=end; ++element )
1025  {
1026  const IntrinsicType y1( set( element->value() ) );
1027 
1028  for( size_t i=0UL; i<(~A).rows(); i+=IT::size ) {
1029  (~A).store( i, element->index(), (~A).load(i,element->index()) - x.load(i) * y1 );
1030  }
1031  }
1032  }
1034  //**********************************************************************************************
1035 
1036  //**Subtraction assignment to sparse matrices***************************************************
1037  // No special implementation for the subtraction assignment to sparse matrices.
1038  //**********************************************************************************************
1039 
1040  //**Multiplication assignment to dense matrices*************************************************
1041  // No special implementation for the multiplication assignment to dense matrices.
1042  //**********************************************************************************************
1043 
1044  //**Multiplication assignment to sparse matrices************************************************
1045  // No special implementation for the multiplication assignment to sparse matrices.
1046  //**********************************************************************************************
1047 
1048  //**Compile time checks*************************************************************************
1055  //**********************************************************************************************
1056 };
1057 //*************************************************************************************************
1058 
1059 
1060 
1061 
1062 //=================================================================================================
1063 //
1064 // GLOBAL BINARY ARITHMETIC OPERATORS
1065 //
1066 //=================================================================================================
1067 
1068 //*************************************************************************************************
1097 template< typename T1 // Type of the left-hand side dense vector
1098  , typename T2 > // Type of the right-hand side sparse vector
1099 inline const DVecTSVecMultExpr<T1,T2>
1101 {
1103 
1104  return DVecTSVecMultExpr<T1,T2>( ~lhs, ~rhs );
1105 }
1106 //*************************************************************************************************
1107 
1108 
1109 
1110 
1111 //=================================================================================================
1112 //
1113 // EXPRESSION TRAIT SPECIALIZATIONS
1114 //
1115 //=================================================================================================
1116 
1117 //*************************************************************************************************
1119 template< typename VT1, typename VT2, bool AF >
1120 struct SubmatrixExprTrait< DVecTSVecMultExpr<VT1,VT2>, AF >
1121 {
1122  public:
1123  //**********************************************************************************************
1124  typedef typename MultExprTrait< typename SubvectorExprTrait<const VT1,AF>::Type
1125  , typename SubvectorExprTrait<const VT2,AF>::Type >::Type Type;
1126  //**********************************************************************************************
1127 };
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1134 template< typename VT1, typename VT2 >
1135 struct RowExprTrait< DVecTSVecMultExpr<VT1,VT2> >
1136 {
1137  public:
1138  //**********************************************************************************************
1139  typedef typename MultExprTrait< typename VT1::ReturnType, VT2 >::Type Type;
1140  //**********************************************************************************************
1141 };
1143 //*************************************************************************************************
1144 
1145 
1146 //*************************************************************************************************
1148 template< typename VT1, typename VT2 >
1149 struct ColumnExprTrait< DVecTSVecMultExpr<VT1,VT2> >
1150 {
1151  public:
1152  //**********************************************************************************************
1153  typedef typename MultExprTrait< VT1, typename VT2::ReturnType >::Type Type;
1154  //**********************************************************************************************
1155 };
1157 //*************************************************************************************************
1158 
1159 } // namespace blaze
1160 
1161 #endif
ValueType * PointerType
Pointer return type.
Definition: DVecTSVecMultExpr.h:219
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:226
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:220
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:4075
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DVecTSVecMultExpr.h:462
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:221
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DVecTSVecMultExpr.h:386
#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:4622
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:197
Header file for the ColumnExprTrait class template.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:308
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:266
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:2384
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:249
IteratorType it_
Iterator over the elements of the right-hand side sparse vector expression.
Definition: DVecTSVecMultExpr.h:327
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:286
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: DVecTSVecMultExpr.h:217
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:351
Element ValueType
Type of the underlying pointers.
Definition: DVecTSVecMultExpr.h:218
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: DVecTSVecMultExpr.h:256
DVecTSVecMultExpr(const VT1 &lhs, const VT2 &rhs)
Constructor for the DVecTSVecMultExpr class.
Definition: DVecTSVecMultExpr.h:338
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:225
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DVecTSVecMultExpr.h:365
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:245
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
LeftOperand lhs_
Left-hand side dense vector of the multiplication expression.
Definition: DVecTSVecMultExpr.h:469
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:450
ConstIterator(LeftElement v, IteratorType it)
Constructor for the ConstIterator class.
Definition: DVecTSVecMultExpr.h:234
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecTSVecMultExpr.h:297
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:224
#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:228
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
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:438
Header file for the IsNumeric type trait.
LeftOperand leftOperand() const
Returns the left-hand side dense vector operand.
Definition: DVecTSVecMultExpr.h:428
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DVecTSVecMultExpr.h:376
Iterator over the elements of the dense vector-sparse vector outer product expression.
Definition: DVecTSVecMultExpr.h:204
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2383
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:748
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DVecTSVecMultExpr.h:396
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:470
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:209
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: DVecTSVecMultExpr.h:417
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:227
ReturnType value() const
Access to the current value of the sparse element.
Definition: DVecTSVecMultExpr.h:276
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:212
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:2379
LeftElement v_
Element of the left-hand side dense vector expression.
Definition: DVecTSVecMultExpr.h:326
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: DVecTSVecMultExpr.h:319
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:215
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:406
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