DMatDMatAddExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATDMATADDEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
54 #include <blaze/math/SIMD.h>
76 #include <blaze/system/Inline.h>
78 #include <blaze/util/Assert.h>
80 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/mpl/And.h>
84 #include <blaze/util/mpl/If.h>
85 #include <blaze/util/mpl/Max.h>
86 #include <blaze/util/mpl/Or.h>
87 #include <blaze/util/Types.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS DMATDMATADDEXPR
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
105 template< typename MT1 // Type of the left-hand side dense matrix
106  , typename MT2 // Type of the right-hand side dense matrix
107  , bool SO > // Storage order
108 class DMatDMatAddExpr : public DenseMatrix< DMatDMatAddExpr<MT1,MT2,SO>, SO >
109  , private MatMatAddExpr
110  , private Computation
111 {
112  private:
113  //**Type definitions****************************************************************************
122  //**********************************************************************************************
123 
124  //**Return type evaluation**********************************************************************
126 
131  enum : bool { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
132 
135  //**********************************************************************************************
136 
137  //**Serial evaluation strategy******************************************************************
139 
145  enum : bool { useAssign = RequiresEvaluation<MT1>::value || RequiresEvaluation<MT2>::value || !returnExpr };
146 
148  template< typename MT >
150  struct UseAssign {
151  enum : bool { value = useAssign };
152  };
154  //**********************************************************************************************
155 
156  //**Parallel evaluation strategy****************************************************************
158 
164  template< typename MT >
165  struct UseSMPAssign {
166  enum : bool { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
167  };
169  //**********************************************************************************************
170 
171  public:
172  //**Type definitions****************************************************************************
178 
181 
184 
186  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
187 
189  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
190  //**********************************************************************************************
191 
192  //**ConstIterator class definition**************************************************************
196  {
197  public:
198  //**Type definitions*************************************************************************
199  typedef std::random_access_iterator_tag IteratorCategory;
200  typedef ElementType ValueType;
201  typedef ElementType* PointerType;
202  typedef ElementType& ReferenceType;
204 
205  // STL iterator requirements
206  typedef IteratorCategory iterator_category;
207  typedef ValueType value_type;
208  typedef PointerType pointer;
209  typedef ReferenceType reference;
210  typedef DifferenceType difference_type;
211 
214 
217  //*******************************************************************************************
218 
219  //**Constructor******************************************************************************
225  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right )
226  : left_ ( left ) // Iterator to the current left-hand side element
227  , right_( right ) // Iterator to the current right-hand side element
228  {}
229  //*******************************************************************************************
230 
231  //**Addition assignment operator*************************************************************
237  inline ConstIterator& operator+=( size_t inc ) {
238  left_ += inc;
239  right_ += inc;
240  return *this;
241  }
242  //*******************************************************************************************
243 
244  //**Subtraction assignment operator**********************************************************
250  inline ConstIterator& operator-=( size_t dec ) {
251  left_ -= dec;
252  right_ -= dec;
253  return *this;
254  }
255  //*******************************************************************************************
256 
257  //**Prefix increment operator****************************************************************
263  ++left_;
264  ++right_;
265  return *this;
266  }
267  //*******************************************************************************************
268 
269  //**Postfix increment operator***************************************************************
274  inline const ConstIterator operator++( int ) {
275  return ConstIterator( left_++, right_++ );
276  }
277  //*******************************************************************************************
278 
279  //**Prefix decrement operator****************************************************************
285  --left_;
286  --right_;
287  return *this;
288  }
289  //*******************************************************************************************
290 
291  //**Postfix decrement operator***************************************************************
296  inline const ConstIterator operator--( int ) {
297  return ConstIterator( left_--, right_-- );
298  }
299  //*******************************************************************************************
300 
301  //**Element access operator******************************************************************
306  inline ReturnType operator*() const {
307  return (*left_) + (*right_);
308  }
309  //*******************************************************************************************
310 
311  //**Load function****************************************************************************
316  inline auto load() const noexcept {
317  return left_.load() + right_.load();
318  }
319  //*******************************************************************************************
320 
321  //**Equality operator************************************************************************
327  inline bool operator==( const ConstIterator& rhs ) const {
328  return left_ == rhs.left_;
329  }
330  //*******************************************************************************************
331 
332  //**Inequality operator**********************************************************************
338  inline bool operator!=( const ConstIterator& rhs ) const {
339  return left_ != rhs.left_;
340  }
341  //*******************************************************************************************
342 
343  //**Less-than operator***********************************************************************
349  inline bool operator<( const ConstIterator& rhs ) const {
350  return left_ < rhs.left_;
351  }
352  //*******************************************************************************************
353 
354  //**Greater-than operator********************************************************************
360  inline bool operator>( const ConstIterator& rhs ) const {
361  return left_ > rhs.left_;
362  }
363  //*******************************************************************************************
364 
365  //**Less-or-equal-than operator**************************************************************
371  inline bool operator<=( const ConstIterator& rhs ) const {
372  return left_ <= rhs.left_;
373  }
374  //*******************************************************************************************
375 
376  //**Greater-or-equal-than operator***********************************************************
382  inline bool operator>=( const ConstIterator& rhs ) const {
383  return left_ >= rhs.left_;
384  }
385  //*******************************************************************************************
386 
387  //**Subtraction operator*********************************************************************
393  inline DifferenceType operator-( const ConstIterator& rhs ) const {
394  return left_ - rhs.left_;
395  }
396  //*******************************************************************************************
397 
398  //**Addition operator************************************************************************
405  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
406  return ConstIterator( it.left_ + inc, it.right_ + inc );
407  }
408  //*******************************************************************************************
409 
410  //**Addition operator************************************************************************
417  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
418  return ConstIterator( it.left_ + inc, it.right_ + inc );
419  }
420  //*******************************************************************************************
421 
422  //**Subtraction operator*********************************************************************
429  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
430  return ConstIterator( it.left_ - dec, it.right_ - dec );
431  }
432  //*******************************************************************************************
433 
434  private:
435  //**Member variables*************************************************************************
436  LeftIteratorType left_;
437  RightIteratorType right_;
438  //*******************************************************************************************
439  };
440  //**********************************************************************************************
441 
442  //**Compilation flags***************************************************************************
444  enum : bool { simdEnabled = MT1::simdEnabled && MT2::simdEnabled &&
446 
448  enum : bool { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
449  //**********************************************************************************************
450 
451  //**SIMD properties*****************************************************************************
453  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
454  //**********************************************************************************************
455 
456  //**Constructor*********************************************************************************
462  explicit inline DMatDMatAddExpr( const MT1& lhs, const MT2& rhs ) noexcept
463  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
464  , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
465  {
466  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
467  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
468  }
469  //**********************************************************************************************
470 
471  //**Access operator*****************************************************************************
478  inline ReturnType operator()( size_t i, size_t j ) const {
479  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
480  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
481  return lhs_(i,j) + rhs_(i,j);
482  }
483  //**********************************************************************************************
484 
485  //**At function*********************************************************************************
493  inline ReturnType at( size_t i, size_t j ) const {
494  if( i >= lhs_.rows() ) {
495  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
496  }
497  if( j >= lhs_.columns() ) {
498  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
499  }
500  return (*this)(i,j);
501  }
502  //**********************************************************************************************
503 
504  //**Load function*******************************************************************************
511  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
512  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
513  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
514  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
515  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
516  return lhs_.load(i,j) + rhs_.load(i,j);
517  }
518  //**********************************************************************************************
519 
520  //**Begin function******************************************************************************
526  inline ConstIterator begin( size_t i ) const {
527  return ConstIterator( lhs_.begin(i), rhs_.begin(i) );
528  }
529  //**********************************************************************************************
530 
531  //**End function********************************************************************************
537  inline ConstIterator end( size_t i ) const {
538  return ConstIterator( lhs_.end(i), rhs_.end(i) );
539  }
540  //**********************************************************************************************
541 
542  //**Rows function*******************************************************************************
547  inline size_t rows() const noexcept {
548  return lhs_.rows();
549  }
550  //**********************************************************************************************
551 
552  //**Columns function****************************************************************************
557  inline size_t columns() const noexcept {
558  return lhs_.columns();
559  }
560  //**********************************************************************************************
561 
562  //**Left operand access*************************************************************************
567  inline LeftOperand leftOperand() const noexcept {
568  return lhs_;
569  }
570  //**********************************************************************************************
571 
572  //**Right operand access************************************************************************
577  inline RightOperand rightOperand() const noexcept {
578  return rhs_;
579  }
580  //**********************************************************************************************
581 
582  //**********************************************************************************************
588  template< typename T >
589  inline bool canAlias( const T* alias ) const noexcept {
590  return ( IsExpression<MT1>::value && ( RequiresEvaluation<MT1>::value ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
591  ( IsExpression<MT2>::value && ( RequiresEvaluation<MT2>::value ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
592  }
593  //**********************************************************************************************
594 
595  //**********************************************************************************************
601  template< typename T >
602  inline bool isAliased( const T* alias ) const noexcept {
603  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
604  }
605  //**********************************************************************************************
606 
607  //**********************************************************************************************
612  inline bool isAligned() const noexcept {
613  return lhs_.isAligned() && rhs_.isAligned();
614  }
615  //**********************************************************************************************
616 
617  //**********************************************************************************************
622  inline bool canSMPAssign() const noexcept {
623  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
624  ( rows() * columns() >= SMP_DMATDMATADD_THRESHOLD );
625  }
626  //**********************************************************************************************
627 
628  private:
629  //**Member variables****************************************************************************
630  LeftOperand lhs_;
631  RightOperand rhs_;
632  //**********************************************************************************************
633 
634  //**Assignment to dense matrices****************************************************************
648  template< typename MT // Type of the target dense matrix
649  , bool SO2 > // Storage order of the target dense matrix
650  friend inline EnableIf_< UseAssign<MT> >
651  assign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
652  {
654 
655  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
656  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
657 
658  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
659  addAssign( ~lhs, rhs.rhs_ );
660  }
661  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
662  addAssign( ~lhs, rhs.lhs_ );
663  }
664  else {
665  assign ( ~lhs, rhs.lhs_ );
666  addAssign( ~lhs, rhs.rhs_ );
667  }
668  }
670  //**********************************************************************************************
671 
672  //**Assignment to sparse matrices***************************************************************
686  template< typename MT // Type of the target sparse matrix
687  , bool SO2 > // Storage order of the target sparse matrix
688  friend inline EnableIf_< UseAssign<MT> >
689  assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
690  {
692 
694 
701 
702  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
703  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
704 
705  const TmpType tmp( serial( rhs ) );
706  assign( ~lhs, tmp );
707  }
709  //**********************************************************************************************
710 
711  //**Addition assignment to dense matrices*******************************************************
725  template< typename MT // Type of the target dense matrix
726  , bool SO2 > // Storage order of the target dense matrix
727  friend inline EnableIf_< UseAssign<MT> >
728  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
729  {
731 
732  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
733  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
734 
735  addAssign( ~lhs, rhs.lhs_ );
736  addAssign( ~lhs, rhs.rhs_ );
737  }
739  //**********************************************************************************************
740 
741  //**Addition assignment to sparse matrices******************************************************
742  // No special implementation for the addition assignment to sparse matrices.
743  //**********************************************************************************************
744 
745  //**Subtraction assignment to dense matrices****************************************************
759  template< typename MT // Type of the target dense matrix
760  , bool SO2 > // Storage order of the target dense matrix
761  friend inline EnableIf_< UseAssign<MT> >
762  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
763  {
765 
766  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
767  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
768 
769  subAssign( ~lhs, rhs.lhs_ );
770  subAssign( ~lhs, rhs.rhs_ );
771  }
773  //**********************************************************************************************
774 
775  //**Subtraction assignment to sparse matrices***************************************************
776  // No special implementation for the subtraction assignment to sparse matrices.
777  //**********************************************************************************************
778 
779  //**Multiplication assignment to dense matrices*************************************************
780  // No special implementation for the multiplication assignment to dense matrices.
781  //**********************************************************************************************
782 
783  //**Multiplication assignment to sparse matrices************************************************
784  // No special implementation for the multiplication assignment to sparse matrices.
785  //**********************************************************************************************
786 
787  //**SMP assignment to dense matrices************************************************************
801  template< typename MT // Type of the target dense matrix
802  , bool SO2 > // Storage order of the target dense matrix
803  friend inline EnableIf_< UseSMPAssign<MT> >
804  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
805  {
807 
808  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
809  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
810 
811  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
812  smpAddAssign( ~lhs, rhs.rhs_ );
813  }
814  else if( !IsExpression<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
815  smpAddAssign( ~lhs, rhs.lhs_ );
816  }
817  else {
818  smpAssign ( ~lhs, rhs.lhs_ );
819  smpAddAssign( ~lhs, rhs.rhs_ );
820  }
821  }
823  //**********************************************************************************************
824 
825  //**SMP assignment to sparse matrices***********************************************************
839  template< typename MT // Type of the target sparse matrix
840  , bool SO2 > // Storage order of the target sparse matrix
841  friend inline EnableIf_< UseSMPAssign<MT> >
843  {
845 
847 
854 
855  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
856  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
857 
858  const TmpType tmp( rhs );
859  smpAssign( ~lhs, tmp );
860  }
862  //**********************************************************************************************
863 
864  //**SMP addition assignment to dense matrices***************************************************
878  template< typename MT // Type of the target dense matrix
879  , bool SO2 > // Storage order of the target dense matrix
880  friend inline EnableIf_< UseSMPAssign<MT> >
882  {
884 
885  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
886  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
887 
888  smpAddAssign( ~lhs, rhs.lhs_ );
889  smpAddAssign( ~lhs, rhs.rhs_ );
890  }
892  //**********************************************************************************************
893 
894  //**SMP addition assignment to sparse matrices**************************************************
895  // No special implementation for the SMP addition assignment to sparse matrices.
896  //**********************************************************************************************
897 
898  //**SMP subtraction assignment to dense matrices************************************************
912  template< typename MT // Type of the target dense matrix
913  , bool SO2 > // Storage order of the target dense matrix
914  friend inline EnableIf_< UseSMPAssign<MT> >
916  {
918 
919  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
920  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
921 
922  smpSubAssign( ~lhs, rhs.lhs_ );
923  smpSubAssign( ~lhs, rhs.rhs_ );
924  }
926  //**********************************************************************************************
927 
928  //**SMP subtraction assignment to sparse matrices***********************************************
929  // No special implementation for the SMP subtraction assignment to sparse matrices.
930  //**********************************************************************************************
931 
932  //**SMP multiplication assignment to dense matrices*********************************************
933  // No special implementation for the SMP multiplication assignment to dense matrices.
934  //**********************************************************************************************
935 
936  //**SMP multiplication assignment to sparse matrices********************************************
937  // No special implementation for the SMP multiplication assignment to sparse matrices.
938  //**********************************************************************************************
939 
940  //**Compile time checks*************************************************************************
947  //**********************************************************************************************
948 };
949 //*************************************************************************************************
950 
951 
952 
953 
954 //=================================================================================================
955 //
956 // GLOBAL BINARY ARITHMETIC OPERATORS
957 //
958 //=================================================================================================
959 
960 //*************************************************************************************************
987 template< typename T1 // Type of the left-hand side dense matrix
988  , typename T2 // Type of the right-hand side dense matrix
989  , bool SO > // Storage order
990 inline const DMatDMatAddExpr<T1,T2,SO>
992 {
994 
995  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
996  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
997  }
998 
999  return DMatDMatAddExpr<T1,T2,SO>( ~lhs, ~rhs );
1000 }
1001 //*************************************************************************************************
1002 
1003 
1004 
1005 
1006 //=================================================================================================
1007 //
1008 // ROWS SPECIALIZATIONS
1009 //
1010 //=================================================================================================
1011 
1012 //*************************************************************************************************
1014 template< typename MT1, typename MT2, bool SO >
1015 struct Rows< DMatDMatAddExpr<MT1,MT2,SO> >
1016  : public Max< Rows<MT1>, Rows<MT2> >
1017 {};
1019 //*************************************************************************************************
1020 
1021 
1022 
1023 
1024 //=================================================================================================
1025 //
1026 // COLUMNS SPECIALIZATIONS
1027 //
1028 //=================================================================================================
1029 
1030 //*************************************************************************************************
1032 template< typename MT1, typename MT2, bool SO >
1033 struct Columns< DMatDMatAddExpr<MT1,MT2,SO> >
1034  : public Max< Columns<MT1>, Columns<MT2> >
1035 {};
1037 //*************************************************************************************************
1038 
1039 
1040 
1041 
1042 //=================================================================================================
1043 //
1044 // ISALIGNED SPECIALIZATIONS
1045 //
1046 //=================================================================================================
1047 
1048 //*************************************************************************************************
1050 template< typename MT1, typename MT2, bool SO >
1051 struct IsAligned< DMatDMatAddExpr<MT1,MT2,SO> >
1052  : public BoolConstant< And< IsAligned<MT1>, IsAligned<MT2> >::value >
1053 {};
1055 //*************************************************************************************************
1056 
1057 
1058 
1059 
1060 //=================================================================================================
1061 //
1062 // ISPADDED SPECIALIZATIONS
1063 //
1064 //=================================================================================================
1065 
1066 //*************************************************************************************************
1068 template< typename MT1, typename MT2, bool SO >
1069 struct IsPadded< DMatDMatAddExpr<MT1,MT2,SO> >
1070  : public BoolConstant< And< IsPadded<MT1>, IsPadded<MT2> >::value >
1071 {};
1073 //*************************************************************************************************
1074 
1075 
1076 
1077 
1078 //=================================================================================================
1079 //
1080 // ISSYMMETRIC SPECIALIZATIONS
1081 //
1082 //=================================================================================================
1083 
1084 //*************************************************************************************************
1086 template< typename MT1, typename MT2, bool SO >
1087 struct IsSymmetric< DMatDMatAddExpr<MT1,MT2,SO> >
1088  : public BoolConstant< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
1089 {};
1091 //*************************************************************************************************
1092 
1093 
1094 
1095 
1096 //=================================================================================================
1097 //
1098 // ISHERMITIAN SPECIALIZATIONS
1099 //
1100 //=================================================================================================
1101 
1102 //*************************************************************************************************
1104 template< typename MT1, typename MT2, bool SO >
1105 struct IsHermitian< DMatDMatAddExpr<MT1,MT2,SO> >
1106  : public BoolConstant< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
1107 {};
1109 //*************************************************************************************************
1110 
1111 
1112 
1113 
1114 //=================================================================================================
1115 //
1116 // ISLOWER SPECIALIZATIONS
1117 //
1118 //=================================================================================================
1119 
1120 //*************************************************************************************************
1122 template< typename MT1, typename MT2, bool SO >
1123 struct IsLower< DMatDMatAddExpr<MT1,MT2,SO> >
1124  : public BoolConstant< And< IsLower<MT1>, IsLower<MT2> >::value >
1125 {};
1127 //*************************************************************************************************
1128 
1129 
1130 
1131 
1132 //=================================================================================================
1133 //
1134 // ISUNILOWER SPECIALIZATIONS
1135 //
1136 //=================================================================================================
1137 
1138 //*************************************************************************************************
1140 template< typename MT1, typename MT2, bool SO >
1141 struct IsUniLower< DMatDMatAddExpr<MT1,MT2,SO> >
1142  : public BoolConstant< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
1143  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
1144 {};
1146 //*************************************************************************************************
1147 
1148 
1149 
1150 
1151 //=================================================================================================
1152 //
1153 // ISSTRICTLYLOWER SPECIALIZATIONS
1154 //
1155 //=================================================================================================
1156 
1157 //*************************************************************************************************
1159 template< typename MT1, typename MT2, bool SO >
1160 struct IsStrictlyLower< DMatDMatAddExpr<MT1,MT2,SO> >
1161  : public BoolConstant< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
1162 {};
1164 //*************************************************************************************************
1165 
1166 
1167 
1168 
1169 //=================================================================================================
1170 //
1171 // ISUPPER SPECIALIZATIONS
1172 //
1173 //=================================================================================================
1174 
1175 //*************************************************************************************************
1177 template< typename MT1, typename MT2, bool SO >
1178 struct IsUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1179  : public BoolConstant< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1180 {};
1182 //*************************************************************************************************
1183 
1184 
1185 
1186 
1187 //=================================================================================================
1188 //
1189 // ISUNIUPPER SPECIALIZATIONS
1190 //
1191 //=================================================================================================
1192 
1193 //*************************************************************************************************
1195 template< typename MT1, typename MT2, bool SO >
1196 struct IsUniUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1197  : public BoolConstant< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1198  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
1199 {};
1201 //*************************************************************************************************
1202 
1203 
1204 
1205 
1206 //=================================================================================================
1207 //
1208 // ISSTRICTLYUPPER SPECIALIZATIONS
1209 //
1210 //=================================================================================================
1211 
1212 //*************************************************************************************************
1214 template< typename MT1, typename MT2, bool SO >
1215 struct IsStrictlyUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1216  : public BoolConstant< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1217 {};
1219 //*************************************************************************************************
1220 
1221 
1222 
1223 
1224 //=================================================================================================
1225 //
1226 // EXPRESSION TRAIT SPECIALIZATIONS
1227 //
1228 //=================================================================================================
1229 
1230 //*************************************************************************************************
1232 template< typename MT1, typename MT2, bool SO, bool AF >
1233 struct SubmatrixExprTrait< DMatDMatAddExpr<MT1,MT2,SO>, AF >
1234 {
1235  public:
1236  //**********************************************************************************************
1239  //**********************************************************************************************
1240 };
1242 //*************************************************************************************************
1243 
1244 
1245 //*************************************************************************************************
1247 template< typename MT1, typename MT2, bool SO >
1248 struct RowExprTrait< DMatDMatAddExpr<MT1,MT2,SO> >
1249 {
1250  public:
1251  //**********************************************************************************************
1254  //**********************************************************************************************
1255 };
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1262 template< typename MT1, typename MT2, bool SO >
1263 struct ColumnExprTrait< DMatDMatAddExpr<MT1,MT2,SO> >
1264 {
1265  public:
1266  //**********************************************************************************************
1269  //**********************************************************************************************
1270 };
1272 //*************************************************************************************************
1273 
1274 } // namespace blaze
1275 
1276 #endif
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatDMatAddExpr.h:306
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:360
typename SubmatrixExprTrait< MT, AF >::Type SubmatrixExprTrait_
Auxiliary alias declaration for the SubmatrixExprTrait type trait.The SubmatrixExprTrait_ alias decla...
Definition: SubmatrixExprTrait.h:134
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Header file for the Max class template.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatAddExpr.h:262
DMatDMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatAddExpr class.
Definition: DMatDMatAddExpr.h:462
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatAddExpr.h:237
ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatAddExpr.h:225
PointerType pointer
Pointer return type.
Definition: DMatDMatAddExpr.h:208
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatAddExpr.h:250
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatDMatAddExpr.h:203
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:721
Header file for basic type definitions.
EnableIf_< IsDenseMatrix< MT1 > > 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 serial shim.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
#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:61
Header file for the ColumnExprTrait class template.
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:189
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
ElementType_< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:121
Header file for the And class template.
ElementType * PointerType
Pointer return type.
Definition: DMatDMatAddExpr.h:201
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:163
Header file for the AddExprTrait class template.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatAddExpr.h:180
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatAddExpr.h:199
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.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatAddExpr.h:602
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatAddExpr.h:557
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatDMatAddExpr.h:177
Header file for the RequiresEvaluation type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:567
Header file for the IsUniLower type trait.
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:115
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > 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
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:71
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:119
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:114
Constraint on the data type.
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
Iterator over the elements of the dense matrix.
Definition: DMatDMatAddExpr.h:195
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatAddExpr.h:175
AddTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatAddExpr.h:174
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Constraint on the data type.
ConstIterator_< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:213
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DMatDMatAddExpr.h:437
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatDMatAddExpr.h:526
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:327
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatAddExpr.h:547
Expression object for dense matrix-dense matrix additions.The DMatDMatAddExpr class represents the co...
Definition: DMatDMatAddExpr.h:108
typename RowExprTrait< MT >::Type RowExprTrait_
Auxiliary alias declaration for the RowExprTrait type trait.The RowExprTrait_ alias declaration provi...
Definition: RowExprTrait.h:134
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatAddExpr.h:393
Header file for the IsSymmetric type trait.
typename AddExprTrait< T1, T2 >::Type AddExprTrait_
Auxiliary alias declaration for the AddExprTrait class template.The AddExprTrait_ alias declaration p...
Definition: AddExprTrait.h:219
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatDMatAddExpr.h:296
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
EnableIf_< IsDenseMatrix< MT1 > > 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 Or class template.
IfTrue_< useAssign, const ResultType, const DMatDMatAddExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatDMatAddExpr.h:183
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the HasSIMDAdd type trait.
ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatDMatAddExpr.h:284
Header file for the DenseMatrix base class.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatAddExpr.h:478
Header file for the Columns type trait.
ReturnType_< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:117
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatDMatAddExpr.h:537
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:577
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:119
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:405
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
Base class for all matrix/matrix addition expression templates.The MatMatAddExpr class serves as a ta...
Definition: MatMatAddExpr.h:65
ReferenceType reference
Reference return type.
Definition: DMatDMatAddExpr.h:209
Evaluation of the expression type type of a submatrix operation.Via this type trait it is possible to...
Definition: SubmatrixExprTrait.h:80
Header file for the IsLower type trait.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:349
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:511
Header file for the IsAligned type trait.
typename ColumnExprTrait< MT >::Type ColumnExprTrait_
Auxiliary alias declaration for the ColumnExprTrait type trait.The ColumnExprTrait_ alias declaration...
Definition: ColumnExprTrait.h:133
#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:60
Constraints on the storage order of matrix types.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatAddExpr.h:589
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:186
Evaluation of the expression type type of a row operation.Via this type trait it is possible to evalu...
Definition: RowExprTrait.h:79
#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:109
AddExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatAddExpr.h:134
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatAddExpr.h:493
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:631
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:316
Header file for the IsPadded type trait.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDMatAddExpr.h:612
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
Header file for the SubmatrixExprTrait class template.
Header file for run time assertion macros.
Compile time value evaluation.The Max class template selects the larger of the two given template arg...
Definition: Max.h:72
Header file for the addition trait.
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatAddExpr.h:202
ElementType_< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:120
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
Constraint on the data type.
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:200
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:93
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
Header file for the MatMatAddExpr base class.
const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatAddExpr.h:274
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
#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:84
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatDMatAddExpr.h:417
ReturnType_< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:116
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:382
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
ConstIterator_< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:216
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatAddExpr.h:622
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:371
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatAddExpr.h:436
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatAddExpr.h:206
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:630
Header file for the IntegralConstant class template.
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:76
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:76
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:429
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:338
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
System settings for the inline keywords.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatAddExpr.h:176
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
DifferenceType difference_type
Difference between two iterators.
Definition: DMatDMatAddExpr.h:210
CompositeType_< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:118
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
Evaluation of the expression type type of a column operation.Via this type trait it is possible to ev...
Definition: ColumnExprTrait.h:78
#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
DMatDMatAddExpr< MT1, MT2, SO > This
Type of this DMatDMatAdd instance.
Definition: DMatDMatAddExpr.h:173
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:71
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ValueType value_type
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:207