Blaze 3.9
SMatTSMatSchurExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATTSMATSCHUREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATTSMATSCHUREXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/Aliases.h>
72#include <blaze/util/Assert.h>
73#include <blaze/util/EnableIf.h>
77#include <blaze/util/mpl/If.h>
78#include <blaze/util/Types.h>
79
80
81namespace blaze {
82
83//=================================================================================================
84//
85// CLASS SMATTSMATSCHUREXPR
86//
87//=================================================================================================
88
89//*************************************************************************************************
96template< typename MT1 // Type of the left-hand side sparse matrix
97 , typename MT2 > // Type of the right-hand side sparse matrix
99 : public SchurExpr< SparseMatrix< SMatTSMatSchurExpr<MT1,MT2>, false > >
100 , private Computation
101{
102 private:
103 //**Type definitions****************************************************************************
110 //**********************************************************************************************
111
112 //**Return type evaluation**********************************************************************
114
119 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
120
122 using ExprReturnType = decltype( std::declval<RN1>() * std::declval<RN2>() );
123 //**********************************************************************************************
124
125 //**Serial evaluation strategy******************************************************************
127
132 template< typename T1, typename T2 >
133 static constexpr bool UseSymmetricKernel_v =
134 ( ( StorageOrder_v<T1> != StorageOrder_v<T2> ) && IsSymmetric_v<T2> );
136 //**********************************************************************************************
137
138 public:
139 //**Type definitions****************************************************************************
142
145
150
153
156
158 using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
159
161 using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
162 //**********************************************************************************************
163
164 //**Compilation flags***************************************************************************
166 static constexpr bool smpAssignable = false;
167 //**********************************************************************************************
168
169 //**Constructor*********************************************************************************
175 inline SMatTSMatSchurExpr( const MT1& lhs, const MT2& rhs ) noexcept
176 : lhs_( lhs ) // Left-hand side sparse matrix of the Schur product expression
177 , rhs_( rhs ) // Right-hand side sparse matrix of the Schur product expression
178 {
179 BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
180 BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
181 }
182 //**********************************************************************************************
183
184 //**Access operator*****************************************************************************
191 inline ReturnType operator()( size_t i, size_t j ) const {
192 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
193 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
194 return lhs_(i,j) * rhs_(i,j);
195 }
196 //**********************************************************************************************
197
198 //**At function*********************************************************************************
206 inline ReturnType at( size_t i, size_t j ) const {
207 if( i >= lhs_.rows() ) {
208 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
209 }
210 if( j >= lhs_.columns() ) {
211 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
212 }
213 return (*this)(i,j);
214 }
215 //**********************************************************************************************
216
217 //**Rows function*******************************************************************************
222 inline size_t rows() const noexcept {
223 return lhs_.rows();
224 }
225 //**********************************************************************************************
226
227 //**Columns function****************************************************************************
232 inline size_t columns() const noexcept {
233 return lhs_.columns();
234 }
235 //**********************************************************************************************
236
237 //**NonZeros function***************************************************************************
242 inline size_t nonZeros() const {
243 return min( lhs_.nonZeros(), rhs_.nonZeros() );
244 }
245 //**********************************************************************************************
246
247 //**NonZeros function***************************************************************************
253 inline size_t nonZeros( size_t i ) const {
254 return min( lhs_.nonZeros(i), rhs_.nonZeros(i) );
255 }
256 //**********************************************************************************************
257
258 //**Left operand access*************************************************************************
263 inline LeftOperand leftOperand() const noexcept {
264 return lhs_;
265 }
266 //**********************************************************************************************
267
268 //**Right operand access************************************************************************
273 inline RightOperand rightOperand() const noexcept {
274 return rhs_;
275 }
276 //**********************************************************************************************
277
278 //**********************************************************************************************
284 template< typename T >
285 inline bool canAlias( const T* alias ) const noexcept {
286 return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
287 }
288 //**********************************************************************************************
289
290 //**********************************************************************************************
296 template< typename T >
297 inline bool isAliased( const T* alias ) const noexcept {
298 return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
299 }
300 //**********************************************************************************************
301
302 private:
303 //**Member variables****************************************************************************
306 //**********************************************************************************************
307
308 //**Assignment to row-major dense matrices******************************************************
321 template< typename MT > // Type of the target dense matrix
322 friend inline auto assign( DenseMatrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
324 {
326
327 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
328 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
329
330 // Evaluation of the left-hand side sparse matrix operand
331 CT1 A( serial( rhs.lhs_ ) );
332
333 // Evaluation of the right-hand side sparse matrix operand
334 const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
335
336 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
337 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
338 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
339 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
340 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
341 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
342
343 assign( *lhs, A % B );
344 }
346 //**********************************************************************************************
347
348 //**Assignment to column-major dense matrices***************************************************
361 template< typename MT > // Type of the target dense matrix
362 friend inline auto assign( DenseMatrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
364 {
366
368
369 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
370 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
371
372 // Evaluation of the left-hand side sparse matrix operand
373 const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
374
375 // Evaluation of the right-hand side sparse matrix operand
376 CT2 B( serial( rhs.rhs_ ) );
377
378 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
379 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
380 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
381 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
382 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
383 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
384
385 assign( *lhs, A % B );
386 }
388 //**********************************************************************************************
389
390 //**Assignment to row-major sparse matrices*****************************************************
403 template< typename MT > // Type of the target sparse matrix
404 friend inline auto assign( SparseMatrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
405 -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
406 {
408
409 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
410 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
411
412 // Evaluation of the left-hand side sparse matrix operand
413 CT1 A( serial( rhs.lhs_ ) );
414
415 // Evaluation of the right-hand side sparse matrix operand
416 const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
417
418 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
419 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
420 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
421 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
422 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
423 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
424
425 assign( *lhs, A % B );
426 }
428 //**********************************************************************************************
429
430 //**Assignment to column-major sparse matrices**************************************************
443 template< typename MT > // Type of the target sparse matrix
444 friend inline auto assign( SparseMatrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
445 -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
446 {
448
450
451 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
452 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
453
454 // Evaluation of the left-hand side sparse matrix operand
455 const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
456
457 // Evaluation of the right-hand side sparse matrix operand
458 CT2 B( serial( rhs.rhs_ ) );
459
460 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
461 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
462 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
463 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
464 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
465 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
466
467 assign( *lhs, A % B );
468 }
470 //**********************************************************************************************
471
472 //**Restructuring assignment to row-major matrices**********************************************
485 template< typename MT > // Type of the target sparse matrix
486 friend inline auto assign( Matrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
487 -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
488 {
490
491 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
492 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
493
494 assign( *lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
495 }
497 //**********************************************************************************************
498
499 //**Restructuring assignment to column-major matrices*******************************************
512 template< typename MT > // Type of the target sparse matrix
513 friend inline auto assign( Matrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
514 -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
515 {
517
519
520 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
521 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
522
523 assign( *lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
524 }
526 //**********************************************************************************************
527
528 //**Addition assignment to row-major dense matrices*********************************************
541 template< typename MT > // Type of the target dense matrix
542 friend inline auto addAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
543 -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
544 {
546
547 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
548 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
549
550 // Evaluation of the left-hand side sparse matrix operand
551 CT1 A( serial( rhs.lhs_ ) );
552
553 // Evaluation of the right-hand side sparse matrix operand
554 const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
555
556 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
557 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
558 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
559 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
560 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
561 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
562
563 addAssign( *lhs, A % B );
564 }
566 //**********************************************************************************************
567
568 //**Addition assignment to column-major dense matrices******************************************
581 template< typename MT > // Type of the target dense matrix
582 friend inline auto addAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
583 -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
584 {
586
588
589 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
590 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
591
592 // Evaluation of the left-hand side sparse matrix operand
593 const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
594
595 // Evaluation of the right-hand side sparse matrix operand
596 CT2 B( serial( rhs.rhs_ ) );
597
598 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
599 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
600 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
601 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
602 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
603 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
604
605 addAssign( *lhs, A % B );
606 }
608 //**********************************************************************************************
609
610 //**Restructuring addition assignment to row-major matrices*************************************
623 template< typename MT > // Type of the target sparse matrix
624 friend inline auto addAssign( Matrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
625 -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
626 {
628
629 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
630 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
631
632 addAssign( *lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
633 }
635 //**********************************************************************************************
636
637 //**Restructuring addition assignment to column-major matrices**********************************
650 template< typename MT > // Type of the target sparse matrix
651 friend inline auto addAssign( Matrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
652 -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
653 {
655
657
658 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
659 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
660
661 addAssign( *lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
662 }
664 //**********************************************************************************************
665
666 //**Addition assignment to sparse matrices******************************************************
667 // No special implementation for the addition assignment to sparse matrices.
668 //**********************************************************************************************
669
670 //**Subtraction assignment to row-major dense matrices******************************************
683 template< typename MT > // Type of the target dense matrix
684 friend inline auto subAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
685 -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
686 {
688
689 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
690 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
691
692 // Evaluation of the left-hand side sparse matrix operand
693 CT1 A( serial( rhs.lhs_ ) );
694
695 // Evaluation of the right-hand side sparse matrix operand
696 const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
697
698 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
699 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
700 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
701 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
702 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
703 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
704
705 subAssign( *lhs, A % B );
706 }
708 //**********************************************************************************************
709
710 //**Subtraction assignment to column-major dense matrices***************************************
723 template< typename MT > // Type of the target dense matrix
724 friend inline auto subAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
725 -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
726 {
728
730
731 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
732 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
733
734 // Evaluation of the left-hand side sparse matrix operand
735 const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
736
737 // Evaluation of the right-hand side sparse matrix operand
738 CT2 B( serial( rhs.rhs_ ) );
739
740 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
741 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
742 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
743 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
744 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
745 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
746
747 subAssign( *lhs, A % B );
748 }
750 //**********************************************************************************************
751
752 //**Restructuring subtraction assignment to row-major matrices**********************************
765 template< typename MT > // Type of the target sparse matrix
766 friend inline auto subAssign( Matrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
767 -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
768 {
770
771 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
772 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
773
774 subAssign( *lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
775 }
777 //**********************************************************************************************
778
779 //**Restructuring subtraction assignment to column-major matrices*******************************
792 template< typename MT > // Type of the target sparse matrix
793 friend inline auto subAssign( Matrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
794 -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
795 {
797
799
800 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
801 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
802
803 subAssign( *lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
804 }
806 //**********************************************************************************************
807
808 //**Subtraction assignment to sparse matrices***************************************************
809 // No special implementation for the subtraction assignment to sparse matrices.
810 //**********************************************************************************************
811
812 //**Schur product assignment to row-major dense matrices****************************************
825 template< typename MT > // Type of the target dense matrix
826 friend inline auto schurAssign( DenseMatrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
827 -> DisableIf_t< UseSymmetricKernel_v<MT,MT2> >
828 {
830
831 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
832 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
833
834 // Evaluation of the left-hand side sparse matrix operand
835 CT1 A( serial( rhs.lhs_ ) );
836
837 // Evaluation of the right-hand side sparse matrix operand
838 const OppositeType_t<RT2> B( serial( rhs.rhs_ ) );
839
840 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
841 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
842 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
843 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
844 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
845 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
846
847 schurAssign( *lhs, A % B );
848 }
850 //**********************************************************************************************
851
852 //**Schur product assignment to column-major dense matrices*************************************
865 template< typename MT > // Type of the target dense matrix
866 friend inline auto schurAssign( DenseMatrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
867 -> DisableIf_t< UseSymmetricKernel_v<MT,MT1> >
868 {
870
872
873 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
874 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
875
876 // Evaluation of the left-hand side sparse matrix operand
877 const OppositeType_t<RT1> A( serial( rhs.lhs_ ) );
878
879 // Evaluation of the right-hand side sparse matrix operand
880 CT2 B( serial( rhs.rhs_ ) );
881
882 BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
883 BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
884 BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
885 BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
886 BLAZE_INTERNAL_ASSERT( A.rows() == (*lhs).rows() , "Invalid number of rows" );
887 BLAZE_INTERNAL_ASSERT( A.columns() == (*lhs).columns() , "Invalid number of columns" );
888
889 schurAssign( *lhs, A % B );
890 }
892 //**********************************************************************************************
893
894 //**Restructuring Schur product assignment to row-major matrices********************************
907 template< typename MT > // Type of the target sparse matrix
908 friend inline auto schurAssign( Matrix<MT,false>& lhs, const SMatTSMatSchurExpr& rhs )
909 -> EnableIf_t< UseSymmetricKernel_v<MT,MT2> >
910 {
912
913 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
914 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
915
916 schurAssign( *lhs, rhs.lhs_ % trans( rhs.rhs_ ) );
917 }
919 //**********************************************************************************************
920
921 //**Restructuring Schur product assignment to column-major matrices*****************************
934 template< typename MT > // Type of the target sparse matrix
935 friend inline auto schurAssign( Matrix<MT,true>& lhs, const SMatTSMatSchurExpr& rhs )
936 -> EnableIf_t< UseSymmetricKernel_v<MT,MT1> >
937 {
939
941
942 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
943 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
944
945 schurAssign( *lhs, trans( rhs.lhs_ ) % rhs.rhs_ );
946 }
948 //**********************************************************************************************
949
950 //**Multiplication assignment to dense matrices*************************************************
951 // No special implementation for the multiplication assignment to dense matrices.
952 //**********************************************************************************************
953
954 //**Multiplication assignment to sparse matrices************************************************
955 // No special implementation for the multiplication assignment to sparse matrices.
956 //**********************************************************************************************
957
958 //**SMP assignment to dense matrices************************************************************
959 // No special implementation for the SMP assignment to dense matrices.
960 //**********************************************************************************************
961
962 //**SMP assignment to sparse matrices***********************************************************
963 // No special implementation for the SMP assignment to sparse matrices.
964 //**********************************************************************************************
965
966 //**SMP addition assignment to dense matrices***************************************************
967 // No special implementation for the SMP addition assignment to dense matrices.
968 //**********************************************************************************************
969
970 //**SMP addition assignment to sparse matrices**************************************************
971 // No special implementation for the SMP addition assignment to sparse matrices.
972 //**********************************************************************************************
973
974 //**SMP subtraction assignment to dense matrices************************************************
975 // No special implementation for the SMP subtraction assignment to dense matrices.
976 //**********************************************************************************************
977
978 //**SMP subtraction assignment to sparse matrices***********************************************
979 // No special implementation for the SMP subtraction assignment to sparse matrices.
980 //**********************************************************************************************
981
982 //**SMP Schur product assignment to dense matrices**********************************************
995 template< typename MT // Type of the target dense matrix
996 , bool SO > // Storage order of the target dense matrix
997 friend inline void smpSchurAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatSchurExpr& rhs )
998 {
1000
1001 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
1002 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
1003
1004 smpSchurAssign( *lhs, rhs.lhs_ );
1005 smpSchurAssign( *lhs, rhs.rhs_ );
1006 }
1008 //**********************************************************************************************
1009
1010 //**SMP Schur product assignment to sparse matrices*********************************************
1011 // No special implementation for the SMP Schur product assignment to sparse matrices.
1012 //**********************************************************************************************
1013
1014 //**SMP multiplication assignment to dense matrices*********************************************
1015 // No special implementation for the SMP multiplication assignment to dense matrices.
1016 //**********************************************************************************************
1017
1018 //**SMP multiplication assignment to sparse matrices********************************************
1019 // No special implementation for the SMP multiplication assignment to sparse matrices.
1020 //**********************************************************************************************
1021
1022 //**Compile time checks*************************************************************************
1032 //**********************************************************************************************
1033};
1034//*************************************************************************************************
1035
1036
1037
1038
1039//=================================================================================================
1040//
1041// GLOBAL BINARY ARITHMETIC OPERATORS
1042//
1043//=================================================================================================
1044
1045//*************************************************************************************************
1058template< typename MT1 // Type of the left-hand side sparse matrix
1059 , typename MT2 // Type of the right-hand side sparse matrix
1060 , DisableIf_t< ( IsUniLower_v<MT1> && IsUniUpper_v<MT2> ) ||
1061 ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) ||
1062 ( IsStrictlyLower_v<MT1> && IsUpper_v<MT2> ) ||
1063 ( IsStrictlyUpper_v<MT1> && IsLower_v<MT2> ) ||
1064 ( IsLower_v<MT1> && IsStrictlyUpper_v<MT2> ) ||
1065 ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) ||
1066 ( IsZero_v<MT1> || IsZero_v<MT2> ) >* = nullptr >
1067inline const SMatTSMatSchurExpr<MT1,MT2>
1068 smattsmatschur( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1069{
1071
1072 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1073 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1074
1075 return SMatTSMatSchurExpr<MT1,MT2>( *lhs, *rhs );
1076}
1078//*************************************************************************************************
1079
1080
1081//*************************************************************************************************
1095template< typename MT1 // Type of the left-hand side sparse matrix
1096 , typename MT2 // Type of the right-hand side sparse matrix
1097 , EnableIf_t< ( IsUniLower_v<MT1> && IsUniUpper_v<MT2> ) ||
1098 ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) >* = nullptr >
1099inline decltype(auto)
1100 smattsmatschur( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1101{
1103
1104 MAYBE_UNUSED( rhs );
1105
1106 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1107 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1108
1109 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1110
1113
1114 return ReturnType( (*lhs).rows() );
1115}
1117//*************************************************************************************************
1118
1119
1120//*************************************************************************************************
1134template< typename MT1 // Type of the left-hand side sparse matrix
1135 , typename MT2 // Type of the right-hand side sparse matrix
1136 , EnableIf_t< ( IsStrictlyLower_v<MT1> && IsUpper_v<MT2> ) ||
1137 ( IsStrictlyUpper_v<MT1> && IsLower_v<MT2> ) ||
1138 ( IsLower_v<MT1> && IsStrictlyUpper_v<MT2> ) ||
1139 ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) ||
1140 ( IsZero_v<MT1> || IsZero_v<MT2> ) >* = nullptr >
1141inline decltype(auto)
1142 smattsmatschur( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1143{
1145
1146 MAYBE_UNUSED( rhs );
1147
1148 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1149 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1150
1151 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1152
1155
1156 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1157}
1159//*************************************************************************************************
1160
1161
1162//*************************************************************************************************
1191template< typename MT1 // Type of the left-hand side sparse matrix
1192 , typename MT2 > // Type of the right-hand side sparse matrix
1193inline decltype(auto)
1194 operator%( const SparseMatrix<MT1,false>& lhs, const SparseMatrix<MT2,true>& rhs )
1195{
1197
1198 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1199 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1200 }
1201
1202 return smattsmatschur( *lhs, *rhs );
1203}
1204//*************************************************************************************************
1205
1206} // namespace blaze
1207
1208#endif
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Constraints on the storage order of matrix types.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Constraint on the data type.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsTemporary type trait class.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Constraints on the storage order of matrix types.
Header file for the Schur product trait.
Constraint on the data type.
Constraint on the data type.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Expression object for sparse matrix-transpose sparse matrix Schur product.
Definition: SMatTSMatSchurExpr.h:101
ReturnType_t< MT1 > RN1
Return type of the left-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:106
SMatTSMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatTSMatSchurExpr class.
Definition: SMatTSMatSchurExpr.h:175
RightOperand rhs_
Right-hand side sparse matrix of the Schur product expression.
Definition: SMatTSMatSchurExpr.h:305
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatTSMatSchurExpr.h:149
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTSMatSchurExpr.h:206
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:158
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:105
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatTSMatSchurExpr.h:253
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SMatTSMatSchurExpr.h:122
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatTSMatSchurExpr.h:222
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatTSMatSchurExpr.h:297
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:161
ReturnType_t< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:107
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatTSMatSchurExpr.h:155
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTSMatSchurExpr.h:191
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTSMatSchurExpr.h:147
LeftOperand lhs_
Left-hand side sparse matrix of the Schur product expression.
Definition: SMatTSMatSchurExpr.h:304
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatTSMatSchurExpr.h:148
ResultType_t< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:104
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatTSMatSchurExpr.h:263
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatTSMatSchurExpr.h:232
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SMatTSMatSchurExpr.h:146
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatTSMatSchurExpr.h:166
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatTSMatSchurExpr.h:152
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatTSMatSchurExpr.h:285
CompositeType_t< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:109
CompositeType_t< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatSchurExpr.h:108
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose sparse matrix operand.
Definition: SMatTSMatSchurExpr.h:273
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SMatTSMatSchurExpr.h:119
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatTSMatSchurExpr.h:242
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the SchurExpr base class.
Header file for the SparseMatrix base class.
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:1339
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_IDENTITY_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Identity.h:60
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_SCHUREXPR(T1, T2)
Constraint on the data type.
Definition: SchurExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:61
typename SchurTrait< T1, T2 >::Type SchurTrait_t
Auxiliary alias declaration for the SchurTrait class template.
Definition: SchurTrait.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Header file for all forward declarations for sparse vectors and matrices.
Header file for the StorageOrder type trait.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all Schur product expression templates.
Definition: SchurExpr.h:68
Header file for the IsZero type trait.
Header file for basic type definitions.
Header file for the generic min algorithm.