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 
72 #include <blaze/system/Blocking.h>
74 #include <blaze/util/Assert.h>
76 #include <blaze/util/DisableIf.h>
77 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/Exception.h>
80 #include <blaze/util/mpl/And.h>
81 #include <blaze/util/mpl/Max.h>
82 #include <blaze/util/mpl/Not.h>
83 #include <blaze/util/mpl/Or.h>
84 #include <blaze/util/SelectType.h>
85 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS DMATTDMATADDEXPR
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
104 template< typename MT1 // Type of the left-hand side dense matrix
105  , typename MT2 > // Type of the right-hand side dense matrix
106 class DMatTDMatAddExpr : public DenseMatrix< DMatTDMatAddExpr<MT1,MT2>, false >
107  , private MatMatAddExpr
108  , private Computation
109 {
110  private:
111  //**Type definitions****************************************************************************
112  typedef typename MT1::ResultType RT1;
113  typedef typename MT2::ResultType RT2;
114  typedef typename MT1::ReturnType RN1;
115  typedef typename MT2::ReturnType RN2;
116  typedef typename MT1::CompositeType CT1;
117  typedef typename MT2::CompositeType CT2;
118  //**********************************************************************************************
119 
120  //**Return type evaluation**********************************************************************
122 
127  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
128 
131  //**********************************************************************************************
132 
133  //**Serial evaluation strategy******************************************************************
135 
141  enum { useAssign = RequiresEvaluation<MT1>::value || RequiresEvaluation<MT2>::value || !returnExpr };
142 
144  template< typename MT >
146  struct UseAssign {
147  enum { value = useAssign };
148  };
150  //**********************************************************************************************
151 
152  //**Parallel evaluation strategy****************************************************************
154 
160  template< typename MT >
161  struct UseSMPAssign {
162  enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
163  };
165  //**********************************************************************************************
166 
167  public:
168  //**Type definitions****************************************************************************
174 
177 
179  typedef const ResultType CompositeType;
180 
182  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
183 
185  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
186  //**********************************************************************************************
187 
188  //**Compilation flags***************************************************************************
190  enum { vectorizable = 0 };
191 
193  enum { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
194  //**********************************************************************************************
195 
196  //**Constructor*********************************************************************************
202  explicit inline DMatTDMatAddExpr( const MT1& lhs, const MT2& rhs )
203  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
204  , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
205  {
206  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
207  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
208  }
209  //**********************************************************************************************
210 
211  //**Access operator*****************************************************************************
218  inline ReturnType operator()( size_t i, size_t j ) const {
219  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
220  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
221  return lhs_(i,j) + rhs_(i,j);
222  }
223  //**********************************************************************************************
224 
225  //**At function*********************************************************************************
233  inline ReturnType at( size_t i, size_t j ) const {
234  if( i >= lhs_.rows() ) {
235  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
236  }
237  if( j >= lhs_.columns() ) {
238  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
239  }
240  return (*this)(i,j);
241  }
242  //**********************************************************************************************
243 
244  //**Rows function*******************************************************************************
249  inline size_t rows() const {
250  return lhs_.rows();
251  }
252  //**********************************************************************************************
253 
254  //**Columns function****************************************************************************
259  inline size_t columns() const {
260  return lhs_.columns();
261  }
262  //**********************************************************************************************
263 
264  //**Left operand access*************************************************************************
269  inline LeftOperand leftOperand() const {
270  return lhs_;
271  }
272  //**********************************************************************************************
273 
274  //**Right operand access************************************************************************
279  inline RightOperand rightOperand() const {
280  return rhs_;
281  }
282  //**********************************************************************************************
283 
284  //**********************************************************************************************
290  template< typename T >
291  inline bool canAlias( const T* alias ) const {
292  return ( IsExpression<MT1>::value && ( RequiresEvaluation<MT1>::value ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
293  ( IsExpression<MT2>::value && ( RequiresEvaluation<MT2>::value ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
294  }
295  //**********************************************************************************************
296 
297  //**********************************************************************************************
303  template< typename T >
304  inline bool isAliased( const T* alias ) const {
305  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
306  }
307  //**********************************************************************************************
308 
309  //**********************************************************************************************
314  inline bool isAligned() const {
315  return lhs_.isAligned() && rhs_.isAligned();
316  }
317  //**********************************************************************************************
318 
319  //**********************************************************************************************
324  inline bool canSMPAssign() const {
325  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
326  ( rows() > SMP_DMATTDMATADD_THRESHOLD );
327  }
328  //**********************************************************************************************
329 
330  private:
331  //**Member variables****************************************************************************
332  LeftOperand lhs_;
333  RightOperand rhs_;
334  //**********************************************************************************************
335 
336  //**Assignment to dense matrices****************************************************************
350  template< typename MT // Type of the target dense matrix
351  , bool SO2 > // Storage order of the target dense matrix
352  friend inline typename DisableIf< UseAssign<MT> >::Type
353  assign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
354  {
356 
357  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
358  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
359 
360  const size_t m( rhs.rows() );
361  const size_t n( rhs.columns() );
362  const size_t block( BLOCK_SIZE );
363 
364  for( size_t ii=0UL; ii<m; ii+=block ) {
365  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
366  for( size_t jj=0UL; jj<n; jj+=block ) {
367  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
368  for( size_t i=ii; i<iend; ++i ) {
369  for( size_t j=jj; j<jend; ++j ) {
370  (~lhs)(i,j) = rhs.lhs_(i,j) + rhs.rhs_(i,j);
371  }
372  }
373  }
374  }
375  }
377  //**********************************************************************************************
378 
379  //**Assignment to dense matrices****************************************************************
393  template< typename MT // Type of the target dense matrix
394  , bool SO2 > // Storage order of the target dense matrix
395  friend inline typename EnableIf< UseAssign<MT> >::Type
396  assign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
397  {
399 
400  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
401  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
402 
403  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
404  addAssign( ~lhs, rhs.rhs_ );
405  }
406  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
407  addAssign( ~lhs, rhs.lhs_ );
408  }
409  else {
410  assign ( ~lhs, rhs.lhs_ );
411  addAssign( ~lhs, rhs.rhs_ );
412  }
413  }
415  //**********************************************************************************************
416 
417  //**Assignment to sparse matrices***************************************************************
429  template< typename MT // Type of the target sparse matrix
430  , bool SO2 > // Storage order of the target sparse matrix
431  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
432  {
434 
435  typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
436 
443 
444  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
445  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
446 
447  const TmpType tmp( serial( rhs ) );
448  assign( ~lhs, tmp );
449  }
451  //**********************************************************************************************
452 
453  //**Addition assignment to dense matrices*******************************************************
467  template< typename MT // Type of the target dense matrix
468  , bool SO2 > // Storage order of the target dense matrix
469  friend inline typename DisableIf< UseAssign<MT> >::Type
470  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
471  {
473 
474  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
475  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
476 
477  const size_t m( rhs.rows() );
478  const size_t n( rhs.columns() );
479  const size_t block( BLOCK_SIZE );
480 
481  for( size_t ii=0UL; ii<m; ii+=block ) {
482  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
483  for( size_t jj=0UL; jj<n; jj+=block ) {
484  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
485  for( size_t i=ii; i<iend; ++i ) {
486  for( size_t j=jj; j<jend; ++j ) {
487  (~lhs)(i,j) += rhs.lhs_(i,j) + rhs.rhs_(i,j);
488  }
489  }
490  }
491  }
492  }
494  //**********************************************************************************************
495 
496  //**Addition assignment to dense matrices*******************************************************
510  template< typename MT // Type of the target dense matrix
511  , bool SO2 > // Storage order of the target dense matrix
512  friend inline typename EnableIf< UseAssign<MT> >::Type
513  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
514  {
516 
517  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
518  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
519 
520  addAssign( ~lhs, rhs.lhs_ );
521  addAssign( ~lhs, rhs.rhs_ );
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****************************************************
544  template< typename MT // Type of the target dense matrix
545  , bool SO2 > // Storage order of the target dense matrix
546  friend inline typename DisableIf< UseAssign<MT> >::Type
547  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
548  {
550 
551  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
552  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
553 
554  const size_t m( rhs.rows() );
555  const size_t n( rhs.columns() );
556  const size_t block( BLOCK_SIZE );
557 
558  for( size_t ii=0UL; ii<m; ii+=block ) {
559  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
560  for( size_t jj=0UL; jj<n; jj+=block ) {
561  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
562  for( size_t i=ii; i<iend; ++i ) {
563  for( size_t j=jj; j<jend; ++j ) {
564  (~lhs)(i,j) -= rhs.lhs_(i,j) + rhs.rhs_(i,j);
565  }
566  }
567  }
568  }
569  }
571  //**********************************************************************************************
572 
573  //**Subtraction assignment to dense matrices****************************************************
587  template< typename MT // Type of the target dense matrix
588  , bool SO2 > // Storage order of the target dense matrix
589  friend inline typename EnableIf< UseAssign<MT> >::Type
590  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
591  {
593 
594  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
595  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
596 
597  subAssign( ~lhs, rhs.lhs_ );
598  subAssign( ~lhs, rhs.rhs_ );
599  }
601  //**********************************************************************************************
602 
603  //**Subtraction assignment to sparse matrices***************************************************
604  // No special implementation for the subtraction assignment to sparse matrices.
605  //**********************************************************************************************
606 
607  //**Multiplication assignment to dense matrices*************************************************
608  // No special implementation for the multiplication assignment to dense matrices.
609  //**********************************************************************************************
610 
611  //**Multiplication assignment to sparse matrices************************************************
612  // No special implementation for the multiplication assignment to sparse matrices.
613  //**********************************************************************************************
614 
615  //**SMP assignment to dense matrices************************************************************
629  template< typename MT // Type of the target dense matrix
630  , bool SO2 > // Storage order of the target dense matrix
631  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
632  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
633  {
635 
636  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
637  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
638 
639  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
640  smpAddAssign( ~lhs, rhs.rhs_ );
641  }
642  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
643  smpAddAssign( ~lhs, rhs.lhs_ );
644  }
645  else {
646  smpAssign ( ~lhs, rhs.lhs_ );
647  smpAddAssign( ~lhs, rhs.rhs_ );
648  }
649  }
651  //**********************************************************************************************
652 
653  //**SMP assignment to sparse matrices***********************************************************
667  template< typename MT // Type of the target sparse matrix
668  , bool SO2 > // Storage order of the target sparse matrix
669  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
670  smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
671  {
673 
674  typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
675 
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  const TmpType tmp( rhs );
687  smpAssign( ~lhs, tmp );
688  }
690  //**********************************************************************************************
691 
692  //**SMP addition assignment to dense matrices***************************************************
707  template< typename MT // Type of the target dense matrix
708  , bool SO2 > // Storage order of the target dense matrix
709  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
710  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
711  {
713 
714  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
715  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
716 
717  smpAddAssign( ~lhs, rhs.lhs_ );
718  smpAddAssign( ~lhs, rhs.rhs_ );
719  }
721  //**********************************************************************************************
722 
723  //**SMP addition assignment to sparse matrices**************************************************
724  // No special implementation for the SMP addition assignment to sparse matrices.
725  //**********************************************************************************************
726 
727  //**SMP subtraction assignment to dense matrices************************************************
742  template< typename MT // Type of the target dense matrix
743  , bool SO2 > // Storage order of the target dense matrix
744  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
745  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatTDMatAddExpr& rhs )
746  {
748 
749  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
750  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
751 
752  smpSubAssign( ~lhs, rhs.lhs_ );
753  smpSubAssign( ~lhs, rhs.rhs_ );
754  }
756  //**********************************************************************************************
757 
758  //**SMP subtraction assignment to sparse matrices***********************************************
759  // No special implementation for the SMP subtraction assignment to sparse matrices.
760  //**********************************************************************************************
761 
762  //**SMP multiplication assignment to dense matrices*********************************************
763  // No special implementation for the SMP multiplication assignment to dense matrices.
764  //**********************************************************************************************
765 
766  //**SMP multiplication assignment to sparse matrices********************************************
767  // No special implementation for the SMP multiplication assignment to sparse matrices.
768  //**********************************************************************************************
769 
770  //**Compile time checks*************************************************************************
778  //**********************************************************************************************
779 };
780 //*************************************************************************************************
781 
782 
783 
784 
785 //=================================================================================================
786 //
787 // GLOBAL BINARY ARITHMETIC OPERATORS
788 //
789 //=================================================================================================
790 
791 //*************************************************************************************************
820 template< typename T1 // Type of the left-hand side dense matrix
821  , typename T2 > // Type of the right-hand side dense matrix
822 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
823  , const DMatTDMatAddExpr<T1,T2> >::Type
825 {
827 
828  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
829  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
830  }
831 
832  return DMatTDMatAddExpr<T1,T2>( ~lhs, ~rhs );
833 }
834 //*************************************************************************************************
835 
836 
837 //*************************************************************************************************
866 template< typename T1 // Type of the left-hand side dense matrix
867  , typename T2 > // Type of the right-hand side dense matrix
868 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
869  , const DMatTDMatAddExpr<T2,T1> >::Type
871 {
873 
874  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
875  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
876  }
877 
878  return DMatTDMatAddExpr<T2,T1>( ~rhs, ~lhs );
879 }
880 //*************************************************************************************************
881 
882 
883 
884 
885 //=================================================================================================
886 //
887 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
888 //
889 //=================================================================================================
890 
891 //*************************************************************************************************
905 template< typename T1 // Type of the left-hand side dense matrix
906  , typename T2 > // Type of the right-hand side dense matrix
907 inline typename EnableIf< And< IsSymmetric<T1>, Not< IsSymmetric<T2> > >
908  , const typename AddExprTrait<T1,T2>::Type >::Type
909  operator+( const DenseMatrix<T1,false>& lhs, const DenseMatrix<T2,true>& rhs )
910 {
912 
913  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
914  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
915  }
916 
917  return trans( ~lhs ) + ~rhs;
918 }
920 //*************************************************************************************************
921 
922 
923 //*************************************************************************************************
937 template< typename T1 // Type of the left-hand side dense matrix
938  , typename T2 > // Type of the right-hand side dense matrix
939 inline typename EnableIf< IsSymmetric<T2>
940  , const typename AddExprTrait<T1,T2>::Type >::Type
941  operator+( const DenseMatrix<T1,false>& lhs, const DenseMatrix<T2,true>& rhs )
942 {
944 
945  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
946  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
947  }
948 
949  return (~lhs) + trans( ~rhs );
950 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
969 template< typename T1 // Type of the left-hand side dense matrix
970  , typename T2 > // Type of the right-hand side dense matrix
971 inline typename EnableIf< And< Not< IsSymmetric<T1> >, IsSymmetric<T2> >
972  , const typename AddExprTrait<T2,T1>::Type >::Type
973  operator+( const DenseMatrix<T1,true>& lhs, const DenseMatrix<T2,false>& rhs )
974 {
976 
977  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
978  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
979  }
980 
981  return trans( ~rhs ) + (~lhs);
982 }
984 //*************************************************************************************************
985 
986 
987 //*************************************************************************************************
1001 template< typename T1 // Type of the left-hand side dense matrix
1002  , typename T2 > // Type of the right-hand side dense matrix
1003 inline typename EnableIf< IsSymmetric<T1>
1004  , const typename AddExprTrait<T2,T1>::Type >::Type
1005  operator+( const DenseMatrix<T1,true>& lhs, const DenseMatrix<T2,false>& rhs )
1006 {
1008 
1009  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
1010  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1011  }
1012 
1013  return (~rhs) + trans( ~lhs );
1014 }
1016 //*************************************************************************************************
1017 
1018 
1019 
1020 
1021 //=================================================================================================
1022 //
1023 // ROWS SPECIALIZATIONS
1024 //
1025 //=================================================================================================
1026 
1027 //*************************************************************************************************
1029 template< typename MT1, typename MT2 >
1030 struct Rows< DMatTDMatAddExpr<MT1,MT2> >
1031  : public Max< Rows<MT1>, Rows<MT2> >
1032 {};
1034 //*************************************************************************************************
1035 
1036 
1037 
1038 
1039 //=================================================================================================
1040 //
1041 // COLUMNS SPECIALIZATIONS
1042 //
1043 //=================================================================================================
1044 
1045 //*************************************************************************************************
1047 template< typename MT1, typename MT2 >
1048 struct Columns< DMatTDMatAddExpr<MT1,MT2> >
1049  : public Max< Columns<MT1>, Columns<MT2> >
1050 {};
1052 //*************************************************************************************************
1053 
1054 
1055 
1056 
1057 //=================================================================================================
1058 //
1059 // ISALIGNED SPECIALIZATIONS
1060 //
1061 //=================================================================================================
1062 
1063 //*************************************************************************************************
1065 template< typename MT1, typename MT2 >
1066 struct IsAligned< DMatTDMatAddExpr<MT1,MT2> >
1067  : public IsTrue< And< IsAligned<MT1>, IsAligned<MT2> >::value >
1068 {};
1070 //*************************************************************************************************
1071 
1072 
1073 
1074 
1075 //=================================================================================================
1076 //
1077 // ISSYMMETRIC SPECIALIZATIONS
1078 //
1079 //=================================================================================================
1080 
1081 //*************************************************************************************************
1083 template< typename MT1, typename MT2 >
1084 struct IsSymmetric< DMatTDMatAddExpr<MT1,MT2> >
1085  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
1086 {};
1088 //*************************************************************************************************
1089 
1090 
1091 
1092 
1093 //=================================================================================================
1094 //
1095 // ISHERMITIAN SPECIALIZATIONS
1096 //
1097 //=================================================================================================
1098 
1099 //*************************************************************************************************
1101 template< typename MT1, typename MT2 >
1102 struct IsHermitian< DMatTDMatAddExpr<MT1,MT2> >
1103  : public IsTrue< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
1104 {};
1106 //*************************************************************************************************
1107 
1108 
1109 
1110 
1111 //=================================================================================================
1112 //
1113 // ISLOWER SPECIALIZATIONS
1114 //
1115 //=================================================================================================
1116 
1117 //*************************************************************************************************
1119 template< typename MT1, typename MT2 >
1120 struct IsLower< DMatTDMatAddExpr<MT1,MT2> >
1121  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
1122 {};
1124 //*************************************************************************************************
1125 
1126 
1127 
1128 
1129 //=================================================================================================
1130 //
1131 // ISUNILOWER SPECIALIZATIONS
1132 //
1133 //=================================================================================================
1134 
1135 //*************************************************************************************************
1137 template< typename MT1, typename MT2 >
1138 struct IsUniLower< DMatTDMatAddExpr<MT1,MT2> >
1139  : public IsTrue< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
1140  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
1141 {};
1143 //*************************************************************************************************
1144 
1145 
1146 
1147 
1148 //=================================================================================================
1149 //
1150 // ISSTRICTLYLOWER SPECIALIZATIONS
1151 //
1152 //=================================================================================================
1153 
1154 //*************************************************************************************************
1156 template< typename MT1, typename MT2 >
1157 struct IsStrictlyLower< DMatTDMatAddExpr<MT1,MT2> >
1158  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
1159 {};
1161 //*************************************************************************************************
1162 
1163 
1164 
1165 
1166 //=================================================================================================
1167 //
1168 // ISUPPER SPECIALIZATIONS
1169 //
1170 //=================================================================================================
1171 
1172 //*************************************************************************************************
1174 template< typename MT1, typename MT2 >
1175 struct IsUpper< DMatTDMatAddExpr<MT1,MT2> >
1176  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1177 {};
1179 //*************************************************************************************************
1180 
1181 
1182 
1183 
1184 //=================================================================================================
1185 //
1186 // ISUNIUPPER SPECIALIZATIONS
1187 //
1188 //=================================================================================================
1189 
1190 //*************************************************************************************************
1192 template< typename MT1, typename MT2 >
1193 struct IsUniUpper< DMatTDMatAddExpr<MT1,MT2> >
1194  : public IsTrue< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1195  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
1196 {};
1198 //*************************************************************************************************
1199 
1200 
1201 
1202 
1203 //=================================================================================================
1204 //
1205 // ISSTRICTLYUPPER SPECIALIZATIONS
1206 //
1207 //=================================================================================================
1208 
1209 //*************************************************************************************************
1211 template< typename MT1, typename MT2 >
1212 struct IsStrictlyUpper< DMatTDMatAddExpr<MT1,MT2> >
1213  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1214 {};
1216 //*************************************************************************************************
1217 
1218 
1219 
1220 
1221 //=================================================================================================
1222 //
1223 // EXPRESSION TRAIT SPECIALIZATIONS
1224 //
1225 //=================================================================================================
1226 
1227 //*************************************************************************************************
1229 template< typename MT1, typename MT2, bool AF >
1230 struct SubmatrixExprTrait< DMatTDMatAddExpr<MT1,MT2>, AF >
1231 {
1232  public:
1233  //**********************************************************************************************
1234  typedef typename AddExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1235  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1236  //**********************************************************************************************
1237 };
1239 //*************************************************************************************************
1240 
1241 
1242 //*************************************************************************************************
1244 template< typename MT1, typename MT2 >
1245 struct RowExprTrait< DMatTDMatAddExpr<MT1,MT2> >
1246 {
1247  public:
1248  //**********************************************************************************************
1249  typedef typename AddExprTrait< typename RowExprTrait<const MT1>::Type
1250  , typename RowExprTrait<const MT2>::Type >::Type Type;
1251  //**********************************************************************************************
1252 };
1254 //*************************************************************************************************
1255 
1256 
1257 //*************************************************************************************************
1259 template< typename MT1, typename MT2 >
1260 struct ColumnExprTrait< DMatTDMatAddExpr<MT1,MT2> >
1261 {
1262  public:
1263  //**********************************************************************************************
1264  typedef typename AddExprTrait< typename ColumnExprTrait<const MT1>::Type
1265  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1266  //**********************************************************************************************
1267 };
1269 //*************************************************************************************************
1270 
1271 } // namespace blaze
1272 
1273 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Header file for the Max class template.
Header file for kernel specific block sizes.
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:207
#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:647
Header file for the ColumnExprTrait class template.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatAddExpr.h:171
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:172
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
Header file for the And class template.
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:170
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:721
Header file for the Computation base class.
Constraints on the storage order of matrix types.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatAddExpr.h:291
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:116
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:202
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:114
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatTDMatAddExpr.h:249
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.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatAddExpr.h:233
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:179
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: ColumnMajorMatrix.h:79
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:176
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
Header file for the DenseMatrix base class.
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
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatTDMatAddExpr.h:130
#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:259
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:304
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:169
Header file for the serial shim.
MT2::ResultType RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:113
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:185
#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: RowMajorMatrix.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:332
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:138
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.
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatTDMatAddExpr.h:173
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:333
RightOperand rightOperand() const
Returns the right-hand side transpose dense matrix operand.
Definition: DMatTDMatAddExpr.h:279
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatAddExpr.h:269
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
Constraints on the storage order of matrix types.
MT2::ReturnType RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:115
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:122
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:182
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:112
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatAddExpr.h:218
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
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:314
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
Header file for the IsUpper type trait.
Header file for exception macros.
MT2::CompositeType CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:117
Header file for the IsHermitian type trait.
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:324
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:106