Blaze 3.9
Loading...
Searching...
No Matches
DMatTDMatSchurExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATSCHUREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATTDMATSCHUREXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/Aliases.h>
76#include <blaze/util/Assert.h>
77#include <blaze/util/EnableIf.h>
81#include <blaze/util/mpl/If.h>
82#include <blaze/util/Types.h>
83
84
85namespace blaze {
86
87//=================================================================================================
88//
89// CLASS DMATTDMATSCHUREXPR
90//
91//=================================================================================================
92
93//*************************************************************************************************
100template< typename MT1 // Type of the left-hand side dense matrix
101 , typename MT2 > // Type of the right-hand side dense matrix
103 : public SchurExpr< DenseMatrix< DMatTDMatSchurExpr<MT1,MT2>, false > >
104 , private Computation
105{
106 private:
107 //**Type definitions****************************************************************************
114 //**********************************************************************************************
115
116 //**Return type evaluation**********************************************************************
118
123 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
124
126 using ExprReturnType = decltype( std::declval<RN1>() * std::declval<RN2>() );
127 //**********************************************************************************************
128
129 //**Serial evaluation strategy******************************************************************
131
137 static constexpr bool useAssign =
139
142 template< typename MT >
143 static constexpr bool UseAssign_v = useAssign;
145 //**********************************************************************************************
146
147 //**Parallel evaluation strategy****************************************************************
150
155 template< typename MT >
156 static constexpr bool UseSMPAssign_v =
157 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign );
159 //**********************************************************************************************
160
161 public:
162 //**Type definitions****************************************************************************
165
168
173
176
179
181 using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
182
184 using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
185 //**********************************************************************************************
186
187 //**Compilation flags***************************************************************************
189 static constexpr bool simdEnabled = false;
190
192 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
193 //**********************************************************************************************
194
195 //**Constructor*********************************************************************************
201 inline DMatTDMatSchurExpr( const MT1& lhs, const MT2& rhs ) noexcept
202 : lhs_( lhs ) // Left-hand side dense matrix of the Schur product expression
203 , rhs_( rhs ) // Right-hand side dense matrix of the Schur product expression
204 {
205 BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
206 BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
207 }
208 //**********************************************************************************************
209
210 //**Access operator*****************************************************************************
217 inline ReturnType operator()( size_t i, size_t j ) const {
218 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
219 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
220 return lhs_(i,j) * rhs_(i,j);
221 }
222 //**********************************************************************************************
223
224 //**At function*********************************************************************************
232 inline ReturnType at( size_t i, size_t j ) const {
233 if( i >= lhs_.rows() ) {
234 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
235 }
236 if( j >= lhs_.columns() ) {
237 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
238 }
239 return (*this)(i,j);
240 }
241 //**********************************************************************************************
242
243 //**Rows function*******************************************************************************
248 inline size_t rows() const noexcept {
249 return lhs_.rows();
250 }
251 //**********************************************************************************************
252
253 //**Columns function****************************************************************************
258 inline size_t columns() const noexcept {
259 return lhs_.columns();
260 }
261 //**********************************************************************************************
262
263 //**Left operand access*************************************************************************
268 inline LeftOperand leftOperand() const noexcept {
269 return lhs_;
270 }
271 //**********************************************************************************************
272
273 //**Right operand access************************************************************************
278 inline RightOperand rightOperand() const noexcept {
279 return rhs_;
280 }
281 //**********************************************************************************************
282
283 //**********************************************************************************************
289 template< typename T >
290 inline bool canAlias( const T* alias ) const noexcept {
291 return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
292 ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
293 }
294 //**********************************************************************************************
295
296 //**********************************************************************************************
302 template< typename T >
303 inline bool isAliased( const T* alias ) const noexcept {
304 return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
305 }
306 //**********************************************************************************************
307
308 //**********************************************************************************************
313 inline bool isAligned() const noexcept {
314 return lhs_.isAligned() && rhs_.isAligned();
315 }
316 //**********************************************************************************************
317
318 //**********************************************************************************************
323 inline bool canSMPAssign() const noexcept {
324 return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
325 ( rows() * columns() >= SMP_DMATTDMATSCHUR_THRESHOLD );
326 }
327 //**********************************************************************************************
328
329 private:
330 //**Member variables****************************************************************************
333 //**********************************************************************************************
334
335 //**Assignment to dense matrices****************************************************************
349 template< typename MT // Type of the target dense matrix
350 , bool SO > // Storage order of the target dense matrix
351 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
353 {
355
356 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
357 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
358
359 constexpr size_t block( BLOCK_SIZE );
360
361 const size_t m( rhs.rows() );
362 const size_t n( rhs.columns() );
363
364 for( size_t ii=0UL; ii<m; ii+=block ) {
365 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
366 for( size_t jj=0UL; jj<n; jj+=block ) {
367 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
368 for( size_t i=ii; i<iend; ++i ) {
369 for( size_t j=jj; j<jend; ++j ) {
370 (*lhs)(i,j) = rhs.lhs_(i,j) * rhs.rhs_(i,j);
371 }
372 }
373 }
374 }
375 }
377 //**********************************************************************************************
378
379 //**Assignment to dense matrices****************************************************************
394 template< typename MT // Type of the target dense matrix
395 , bool SO > // Storage order of the target dense matrix
396 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
398 {
400
401 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
402 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
403
404 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
405 schurAssign( *lhs, rhs.rhs_ );
406 }
407 else {
408 CT1 A( serial( rhs.lhs_ ) );
409 CT2 B( serial( rhs.rhs_ ) );
410 assign( *lhs, A % B );
411 }
412 }
414 //**********************************************************************************************
415
416 //**Assignment to dense matrices****************************************************************
431 template< typename MT // Type of the target dense matrix
432 , bool SO > // Storage order of the target dense matrix
433 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
435 {
437
438 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
439 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
440
441 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
442 schurAssign( *lhs, rhs.rhs_ );
443 }
444 else if( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) {
445 schurAssign( *lhs, rhs.lhs_ );
446 }
447 else if( !RequiresEvaluation_v<MT2> ) {
448 assign ( *lhs, rhs.rhs_ );
449 schurAssign( *lhs, rhs.lhs_ );
450 }
451 else {
452 assign ( *lhs, rhs.lhs_ );
453 schurAssign( *lhs, rhs.rhs_ );
454 }
455 }
457 //**********************************************************************************************
458
459 //**Assignment to sparse matrices***************************************************************
471 template< typename MT // Type of the target sparse matrix
472 , bool SO > // Storage order of the target sparse matrix
473 friend inline void assign( SparseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
474 {
476
478
485
486 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
487 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
488
489 const TmpType tmp( serial( rhs ) );
490 assign( *lhs, tmp );
491 }
493 //**********************************************************************************************
494
495 //**Addition assignment to dense matrices*******************************************************
510 template< typename MT // Type of the target dense matrix
511 , bool SO > // Storage order of the target dense matrix
512 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
514 {
516
517 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
518 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
519
520 constexpr size_t block( BLOCK_SIZE );
521
522 const size_t m( rhs.rows() );
523 const size_t n( rhs.columns() );
524
525 for( size_t ii=0UL; ii<m; ii+=block ) {
526 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
527 for( size_t jj=0UL; jj<n; jj+=block ) {
528 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
529 for( size_t i=ii; i<iend; ++i ) {
530 for( size_t j=jj; j<jend; ++j ) {
531 (*lhs)(i,j) += rhs.lhs_(i,j) * rhs.rhs_(i,j);
532 }
533 }
534 }
535 }
536 }
538 //**********************************************************************************************
539
540 //**Addition assignment to dense matrices*******************************************************
555 template< typename MT // Type of the target dense matrix
556 , bool SO > // Storage order of the target dense matrix
557 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
559 {
561
565
566 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
567 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
568
569 const ResultType tmp( serial( rhs ) );
570 addAssign( *lhs, tmp );
571 }
573 //**********************************************************************************************
574
575 //**Addition assignment to sparse matrices******************************************************
576 // No special implementation for the addition assignment to sparse matrices.
577 //**********************************************************************************************
578
579 //**Subtraction assignment to dense matrices****************************************************
594 template< typename MT // Type of the target dense matrix
595 , bool SO > // Storage order of the target dense matrix
596 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
598 {
600
601 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
602 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
603
604 constexpr size_t block( BLOCK_SIZE );
605
606 const size_t m( rhs.rows() );
607 const size_t n( rhs.columns() );
608
609 for( size_t ii=0UL; ii<m; ii+=block ) {
610 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
611 for( size_t jj=0UL; jj<n; jj+=block ) {
612 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
613 for( size_t i=ii; i<iend; ++i ) {
614 for( size_t j=jj; j<jend; ++j ) {
615 (*lhs)(i,j) -= rhs.lhs_(i,j) * rhs.rhs_(i,j);
616 }
617 }
618 }
619 }
620 }
622 //**********************************************************************************************
623
624 //**Subtraction assignment to dense matrices****************************************************
639 template< typename MT // Type of the target dense matrix
640 , bool SO > // Storage order of the target dense matrix
641 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
643 {
645
649
650 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
651 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
652
653 const ResultType tmp( serial( rhs ) );
654 subAssign( *lhs, tmp );
655 }
657 //**********************************************************************************************
658
659 //**Subtraction assignment to sparse matrices***************************************************
660 // No special implementation for the subtraction assignment to sparse matrices.
661 //**********************************************************************************************
662
663 //**Schur product assignment to dense matrices**************************************************
678 template< typename MT // Type of the target dense matrix
679 , bool SO > // Storage order of the target dense matrix
680 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
682 {
684
685 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
686 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
687
688 constexpr size_t block( BLOCK_SIZE );
689
690 const size_t m( rhs.rows() );
691 const size_t n( rhs.columns() );
692
693 for( size_t ii=0UL; ii<m; ii+=block ) {
694 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
695 for( size_t jj=0UL; jj<n; jj+=block ) {
696 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
697 for( size_t i=ii; i<iend; ++i ) {
698 for( size_t j=jj; j<jend; ++j ) {
699 (*lhs)(i,j) *= rhs.lhs_(i,j) * rhs.rhs_(i,j);
700 }
701 }
702 }
703 }
704 }
706 //**********************************************************************************************
707
708 //**Schur product assignment to dense matrices**************************************************
724 template< typename MT // Type of the target dense matrix
725 , bool SO > // Storage order of the target dense matrix
726 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
728 {
730
734
735 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
736 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
737
738 const ResultType tmp( serial( rhs ) );
739 schurAssign( *lhs, tmp );
740 }
742 //**********************************************************************************************
743
744 //**Schur product assignment to dense matrices**************************************************
760 template< typename MT // Type of the target dense matrix
761 , bool SO > // Storage order of the target dense matrix
762 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
764 {
766
767 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
768 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
769
771 schurAssign( *lhs, rhs.rhs_ );
772 schurAssign( *lhs, rhs.lhs_ );
773 }
774 else {
775 schurAssign( *lhs, rhs.lhs_ );
776 schurAssign( *lhs, rhs.rhs_ );
777 }
778 }
780 //**********************************************************************************************
781
782 //**Schur product assignment to sparse matrices*************************************************
783 // No special implementation for the Schur product assignment to sparse matrices.
784 //**********************************************************************************************
785
786 //**Multiplication assignment to dense matrices*************************************************
787 // No special implementation for the multiplication assignment to dense matrices.
788 //**********************************************************************************************
789
790 //**Multiplication assignment to sparse matrices************************************************
791 // No special implementation for the multiplication assignment to sparse matrices.
792 //**********************************************************************************************
793
794 //**SMP assignment to dense matrices************************************************************
809 template< typename MT // Type of the target dense matrix
810 , bool SO > // Storage order of the target dense matrix
811 friend inline auto smpAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
813 {
815
816 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
817 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
818
819 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
820 smpSchurAssign( *lhs, rhs.rhs_ );
821 }
822 else {
823 CT1 A( rhs.lhs_ );
824 CT2 B( rhs.rhs_ );
825 smpAssign( *lhs, A % B );
826 }
827 }
829 //**********************************************************************************************
830
831 //**SMP assignment to dense matrices************************************************************
846 template< typename MT // Type of the target dense matrix
847 , bool SO > // Storage order of the target dense matrix
848 friend inline auto smpAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
850 {
852
853 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
854 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
855
856 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
857 smpSchurAssign( *lhs, rhs.rhs_ );
858 }
859 else if( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) {
860 smpSchurAssign( *lhs, rhs.lhs_ );
861 }
862 else if( !RequiresEvaluation_v<MT2> ) {
863 smpAssign ( *lhs, rhs.rhs_ );
864 smpSchurAssign( *lhs, rhs.lhs_ );
865 }
866 else {
867 smpAssign ( *lhs, rhs.lhs_ );
868 smpSchurAssign( *lhs, rhs.rhs_ );
869 }
870 }
872 //**********************************************************************************************
873
874 //**SMP assignment to sparse matrices***********************************************************
889 template< typename MT // Type of the target sparse matrix
890 , bool SO > // Storage order of the target sparse matrix
891 friend inline auto smpAssign( SparseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
893 {
895
897
904
905 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
906 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
907
908 const TmpType tmp( rhs );
909 smpAssign( *lhs, tmp );
910 }
912 //**********************************************************************************************
913
914 //**SMP addition assignment to dense matrices***************************************************
929 template< typename MT // Type of the target dense matrix
930 , bool SO > // Storage order of the target dense matrix
931 friend inline auto smpAddAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
933 {
935
939
940 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
941 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
942
943 const ResultType tmp( rhs );
944 smpAddAssign( *lhs, tmp );
945 }
947 //**********************************************************************************************
948
949 //**SMP addition assignment to sparse matrices**************************************************
950 // No special implementation for the SMP addition assignment to sparse matrices.
951 //**********************************************************************************************
952
953 //**SMP subtraction assignment to dense matrices************************************************
968 template< typename MT // Type of the target dense matrix
969 , bool SO > // Storage order of the target dense matrix
970 friend inline auto smpSubAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
972 {
974
978
979 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
980 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
981
982 const ResultType tmp( rhs );
983 smpSubAssign( *lhs, tmp );
984 }
986 //**********************************************************************************************
987
988 //**SMP subtraction assignment to sparse matrices***********************************************
989 // No special implementation for the SMP subtraction assignment to sparse matrices.
990 //**********************************************************************************************
991
992 //**SMP Schur product assignment to dense matrices**********************************************
1008 template< typename MT // Type of the target dense matrix
1009 , bool SO > // Storage order of the target dense matrix
1010 friend inline auto smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
1012 {
1014
1018
1019 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
1020 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
1021
1022 const ResultType tmp( rhs );
1023 smpSchurAssign( *lhs, tmp );
1024 }
1026 //**********************************************************************************************
1027
1028 //**SMP Schur product assignment to dense matrices**********************************************
1044 template< typename MT // Type of the target dense matrix
1045 , bool SO > // Storage order of the target dense matrix
1046 friend inline auto smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSchurExpr& rhs )
1048 {
1050
1051 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
1052 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
1053
1055 smpSchurAssign( *lhs, rhs.rhs_ );
1056 smpSchurAssign( *lhs, rhs.lhs_ );
1057 }
1058 else {
1059 smpSchurAssign( *lhs, rhs.lhs_ );
1060 smpSchurAssign( *lhs, rhs.rhs_ );
1061 }
1062 }
1064 //**********************************************************************************************
1065
1066 //**SMP Schur product assignment to sparse matrices*********************************************
1067 // No special implementation for the SMP Schur product assignment to sparse matrices.
1068 //**********************************************************************************************
1069
1070 //**SMP multiplication assignment to dense matrices*********************************************
1071 // No special implementation for the SMP multiplication assignment to dense matrices.
1072 //**********************************************************************************************
1073
1074 //**SMP multiplication assignment to sparse matrices********************************************
1075 // No special implementation for the SMP multiplication assignment to sparse matrices.
1076 //**********************************************************************************************
1077
1078 //**Compile time checks*************************************************************************
1085 //**********************************************************************************************
1086};
1087//*************************************************************************************************
1088
1089
1090
1091
1092//=================================================================================================
1093//
1094// GLOBAL BINARY ARITHMETIC OPERATORS
1095//
1096//=================================================================================================
1097
1098//*************************************************************************************************
1111template< typename MT1 // Type of the left-hand side dense matrix
1112 , typename MT2 // Type of the right-hand side dense matrix
1120 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1121inline const DMatTDMatSchurExpr<MT1,MT2>
1122 dmattdmatschur( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1123{
1125
1126 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1127 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1128
1129 return DMatTDMatSchurExpr<MT1,MT2>( *lhs, *rhs );
1130}
1132//*************************************************************************************************
1133
1134
1135//*************************************************************************************************
1148template< typename MT1 // Type of the left-hand side dense matrix
1149 , typename MT2 // Type of the right-hand side dense matrix
1157 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1158inline decltype(auto)
1159 dmattdmatschur( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1160{
1162
1163 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1164 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1165
1166 return trans( *lhs ) % *rhs;
1167}
1169//*************************************************************************************************
1170
1171
1172//*************************************************************************************************
1185template< typename MT1 // Type of the left-hand side dense matrix
1186 , typename MT2 // Type of the right-hand side dense matrix
1193 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1194inline decltype(auto)
1195 dmattdmatschur( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1196{
1198
1199 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1200 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1201
1202 return (*lhs) % trans( *rhs );
1203}
1205//*************************************************************************************************
1206
1207
1208//*************************************************************************************************
1222template< typename MT1 // Type of the left-hand side dense matrix
1223 , typename MT2 // Type of the right-hand side dense matrix
1225 ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) >* = nullptr >
1226inline decltype(auto)
1227 dmattdmatschur( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1228{
1230
1231 MAYBE_UNUSED( rhs );
1232
1233 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1234 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1235
1236 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1237
1240
1241 return ReturnType( (*lhs).rows() );
1242}
1244//*************************************************************************************************
1245
1246
1247//*************************************************************************************************
1261template< typename MT1 // Type of the left-hand side dense matrix
1262 , typename MT2 // Type of the right-hand side dense matrix
1266 ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1267inline decltype(auto)
1268 dmattdmatschur( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1269{
1271
1272 MAYBE_UNUSED( rhs );
1273
1274 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1275 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1276
1277 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1278
1281
1282 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1283}
1285//*************************************************************************************************
1286
1287
1288//*************************************************************************************************
1317template< typename MT1 // Type of the left-hand side dense matrix
1318 , typename MT2 > // Type of the right-hand side dense matrix
1319inline decltype(auto)
1320 operator%( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1321{
1323
1324 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1325 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1326 }
1327
1328 return dmattdmatschur( *lhs, *rhs );
1329}
1330//*************************************************************************************************
1331
1332
1333//*************************************************************************************************
1346template< typename MT1 // Type of the left-hand side dense matrix
1347 , typename MT2 // Type of the right-hand side dense matrix
1355 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1356inline const DMatTDMatSchurExpr<MT1,MT2>
1357 tdmatdmatschur( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1358{
1360
1361 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1362 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1363
1364 return DMatTDMatSchurExpr<MT1,MT2>( *lhs, *rhs );
1365}
1367//*************************************************************************************************
1368
1369
1370//*************************************************************************************************
1383template< typename MT1 // Type of the left-hand side dense matrix
1384 , typename MT2 // Type of the right-hand side dense matrix
1392 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1393inline decltype(auto)
1394 tdmatdmatschur( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1395{
1397
1398 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1399 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1400
1401 return (*lhs) % trans( *rhs );
1402}
1404//*************************************************************************************************
1405
1406
1407//*************************************************************************************************
1420template< typename MT1 // Type of the left-hand side dense matrix
1421 , typename MT2 // Type of the right-hand side dense matrix
1428 !( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1429inline decltype(auto)
1430 tdmatdmatschur( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1431{
1433
1434 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1435 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1436
1437 return trans( *lhs ) % (*rhs);
1438}
1440//*************************************************************************************************
1441
1442
1443//*************************************************************************************************
1457template< typename MT1 // Type of the left-hand side dense matrix
1458 , typename MT2 // Type of the right-hand side dense matrix
1460 ( IsUniUpper_v<MT1> && IsUniLower_v<MT2> ) >* = nullptr >
1461inline decltype(auto)
1462 tdmatdmatschur( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1463{
1465
1466 MAYBE_UNUSED( rhs );
1467
1468 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1469 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1470
1471 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1472
1475
1476 return ReturnType( (*lhs).rows() );
1477}
1479//*************************************************************************************************
1480
1481
1482//*************************************************************************************************
1496template< typename MT1 // Type of the left-hand side dense matrix
1497 , typename MT2 // Type of the right-hand side dense matrix
1501 ( IsUpper_v<MT1> && IsStrictlyLower_v<MT2> ) >* = nullptr >
1502inline decltype(auto)
1503 tdmatdmatschur( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1504{
1506
1507 MAYBE_UNUSED( rhs );
1508
1509 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1510 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1511
1512 using ReturnType = const SchurTrait_t< ResultType_t<MT1>, ResultType_t<MT2> >;
1513
1516
1517 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1518}
1520//*************************************************************************************************
1521
1522
1523//*************************************************************************************************
1552template< typename MT1 // Type of the left-hand side dense matrix
1553 , typename MT2 > // Type of the right-hand side dense matrix
1554inline decltype(auto)
1555 operator%( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1556{
1558
1559 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1560 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1561 }
1562
1563 return tdmatdmatschur( *lhs, *rhs );
1564}
1565//*************************************************************************************************
1566
1567
1568
1569
1570//=================================================================================================
1571//
1572// ISALIGNED SPECIALIZATIONS
1573//
1574//=================================================================================================
1575
1576//*************************************************************************************************
1578template< typename MT1, typename MT2 >
1579struct IsAligned< DMatTDMatSchurExpr<MT1,MT2> >
1580 : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1581{};
1583//*************************************************************************************************
1584
1585} // namespace blaze
1586
1587#endif
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition Aliases.h:470
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition Aliases.h:310
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for run time assertion macros.
Header file for kernel specific block sizes.
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 IsAligned type trait.
Header file for the IsCommutative type trait.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsOperation type trait class.
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.
Expression object for dense matrix-transpose dense matrix Schur product.
Definition DMatTDMatSchurExpr.h:105
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition DMatTDMatSchurExpr.h:323
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition DMatTDMatSchurExpr.h:217
DMatTDMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatTDMatSchurExpr class.
Definition DMatTDMatSchurExpr.h:201
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition DMatTDMatSchurExpr.h:313
DMatTDMatSchurExpr< MT1, MT2 > This
Type of this DMatTDMatSchurExpr instance.
Definition DMatTDMatSchurExpr.h:164
const ResultType CompositeType
Data type for composite expression templates.
Definition DMatTDMatSchurExpr.h:178
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:110
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:113
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition DMatTDMatSchurExpr.h:258
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition DMatTDMatSchurExpr.h:278
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition DMatTDMatSchurExpr.h:268
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition DMatTDMatSchurExpr.h:123
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition DMatTDMatSchurExpr.h:126
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the Schur product expression.
Definition DMatTDMatSchurExpr.h:137
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition DMatTDMatSchurExpr.h:232
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:112
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:108
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:169
LeftOperand lhs_
Left-hand side dense matrix of the Schur product expression.
Definition DMatTDMatSchurExpr.h:331
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition DMatTDMatSchurExpr.h:192
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:175
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:109
SchurExpr< DenseMatrix< This, false > > BaseType
Base type of this DMatTDMatSchurExpr instance.
Definition DMatTDMatSchurExpr.h:167
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:184
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition DMatTDMatSchurExpr.h:248
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:171
RightOperand rhs_
Right-hand side dense matrix of the Schur product expression.
Definition DMatTDMatSchurExpr.h:332
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:181
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:111
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition DMatTDMatSchurExpr.h:170
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition DMatTDMatSchurExpr.h:290
ElementType_t< ResultType > ElementType
Resulting element type.
Definition DMatTDMatSchurExpr.h:172
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition DMatTDMatSchurExpr.h:303
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition DMatTDMatSchurExpr.h:189
Base class for dense matrices.
Definition DenseMatrix.h:82
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseMatrix base class.
Header file for the SchurExpr base class.
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_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition StorageOrder.h:84
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_DIFFERENT_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition StorageOrder.h:106
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition DenseMatrix.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
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition StorageOrder.h:63
typename SchurTrait< T1, T2 >::Type SchurTrait_t
Auxiliary alias declaration for the SchurTrait class template.
Definition SchurTrait.h:137
constexpr bool RequiresEvaluation_v
Auxiliary variable template for the RequiresEvaluation type trait.
Definition RequiresEvaluation.h:91
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.
Definition IsStrictlyUpper.h:173
constexpr bool IsSymmetric_v
Auxiliary variable template for the IsSymmetric type trait.
Definition IsSymmetric.h:172
constexpr bool IsExpression_v
Auxiliary variable template for the IsExpression type trait.
Definition IsExpression.h:114
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.
Definition IsUniUpper.h:173
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.
Definition IsStrictlyLower.h:173
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.
Definition IsUpper.h:175
constexpr bool IsCommutative_v
Auxiliary variable template for the IsCommutative type trait.
Definition IsCommutative.h:117
constexpr bool IsOperation_v
Auxiliary variable template for the IsOperation type trait.
Definition IsOperation.h:89
constexpr bool IsTemporary_v
Auxiliary variable template for the IsTemporary type trait.
Definition IsTemporary.h:88
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.
Definition IsLower.h:175
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.
Definition IsUniLower.h:173
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition Matrix.h:1424
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition DenseMatrix.h:162
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:100
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
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:131
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#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
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition FunctionTrace.h:94
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition IntegralConstant.h:110
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
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 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 thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.