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 <stdexcept>
70 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/mpl/And.h>
76 #include <blaze/util/mpl/Max.h>
77 #include <blaze/util/mpl/Not.h>
78 #include <blaze/util/mpl/Or.h>
79 #include <blaze/util/SelectType.h>
80 #include <blaze/util/Types.h>
82 
83 
84 namespace blaze {
85 
86 //=================================================================================================
87 //
88 // CLASS DMATTDMATADDEXPR
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
99 template< typename MT1 // Type of the left-hand side dense matrix
100  , typename MT2 > // Type of the right-hand side dense matrix
101 class DMatTDMatAddExpr : public DenseMatrix< DMatTDMatAddExpr<MT1,MT2>, false >
102  , private MatMatAddExpr
103  , private Computation
104 {
105  private:
106  //**Type definitions****************************************************************************
107  typedef typename MT1::ResultType RT1;
108  typedef typename MT2::ResultType RT2;
109  typedef typename MT1::ReturnType RN1;
110  typedef typename MT2::ReturnType RN2;
111  typedef typename MT1::CompositeType CT1;
112  typedef typename MT2::CompositeType CT2;
113  //**********************************************************************************************
114 
115  //**Return type evaluation**********************************************************************
117 
122  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
123 
126  //**********************************************************************************************
127 
128  //**Serial evaluation strategy******************************************************************
130 
136  enum { useAssign = RequiresEvaluation<MT1>::value || RequiresEvaluation<MT2>::value || !returnExpr };
137 
139  template< typename MT >
141  struct UseAssign {
142  enum { value = useAssign };
143  };
145  //**********************************************************************************************
146 
147  //**Parallel evaluation strategy****************************************************************
149 
155  template< typename MT >
156  struct UseSMPAssign {
157  enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
158  };
160  //**********************************************************************************************
161 
162  public:
163  //**Type definitions****************************************************************************
169 
172 
174  typedef const ResultType CompositeType;
175 
177  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
178 
180  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
181  //**********************************************************************************************
182 
183  //**Compilation flags***************************************************************************
185  enum { vectorizable = 0 };
186 
188  enum { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
189  //**********************************************************************************************
190 
191  //**Constructor*********************************************************************************
197  explicit inline DMatTDMatAddExpr( const MT1& lhs, const MT2& rhs )
198  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
199  , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
200  {
201  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
202  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
203  }
204  //**********************************************************************************************
205 
206  //**Access operator*****************************************************************************
213  inline ReturnType operator()( size_t i, size_t j ) const {
214  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
215  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
216  return lhs_(i,j) + rhs_(i,j);
217  }
218  //**********************************************************************************************
219 
220  //**Rows function*******************************************************************************
225  inline size_t rows() const {
226  return lhs_.rows();
227  }
228  //**********************************************************************************************
229 
230  //**Columns function****************************************************************************
235  inline size_t columns() const {
236  return lhs_.columns();
237  }
238  //**********************************************************************************************
239 
240  //**Left operand access*************************************************************************
245  inline LeftOperand leftOperand() const {
246  return lhs_;
247  }
248  //**********************************************************************************************
249 
250  //**Right operand access************************************************************************
255  inline RightOperand rightOperand() const {
256  return rhs_;
257  }
258  //**********************************************************************************************
259 
260  //**********************************************************************************************
266  template< typename T >
267  inline bool canAlias( const T* alias ) const {
268  return ( IsExpression<MT1>::value && ( RequiresEvaluation<MT1>::value ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
269  ( IsExpression<MT2>::value && ( RequiresEvaluation<MT2>::value ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
270  }
271  //**********************************************************************************************
272 
273  //**********************************************************************************************
279  template< typename T >
280  inline bool isAliased( const T* alias ) const {
281  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
282  }
283  //**********************************************************************************************
284 
285  //**********************************************************************************************
290  inline bool isAligned() const {
291  return lhs_.isAligned() && rhs_.isAligned();
292  }
293  //**********************************************************************************************
294 
295  //**********************************************************************************************
300  inline bool canSMPAssign() const {
301  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
303  }
304  //**********************************************************************************************
305 
306  private:
307  //**Member variables****************************************************************************
308  LeftOperand lhs_;
309  RightOperand rhs_;
310  //**********************************************************************************************
311 
312  //**Assignment to dense matrices****************************************************************
326  template< typename MT // Type of the target dense matrix
327  , bool SO2 > // Storage order of the target dense matrix
328  friend inline typename DisableIf< UseAssign<MT> >::Type
329  assign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
330  {
332 
333  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
334  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
335 
336  const size_t m( rhs.rows() );
337  const size_t n( rhs.columns() );
338  const size_t block( 16UL );
339 
340  for( size_t ii=0UL; ii<m; ii+=block ) {
341  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
342  for( size_t jj=0UL; jj<n; jj+=block ) {
343  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
344  for( size_t i=ii; i<iend; ++i ) {
345  for( size_t j=jj; j<jend; ++j ) {
346  (~lhs)(i,j) = rhs.lhs_(i,j) + rhs.rhs_(i,j);
347  }
348  }
349  }
350  }
351  }
353  //**********************************************************************************************
354 
355  //**Assignment to dense matrices****************************************************************
369  template< typename MT // Type of the target dense matrix
370  , bool SO2 > // Storage order of the target dense matrix
371  friend inline typename EnableIf< UseAssign<MT> >::Type
372  assign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
373  {
375 
376  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
377  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
378 
379  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
380  addAssign( ~lhs, rhs.rhs_ );
381  }
382  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
383  addAssign( ~lhs, rhs.lhs_ );
384  }
385  else {
386  assign ( ~lhs, rhs.lhs_ );
387  addAssign( ~lhs, rhs.rhs_ );
388  }
389  }
391  //**********************************************************************************************
392 
393  //**Assignment to sparse matrices***************************************************************
405  template< typename MT // Type of the target sparse matrix
406  , bool SO2 > // Storage order of the target sparse matrix
407  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
408  {
410 
411  typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
412 
419 
420  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
421  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
422 
423  const TmpType tmp( serial( rhs ) );
424  assign( ~lhs, tmp );
425  }
427  //**********************************************************************************************
428 
429  //**Addition assignment to dense matrices*******************************************************
443  template< typename MT // Type of the target dense matrix
444  , bool SO2 > // Storage order of the target dense matrix
445  friend inline typename DisableIf< UseAssign<MT> >::Type
446  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
447  {
449 
450  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
451  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
452 
453  const size_t m( rhs.rows() );
454  const size_t n( rhs.columns() );
455  const size_t block( 16UL );
456 
457  for( size_t ii=0UL; ii<m; ii+=block ) {
458  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
459  for( size_t jj=0UL; jj<n; jj+=block ) {
460  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
461  for( size_t i=ii; i<iend; ++i ) {
462  for( size_t j=jj; j<jend; ++j ) {
463  (~lhs)(i,j) += rhs.lhs_(i,j) + rhs.rhs_(i,j);
464  }
465  }
466  }
467  }
468  }
470  //**********************************************************************************************
471 
472  //**Addition assignment to dense matrices*******************************************************
486  template< typename MT // Type of the target dense matrix
487  , bool SO2 > // Storage order of the target dense matrix
488  friend inline typename EnableIf< UseAssign<MT> >::Type
489  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
490  {
492 
493  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
494  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
495 
496  addAssign( ~lhs, rhs.lhs_ );
497  addAssign( ~lhs, rhs.rhs_ );
498  }
500  //**********************************************************************************************
501 
502  //**Addition assignment to sparse matrices******************************************************
503  // No special implementation for the addition assignment to sparse matrices.
504  //**********************************************************************************************
505 
506  //**Subtraction assignment to dense matrices****************************************************
520  template< typename MT // Type of the target dense matrix
521  , bool SO2 > // Storage order of the target dense matrix
522  friend inline typename DisableIf< UseAssign<MT> >::Type
523  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
524  {
526 
527  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
528  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
529 
530  const size_t m( rhs.rows() );
531  const size_t n( rhs.columns() );
532  const size_t block( 16UL );
533 
534  for( size_t ii=0UL; ii<m; ii+=block ) {
535  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
536  for( size_t jj=0UL; jj<n; jj+=block ) {
537  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
538  for( size_t i=ii; i<iend; ++i ) {
539  for( size_t j=jj; j<jend; ++j ) {
540  (~lhs)(i,j) -= rhs.lhs_(i,j) + rhs.rhs_(i,j);
541  }
542  }
543  }
544  }
545  }
547  //**********************************************************************************************
548 
549  //**Subtraction assignment to dense matrices****************************************************
563  template< typename MT // Type of the target dense matrix
564  , bool SO2 > // Storage order of the target dense matrix
565  friend inline typename EnableIf< UseAssign<MT> >::Type
566  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
567  {
569 
570  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
571  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
572 
573  subAssign( ~lhs, rhs.lhs_ );
574  subAssign( ~lhs, rhs.rhs_ );
575  }
577  //**********************************************************************************************
578 
579  //**Subtraction assignment to sparse matrices***************************************************
580  // No special implementation for the subtraction assignment to sparse matrices.
581  //**********************************************************************************************
582 
583  //**Multiplication assignment to dense matrices*************************************************
584  // No special implementation for the multiplication assignment to dense matrices.
585  //**********************************************************************************************
586 
587  //**Multiplication assignment to sparse matrices************************************************
588  // No special implementation for the multiplication assignment to sparse matrices.
589  //**********************************************************************************************
590 
591  //**SMP assignment to dense matrices************************************************************
605  template< typename MT // Type of the target dense matrix
606  , bool SO2 > // Storage order of the target dense matrix
607  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
608  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
609  {
611 
612  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
613  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
614 
615  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
616  smpAddAssign( ~lhs, rhs.rhs_ );
617  }
618  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
619  smpAddAssign( ~lhs, rhs.lhs_ );
620  }
621  else {
622  smpAssign ( ~lhs, rhs.lhs_ );
623  smpAddAssign( ~lhs, rhs.rhs_ );
624  }
625  }
627  //**********************************************************************************************
628 
629  //**SMP assignment to sparse matrices***********************************************************
643  template< typename MT // Type of the target sparse matrix
644  , bool SO2 > // Storage order of the target sparse matrix
645  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
646  smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
647  {
649 
650  typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
651 
658 
659  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
660  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
661 
662  const TmpType tmp( rhs );
663  smpAssign( ~lhs, tmp );
664  }
666  //**********************************************************************************************
667 
668  //**SMP addition assignment to dense matrices***************************************************
683  template< typename MT // Type of the target dense matrix
684  , bool SO2 > // Storage order of the target dense matrix
685  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
686  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
687  {
689 
690  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
691  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
692 
693  smpAddAssign( ~lhs, rhs.lhs_ );
694  smpAddAssign( ~lhs, rhs.rhs_ );
695  }
697  //**********************************************************************************************
698 
699  //**SMP addition assignment to sparse matrices**************************************************
700  // No special implementation for the SMP addition assignment to sparse matrices.
701  //**********************************************************************************************
702 
703  //**SMP subtraction assignment to dense matrices************************************************
718  template< typename MT // Type of the target dense matrix
719  , bool SO2 > // Storage order of the target dense matrix
720  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
721  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
722  {
724 
725  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
726  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
727 
728  smpSubAssign( ~lhs, rhs.lhs_ );
729  smpSubAssign( ~lhs, rhs.rhs_ );
730  }
732  //**********************************************************************************************
733 
734  //**SMP subtraction assignment to sparse matrices***********************************************
735  // No special implementation for the SMP subtraction assignment to sparse matrices.
736  //**********************************************************************************************
737 
738  //**SMP multiplication assignment to dense matrices*********************************************
739  // No special implementation for the SMP multiplication assignment to dense matrices.
740  //**********************************************************************************************
741 
742  //**SMP multiplication assignment to sparse matrices********************************************
743  // No special implementation for the SMP multiplication assignment to sparse matrices.
744  //**********************************************************************************************
745 
746  //**Compile time checks*************************************************************************
754  //**********************************************************************************************
755 };
756 //*************************************************************************************************
757 
758 
759 
760 
761 //=================================================================================================
762 //
763 // GLOBAL BINARY ARITHMETIC OPERATORS
764 //
765 //=================================================================================================
766 
767 //*************************************************************************************************
796 template< typename T1 // Type of the left-hand side dense matrix
797  , typename T2 > // Type of the right-hand side dense matrix
798 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
799  , const DMatTDMatAddExpr<T1,T2> >::Type
801 {
803 
804  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
805  throw std::invalid_argument( "Matrix sizes do not match" );
806 
807  return DMatTDMatAddExpr<T1,T2>( ~lhs, ~rhs );
808 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
841 template< typename T1 // Type of the left-hand side dense matrix
842  , typename T2 > // Type of the right-hand side dense matrix
843 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
844  , const DMatTDMatAddExpr<T2,T1> >::Type
846 {
848 
849  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
850  throw std::invalid_argument( "Matrix sizes do not match" );
851 
852  return DMatTDMatAddExpr<T2,T1>( ~rhs, ~lhs );
853 }
854 //*************************************************************************************************
855 
856 
857 
858 
859 //=================================================================================================
860 //
861 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
862 //
863 //=================================================================================================
864 
865 //*************************************************************************************************
879 template< typename T1 // Type of the left-hand side dense matrix
880  , typename T2 > // Type of the right-hand side dense matrix
881 inline typename EnableIf< And< IsSymmetric<T1>, Not< IsSymmetric<T2> > >
882  , const typename AddExprTrait<T1,T2>::Type >::Type
883  operator+( const DenseMatrix<T1,false>& lhs, const DenseMatrix<T2,true>& rhs )
884 {
886 
887  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
888  throw std::invalid_argument( "Matrix sizes do not match" );
889 
890  return trans( ~lhs ) + ~rhs;
891 }
893 //*************************************************************************************************
894 
895 
896 //*************************************************************************************************
910 template< typename T1 // Type of the left-hand side dense matrix
911  , typename T2 > // Type of the right-hand side dense matrix
912 inline typename EnableIf< IsSymmetric<T2>
913  , const typename AddExprTrait<T1,T2>::Type >::Type
914  operator+( const DenseMatrix<T1,false>& lhs, const DenseMatrix<T2,true>& rhs )
915 {
917 
918  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
919  throw std::invalid_argument( "Matrix sizes do not match" );
920 
921  return (~lhs) + trans( ~rhs );
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
941 template< typename T1 // Type of the left-hand side dense matrix
942  , typename T2 > // Type of the right-hand side dense matrix
943 inline typename EnableIf< And< Not< IsSymmetric<T1> >, IsSymmetric<T2> >
944  , const typename AddExprTrait<T2,T1>::Type >::Type
945  operator+( const DenseMatrix<T1,true>& lhs, const DenseMatrix<T2,false>& rhs )
946 {
948 
949  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
950  throw std::invalid_argument( "Matrix sizes do not match" );
951 
952  return trans( ~rhs ) + (~lhs);
953 }
955 //*************************************************************************************************
956 
957 
958 //*************************************************************************************************
972 template< typename T1 // Type of the left-hand side dense matrix
973  , typename T2 > // Type of the right-hand side dense matrix
974 inline typename EnableIf< IsSymmetric<T1>
975  , const typename AddExprTrait<T2,T1>::Type >::Type
976  operator+( const DenseMatrix<T1,true>& lhs, const DenseMatrix<T2,false>& rhs )
977 {
979 
980  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
981  throw std::invalid_argument( "Matrix sizes do not match" );
982 
983  return (~rhs) + trans( ~lhs );
984 }
986 //*************************************************************************************************
987 
988 
989 
990 
991 //=================================================================================================
992 //
993 // ROWS SPECIALIZATIONS
994 //
995 //=================================================================================================
996 
997 //*************************************************************************************************
999 template< typename MT1, typename MT2 >
1000 struct Rows< DMatTDMatAddExpr<MT1,MT2> >
1001  : public Max< Rows<MT1>, Rows<MT2> >::Type
1002 {};
1004 //*************************************************************************************************
1005 
1006 
1007 
1008 
1009 //=================================================================================================
1010 //
1011 // COLUMNS SPECIALIZATIONS
1012 //
1013 //=================================================================================================
1014 
1015 //*************************************************************************************************
1017 template< typename MT1, typename MT2 >
1018 struct Columns< DMatTDMatAddExpr<MT1,MT2> >
1019  : public Max< Columns<MT1>, Columns<MT2> >::Type
1020 {};
1022 //*************************************************************************************************
1023 
1024 
1025 
1026 
1027 //=================================================================================================
1028 //
1029 // ISSYMMETRIC SPECIALIZATIONS
1030 //
1031 //=================================================================================================
1032 
1033 //*************************************************************************************************
1035 template< typename MT1, typename MT2 >
1036 struct IsSymmetric< DMatTDMatAddExpr<MT1,MT2> >
1037  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
1038 {};
1040 //*************************************************************************************************
1041 
1042 
1043 
1044 
1045 //=================================================================================================
1046 //
1047 // ISLOWER SPECIALIZATIONS
1048 //
1049 //=================================================================================================
1050 
1051 //*************************************************************************************************
1053 template< typename MT1, typename MT2 >
1054 struct IsLower< DMatTDMatAddExpr<MT1,MT2> >
1055  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
1056 {};
1058 //*************************************************************************************************
1059 
1060 
1061 
1062 
1063 //=================================================================================================
1064 //
1065 // ISUNILOWER SPECIALIZATIONS
1066 //
1067 //=================================================================================================
1068 
1069 //*************************************************************************************************
1071 template< typename MT1, typename MT2 >
1072 struct IsUniLower< DMatTDMatAddExpr<MT1,MT2> >
1073  : public IsTrue< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
1074  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
1075 {};
1077 //*************************************************************************************************
1078 
1079 
1080 
1081 
1082 //=================================================================================================
1083 //
1084 // ISSTRICTLYLOWER SPECIALIZATIONS
1085 //
1086 //=================================================================================================
1087 
1088 //*************************************************************************************************
1090 template< typename MT1, typename MT2 >
1091 struct IsStrictlyLower< DMatTDMatAddExpr<MT1,MT2> >
1092  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
1093 {};
1095 //*************************************************************************************************
1096 
1097 
1098 
1099 
1100 //=================================================================================================
1101 //
1102 // ISUPPER SPECIALIZATIONS
1103 //
1104 //=================================================================================================
1105 
1106 //*************************************************************************************************
1108 template< typename MT1, typename MT2 >
1109 struct IsUpper< DMatTDMatAddExpr<MT1,MT2> >
1110  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1111 {};
1113 //*************************************************************************************************
1114 
1115 
1116 
1117 
1118 //=================================================================================================
1119 //
1120 // ISUNIUPPER SPECIALIZATIONS
1121 //
1122 //=================================================================================================
1123 
1124 //*************************************************************************************************
1126 template< typename MT1, typename MT2 >
1127 struct IsUniUpper< DMatTDMatAddExpr<MT1,MT2> >
1128  : public IsTrue< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1129  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
1130 {};
1132 //*************************************************************************************************
1133 
1134 
1135 
1136 
1137 //=================================================================================================
1138 //
1139 // ISSTRICTLYUPPER SPECIALIZATIONS
1140 //
1141 //=================================================================================================
1142 
1143 //*************************************************************************************************
1145 template< typename MT1, typename MT2 >
1146 struct IsStrictlyUpper< DMatTDMatAddExpr<MT1,MT2> >
1147  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1148 {};
1150 //*************************************************************************************************
1151 
1152 
1153 
1154 
1155 //=================================================================================================
1156 //
1157 // EXPRESSION TRAIT SPECIALIZATIONS
1158 //
1159 //=================================================================================================
1160 
1161 //*************************************************************************************************
1163 template< typename MT1, typename MT2, bool AF >
1164 struct SubmatrixExprTrait< DMatTDMatAddExpr<MT1,MT2>, AF >
1165 {
1166  public:
1167  //**********************************************************************************************
1168  typedef typename AddExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1169  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1170  //**********************************************************************************************
1171 };
1173 //*************************************************************************************************
1174 
1175 
1176 //*************************************************************************************************
1178 template< typename MT1, typename MT2 >
1179 struct RowExprTrait< DMatTDMatAddExpr<MT1,MT2> >
1180 {
1181  public:
1182  //**********************************************************************************************
1183  typedef typename AddExprTrait< typename RowExprTrait<const MT1>::Type
1184  , typename RowExprTrait<const MT2>::Type >::Type Type;
1185  //**********************************************************************************************
1186 };
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1193 template< typename MT1, typename MT2 >
1194 struct ColumnExprTrait< DMatTDMatAddExpr<MT1,MT2> >
1195 {
1196  public:
1197  //**********************************************************************************************
1198  typedef typename AddExprTrait< typename ColumnExprTrait<const MT1>::Type
1199  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1200  //**********************************************************************************************
1201 };
1203 //*************************************************************************************************
1204 
1205 } // namespace blaze
1206 
1207 #endif
Header file for the Max class template.
Evaluation of the return type of an addition expression.Via this type trait it is possible to evaluat...
Definition: AddExprTrait.h:104
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
Header file for basic type definitions.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
Header file for the ColumnExprTrait class template.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatAddExpr.h:166
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:167
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:261
Header file for the And class template.
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:165
Header file for the AddExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
Header file for the Computation base class.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatAddExpr.h:267
Header file for the RequiresEvaluation type trait.
Header file for the IsUniLower type trait.
MT1::CompositeType CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:111
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Constraint on the data type.
DMatTDMatAddExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the DMatTDMatAddExpr class.
Definition: DMatTDMatAddExpr.h:197
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
MT1::ReturnType RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:109
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatTDMatAddExpr.h:225
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatTDMatAddExpr.h:174
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:171
Header file for the Or class template.
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Header file for the Columns type trait.
Header file for the Not class template.
Base class for all matrix/matrix addition expression templates.The MatMatAddExpr class serves as a ta...
Definition: MatMatAddExpr.h:65
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
Header file for the IsLower type trait.
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatTDMatAddExpr.h:125
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:78
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatTDMatAddExpr.h:235
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatAddExpr.h:165
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatAddExpr.h:280
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
DMatTDMatAddExpr< MT1, MT2 > This
Type of this DMatTDMatAdd instance.
Definition: DMatTDMatAddExpr.h:164
Header file for the serial shim.
MT2::ResultType RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:108
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the SubmatrixExprTrait class template.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:180
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:308
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:150
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatTDMatAddExpr.h:168
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:309
RightOperand rightOperand() const
Returns the right-hand side transpose dense matrix operand.
Definition: DMatTDMatAddExpr.h:255
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatAddExpr.h:245
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
const size_t SMP_DMATTDMATADD_THRESHOLD
SMP row-major dense matrix/column-major dense matrix addition threshold.This threshold specifies when...
Definition: Thresholds.h:739
MT2::ReturnType RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:110
Header file for the MatMatAddExpr base class.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:283
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:177
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:107
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatAddExpr.h:213
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:937
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool isAligned() const
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatAddExpr.h:290
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
Header file for the IsTrue value trait.
Header file for the IsUpper type trait.
MT2::CompositeType CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:112
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: DMatTDMatAddExpr.h:300
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:87
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
Expression object for dense matrix-transpose dense matrix additions.The DMatTDMatAddExpr class repres...
Definition: DMatTDMatAddExpr.h:101
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849