Blaze 3.9
DMatTDMatAddExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATADDEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATTDMATADDEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
44#include <blaze/math/Aliases.h>
67#include <blaze/util/Assert.h>
68#include <blaze/util/EnableIf.h>
71#include <blaze/util/mpl/If.h>
72#include <blaze/util/Types.h>
73
74
75namespace blaze {
76
77//=================================================================================================
78//
79// CLASS DMATTDMATADDEXPR
80//
81//=================================================================================================
82
83//*************************************************************************************************
90template< typename MT1 // Type of the left-hand side dense matrix
91 , typename MT2 > // Type of the right-hand side dense matrix
93 : public MatMatAddExpr< DenseMatrix< DMatTDMatAddExpr<MT1,MT2>, false > >
94 , private Computation
95{
96 private:
97 //**Type definitions****************************************************************************
104 //**********************************************************************************************
105
106 //**Return type evaluation**********************************************************************
108
113 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
114
116 using ExprReturnType = decltype( std::declval<RN1>() + std::declval<RN2>() );
117 //**********************************************************************************************
118
119 //**Serial evaluation strategy******************************************************************
121
127 static constexpr bool useAssign =
128 ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> || !returnExpr );
129
132 template< typename MT >
133 static constexpr bool UseAssign_v = useAssign;
135 //**********************************************************************************************
136
137 //**Parallel evaluation strategy****************************************************************
139
145 template< typename MT >
146 static constexpr bool UseSMPAssign_v =
147 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign );
149 //**********************************************************************************************
150
151 public:
152 //**Type definitions****************************************************************************
155
158
163
166
169
171 using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
172
174 using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
175 //**********************************************************************************************
176
177 //**Compilation flags***************************************************************************
179 static constexpr bool simdEnabled = false;
180
182 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
183 //**********************************************************************************************
184
185 //**Constructor*********************************************************************************
191 inline DMatTDMatAddExpr( const MT1& lhs, const MT2& rhs ) noexcept
192 : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
193 , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
194 {
195 BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
196 BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
197 }
198 //**********************************************************************************************
199
200 //**Access operator*****************************************************************************
207 inline ReturnType operator()( size_t i, size_t j ) const {
208 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
209 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
210 return lhs_(i,j) + rhs_(i,j);
211 }
212 //**********************************************************************************************
213
214 //**At function*********************************************************************************
222 inline ReturnType at( size_t i, size_t j ) const {
223 if( i >= lhs_.rows() ) {
224 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
225 }
226 if( j >= lhs_.columns() ) {
227 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
228 }
229 return (*this)(i,j);
230 }
231 //**********************************************************************************************
232
233 //**Rows function*******************************************************************************
238 inline size_t rows() const noexcept {
239 return lhs_.rows();
240 }
241 //**********************************************************************************************
242
243 //**Columns function****************************************************************************
248 inline size_t columns() const noexcept {
249 return lhs_.columns();
250 }
251 //**********************************************************************************************
252
253 //**Left operand access*************************************************************************
258 inline LeftOperand leftOperand() const noexcept {
259 return lhs_;
260 }
261 //**********************************************************************************************
262
263 //**Right operand access************************************************************************
268 inline RightOperand rightOperand() const noexcept {
269 return rhs_;
270 }
271 //**********************************************************************************************
272
273 //**********************************************************************************************
279 template< typename T >
280 inline bool canAlias( const T* alias ) const noexcept {
281 return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
282 ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
283 }
284 //**********************************************************************************************
285
286 //**********************************************************************************************
292 template< typename T >
293 inline bool isAliased( const T* alias ) const noexcept {
294 return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
295 }
296 //**********************************************************************************************
297
298 //**********************************************************************************************
303 inline bool isAligned() const noexcept {
304 return lhs_.isAligned() && rhs_.isAligned();
305 }
306 //**********************************************************************************************
307
308 //**********************************************************************************************
313 inline bool canSMPAssign() const noexcept {
314 return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
315 ( rows() * columns() >= SMP_DMATTDMATADD_THRESHOLD );
316 }
317 //**********************************************************************************************
318
319 private:
320 //**Member variables****************************************************************************
323 //**********************************************************************************************
324
325 //**Assignment to dense matrices****************************************************************
339 template< typename MT // Type of the target dense matrix
340 , bool SO > // Storage order of the target dense matrix
341 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
343 {
345
346 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
347 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
348
349 constexpr size_t block( BLOCK_SIZE );
350
351 const size_t m( rhs.rows() );
352 const size_t n( rhs.columns() );
353
354 for( size_t ii=0UL; ii<m; ii+=block ) {
355 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
356 for( size_t jj=0UL; jj<n; jj+=block ) {
357 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
358 for( size_t i=ii; i<iend; ++i ) {
359 for( size_t j=jj; j<jend; ++j ) {
360 (*lhs)(i,j) = rhs.lhs_(i,j) + rhs.rhs_(i,j);
361 }
362 }
363 }
364 }
365 }
367 //**********************************************************************************************
368
369 //**Assignment to dense matrices****************************************************************
383 template< typename MT // Type of the target dense matrix
384 , bool SO > // Storage order of the target dense matrix
385 friend inline auto assign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
387 {
389
390 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
391 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
392
393 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
394 addAssign( *lhs, rhs.rhs_ );
395 }
396 else if( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) {
397 addAssign( *lhs, rhs.lhs_ );
398 }
399 else if( !RequiresEvaluation_v<MT2> ) {
400 assign ( *lhs, rhs.rhs_ );
401 addAssign( *lhs, rhs.lhs_ );
402 }
403 else {
404 assign ( *lhs, rhs.lhs_ );
405 addAssign( *lhs, rhs.rhs_ );
406 }
407 }
409 //**********************************************************************************************
410
411 //**Assignment to sparse matrices***************************************************************
423 template< typename MT // Type of the target sparse matrix
424 , bool SO > // Storage order of the target sparse matrix
425 friend inline void assign( SparseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
426 {
428
429 using TmpType = If_t< SO, OppositeType, ResultType >;
430
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 const TmpType tmp( serial( rhs ) );
442 assign( *lhs, tmp );
443 }
445 //**********************************************************************************************
446
447 //**Addition assignment to dense matrices*******************************************************
461 template< typename MT // Type of the target dense matrix
462 , bool SO > // Storage order of the target dense matrix
463 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
464 -> DisableIf_t< UseAssign_v<MT> >
465 {
467
468 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
469 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
470
471 constexpr size_t block( BLOCK_SIZE );
472
473 const size_t m( rhs.rows() );
474 const size_t n( rhs.columns() );
475
476 for( size_t ii=0UL; ii<m; ii+=block ) {
477 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
478 for( size_t jj=0UL; jj<n; jj+=block ) {
479 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
480 for( size_t i=ii; i<iend; ++i ) {
481 for( size_t j=jj; j<jend; ++j ) {
482 (*lhs)(i,j) += rhs.lhs_(i,j) + rhs.rhs_(i,j);
483 }
484 }
485 }
486 }
487 }
489 //**********************************************************************************************
490
491 //**Addition assignment to dense matrices*******************************************************
505 template< typename MT // Type of the target dense matrix
506 , bool SO > // Storage order of the target dense matrix
507 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
508 -> EnableIf_t< UseAssign_v<MT> >
509 {
511
512 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
513 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
514
515 if( !RequiresEvaluation_v<MT2> ) {
516 addAssign( *lhs, rhs.rhs_ );
517 addAssign( *lhs, rhs.lhs_ );
518 }
519 else {
520 addAssign( *lhs, rhs.lhs_ );
521 addAssign( *lhs, rhs.rhs_ );
522 }
523 }
525 //**********************************************************************************************
526
527 //**Addition assignment to sparse matrices******************************************************
528 // No special implementation for the addition assignment to sparse matrices.
529 //**********************************************************************************************
530
531 //**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 DMatTDMatAddExpr& 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****************************************************
589 template< typename MT // Type of the target dense matrix
590 , bool SO > // Storage order of the target dense matrix
591 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
592 -> EnableIf_t< UseAssign_v<MT> >
593 {
595
596 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
597 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
598
599 if( !RequiresEvaluation_v<MT2> ) {
600 subAssign( *lhs, rhs.rhs_ );
601 subAssign( *lhs, rhs.lhs_ );
602 }
603 else {
604 subAssign( *lhs, rhs.lhs_ );
605 subAssign( *lhs, rhs.rhs_ );
606 }
607 }
609 //**********************************************************************************************
610
611 //**Subtraction assignment to sparse matrices***************************************************
612 // No special implementation for the subtraction assignment to sparse matrices.
613 //**********************************************************************************************
614
615 //**Schur product assignment to dense matrices**************************************************
630 template< typename MT // Type of the target dense matrix
631 , bool SO > // Storage order of the target dense matrix
632 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
633 -> DisableIf_t< UseAssign_v<MT> >
634 {
636
640
641 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
642 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
643
644 const ResultType tmp( serial( rhs ) );
645 schurAssign( *lhs, tmp );
646 }
648 //**********************************************************************************************
649
650 //**Schur product assignment to sparse matrices*************************************************
651 // No special implementation for the Schur product assignment to sparse matrices.
652 //**********************************************************************************************
653
654 //**Multiplication assignment to dense matrices*************************************************
655 // No special implementation for the multiplication assignment to dense matrices.
656 //**********************************************************************************************
657
658 //**Multiplication assignment to sparse matrices************************************************
659 // No special implementation for the multiplication assignment to sparse matrices.
660 //**********************************************************************************************
661
662 //**SMP assignment to dense matrices************************************************************
676 template< typename MT // Type of the target dense matrix
677 , bool SO > // Storage order of the target dense matrix
678 friend inline auto smpAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
679 -> EnableIf_t< UseSMPAssign_v<MT> >
680 {
682
683 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
684 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
685
686 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
687 smpAddAssign( *lhs, rhs.rhs_ );
688 }
689 else if( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) {
690 smpAddAssign( *lhs, rhs.lhs_ );
691 }
692 else if( !RequiresEvaluation_v<MT2> ) {
693 smpAssign ( *lhs, rhs.rhs_ );
694 smpAddAssign( *lhs, rhs.lhs_ );
695 }
696 else {
697 smpAssign ( *lhs, rhs.lhs_ );
698 smpAddAssign( *lhs, rhs.rhs_ );
699 }
700 }
702 //**********************************************************************************************
703
704 //**SMP assignment to sparse matrices***********************************************************
718 template< typename MT // Type of the target sparse matrix
719 , bool SO > // Storage order of the target sparse matrix
720 friend inline auto smpAssign( SparseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
721 -> EnableIf_t< UseSMPAssign_v<MT> >
722 {
724
725 using TmpType = If_t< SO, OppositeType, ResultType >;
726
733
734 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
735 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
736
737 const TmpType tmp( rhs );
738 smpAssign( *lhs, tmp );
739 }
741 //**********************************************************************************************
742
743 //**SMP addition assignment to dense matrices***************************************************
758 template< typename MT // Type of the target dense matrix
759 , bool SO > // Storage order of the target dense matrix
760 friend inline auto smpAddAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
761 -> EnableIf_t< UseSMPAssign_v<MT> >
762 {
764
765 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
766 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
767
768 if( !RequiresEvaluation_v<MT2> ) {
769 smpAddAssign( *lhs, rhs.rhs_ );
770 smpAddAssign( *lhs, rhs.lhs_ );
771 }
772 else {
773 smpAddAssign( *lhs, rhs.lhs_ );
774 smpAddAssign( *lhs, rhs.rhs_ );
775 }
776 }
778 //**********************************************************************************************
779
780 //**SMP addition assignment to sparse matrices**************************************************
781 // No special implementation for the SMP addition assignment to sparse matrices.
782 //**********************************************************************************************
783
784 //**SMP subtraction assignment to dense matrices************************************************
799 template< typename MT // Type of the target dense matrix
800 , bool SO > // Storage order of the target dense matrix
801 friend inline auto smpSubAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
802 -> EnableIf_t< UseSMPAssign_v<MT> >
803 {
805
806 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
807 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
808
809 if( !RequiresEvaluation_v<MT2> ) {
810 smpSubAssign( *lhs, rhs.rhs_ );
811 smpSubAssign( *lhs, rhs.lhs_ );
812 }
813 else {
814 smpSubAssign( *lhs, rhs.lhs_ );
815 smpSubAssign( *lhs, rhs.rhs_ );
816 }
817 }
819 //**********************************************************************************************
820
821 //**SMP subtraction assignment to sparse matrices***********************************************
822 // No special implementation for the SMP subtraction assignment to sparse matrices.
823 //**********************************************************************************************
824
825 //**SMP Schur product assignment to dense matrices**********************************************
840 template< typename MT // Type of the target dense matrix
841 , bool SO > // Storage order of the target dense matrix
842 friend inline auto smpSchurAssign( DenseMatrix<MT,SO>& lhs, const DMatTDMatAddExpr& rhs )
843 -> EnableIf_t< UseSMPAssign_v<MT> >
844 {
846
850
851 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
852 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
853
854 const ResultType tmp( rhs );
855 smpSchurAssign( *lhs, tmp );
856 }
858 //**********************************************************************************************
859
860 //**SMP Schur product assignment to sparse matrices*********************************************
861 // No special implementation for the SMP Schur product assignment to sparse matrices.
862 //**********************************************************************************************
863
864 //**SMP multiplication assignment to dense matrices*********************************************
865 // No special implementation for the SMP multiplication assignment to dense matrices.
866 //**********************************************************************************************
867
868 //**SMP multiplication assignment to sparse matrices********************************************
869 // No special implementation for the SMP multiplication assignment to sparse matrices.
870 //**********************************************************************************************
871
872 //**Compile time checks*************************************************************************
880 //**********************************************************************************************
881};
882//*************************************************************************************************
883
884
885
886
887//=================================================================================================
888//
889// GLOBAL BINARY ARITHMETIC OPERATORS
890//
891//=================================================================================================
892
893//*************************************************************************************************
906template< typename MT1 // Type of the left-hand side dense matrix
907 , typename MT2 // Type of the right-hand side dense matrix
908 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
909inline const DMatTDMatAddExpr<MT1,MT2>
910 dmattdmatadd( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
911{
913
914 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
915 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
916
917 return DMatTDMatAddExpr<MT1,MT2>( *lhs, *rhs );
918}
920//*************************************************************************************************
921
922
923//*************************************************************************************************
936template< typename MT1 // Type of the left-hand side dense matrix
937 , typename MT2 // Type of the right-hand side dense matrix
938 , EnableIf_t< IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
939inline decltype(auto)
940 dmattdmatadd( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
941{
943
944 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
945 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
946
947 return trans( *lhs ) + *rhs;
948}
950//*************************************************************************************************
951
952
953//*************************************************************************************************
966template< typename MT1 // Type of the left-hand side dense matrix
967 , typename MT2 // Type of the right-hand side dense matrix
968 , EnableIf_t< IsSymmetric_v<MT2> >* = nullptr >
969inline decltype(auto)
970 dmattdmatadd( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
971{
973
974 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
975 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
976
977 return (*lhs) + trans( *rhs );
978}
980//*************************************************************************************************
981
982
983//*************************************************************************************************
1012template< typename MT1 // Type of the left-hand side dense matrix
1013 , typename MT2 > // Type of the right-hand side dense matrix
1014inline decltype(auto)
1015 operator+( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs )
1016{
1018
1019 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1020 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1021 }
1022
1023 return dmattdmatadd( *lhs, *rhs );
1024}
1025//*************************************************************************************************
1026
1027
1028//*************************************************************************************************
1041template< typename MT1 // Type of the left-hand side dense matrix
1042 , typename MT2 // Type of the right-hand side dense matrix
1043 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* = nullptr >
1044inline const DMatTDMatAddExpr<MT2,MT1>
1045 tdmatdmatadd( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1046{
1048
1049 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1050 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1051
1052 return DMatTDMatAddExpr<MT2,MT1>( *rhs, *lhs );
1053}
1055//*************************************************************************************************
1056
1057
1058//*************************************************************************************************
1071template< typename MT1 // Type of the left-hand side dense matrix
1072 , typename MT2 // Type of the right-hand side dense matrix
1073 , EnableIf_t< !IsSymmetric_v<MT1> && IsSymmetric_v<MT2> >* = nullptr >
1074inline decltype(auto)
1075 tdmatdmatadd( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1076{
1078
1079 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1080 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1081
1082 return trans( *rhs ) + (*lhs);
1083}
1085//*************************************************************************************************
1086
1087
1088//*************************************************************************************************
1101template< typename MT1 // Type of the left-hand side dense matrix
1102 , typename MT2 // Type of the right-hand side dense matrix >
1103 , EnableIf_t< IsSymmetric_v<MT1> >* = nullptr >
1104inline decltype(auto)
1105 tdmatdmatadd( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1106{
1108
1109 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == (*rhs).rows() , "Invalid number of rows" );
1110 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == (*rhs).columns(), "Invalid number of columns" );
1111
1112 return (*rhs) + trans( *lhs );
1113}
1115//*************************************************************************************************
1116
1117
1118//*************************************************************************************************
1147template< typename MT1 // Type of the left-hand side dense matrix
1148 , typename MT2 > // Type of the right-hand side dense matrix
1149inline decltype(auto)
1150 operator+( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs )
1151{
1153
1154 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1155 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1156 }
1157
1158 return tdmatdmatadd( *lhs, *rhs );
1159}
1160//*************************************************************************************************
1161
1162
1163
1164
1165//=================================================================================================
1166//
1167// ISALIGNED SPECIALIZATIONS
1168//
1169//=================================================================================================
1170
1171//*************************************************************************************************
1173template< typename MT1, typename MT2 >
1174struct IsAligned< DMatTDMatAddExpr<MT1,MT2> >
1175 : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1176{};
1178//*************************************************************************************************
1179
1180
1181
1182
1183//=================================================================================================
1184//
1185// ISSTRICTLYUPPER SPECIALIZATIONS
1186//
1187//=================================================================================================
1188
1189//*************************************************************************************************
1191template< typename MT1, typename MT2 >
1192struct IsStrictlyUpper< DMatTDMatAddExpr<MT1,MT2> >
1193 : public BoolConstant< IsStrictlyUpper_v<MT1> && IsStrictlyUpper_v<MT2> >
1194{};
1196//*************************************************************************************************
1197
1198} // namespace blaze
1199
1200#endif
Header file for the addition trait.
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 IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsTemporary type trait class.
Constraints on the storage order of matrix types.
Expression object for dense matrix-transpose dense matrix additions.
Definition: DMatTDMatAddExpr.h:95
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:161
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatAddExpr.h:280
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:321
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTDMatAddExpr.h:238
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the addition expression.
Definition: DMatTDMatAddExpr.h:127
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:101
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:171
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatAddExpr.h:222
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatAddExpr.h:207
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatTDMatAddExpr.h:116
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:322
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:98
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatAddExpr.h:303
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatAddExpr.h:160
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatTDMatAddExpr.h:113
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatTDMatAddExpr.h:248
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:174
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:165
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatTDMatAddExpr.h:168
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatTDMatAddExpr.h:162
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition: DMatTDMatAddExpr.h:268
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:99
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:159
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatAddExpr.h:293
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatTDMatAddExpr.h:179
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatAddExpr.h:258
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatTDMatAddExpr.h:313
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:100
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:103
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:102
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatTDMatAddExpr.h:182
DMatTDMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatTDMatAddExpr class.
Definition: DMatTDMatAddExpr.h:191
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 MatMatAddExpr 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_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.
Definition: MatMatAddExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition: AddTrait.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 addition expression templates.
Definition: MatMatAddExpr.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.