Blaze 3.9
DMatTDMatSubExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATSUBEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATTDMATSUBEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/Aliases.h>
66#include <blaze/util/Assert.h>
67#include <blaze/util/EnableIf.h>
70#include <blaze/util/mpl/If.h>
71#include <blaze/util/Types.h>
72
73
74namespace blaze {
75
76//=================================================================================================
77//
78// CLASS DMATTDMATSUBEXPR
79//
80//=================================================================================================
81
82//*************************************************************************************************
89template< typename MT1 // Type of the left-hand side dense matrix
90 , typename MT2 > // Type of the right-hand side dense matrix
92 : public MatMatSubExpr< DenseMatrix< DMatTDMatSubExpr<MT1,MT2>, false > >
93 , private Computation
94{
95 private:
96 //**Type definitions****************************************************************************
103 //**********************************************************************************************
104
105 //**Return type evaluation**********************************************************************
107
112 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
113
115 using ExprReturnType = decltype( std::declval<RN1>() - std::declval<RN2>() );
116 //**********************************************************************************************
117
118 //**Serial evaluation strategy******************************************************************
120
126 static constexpr bool useAssign =
127 ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> || !returnExpr );
128
131 template< typename MT >
132 static constexpr bool UseAssign_v = useAssign;
134 //**********************************************************************************************
135
136 //**Parallel evaluation strategy****************************************************************
138
144 template< typename MT >
145 static constexpr bool UseSMPAssign_v =
146 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign );
148 //**********************************************************************************************
149
150 public:
151 //**Type definitions****************************************************************************
154
157
162
165
168
170 using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
171
173 using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
174 //**********************************************************************************************
175
176 //**Compilation flags***************************************************************************
178 static constexpr bool simdEnabled = false;
179
181 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
182 //**********************************************************************************************
183
184 //**Constructor*********************************************************************************
190 inline DMatTDMatSubExpr( const MT1& lhs, const MT2& rhs ) noexcept
191 : lhs_( lhs ) // Left-hand side dense matrix of the subtraction expression
192 , rhs_( rhs ) // Right-hand side dense matrix of the subtraction expression
193 {
194 BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
195 BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
196 }
197 //**********************************************************************************************
198
199 //**Access operator*****************************************************************************
206 inline ReturnType operator()( size_t i, size_t j ) const {
207 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
208 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
209 return lhs_(i,j) - rhs_(i,j);
210 }
211 //**********************************************************************************************
212
213 //**At function*********************************************************************************
221 inline ReturnType at( size_t i, size_t j ) const {
222 if( i >= lhs_.rows() ) {
223 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
224 }
225 if( j >= lhs_.columns() ) {
226 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
227 }
228 return (*this)(i,j);
229 }
230 //**********************************************************************************************
231
232 //**Rows function*******************************************************************************
237 inline size_t rows() const noexcept {
238 return lhs_.rows();
239 }
240 //**********************************************************************************************
241
242 //**Columns function****************************************************************************
247 inline size_t columns() const noexcept {
248 return lhs_.columns();
249 }
250 //**********************************************************************************************
251
252 //**Left operand access*************************************************************************
257 inline LeftOperand leftOperand() const noexcept {
258 return lhs_;
259 }
260 //**********************************************************************************************
261
262 //**Right operand access************************************************************************
267 inline RightOperand rightOperand() const noexcept {
268 return rhs_;
269 }
270 //**********************************************************************************************
271
272 //**********************************************************************************************
278 template< typename T >
279 inline bool canAlias( const T* alias ) const noexcept {
280 return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
281 ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
282 }
283 //**********************************************************************************************
284
285 //**********************************************************************************************
291 template< typename T >
292 inline bool isAliased( const T* alias ) const noexcept {
293 return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
294 }
295 //**********************************************************************************************
296
297 //**********************************************************************************************
302 inline bool isAligned() const noexcept {
303 return lhs_.isAligned() && rhs_.isAligned();
304 }
305 //**********************************************************************************************
306
307 //**********************************************************************************************
312 inline bool canSMPAssign() const noexcept {
313 return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
314 ( rows() * columns() >= SMP_DMATTDMATSUB_THRESHOLD );
315 }
316 //**********************************************************************************************
317
318 private:
319 //**Member variables****************************************************************************
322 //**********************************************************************************************
323
324 //**Assignment to dense matrices****************************************************************
338 template< typename MT // Type of the target dense matrix
339 , bool SO > // Storage order of the target dense matrix
340 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
342 {
344
345 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
346 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
347
348 constexpr size_t block( BLOCK_SIZE );
349
350 const size_t m( rhs.rows() );
351 const size_t n( rhs.columns() );
352
353 for( size_t ii=0UL; ii<m; ii+=block ) {
354 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
355 for( size_t jj=0UL; jj<n; jj+=block ) {
356 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
357 for( size_t i=ii; i<iend; ++i ) {
358 for( size_t j=jj; j<jend; ++j ) {
359 (*lhs)(i,j) = rhs.lhs_(i,j) - rhs.rhs_(i,j);
360 }
361 }
362 }
363 }
364 }
366 //**********************************************************************************************
367
368 //**Assignment to dense matrices****************************************************************
382 template< typename MT // Type of the target dense matrix
383 , bool SO > // Storage order of the target dense matrix
384 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
386 {
388
389 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
390 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
391
392 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
393 subAssign( *lhs, rhs.rhs_ );
394 }
395 else if( ( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) ||
396 ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(*lhs) ) ) ) {
397 assign ( *lhs, -rhs.rhs_ );
398 addAssign( *lhs, rhs.lhs_ );
399 }
400 else {
401 assign ( *lhs, rhs.lhs_ );
402 subAssign( *lhs, rhs.rhs_ );
403 }
404 }
406 //**********************************************************************************************
407
408 //**Assignment to sparse matrices***************************************************************
420 template< typename MT // Type of the target sparse matrix
421 , bool SO > // Storage order of the target sparse matrix
422 friend inline void assign( SparseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
423 {
425
426 using TmpType = If_t< SO, OppositeType, ResultType >;
427
434
435 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
436 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
437
438 const TmpType tmp( serial( rhs ) );
439 assign( *lhs, tmp );
440 }
442 //**********************************************************************************************
443
444 //**Addition assignment to dense matrices*******************************************************
459 template< typename MT // Type of the target dense matrix
460 , bool SO > // Storage order of the target dense matrix
461 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
462 -> DisableIf_t< UseAssign_v<MT> >
463 {
465
466 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
467 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
468
469 constexpr size_t block( BLOCK_SIZE );
470
471 const size_t m( rhs.rows() );
472 const size_t n( rhs.columns() );
473
474 for( size_t ii=0UL; ii<m; ii+=block ) {
475 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
476 for( size_t jj=0UL; jj<n; jj+=block ) {
477 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
478 for( size_t i=ii; i<iend; ++i ) {
479 for( size_t j=jj; j<jend; ++j ) {
480 (*lhs)(i,j) += rhs.lhs_(i,j) - rhs.rhs_(i,j);
481 }
482 }
483 }
484 }
485 }
487 //**********************************************************************************************
488
489 //**Addition assignment to dense matrices*******************************************************
504 template< typename MT // Type of the target dense matrix
505 , bool SO > // Storage order of the target dense matrix
506 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
507 -> EnableIf_t< UseAssign_v<MT> >
508 {
510
511 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
512 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
513
514 if( !RequiresEvaluation_v<MT2> ) {
515 subAssign( *lhs, rhs.rhs_ );
516 addAssign( *lhs, rhs.lhs_ );
517 }
518 else {
519 addAssign( *lhs, rhs.lhs_ );
520 subAssign( *lhs, rhs.rhs_ );
521 }
522 }
524 //**********************************************************************************************
525
526 //**Addition assignment to sparse matrices******************************************************
527 // No special implementation for the addition assignment to sparse matrices.
528 //**********************************************************************************************
529
530 //**Subtraction assignment to dense matrices****************************************************
545 template< typename MT // Type of the target dense matrix
546 , bool SO > // Storage order of the target dense matrix
547 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
548 -> DisableIf_t< UseAssign_v<MT> >
549 {
551
552 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
553 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
554
555 constexpr size_t block( BLOCK_SIZE );
556
557 const size_t m( rhs.rows() );
558 const size_t n( rhs.columns() );
559
560 for( size_t ii=0UL; ii<m; ii+=block ) {
561 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
562 for( size_t jj=0UL; jj<n; jj+=block ) {
563 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
564 for( size_t i=ii; i<iend; ++i ) {
565 for( size_t j=jj; j<jend; ++j ) {
566 (*lhs)(i,j) -= rhs.lhs_(i,j) - rhs.rhs_(i,j);
567 }
568 }
569 }
570 }
571 }
573 //**********************************************************************************************
574
575 //**Subtraction assignment to dense matrices****************************************************
590 template< typename MT // Type of the target dense matrix
591 , bool SO > // Storage order of the target dense matrix
592 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
593 -> EnableIf_t< UseAssign_v<MT> >
594 {
596
597 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
598 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
599
600 if( !RequiresEvaluation_v<MT2> ) {
601 addAssign( *lhs, rhs.rhs_ );
602 subAssign( *lhs, rhs.lhs_ );
603 }
604 else {
605 subAssign( *lhs, rhs.lhs_ );
606 addAssign( *lhs, rhs.rhs_ );
607 }
608 }
610 //**********************************************************************************************
611
612 //**Subtraction assignment to sparse matrices***************************************************
613 // No special implementation for the subtraction assignment to sparse matrices.
614 //**********************************************************************************************
615
616 //**Schur product assignment to dense matrices**************************************************
631 template< typename MT // Type of the target dense matrix
632 , bool SO > // Storage order of the target dense matrix
633 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
634 -> EnableIf_t< UseAssign_v<MT> >
635 {
637
641
642 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
643 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
644
645 const ResultType tmp( serial( rhs ) );
646 schurAssign( *lhs, tmp );
647 }
649 //**********************************************************************************************
650
651 //**Schur product assignment to sparse matrices*************************************************
652 // No special implementation for the Schur product assignment to sparse matrices.
653 //**********************************************************************************************
654
655 //**Multiplication assignment to dense matrices*************************************************
656 // No special implementation for the multiplication assignment to dense matrices.
657 //**********************************************************************************************
658
659 //**Multiplication assignment to sparse matrices************************************************
660 // No special implementation for the multiplication assignment to sparse matrices.
661 //**********************************************************************************************
662
663 //**SMP assignment to dense matrices************************************************************
677 template< typename MT // Type of the target dense matrix
678 , bool SO > // Storage order of the target dense matrix
679 friend inline auto smpAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
680 -> EnableIf_t< UseSMPAssign_v<MT> >
681 {
683
684 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
685 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
686
687 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
688 smpSubAssign( *lhs, rhs.rhs_ );
689 }
690 else if( ( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) ||
691 ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(*lhs) ) ) ) {
692 smpAssign ( *lhs, -rhs.rhs_ );
693 smpAddAssign( *lhs, rhs.lhs_ );
694 }
695 else {
696 smpAssign ( *lhs, rhs.lhs_ );
697 smpSubAssign( *lhs, rhs.rhs_ );
698 }
699 }
701 //**********************************************************************************************
702
703 //**SMP assignment to sparse matrices***********************************************************
717 template< typename MT // Type of the target sparse matrix
718 , bool SO > // Storage order of the target sparse matrix
719 friend inline auto smpAssign( SparseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
720 -> EnableIf_t< UseSMPAssign_v<MT> >
721 {
723
724 using TmpType = If_t< SO, OppositeType, ResultType >;
725
732
733 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
734 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
735
736 const TmpType tmp( rhs );
737 smpAssign( *lhs, tmp );
738 }
740 //**********************************************************************************************
741
742 //**SMP addition assignment to dense matrices***************************************************
757 template< typename MT // Type of the target dense matrix
758 , bool SO > // Storage order of the target dense matrix
759 friend inline auto smpAddAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
760 -> EnableIf_t< UseSMPAssign_v<MT> >
761 {
763
764 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
765 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
766
767 if( !RequiresEvaluation_v<MT2> ) {
768 smpSubAssign( *lhs, rhs.rhs_ );
769 smpAddAssign( *lhs, rhs.lhs_ );
770 }
771 else {
772 smpAddAssign( *lhs, rhs.lhs_ );
773 smpSubAssign( *lhs, rhs.rhs_ );
774 }
775 }
777 //**********************************************************************************************
778
779 //**SMP addition assignment to sparse matrices**************************************************
780 // No special implementation for the SMP addition assignment to sparse matrices.
781 //**********************************************************************************************
782
783 //**SMP subtraction assignment to dense matrices************************************************
798 template< typename MT // Type of the target dense matrix
799 , bool SO > // Storage order of the target dense matrix
800 friend inline auto smpSubAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
801 -> EnableIf_t< UseSMPAssign_v<MT> >
802 {
804
805 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
806 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
807
808 if( !RequiresEvaluation_v<MT2> ) {
809 smpAddAssign( *lhs, rhs.rhs_ );
810 smpSubAssign( *lhs, rhs.lhs_ );
811 }
812 else {
813 smpSubAssign( *lhs, rhs.lhs_ );
814 smpAddAssign( *lhs, rhs.rhs_ );
815 }
816 }
818 //**********************************************************************************************
819
820 //**SMP subtraction assignment to sparse matrices***********************************************
821 // No special implementation for the SMP subtraction assignment to sparse matrices.
822 //**********************************************************************************************
823
824 //**SMP Schur product assignment to dense matrices**********************************************
839 template< typename MT // Type of the target dense matrix
840 , bool SO > // Storage order of the target dense matrix
841 friend inline auto smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatSubExpr& rhs )
842 -> EnableIf_t< UseSMPAssign_v<MT> >
843 {
845
849
850 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
851 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
852
853 const ResultType tmp( rhs );
854 smpSchurAssign( *lhs, tmp );
855 }
857 //**********************************************************************************************
858
859 //**SMP Schur product assignment to sparse matrices*********************************************
860 // No special implementation for the SMP Schur product assignment to sparse matrices.
861 //**********************************************************************************************
862
863 //**SMP multiplication assignment to dense matrices*********************************************
864 // No special implementation for the SMP multiplication assignment to dense matrices.
865 //**********************************************************************************************
866
867 //**SMP multiplication assignment to sparse matrices********************************************
868 // No special implementation for the SMP multiplication assignment to sparse matrices.
869 //**********************************************************************************************
870
871 //**Compile time checks*************************************************************************
878 //**********************************************************************************************
879};
880//*************************************************************************************************
881
882
883
884
885//=================================================================================================
886//
887// GLOBAL BINARY ARITHMETIC OPERATORS
888//
889//=================================================================================================
890
891//*************************************************************************************************
904template< typename MT1 // Type of the left-hand side dense matrix
905 , typename MT2 // Type of the right-hand side dense matrix
906 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
907inline const DMatTDMatSubExpr<MT1,MT2>
908 dmattdmatsub( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
909{
911
912 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
913 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
914
915 return DMatTDMatSubExpr<MT1,MT2>( *lhs, *rhs );
916}
918//*************************************************************************************************
919
920
921//*************************************************************************************************
934template< typename MT1 // Type of the left-hand side dense matrix
935 , typename MT2 // Type of the right-hand side dense matrix
936 , EnableIf_t< IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
937inline decltype(auto)
938 dmattdmatsub( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
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 return trans( *lhs ) - *rhs;
946}
948//*************************************************************************************************
949
950
951//*************************************************************************************************
964template< typename MT1 // Type of the left-hand side dense matrix
965 , typename MT2 // Type of the right-hand side dense matrix
966 , EnableIf_t< IsSymmetric_v<MT2> >* = nullptr >
967inline decltype(auto)
968 dmattdmatsub( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
969{
971
972 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
973 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
974
975 return (*lhs) - trans( *rhs );
976}
978//*************************************************************************************************
979
980
981//*************************************************************************************************
1010template< typename MT1 // Type of the left-hand side dense matrix
1011 , typename MT2 > // Type of the right-hand side dense matrix
1012inline decltype(auto)
1013 operator-( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1014{
1016
1017 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1018 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1019 }
1020
1021 return dmattdmatsub( *lhs, *rhs );
1022}
1023//*************************************************************************************************
1024
1025
1026//*************************************************************************************************
1039template< typename MT1 // Type of the left-hand side dense matrix
1040 , typename MT2 // Type of the right-hand side dense matrix
1041 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
1042inline const DMatTDMatSubExpr<MT1,MT2>
1043 tdmatdmatsub( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1044{
1046
1047 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1048 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1049
1050 return DMatTDMatSubExpr<MT1,MT2>( *lhs, *rhs );
1051}
1053//*************************************************************************************************
1054
1055
1056//*************************************************************************************************
1069template< typename MT1 // Type of the left-hand side dense matrix
1070 , typename MT2 // Type of the right-hand side dense matrix
1071 , EnableIf_t< !IsSymmetric_v<MT1> && IsSymmetric_v<MT2> >* = nullptr >
1072inline decltype(auto)
1073 tdmatdmatsub( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1074{
1076
1077 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1078 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1079
1080 return (*lhs) - trans( *rhs );
1081}
1083//*************************************************************************************************
1084
1085
1086//*************************************************************************************************
1099template< typename MT1 // Type of the left-hand side dense matrix
1100 , typename MT2 // Type of the right-hand side dense matrix
1101 , EnableIf_t< IsSymmetric_v<MT1> >* = nullptr >
1102inline decltype(auto)
1103 tdmatdmatsub( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1104{
1106
1107 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1108 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1109
1110 return trans( *lhs ) - (*rhs);
1111}
1113//*************************************************************************************************
1114
1115
1116//*************************************************************************************************
1145template< typename MT1 // Type of the left-hand side dense matrix
1146 , typename MT2 > // Type of the right-hand side dense matrix
1147inline decltype(auto)
1148 operator-( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1149{
1151
1152 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1153 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1154 }
1155
1156 return tdmatdmatsub( *lhs, *rhs );
1157}
1158//*************************************************************************************************
1159
1160
1161
1162
1163//=================================================================================================
1164//
1165// ISALIGNED SPECIALIZATIONS
1166//
1167//=================================================================================================
1168
1169//*************************************************************************************************
1171template< typename MT1, typename MT2 >
1172struct IsAligned< DMatTDMatSubExpr<MT1,MT2> >
1173 : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1174{};
1176//*************************************************************************************************
1177
1178} // namespace blaze
1179
1180#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.
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.
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 IsExpression type trait class.
Header file for the IsOperation type trait class.
Header file for the IsSymmetric type trait.
Header file for the IsTemporary type trait class.
Constraints on the storage order of matrix types.
Header file for the subtraction trait.
Expression object for dense matrix-transpose dense matrix subtractions.
Definition: DMatTDMatSubExpr.h:94
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:170
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the subtraction expression.
Definition: DMatTDMatSubExpr.h:126
RightOperand rhs_
Right-hand side dense matrix of the subtraction expression.
Definition: DMatTDMatSubExpr.h:321
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:97
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatTDMatSubExpr.h:312
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatSubExpr.h:159
decltype(std::declval< RN1 >() - std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatTDMatSubExpr.h:115
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:99
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:100
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatSubExpr.h:164
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:102
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatTDMatSubExpr.h:247
SubTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatTDMatSubExpr.h:158
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatSubExpr.h:257
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatSubExpr.h:279
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTDMatSubExpr.h:237
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:98
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatTDMatSubExpr.h:181
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:173
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatTDMatSubExpr.h:320
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatSubExpr.h:292
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition: DMatTDMatSubExpr.h:267
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatTDMatSubExpr.h:178
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatTDMatSubExpr.h:112
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatSubExpr.h:101
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatSubExpr.h:302
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatSubExpr.h:206
DMatTDMatSubExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatTDMatSubExpr class.
Definition: DMatTDMatSubExpr.h:190
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatTDMatSubExpr.h:167
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatTDMatSubExpr.h:161
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatSubExpr.h:221
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatSubExpr.h:160
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 MatMatSubExpr 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_FORM_VALID_MATMATSUBEXPR(T1, T2)
Constraint on the data type.
Definition: MatMatSubExpr.h:103
#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_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.
Definition: SubTrait.h:163
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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#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.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all matrix/matrix subtraction expression templates.
Definition: MatMatSubExpr.h:69
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.