SVecSVecOuterExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECOUTEREXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SVECSVECOUTEREXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
65 #include <blaze/util/Assert.h>
67 #include <blaze/util/mpl/If.h>
68 #include <blaze/util/Types.h>
70 
71 
72 namespace blaze {
73 
74 //=================================================================================================
75 //
76 // CLASS SVECSVECOUTEREXPR
77 //
78 //=================================================================================================
79 
80 //*************************************************************************************************
87 template< typename VT1 // Type of the left-hand side sparse vector
88  , typename VT2 > // Type of the right-hand side sparse vector
89 class SVecSVecOuterExpr
90  : public VecTVecMultExpr< SparseMatrix< SVecSVecOuterExpr<VT1,VT2>, false > >
91  , private Computation
92 {
93  private:
94  //**Type definitions****************************************************************************
101  //**********************************************************************************************
102 
103  //**Return type evaluation**********************************************************************
105 
110  enum : bool { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
111 
114  //**********************************************************************************************
115 
116  public:
117  //**Type definitions****************************************************************************
123 
126 
128  using CompositeType = const ResultType;
129 
131  using LeftOperand = If_< IsExpression<VT1>, const VT1, const VT1& >;
132 
134  using RightOperand = If_< IsExpression<VT2>, const VT2, const VT2& >;
135 
137  using LT = If_< IsComputation<VT1>, const RT1, CT1 >;
138 
140  using RT = If_< IsComputation<VT2>, const RT2, CT2 >;
141  //**********************************************************************************************
142 
143  //**Compilation flags***************************************************************************
145  enum : bool { smpAssignable = false };
146  //**********************************************************************************************
147 
148  //**Constructor*********************************************************************************
154  explicit inline SVecSVecOuterExpr( const VT1& lhs, const VT2& rhs ) noexcept
155  : lhs_( lhs ) // Left-hand side sparse vector of the multiplication expression
156  , rhs_( rhs ) // Right-hand side sparse vector of the multiplication expression
157  {}
158  //**********************************************************************************************
159 
160  //**Access operator*****************************************************************************
167  inline ReturnType operator()( size_t i, size_t j ) const {
168  BLAZE_INTERNAL_ASSERT( i < lhs_.size(), "Invalid row access index" );
169  BLAZE_INTERNAL_ASSERT( j < rhs_.size(), "Invalid column access index" );
170 
171  return lhs_[i] * rhs_[j];
172  }
173  //**********************************************************************************************
174 
175  //**At function*********************************************************************************
183  inline ReturnType at( size_t i, size_t j ) const {
184  if( i >= lhs_.size() ) {
185  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
186  }
187  if( j >= rhs_.size() ) {
188  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
189  }
190  return (*this)(i,j);
191  }
192  //**********************************************************************************************
193 
194  //**Rows function*******************************************************************************
199  inline size_t rows() const noexcept {
200  return lhs_.size();
201  }
202  //**********************************************************************************************
203 
204  //**Columns function****************************************************************************
209  inline size_t columns() const noexcept {
210  return rhs_.size();
211  }
212  //**********************************************************************************************
213 
214  //**NonZeros function***************************************************************************
219  inline size_t nonZeros() const {
220  return lhs_.nonZeros() * rhs_.nonZeros();
221  }
222  //**********************************************************************************************
223 
224  //**NonZeros function***************************************************************************
230  inline size_t nonZeros( size_t i ) const {
231  return ( isDefault( lhs_[i] ) )?( size_t(0) ):( rhs_.nonZeros(i) );
232  }
233  //**********************************************************************************************
234 
235  //**Left operand access*************************************************************************
240  inline LeftOperand leftOperand() const noexcept {
241  return lhs_;
242  }
243  //**********************************************************************************************
244 
245  //**Right operand access************************************************************************
250  inline RightOperand rightOperand() const noexcept {
251  return rhs_;
252  }
253  //**********************************************************************************************
254 
255  //**********************************************************************************************
261  template< typename T >
262  inline bool canAlias( const T* alias ) const noexcept {
263  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
264  }
265  //**********************************************************************************************
266 
267  //**********************************************************************************************
273  template< typename T >
274  inline bool isAliased( const T* alias ) const noexcept {
275  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
276  }
277  //**********************************************************************************************
278 
279  private:
280  //**Member variables****************************************************************************
283  //**********************************************************************************************
284 
285  //**Assignment to row-major dense matrices******************************************************
297  template< typename MT > // Type of the target dense matrix
298  friend inline void assign( DenseMatrix<MT,false>& lhs, const SVecSVecOuterExpr& rhs )
299  {
301 
302  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
303  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
304 
305  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
306  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
307 
308  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
309  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
310 
311  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
312  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
313  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
314  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
315 
316  const LeftIterator lend( x.end() );
317  const RightIterator rend( y.end() );
318 
319  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
320  if( !isDefault( lelem->value() ) ) {
321  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
322  (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
323  }
324  }
325  }
326  }
328  //**********************************************************************************************
329 
330  //**Assignment to column-major dense matrices***************************************************
343  template< typename MT > // Type of the target dense matrix
344  friend inline void assign( DenseMatrix<MT,true>& lhs, const SVecSVecOuterExpr& rhs )
345  {
347 
349 
350  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
351  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
352 
353  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
354  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
355 
356  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
357  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
358 
359  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
360  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
361  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
362  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
363 
364  const LeftIterator lend( x.end() );
365  const RightIterator rend( y.end() );
366 
367  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
368  if( !isDefault( relem->value() ) ) {
369  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
370  (~lhs)(lelem->index(),relem->index()) = lelem->value() * relem->value();
371  }
372  }
373  }
374  }
376  //**********************************************************************************************
377 
378  //**Assignment to row-major sparse matrices*****************************************************
390  template< typename MT > // Type of the target sparse matrix
391  friend inline void assign( SparseMatrix<MT,false>& lhs, const SVecSVecOuterExpr& rhs )
392  {
394 
395  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
396  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns() , "Invalid number of columns" );
397  BLAZE_INTERNAL_ASSERT( (~lhs).capacity() >= rhs.nonZeros(), "Insufficient capacity" );
398 
399  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
400  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
401 
402  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
403  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
404 
405  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
406  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
407  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
408  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
409 
410  const LeftIterator lend( x.end() );
411  const RightIterator rend( y.end() );
412  size_t index( 0UL );
413 
414  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
415  if( !isDefault( lelem->value() ) ) {
416  for( ; index < lelem->index(); ++index ) {
417  (~lhs).finalize( index );
418  }
419  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
420  (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
421  }
422  (~lhs).finalize( index++ );
423  }
424  }
425 
426  for( ; index < x.size(); ++index ) {
427  (~lhs).finalize( index );
428  }
429  }
431  //**********************************************************************************************
432 
433  //**Assignment to column-major sparse matrices**************************************************
446  template< typename MT > // Type of the target sparse matrix
447  friend inline void assign( SparseMatrix<MT,true>& lhs, const SVecSVecOuterExpr& rhs )
448  {
450 
452 
453  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
454  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns() , "Invalid number of columns" );
455  BLAZE_INTERNAL_ASSERT( (~lhs).capacity() >= rhs.nonZeros(), "Insufficient capacity" );
456 
457  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
458  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
459 
460  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
461  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
462 
463  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
464  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
465  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
466  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
467 
468  const LeftIterator lend( x.end() );
469  const RightIterator rend( y.end() );
470  size_t index( 0UL );
471 
472  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
473  if( !isDefault( relem->value() ) ) {
474  for( ; index < relem->index(); ++index ) {
475  (~lhs).finalize( index );
476  }
477  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
478  (~lhs).append( lelem->index(), relem->index(), lelem->value() * relem->value() );
479  }
480  (~lhs).finalize( index++ );
481  }
482  }
483 
484  for( ; index < y.size(); ++index ) {
485  (~lhs).finalize( index );
486  }
487  }
489  //**********************************************************************************************
490 
491  //**Addition assignment to row-major dense matrices*********************************************
504  template< typename MT > // Type of the target dense matrix
505  friend inline void addAssign( DenseMatrix<MT,false>& lhs, const SVecSVecOuterExpr& rhs )
506  {
508 
509  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
510  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
511 
512  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
513  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
514 
515  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
516  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
517 
518  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
519  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
520  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
521  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
522 
523  const LeftIterator lend( x.end() );
524  const RightIterator rend( y.end() );
525 
526  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
527  if( !isDefault( lelem->value() ) ) {
528  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
529  (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
530  }
531  }
532  }
533  }
535  //**********************************************************************************************
536 
537  //**Addition assignment to column-major dense matrices******************************************
550  template< typename MT > // Type of the target dense matrix
551  friend inline void addAssign( DenseMatrix<MT,true>& lhs, const SVecSVecOuterExpr& rhs )
552  {
554 
556 
557  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
558  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
559 
560  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
561  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
562 
563  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
564  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
565 
566  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
567  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
568  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
569  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
570 
571  const LeftIterator lend( x.end() );
572  const RightIterator rend( y.end() );
573 
574  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
575  if( !isDefault( relem->value() ) ) {
576  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
577  (~lhs)(lelem->index(),relem->index()) += lelem->value() * relem->value();
578  }
579  }
580  }
581  }
583  //**********************************************************************************************
584 
585  //**Addition assignment to sparse matrices******************************************************
586  // No special implementation for the addition assignment to sparse matrices.
587  //**********************************************************************************************
588 
589  //**Subtraction assignment to row-major dense matrices******************************************
602  template< typename MT > // Type of the target dense matrix
603  friend inline void subAssign( DenseMatrix<MT,false>& lhs, const SVecSVecOuterExpr& rhs )
604  {
606 
607  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
608  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
609 
610  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
611  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
612 
613  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
614  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
615 
616  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
617  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
618  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
619  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
620 
621  const LeftIterator lend( x.end() );
622  const RightIterator rend( y.end() );
623 
624  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
625  if( !isDefault( lelem->value() ) ) {
626  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
627  (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
628  }
629  }
630  }
631  }
633  //**********************************************************************************************
634 
635  //**Subtraction assignment to column-major dense matrices***************************************
648  template< typename MT > // Type of the target dense matrix
649  friend inline void subAssign( DenseMatrix<MT,true>& lhs, const SVecSVecOuterExpr& rhs )
650  {
652 
654 
655  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
656  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
657 
658  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
659  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
660 
661  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
662  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
663 
664  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
665  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
666  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
667  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
668 
669  const LeftIterator lend( x.end() );
670  const RightIterator rend( y.end() );
671 
672  for( RightIterator relem=y.begin(); relem!=rend; ++relem ) {
673  if( !isDefault( relem->value() ) ) {
674  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem ) {
675  (~lhs)(lelem->index(),relem->index()) -= lelem->value() * relem->value();
676  }
677  }
678  }
679  }
681  //**********************************************************************************************
682 
683  //**Subtraction assignment to sparse matrices***************************************************
684  // No special implementation for the subtraction assignment to sparse matrices.
685  //**********************************************************************************************
686 
687  //**Schur product assignment to row-major dense matrices****************************************
700  template< typename MT > // Type of the target dense matrix
701  friend inline void schurAssign( DenseMatrix<MT,false>& lhs, const SVecSVecOuterExpr& rhs )
702  {
704 
705  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
706  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
707 
708  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
709  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
710 
711  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
712  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
713 
714  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
715  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
716  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
717  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
718 
719  const LeftIterator lend( x.end() );
720  const RightIterator rend( y.end() );
721 
722  size_t i( 0UL );
723 
724  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem )
725  {
726  if( isDefault( lelem->value() ) ) continue;
727 
728  for( ; i<lelem->index(); ++i ) {
729  for( size_t j=0UL; j<y.size(); ++j )
730  reset( (~lhs)(i,j) );
731  }
732 
733  size_t j( 0UL );
734 
735  for( RightIterator relem=y.begin(); relem!=rend; ++relem, ++j ) {
736  for( ; j<relem->index(); ++j )
737  reset( (~lhs)(i,j) );
738  (~lhs)(lelem->index(),relem->index()) *= lelem->value() * relem->value();
739  }
740 
741  for( ; j<y.size(); ++j ) {
742  reset( (~lhs)(i,j) );
743  }
744 
745  ++i;
746  }
747 
748  for( ; i<x.size(); ++i ) {
749  for( size_t j=0UL; j<y.size(); ++j )
750  reset( (~lhs)(i,j) );
751  }
752  }
754  //**********************************************************************************************
755 
756  //**Schur product assignment to column-major dense matrices*************************************
769  template< typename MT > // Type of the target dense matrix
770  friend inline void schurAssign( DenseMatrix<MT,true>& lhs, const SVecSVecOuterExpr& rhs )
771  {
773 
775 
776  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
777  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
778 
779  using LeftIterator = ConstIterator_< RemoveReference_<LT> >;
780  using RightIterator = ConstIterator_< RemoveReference_<RT> >;
781 
782  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse vector operand
783  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse vector operand
784 
785  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
786  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
787  BLAZE_INTERNAL_ASSERT( x.size() == (~lhs).rows() , "Invalid vector size" );
788  BLAZE_INTERNAL_ASSERT( y.size() == (~lhs).columns(), "Invalid vector size" );
789 
790  const LeftIterator lend( x.end() );
791  const RightIterator rend( y.end() );
792 
793  size_t j( 0UL );
794 
795  for( RightIterator relem=y.begin(); relem!=rend; ++relem )
796  {
797  if( isDefault( relem->value() ) ) continue;
798 
799  for( ; j<relem->index(); ++j ) {
800  for( size_t i=0UL; i<x.size(); ++i )
801  reset( (~lhs)(i,j) );
802  }
803 
804  size_t i( 0UL );
805 
806  for( LeftIterator lelem=x.begin(); lelem!=lend; ++lelem, ++i ) {
807  for( ; i<lelem->index(); ++i )
808  reset( (~lhs)(i,j) );
809  (~lhs)(lelem->index(),relem->index()) *= lelem->value() * relem->value();
810  }
811 
812  for( ; i<x.size(); ++i ) {
813  reset( (~lhs)(i,j) );
814  }
815 
816  ++j;
817  }
818 
819  for( ; j<y.size(); ++j ) {
820  for( size_t i=0UL; i<x.size(); ++i )
821  reset( (~lhs)(i,j) );
822  }
823  }
825  //**********************************************************************************************
826 
827  //**Schur product assignment to sparse matrices*************************************************
828  // No special implementation for the Schur product assignment to sparse matrices.
829  //**********************************************************************************************
830 
831  //**Multiplication assignment to dense matrices*************************************************
832  // No special implementation for the multiplication assignment to dense matrices.
833  //**********************************************************************************************
834 
835  //**Multiplication assignment to sparse matrices************************************************
836  // No special implementation for the multiplication assignment to sparse matrices.
837  //**********************************************************************************************
838 
839  //**Compile time checks*************************************************************************
847  //**********************************************************************************************
848 };
849 //*************************************************************************************************
850 
851 
852 
853 
854 //=================================================================================================
855 //
856 // GLOBAL BINARY ARITHMETIC OPERATORS
857 //
858 //=================================================================================================
859 
860 //*************************************************************************************************
887 template< typename VT1 // Type of the left-hand side sparse vector
888  , typename VT2 > // Type of the right-hand side sparse vector
889 inline decltype(auto)
890  operator*( const SparseVector<VT1,false>& lhs, const SparseVector<VT2,true>& rhs )
891 {
893 
895  return ReturnType( ~lhs, ~rhs );
896 }
897 //*************************************************************************************************
898 
899 
900 
901 
902 //=================================================================================================
903 //
904 // ROWS SPECIALIZATIONS
905 //
906 //=================================================================================================
907 
908 //*************************************************************************************************
910 template< typename VT1, typename VT2 >
911 struct Rows< SVecSVecOuterExpr<VT1,VT2> >
912  : public Size<VT1>
913 {};
915 //*************************************************************************************************
916 
917 
918 
919 
920 //=================================================================================================
921 //
922 // COLUMNS SPECIALIZATIONS
923 //
924 //=================================================================================================
925 
926 //*************************************************************************************************
928 template< typename VT1, typename VT2 >
929 struct Columns< SVecSVecOuterExpr<VT1,VT2> >
930  : public Size<VT2>
931 {};
933 //*************************************************************************************************
934 
935 } // namespace blaze
936 
937 #endif
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SVecSVecOuterExpr.h:120
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse vector operand.
Definition: SVecSVecOuterExpr.h:240
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SVecSVecOuterExpr.h:121
Header file for auxiliary alias declarations.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
ReturnType_< VT2 > RN2
Return type of the right-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:98
Header file for the Rows type trait.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SVecSVecOuterExpr.h:167
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
Expression object for sparse vector-sparse vector outer products.The SVecSVecOuterExpr class represen...
Definition: Forward.h:144
#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: ColumnVector.h:61
Header file for the serial shim.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:250
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SVecSVecOuterExpr.h:199
Header file for the Computation base class.
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse vector operand.
Definition: SVecSVecOuterExpr.h:250
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
CompositeType_< VT1 > CT1
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:99
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:78
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SVecSVecOuterExpr.h:230
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SVecSVecOuterExpr.h:219
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SVecSVecOuterExpr.h:125
Header file for the SparseMatrix base class.
Constraint on the transpose flag of vector types.
RightOperand rhs_
Right-hand side sparse vector of the multiplication expression.
Definition: SVecSVecOuterExpr.h:282
Constraint on the data type.
typename MultExprTrait< T1, T2 >::Type MultExprTrait_
Auxiliary alias declaration for the MultExprTrait class template.The MultExprTrait_ alias declaration...
Definition: MultExprTrait.h:112
Header file for the MultExprTrait class template.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
ResultType_< VT1 > RT1
Result type of the left-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:95
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
If_< IsComputation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: SVecSVecOuterExpr.h:137
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECTVECMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid vector/vector ...
Definition: VecTVecMultExpr.h:104
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
SVecSVecOuterExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the SVecSVecOuterExpr class.
Definition: SVecSVecOuterExpr.h:154
If_< IsComputation< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: SVecSVecOuterExpr.h:140
MultTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SVecSVecOuterExpr.h:119
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Constraint on the data type.
Header file for the VecTVecMultExpr base class.
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:134
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Header file for run time assertion macros.
MultExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SVecSVecOuterExpr.h:113
CompositeType_< VT2 > CT2
Composite type of the right-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:100
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
Constraint on the data type.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
Constraint on the data type.
ReturnType_< VT1 > RN1
Return type of the left-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:97
Header file for the RemoveReference type trait.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SVecSVecOuterExpr.h:209
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SVecSVecOuterExpr.h:183
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
const ResultType CompositeType
Data type for composite expression templates.
Definition: SVecSVecOuterExpr.h:128
Header file for the IsComputation type trait class.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SVecSVecOuterExpr.h:262
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SVecSVecOuterExpr.h:122
ResultType_< VT2 > RT2
Result type of the right-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:96
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:75
#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: RowVector.h:61
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:75
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SVecSVecOuterExpr.h:274
Header file for the Size type trait.
Size type of the Blaze library.
#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
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side sparse vector expression.
Definition: SVecSVecOuterExpr.h:131
LeftOperand lhs_
Left-hand side sparse vector of the multiplication expression.
Definition: SVecSVecOuterExpr.h:281