TSMatSMatSchurExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSMATSCHUREXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATSMATSCHUREXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
73 #include <blaze/util/Assert.h>
74 #include <blaze/util/DisableIf.h>
75 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/mpl/If.h>
79 #include <blaze/util/Types.h>
81 #include <blaze/util/Unused.h>
82 
83 
84 namespace blaze {
85 
86 //=================================================================================================
87 //
88 // CLASS TSMATSMATSCHUREXPR
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
99 template< typename MT1 // Type of the left-hand side sparse matrix
100  , typename MT2 > // Type of the right-hand side sparse matrix
101 class TSMatSMatSchurExpr
102  : public SchurExpr< SparseMatrix< TSMatSMatSchurExpr<MT1,MT2>, false > >
103  , private Computation
104 {
105  private:
106  //**Type definitions****************************************************************************
113  //**********************************************************************************************
114 
115  //**Return type evaluation**********************************************************************
117 
122  static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
123 
125  using ExprReturnType = decltype( std::declval<RN1>() * std::declval<RN2>() );
126  //**********************************************************************************************
127 
128  //**Serial evaluation strategy******************************************************************
130 
135  template< typename T1, typename T2 >
136  static constexpr bool UseSymmetricKernel_v =
137  ( IsVoid_v< EnableIf_t< StorageOrder_v<T1> != StorageOrder_v<T2> > > && IsSymmetric_v<T2> );
139  //**********************************************************************************************
140 
141  public:
142  //**Type definitions****************************************************************************
149 
152 
154  using CompositeType = const ResultType;
155 
157  using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
158 
160  using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
161  //**********************************************************************************************
162 
163  //**Compilation flags***************************************************************************
165  static constexpr bool smpAssignable = false;
166  //**********************************************************************************************
167 
168  //**Constructor*********************************************************************************
174  explicit inline TSMatSMatSchurExpr( const MT1& lhs, const MT2& rhs ) noexcept
175  : lhs_( lhs ) // Left-hand side sparse matrix of the Schur product expression
176  , rhs_( rhs ) // Right-hand side sparse matrix of the Schur product expression
177  {
178  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
179  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
180  }
181  //**********************************************************************************************
182 
183  //**Access operator*****************************************************************************
190  inline ReturnType operator()( size_t i, size_t j ) const {
191  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
192  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
193  return lhs_(i,j) * rhs_(i,j);
194  }
195  //**********************************************************************************************
196 
197  //**At function*********************************************************************************
205  inline ReturnType at( size_t i, size_t j ) const {
206  if( i >= lhs_.rows() ) {
207  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
208  }
209  if( j >= lhs_.columns() ) {
210  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
211  }
212  return (*this)(i,j);
213  }
214  //**********************************************************************************************
215 
216  //**Rows function*******************************************************************************
221  inline size_t rows() const noexcept {
222  return lhs_.rows();
223  }
224  //**********************************************************************************************
225 
226  //**Columns function****************************************************************************
231  inline size_t columns() const noexcept {
232  return lhs_.columns();
233  }
234  //**********************************************************************************************
235 
236  //**NonZeros function***************************************************************************
241  inline size_t nonZeros() const {
242  return min( lhs_.nonZeros(), rhs_.nonZeros() );
243  }
244  //**********************************************************************************************
245 
246  //**NonZeros function***************************************************************************
252  inline size_t nonZeros( size_t i ) const {
253  return min( lhs_.nonZeros(i), rhs_.nonZeros(i) );
254  }
255  //**********************************************************************************************
256 
257  //**Left operand access*************************************************************************
262  inline LeftOperand leftOperand() const noexcept {
263  return lhs_;
264  }
265  //**********************************************************************************************
266 
267  //**Right operand access************************************************************************
272  inline RightOperand rightOperand() const noexcept {
273  return rhs_;
274  }
275  //**********************************************************************************************
276 
277  //**********************************************************************************************
283  template< typename T >
284  inline bool canAlias( const T* alias ) const noexcept {
285  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
286  }
287  //**********************************************************************************************
288 
289  //**********************************************************************************************
295  template< typename T >
296  inline bool isAliased( const T* alias ) const noexcept {
297  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
298  }
299  //**********************************************************************************************
300 
301  private:
302  //**Member variables****************************************************************************
305  //**********************************************************************************************
306 
307  //**Assignment to row-major dense matrices******************************************************
320  template< typename MT > // Type of the target dense matrix
321  friend inline auto assign( DenseMatrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
323  {
325 
326  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
327  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
328 
329  // Evaluation of the left-hand side sparse matrix operand
330  const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
331 
332  // Evaluation of the right-hand side sparse matrix operand
333  CT2 B( serial( rhs.rhs_ ) );
334 
335  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
336  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
337  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
338  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
339  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
340  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
341 
342  assign( ~lhs, A % B );
343  }
345  //**********************************************************************************************
346 
347  //**Assignment to column-major dense matrices***************************************************
360  template< typename MT > // Type of the target dense matrix
361  friend inline auto assign( DenseMatrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
363  {
365 
367 
368  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
369  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
370 
371  // Evaluation of the left-hand side sparse matrix operand
372  CT1 A( serial( rhs.lhs_ ) );
373 
374  // Evaluation of the right-hand side sparse matrix operand
375  const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
376 
377  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
378  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
379  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
380  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
381  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
382  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
383 
384  assign( ~lhs, A % B );
385  }
387  //**********************************************************************************************
388 
389  //**Assignment to row-major sparse matrices*****************************************************
402  template< typename MT > // Type of the target sparse matrix
403  friend inline auto assign( SparseMatrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
404  -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
405  {
407 
408  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
409  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
410 
411  // Evaluation of the left-hand side sparse matrix operand
412  const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
413 
414  // Evaluation of the right-hand side sparse matrix operand
415  CT2 B( serial( rhs.rhs_ ) );
416 
417  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
418  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
419  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
420  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
421  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
422  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
423 
424  assign( ~lhs, A % B );
425  }
427  //**********************************************************************************************
428 
429  //**Assignment to column-major sparse matrices**************************************************
442  template< typename MT > // Type of the target sparse matrix
443  friend inline auto assign( SparseMatrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
444  -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
445  {
447 
449 
450  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
451  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
452 
453  // Evaluation of the left-hand side sparse matrix operand
454  CT1 A( serial( rhs.lhs_ ) );
455 
456  // Evaluation of the right-hand side sparse matrix operand
457  const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
458 
459  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
460  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
461  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
462  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
463  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
464  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
465 
466  assign( ~lhs, A % B );
467  }
469  //**********************************************************************************************
470 
471  //**Restructuring assignment to row-major matrices**********************************************
484  template< typename MT > // Type of the target matrix
485  friend inline auto assign( Matrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
486  -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
487  {
489 
490  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
491  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
492 
493  assign( ~lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
494  }
496  //**********************************************************************************************
497 
498  //**Restructuring assignment to column-major matrices*******************************************
511  template< typename MT > // Type of the target matrix
512  friend inline auto assign( Matrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
513  -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
514  {
516 
518 
519  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
520  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
521 
522  assign( ~lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
523  }
525  //**********************************************************************************************
526 
527  //**Addition assignment to row-major dense matrices*********************************************
540  template< typename MT > // Type of the target dense matrix
541  friend inline auto addAssign( DenseMatrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
542  -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
543  {
545 
546  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
547  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
548 
549  // Evaluation of the left-hand side sparse matrix operand
550  const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
551 
552  // Evaluation of the right-hand side sparse matrix operand
553  CT2 B( serial( rhs.rhs_ ) );
554 
555  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
556  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
557  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
558  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
559  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
560  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
561 
562  addAssign( ~lhs, A % B );
563  }
565  //**********************************************************************************************
566 
567  //**Addition assignment to column-major dense matrices******************************************
580  template< typename MT > // Type of the target dense matrix
581  friend inline auto addAssign( DenseMatrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
582  -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
583  {
585 
587 
588  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
589  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
590 
591  // Evaluation of the left-hand side sparse matrix operand
592  CT1 A( serial( rhs.lhs_ ) );
593 
594  // Evaluation of the right-hand side sparse matrix operand
595  const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
596 
597  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
598  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
599  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
600  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
601  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
602  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
603 
604  addAssign( ~lhs, A % B );
605  }
607  //**********************************************************************************************
608 
609  //**Restructuring addition assignment to row-major matrices*************************************
622  template< typename MT > // Type of the target matrix
623  friend inline auto addAssign( Matrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
624  -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
625  {
627 
628  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
629  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
630 
631  addAssign( ~lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
632  }
634  //**********************************************************************************************
635 
636  //**Restructuring addition assignment to column-major matrices**********************************
649  template< typename MT > // Type of the target matrix
650  friend inline auto addAssign( Matrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
651  -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
652  {
654 
656 
657  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
658  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
659 
660  addAssign( ~lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
661  }
663  //**********************************************************************************************
664 
665  //**Addition assignment to sparse matrices******************************************************
666  // No special implementation for the addition assignment to sparse matrices.
667  //**********************************************************************************************
668 
669  //**Subtraction assignment to row-major dense matrices******************************************
682  template< typename MT > // Type of the target dense matrix
683  friend inline auto subAssign( DenseMatrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
684  -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
685  {
687 
688  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
689  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
690 
691  // Evaluation of the left-hand side sparse matrix operand
692  const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
693 
694  // Evaluation of the right-hand side sparse matrix operand
695  CT2 B( serial( rhs.rhs_ ) );
696 
697  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
698  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
699  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
700  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
701  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
702  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
703 
704  subAssign( ~lhs, A % B );
705  }
707  //**********************************************************************************************
708 
709  //**Subtraction assignment to column-major dense matrices***************************************
722  template< typename MT > // Type of the target dense matrix
723  friend inline auto subAssign( DenseMatrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
724  -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
725  {
727 
729 
730  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
731  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
732 
733  // Evaluation of the left-hand side sparse matrix operand
734  CT1 A( serial( rhs.lhs_ ) );
735 
736  // Evaluation of the right-hand side sparse matrix operand
737  const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
738 
739  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
740  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
741  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
742  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
743  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
744  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
745 
746  subAssign( ~lhs, A % B );
747  }
749  //**********************************************************************************************
750 
751  //**Restructuring subtraction assignment to row-major matrices**********************************
764  template< typename MT > // Type of the target matrix
765  friend inline auto subAssign( Matrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
766  -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
767  {
769 
770  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
771  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
772 
773  subAssign( ~lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
774  }
776  //**********************************************************************************************
777 
778  //**Restructuring subtraction assignment to column-major matrices*******************************
791  template< typename MT > // Type of the target matrix
792  friend inline auto subAssign( Matrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
793  -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
794  {
796 
798 
799  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
800  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
801 
802  subAssign( ~lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
803  }
805  //**********************************************************************************************
806 
807  //**Subtraction assignment to sparse matrices***************************************************
808  // No special implementation for the subtraction assignment to sparse matrices.
809  //**********************************************************************************************
810 
811  //**Schur product assignment to row-major dense matrices****************************************
824  template< typename MT > // Type of the target dense matrix
825  friend inline auto schurAssign( DenseMatrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
826  -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
827  {
829 
830  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
831  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
832 
833  // Evaluation of the left-hand side sparse matrix operand
834  const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
835 
836  // Evaluation of the right-hand side sparse matrix operand
837  CT2 B( serial( rhs.rhs_ ) );
838 
839  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
840  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
841  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
842  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
843  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
844  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
845 
846  schurAssign( ~lhs, A % B );
847  }
849  //**********************************************************************************************
850 
851  //**Schur product assignment to column-major dense matrices*************************************
864  template< typename MT > // Type of the target dense matrix
865  friend inline auto schurAssign( DenseMatrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
866  -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
867  {
869 
871 
872  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
873  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
874 
875  // Evaluation of the left-hand side sparse matrix operand
876  CT1 A( serial( rhs.lhs_ ) );
877 
878  // Evaluation of the right-hand side sparse matrix operand
879  const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
880 
881  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
882  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
883  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
884  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
885  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
886  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
887 
888  schurAssign( ~lhs, A % B );
889  }
891  //**********************************************************************************************
892 
893  //**Restructuring Schur product assignment to row-major matrices********************************
906  template< typename MT > // Type of the target matrix
907  friend inline auto schurAssign( Matrix<MT,false>& lhs, const TSMatSMatSchurExpr& rhs )
908  -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
909  {
911 
912  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
913  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
914 
915  schurAssign( ~lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
916  }
918  //**********************************************************************************************
919 
920  //**Restructuring Schur product assignment to column-major matrices*****************************
933  template< typename MT > // Type of the target matrix
934  friend inline auto schurAssign( Matrix<MT,true>& lhs, const TSMatSMatSchurExpr& rhs )
935  -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
936  {
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  schurAssign( ~lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
945  }
947  //**********************************************************************************************
948 
949  //**Multiplication assignment to dense matrices*************************************************
950  // No special implementation for the multiplication assignment to dense matrices.
951  //**********************************************************************************************
952 
953  //**Multiplication assignment to sparse matrices************************************************
954  // No special implementation for the multiplication assignment to sparse matrices.
955  //**********************************************************************************************
956 
957  //**SMP assignment to dense matrices************************************************************
958  // No special implementation for the SMP assignment to dense matrices.
959  //**********************************************************************************************
960 
961  //**SMP assignment to sparse matrices***********************************************************
962  // No special implementation for the SMP assignment to sparse matrices.
963  //**********************************************************************************************
964 
965  //**SMP addition assignment to dense matrices***************************************************
966  // No special implementation for the SMP addition assignment to dense matrices.
967  //**********************************************************************************************
968 
969  //**SMP addition assignment to sparse matrices**************************************************
970  // No special implementation for the SMP addition assignment to sparse matrices.
971  //**********************************************************************************************
972 
973  //**SMP subtraction assignment to dense matrices************************************************
974  // No special implementation for the SMP subtraction assignment to dense matrices.
975  //**********************************************************************************************
976 
977  //**SMP subtraction assignment to sparse matrices***********************************************
978  // No special implementation for the SMP subtraction assignment to sparse matrices.
979  //**********************************************************************************************
980 
981  //**SMP Schur product assignment to dense matrices**********************************************
994  template< typename MT // Type of the target dense matrix
995  , bool SO > // Storage order of the target dense matrix
996  friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSchurExpr& rhs )
997  {
999 
1000  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1001  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1002 
1003  smpSchurAssign( ~lhs, rhs.lhs_ );
1004  smpSchurAssign( ~lhs, rhs.rhs_ );
1005  }
1007  //**********************************************************************************************
1008 
1009  //**SMP Schur product assignment to sparse matrices*********************************************
1010  // No special implementation for the SMP Schur product assignment to sparse matrices.
1011  //**********************************************************************************************
1012 
1013  //**SMP multiplication assignment to dense matrices*********************************************
1014  // No special implementation for the SMP multiplication assignment to dense matrices.
1015  //**********************************************************************************************
1016 
1017  //**SMP multiplication assignment to sparse matrices********************************************
1018  // No special implementation for the SMP multiplication assignment to sparse matrices.
1019  //**********************************************************************************************
1020 
1021  //**Compile time checks*************************************************************************
1031  //**********************************************************************************************
1032 };
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // GLOBAL BINARY ARITHMETIC OPERATORS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1057 template< typename MT1 // Type of the left-hand side sparse matrix
1058  , typename MT2 // Type of the right-hand side sparse matrix
1059  , DisableIf_t< ( IsUniLower_v<MT1> && IsUniUpper_v<MT2> ) ||
1060  ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) ||
1061  ( IsStrictlyLower_v<MT1> && IsUpper_v<MT2> ) ||
1062  ( IsStrictlyUpper_v<MT1> && IsLower_v<MT2> ) ||
1063  ( IsLower_v<MT1> && IsStrictlyUpper_v<MT2> ) ||
1064  ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) ||
1065  ( IsZero_v<MT1> || IsZero_v<MT2> ) >* = nullptr >
1066 inline const TSMatSMatSchurExpr<MT1,MT2>
1067  tsmatsmatschur( const SparseMatrix<MT1,true>& lhs, const SparseMatrix<MT2,false>& rhs )
1068 {
1070 
1071  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
1072  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
1073 
1074  return TSMatSMatSchurExpr<MT1,MT2>( ~lhs, ~rhs );
1075 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1094 template< typename MT1 // Type of the left-hand side sparse matrix
1095  , typename MT2 // Type of the right-hand side sparse matrix
1096  , EnableIf_t< ( IsUniLower_v<MT1> && IsUniUpper_v<MT2> ) ||
1097  ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) >* = nullptr >
1098 inline decltype(auto)
1099  tsmatsmatschur( const SparseMatrix<MT1,true>& lhs, const SparseMatrix<MT2,false>& rhs )
1100 {
1102 
1103  UNUSED_PARAMETER( rhs );
1104 
1105  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
1106  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
1107 
1108  using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1109 
1112 
1113  return ReturnType( (~lhs).rows() );
1114 }
1116 //*************************************************************************************************
1117 
1118 
1119 //*************************************************************************************************
1133 template< typename MT1 // Type of the left-hand side sparse matrix
1134  , typename MT2 // Type of the right-hand side sparse matrix
1135  , EnableIf_t< ( IsStrictlyLower_v<MT1> && IsUpper_v<MT2> ) ||
1136  ( IsStrictlyUpper_v<MT1> && IsLower_v<MT2> ) ||
1137  ( IsLower_v<MT1> && IsStrictlyUpper_v<MT2> ) ||
1138  ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) ||
1139  ( IsZero_v<MT1> || IsZero_v<MT2> ) >* = nullptr >
1140 inline decltype(auto)
1141  tsmatsmatschur( const SparseMatrix<MT1,true>& lhs, const SparseMatrix<MT2,false>& rhs )
1142 {
1144 
1145  UNUSED_PARAMETER( rhs );
1146 
1147  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == (~rhs).rows() , "Invalid number of rows" );
1148  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == (~rhs).columns(), "Invalid number of columns" );
1149 
1150  using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1151 
1154 
1155  return ReturnType( (~lhs).rows(), (~lhs).columns() );
1156 }
1158 //*************************************************************************************************
1159 
1160 
1161 //*************************************************************************************************
1190 template< typename MT1 // Type of the left-hand side sparse matrix
1191  , typename MT2 > // Type of the right-hand side sparse matrix
1192 inline decltype(auto)
1193  operator%( const SparseMatrix<MT1,true>& lhs, const SparseMatrix<MT2,false>& rhs )
1194 {
1196 
1197  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
1198  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1199  }
1200 
1201  return tsmatsmatschur( ~lhs, ~rhs );
1202 }
1203 //*************************************************************************************************
1204 
1205 } // namespace blaze
1206 
1207 #endif
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
#define BLAZE_CONSTRAINT_MUST_BE_IDENTITY_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not an identity matrix type...
Definition: Identity.h:60
Header file for the Schur product trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: TSMatSMatSchurExpr.h:165
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:107
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
Constraint on the data type.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TSMatSMatSchurExpr.h:231
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatSMatSchurExpr.h:146
Header file for the Computation base class.
Constraints on the storage order of matrix types.
ReturnType_t< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:110
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TSMatSMatSchurExpr.h:221
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
LeftOperand lhs_
Left-hand side sparse matrix of the Schur product expression.
Definition: TSMatSMatSchurExpr.h:303
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
Header file for the IsUniLower type trait.
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: TSMatSMatSchurExpr.h:252
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_SCHUREXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: SchurExpr.h:103
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
RightOperand rhs_
Right-hand side sparse matrix of the Schur product expression.
Definition: TSMatSMatSchurExpr.h:304
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition: TSMatSMatSchurExpr.h:272
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Header file for all forward declarations for sparse vectors and matrices.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: TSMatSMatSchurExpr.h:148
Header file for the IsVoid type trait.
Header file for the SparseMatrix base class.
Constraint on the data type.
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSMatSchurExpr.h:147
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:111
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type...
Definition: Zero.h:61
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#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
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatSMatSchurExpr.h:190
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSMatSchurExpr.h:296
Header file for the IsLower type trait.
If_t< IsExpression_v< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:157
Header file for the exception macros of the math module.
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:108
Header file for all forward declarations for expression class templates.
If_t< IsExpression_v< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:160
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: TSMatSMatSchurExpr.h:241
#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
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
TSMatSMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TSMatSMatSchurExpr class.
Definition: TSMatSMatSchurExpr.h:174
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatSMatSchurExpr.h:154
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: TSMatSMatSchurExpr.h:145
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSMatSchurExpr.h:262
Header file for the SchurExpr base class.
typename SchurTrait< T1, T2 >::Type SchurTrait_t
Auxiliary alias declaration for the SchurTrait class template.The SchurTrait_t alias declaration prov...
Definition: SchurTrait.h:164
Header file for the IsZero type trait.
#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
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
ReturnType_t< MT1 > RN1
Return type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:109
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: TSMatSMatSchurExpr.h:122
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: TSMatSMatSchurExpr.h:125
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
CompositeType_t< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSchurExpr.h:112
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatSMatSchurExpr.h:205
Header file for the IsComputation type trait class.
Header file for the StorageOrder type trait.
Header file for the IntegralConstant class template.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TSMatSMatSchurExpr.h:284
Header file for the IsUpper type trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type...
Definition: Zero.h:81
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Expression object for transpose sparse matrix-sparse matrix Schur products.The TSMatSMatSchurExpr cla...
Definition: Forward.h:174
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: TSMatSMatSchurExpr.h:151
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
Constraint on the data type.