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>
49 #include <blaze/math/Exception.h>
55 #include <blaze/math/SIMD.h>
74 #include <blaze/system/Inline.h>
76 #include <blaze/util/Assert.h>
77 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/mpl/And.h>
80 #include <blaze/util/mpl/If.h>
81 #include <blaze/util/mpl/Maximum.h>
82 #include <blaze/util/mpl/Or.h>
83 #include <blaze/util/Types.h>
84 
85 
86 namespace blaze {
87 
88 //=================================================================================================
89 //
90 // CLASS DMATDMATADDEXPR
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
101 template< typename MT1 // Type of the left-hand side dense matrix
102  , typename MT2 // Type of the right-hand side dense matrix
103  , bool SO > // Storage order
105  : public MatMatAddExpr< DenseMatrix< DMatDMatAddExpr<MT1,MT2,SO>, SO > >
106  , private Computation
107 {
108  private:
109  //**Type definitions****************************************************************************
118  //**********************************************************************************************
119 
120  //**Return type evaluation**********************************************************************
122 
127  enum : bool { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
128 
131  //**********************************************************************************************
132 
133  //**Serial evaluation strategy******************************************************************
135 
141  enum : bool { useAssign = RequiresEvaluation<MT1>::value || RequiresEvaluation<MT2>::value || !returnExpr };
142 
144  template< typename MT >
146  struct UseAssign {
147  enum : bool { value = useAssign };
148  };
150  //**********************************************************************************************
151 
152  //**Parallel evaluation strategy****************************************************************
154 
160  template< typename MT >
161  struct UseSMPAssign {
162  enum : bool { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
163  };
165  //**********************************************************************************************
166 
167  public:
168  //**Type definitions****************************************************************************
174 
177 
180 
182  using LeftOperand = If_< IsExpression<MT1>, const MT1, const MT1& >;
183 
185  using RightOperand = If_< IsExpression<MT2>, const MT2, const MT2& >;
186  //**********************************************************************************************
187 
188  //**ConstIterator class definition**************************************************************
192  {
193  public:
194  //**Type definitions*************************************************************************
195  using IteratorCategory = std::random_access_iterator_tag;
200 
201  // STL iterator requirements
207 
210 
213  //*******************************************************************************************
214 
215  //**Constructor******************************************************************************
221  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right )
222  : left_ ( left ) // Iterator to the current left-hand side element
223  , right_( right ) // Iterator to the current right-hand side element
224  {}
225  //*******************************************************************************************
226 
227  //**Addition assignment operator*************************************************************
233  inline ConstIterator& operator+=( size_t inc ) {
234  left_ += inc;
235  right_ += inc;
236  return *this;
237  }
238  //*******************************************************************************************
239 
240  //**Subtraction assignment operator**********************************************************
246  inline ConstIterator& operator-=( size_t dec ) {
247  left_ -= dec;
248  right_ -= dec;
249  return *this;
250  }
251  //*******************************************************************************************
252 
253  //**Prefix increment operator****************************************************************
259  ++left_;
260  ++right_;
261  return *this;
262  }
263  //*******************************************************************************************
264 
265  //**Postfix increment operator***************************************************************
270  inline const ConstIterator operator++( int ) {
271  return ConstIterator( left_++, right_++ );
272  }
273  //*******************************************************************************************
274 
275  //**Prefix decrement operator****************************************************************
281  --left_;
282  --right_;
283  return *this;
284  }
285  //*******************************************************************************************
286 
287  //**Postfix decrement operator***************************************************************
292  inline const ConstIterator operator--( int ) {
293  return ConstIterator( left_--, right_-- );
294  }
295  //*******************************************************************************************
296 
297  //**Element access operator******************************************************************
302  inline ReturnType operator*() const {
303  return (*left_) + (*right_);
304  }
305  //*******************************************************************************************
306 
307  //**Load function****************************************************************************
312  inline auto load() const noexcept {
313  return left_.load() + right_.load();
314  }
315  //*******************************************************************************************
316 
317  //**Equality operator************************************************************************
323  inline bool operator==( const ConstIterator& rhs ) const {
324  return left_ == rhs.left_;
325  }
326  //*******************************************************************************************
327 
328  //**Inequality operator**********************************************************************
334  inline bool operator!=( const ConstIterator& rhs ) const {
335  return left_ != rhs.left_;
336  }
337  //*******************************************************************************************
338 
339  //**Less-than operator***********************************************************************
345  inline bool operator<( const ConstIterator& rhs ) const {
346  return left_ < rhs.left_;
347  }
348  //*******************************************************************************************
349 
350  //**Greater-than operator********************************************************************
356  inline bool operator>( const ConstIterator& rhs ) const {
357  return left_ > rhs.left_;
358  }
359  //*******************************************************************************************
360 
361  //**Less-or-equal-than operator**************************************************************
367  inline bool operator<=( const ConstIterator& rhs ) const {
368  return left_ <= rhs.left_;
369  }
370  //*******************************************************************************************
371 
372  //**Greater-or-equal-than operator***********************************************************
378  inline bool operator>=( const ConstIterator& rhs ) const {
379  return left_ >= rhs.left_;
380  }
381  //*******************************************************************************************
382 
383  //**Subtraction operator*********************************************************************
389  inline DifferenceType operator-( const ConstIterator& rhs ) const {
390  return left_ - rhs.left_;
391  }
392  //*******************************************************************************************
393 
394  //**Addition operator************************************************************************
401  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
402  return ConstIterator( it.left_ + inc, it.right_ + inc );
403  }
404  //*******************************************************************************************
405 
406  //**Addition operator************************************************************************
413  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
414  return ConstIterator( it.left_ + inc, it.right_ + inc );
415  }
416  //*******************************************************************************************
417 
418  //**Subtraction operator*********************************************************************
425  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
426  return ConstIterator( it.left_ - dec, it.right_ - dec );
427  }
428  //*******************************************************************************************
429 
430  private:
431  //**Member variables*************************************************************************
434  //*******************************************************************************************
435  };
436  //**********************************************************************************************
437 
438  //**Compilation flags***************************************************************************
440  enum : bool { simdEnabled = MT1::simdEnabled && MT2::simdEnabled &&
442 
444  enum : bool { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
445  //**********************************************************************************************
446 
447  //**SIMD properties*****************************************************************************
449  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
450  //**********************************************************************************************
451 
452  //**Constructor*********************************************************************************
458  explicit inline DMatDMatAddExpr( const MT1& lhs, const MT2& rhs ) noexcept
459  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
460  , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
461  {
462  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
463  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
464  }
465  //**********************************************************************************************
466 
467  //**Access operator*****************************************************************************
474  inline ReturnType operator()( size_t i, size_t j ) const {
475  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
476  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
477  return lhs_(i,j) + rhs_(i,j);
478  }
479  //**********************************************************************************************
480 
481  //**At function*********************************************************************************
489  inline ReturnType at( size_t i, size_t j ) const {
490  if( i >= lhs_.rows() ) {
491  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
492  }
493  if( j >= lhs_.columns() ) {
494  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
495  }
496  return (*this)(i,j);
497  }
498  //**********************************************************************************************
499 
500  //**Load function*******************************************************************************
507  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
508  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
509  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
510  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
511  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
512  return lhs_.load(i,j) + rhs_.load(i,j);
513  }
514  //**********************************************************************************************
515 
516  //**Begin function******************************************************************************
522  inline ConstIterator begin( size_t i ) const {
523  return ConstIterator( lhs_.begin(i), rhs_.begin(i) );
524  }
525  //**********************************************************************************************
526 
527  //**End function********************************************************************************
533  inline ConstIterator end( size_t i ) const {
534  return ConstIterator( lhs_.end(i), rhs_.end(i) );
535  }
536  //**********************************************************************************************
537 
538  //**Rows function*******************************************************************************
543  inline size_t rows() const noexcept {
544  return lhs_.rows();
545  }
546  //**********************************************************************************************
547 
548  //**Columns function****************************************************************************
553  inline size_t columns() const noexcept {
554  return lhs_.columns();
555  }
556  //**********************************************************************************************
557 
558  //**Left operand access*************************************************************************
563  inline LeftOperand leftOperand() const noexcept {
564  return lhs_;
565  }
566  //**********************************************************************************************
567 
568  //**Right operand access************************************************************************
573  inline RightOperand rightOperand() const noexcept {
574  return rhs_;
575  }
576  //**********************************************************************************************
577 
578  //**********************************************************************************************
584  template< typename T >
585  inline bool canAlias( const T* alias ) const noexcept {
586  return ( IsExpression<MT1>::value && ( RequiresEvaluation<MT1>::value ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
587  ( IsExpression<MT2>::value && ( RequiresEvaluation<MT2>::value ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
588  }
589  //**********************************************************************************************
590 
591  //**********************************************************************************************
597  template< typename T >
598  inline bool isAliased( const T* alias ) const noexcept {
599  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
600  }
601  //**********************************************************************************************
602 
603  //**********************************************************************************************
608  inline bool isAligned() const noexcept {
609  return lhs_.isAligned() && rhs_.isAligned();
610  }
611  //**********************************************************************************************
612 
613  //**********************************************************************************************
618  inline bool canSMPAssign() const noexcept {
619  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
620  ( rows() * columns() >= SMP_DMATDMATADD_THRESHOLD );
621  }
622  //**********************************************************************************************
623 
624  private:
625  //**Member variables****************************************************************************
628  //**********************************************************************************************
629 
630  //**Assignment to dense matrices****************************************************************
644  template< typename MT // Type of the target dense matrix
645  , bool SO2 > // Storage order of the target dense matrix
646  friend inline EnableIf_< UseAssign<MT> >
647  assign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
648  {
650 
651  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
652  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
653 
654  if( !IsOperation<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
655  addAssign( ~lhs, rhs.rhs_ );
656  }
657  else if( !IsOperation<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
658  addAssign( ~lhs, rhs.lhs_ );
659  }
660  else {
661  assign ( ~lhs, rhs.lhs_ );
662  addAssign( ~lhs, rhs.rhs_ );
663  }
664  }
666  //**********************************************************************************************
667 
668  //**Assignment to sparse matrices***************************************************************
682  template< typename MT // Type of the target sparse matrix
683  , bool SO2 > // Storage order of the target sparse matrix
684  friend inline EnableIf_< UseAssign<MT> >
685  assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
686  {
688 
690 
697 
698  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
699  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
700 
701  const TmpType tmp( serial( rhs ) );
702  assign( ~lhs, tmp );
703  }
705  //**********************************************************************************************
706 
707  //**Addition assignment to dense matrices*******************************************************
721  template< typename MT // Type of the target dense matrix
722  , bool SO2 > // Storage order of the target dense matrix
723  friend inline EnableIf_< UseAssign<MT> >
724  addAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
725  {
727 
728  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
729  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
730 
731  addAssign( ~lhs, rhs.lhs_ );
732  addAssign( ~lhs, rhs.rhs_ );
733  }
735  //**********************************************************************************************
736 
737  //**Addition assignment to sparse matrices******************************************************
738  // No special implementation for the addition assignment to sparse matrices.
739  //**********************************************************************************************
740 
741  //**Subtraction assignment to dense matrices****************************************************
755  template< typename MT // Type of the target dense matrix
756  , bool SO2 > // Storage order of the target dense matrix
757  friend inline EnableIf_< UseAssign<MT> >
758  subAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
759  {
761 
762  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
763  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
764 
765  subAssign( ~lhs, rhs.lhs_ );
766  subAssign( ~lhs, rhs.rhs_ );
767  }
769  //**********************************************************************************************
770 
771  //**Subtraction assignment to sparse matrices***************************************************
772  // No special implementation for the subtraction assignment to sparse matrices.
773  //**********************************************************************************************
774 
775  //**Schur product assignment to dense matrices**************************************************
789  template< typename MT // Type of the target dense matrix
790  , bool SO2 > // Storage order of the target dense matrix
791  friend inline EnableIf_< UseAssign<MT> >
792  schurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
793  {
795 
799 
800  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
801  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
802 
803  const ResultType tmp( serial( rhs ) );
804  schurAssign( ~lhs, tmp );
805  }
807  //**********************************************************************************************
808 
809  //**Schur product assignment to sparse matrices*************************************************
810  // No special implementation for the Schur product assignment to sparse matrices.
811  //**********************************************************************************************
812 
813  //**Multiplication assignment to dense matrices*************************************************
814  // No special implementation for the multiplication assignment to dense matrices.
815  //**********************************************************************************************
816 
817  //**Multiplication assignment to sparse matrices************************************************
818  // No special implementation for the multiplication assignment to sparse matrices.
819  //**********************************************************************************************
820 
821  //**SMP assignment to dense matrices************************************************************
835  template< typename MT // Type of the target dense matrix
836  , bool SO2 > // Storage order of the target dense matrix
837  friend inline EnableIf_< UseSMPAssign<MT> >
838  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
839  {
841 
842  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
843  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
844 
845  if( !IsOperation<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
846  smpAddAssign( ~lhs, rhs.rhs_ );
847  }
848  else if( !IsOperation<MT2>::value && isSame( ~lhs, rhs.rhs_ ) ) {
849  smpAddAssign( ~lhs, rhs.lhs_ );
850  }
851  else {
852  smpAssign ( ~lhs, rhs.lhs_ );
853  smpAddAssign( ~lhs, rhs.rhs_ );
854  }
855  }
857  //**********************************************************************************************
858 
859  //**SMP assignment to sparse matrices***********************************************************
873  template< typename MT // Type of the target sparse matrix
874  , bool SO2 > // Storage order of the target sparse matrix
875  friend inline EnableIf_< UseSMPAssign<MT> >
877  {
879 
881 
888 
889  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
890  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
891 
892  const TmpType tmp( rhs );
893  smpAssign( ~lhs, tmp );
894  }
896  //**********************************************************************************************
897 
898  //**SMP addition 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  smpAddAssign( ~lhs, rhs.lhs_ );
923  smpAddAssign( ~lhs, rhs.rhs_ );
924  }
926  //**********************************************************************************************
927 
928  //**SMP addition assignment to sparse matrices**************************************************
929  // No special implementation for the SMP addition assignment to sparse matrices.
930  //**********************************************************************************************
931 
932  //**SMP subtraction assignment to dense matrices************************************************
946  template< typename MT // Type of the target dense matrix
947  , bool SO2 > // Storage order of the target dense matrix
948  friend inline EnableIf_< UseSMPAssign<MT> >
950  {
952 
953  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
954  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
955 
956  smpSubAssign( ~lhs, rhs.lhs_ );
957  smpSubAssign( ~lhs, rhs.rhs_ );
958  }
960  //**********************************************************************************************
961 
962  //**SMP subtraction assignment to sparse matrices***********************************************
963  // No special implementation for the SMP subtraction assignment to sparse matrices.
964  //**********************************************************************************************
965 
966  //**SMP Schur product assignment to dense matrices**********************************************
980  template< typename MT // Type of the target dense matrix
981  , bool SO2 > // Storage order of the target dense matrix
982  friend inline EnableIf_< UseSMPAssign<MT> >
984  {
986 
990 
991  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
992  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
993 
994  const ResultType tmp( rhs );
995  smpSchurAssign( ~lhs, tmp );
996  }
998  //**********************************************************************************************
999 
1000  //**SMP Schur product assignment to sparse matrices*********************************************
1001  // No special implementation for the SMP Schur product assignment to sparse matrices.
1002  //**********************************************************************************************
1003 
1004  //**SMP multiplication assignment to dense matrices*********************************************
1005  // No special implementation for the SMP multiplication assignment to dense matrices.
1006  //**********************************************************************************************
1007 
1008  //**SMP multiplication assignment to sparse matrices********************************************
1009  // No special implementation for the SMP multiplication assignment to sparse matrices.
1010  //**********************************************************************************************
1011 
1012  //**Compile time checks*************************************************************************
1019  //**********************************************************************************************
1020 };
1021 //*************************************************************************************************
1022 
1023 
1024 
1025 
1026 //=================================================================================================
1027 //
1028 // GLOBAL BINARY ARITHMETIC OPERATORS
1029 //
1030 //=================================================================================================
1031 
1032 //*************************************************************************************************
1059 template< typename MT1 // Type of the left-hand side dense matrix
1060  , typename MT2 // Type of the right-hand side dense matrix
1061  , bool SO > // Storage order
1062 inline decltype(auto)
1063  operator+( const DenseMatrix<MT1,SO>& lhs, const DenseMatrix<MT2,SO>& rhs )
1064 {
1066 
1067  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
1068  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1069  }
1070 
1072  return ReturnType( ~lhs, ~rhs );
1073 }
1074 //*************************************************************************************************
1075 
1076 
1077 
1078 
1079 //=================================================================================================
1080 //
1081 // SIZE SPECIALIZATIONS
1082 //
1083 //=================================================================================================
1084 
1085 //*************************************************************************************************
1087 template< typename MT1, typename MT2, bool SO >
1088 struct Size< DMatDMatAddExpr<MT1,MT2,SO>, 0UL >
1089  : public Maximum< Size<MT1,0UL>, Size<MT2,0UL> >
1090 {};
1091 
1092 template< typename MT1, typename MT2, bool SO >
1093 struct Size< DMatDMatAddExpr<MT1,MT2,SO>, 1UL >
1094  : public Maximum< Size<MT1,1UL>, Size<MT2,1UL> >
1095 {};
1097 //*************************************************************************************************
1098 
1099 
1100 
1101 
1102 //=================================================================================================
1103 //
1104 // ISALIGNED SPECIALIZATIONS
1105 //
1106 //=================================================================================================
1107 
1108 //*************************************************************************************************
1110 template< typename MT1, typename MT2, bool SO >
1111 struct IsAligned< DMatDMatAddExpr<MT1,MT2,SO> >
1112  : public And< IsAligned<MT1>, IsAligned<MT2> >
1113 {};
1115 //*************************************************************************************************
1116 
1117 
1118 
1119 
1120 //=================================================================================================
1121 //
1122 // ISPADDED SPECIALIZATIONS
1123 //
1124 //=================================================================================================
1125 
1126 //*************************************************************************************************
1128 template< typename MT1, typename MT2, bool SO >
1129 struct IsPadded< DMatDMatAddExpr<MT1,MT2,SO> >
1130  : public And< IsPadded<MT1>, IsPadded<MT2> >
1131 {};
1133 //*************************************************************************************************
1134 
1135 
1136 
1137 
1138 //=================================================================================================
1139 //
1140 // ISSYMMETRIC SPECIALIZATIONS
1141 //
1142 //=================================================================================================
1143 
1144 //*************************************************************************************************
1146 template< typename MT1, typename MT2, bool SO >
1147 struct IsSymmetric< DMatDMatAddExpr<MT1,MT2,SO> >
1148  : public And< IsSymmetric<MT1>, IsSymmetric<MT2> >
1149 {};
1151 //*************************************************************************************************
1152 
1153 
1154 
1155 
1156 //=================================================================================================
1157 //
1158 // ISHERMITIAN SPECIALIZATIONS
1159 //
1160 //=================================================================================================
1161 
1162 //*************************************************************************************************
1164 template< typename MT1, typename MT2, bool SO >
1165 struct IsHermitian< DMatDMatAddExpr<MT1,MT2,SO> >
1166  : public And< IsHermitian<MT1>, IsHermitian<MT2> >
1167 {};
1169 //*************************************************************************************************
1170 
1171 
1172 
1173 
1174 //=================================================================================================
1175 //
1176 // ISLOWER SPECIALIZATIONS
1177 //
1178 //=================================================================================================
1179 
1180 //*************************************************************************************************
1182 template< typename MT1, typename MT2, bool SO >
1183 struct IsLower< DMatDMatAddExpr<MT1,MT2,SO> >
1184  : public And< IsLower<MT1>, IsLower<MT2> >
1185 {};
1187 //*************************************************************************************************
1188 
1189 
1190 
1191 
1192 //=================================================================================================
1193 //
1194 // ISUNILOWER SPECIALIZATIONS
1195 //
1196 //=================================================================================================
1197 
1198 //*************************************************************************************************
1200 template< typename MT1, typename MT2, bool SO >
1201 struct IsUniLower< DMatDMatAddExpr<MT1,MT2,SO> >
1202  : public Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
1203  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >
1204 {};
1206 //*************************************************************************************************
1207 
1208 
1209 
1210 
1211 //=================================================================================================
1212 //
1213 // ISSTRICTLYLOWER SPECIALIZATIONS
1214 //
1215 //=================================================================================================
1216 
1217 //*************************************************************************************************
1219 template< typename MT1, typename MT2, bool SO >
1220 struct IsStrictlyLower< DMatDMatAddExpr<MT1,MT2,SO> >
1221  : public And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >
1222 {};
1224 //*************************************************************************************************
1225 
1226 
1227 
1228 
1229 //=================================================================================================
1230 //
1231 // ISUPPER SPECIALIZATIONS
1232 //
1233 //=================================================================================================
1234 
1235 //*************************************************************************************************
1237 template< typename MT1, typename MT2, bool SO >
1238 struct IsUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1239  : public And< IsUpper<MT1>, IsUpper<MT2> >
1240 {};
1242 //*************************************************************************************************
1243 
1244 
1245 
1246 
1247 //=================================================================================================
1248 //
1249 // ISUNIUPPER SPECIALIZATIONS
1250 //
1251 //=================================================================================================
1252 
1253 //*************************************************************************************************
1255 template< typename MT1, typename MT2, bool SO >
1256 struct IsUniUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1257  : public Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1258  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >
1259 {};
1261 //*************************************************************************************************
1262 
1263 
1264 
1265 
1266 //=================================================================================================
1267 //
1268 // ISSTRICTLYUPPER SPECIALIZATIONS
1269 //
1270 //=================================================================================================
1271 
1272 //*************************************************************************************************
1274 template< typename MT1, typename MT2, bool SO >
1275 struct IsStrictlyUpper< DMatDMatAddExpr<MT1,MT2,SO> >
1276  : public And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >
1277 {};
1279 //*************************************************************************************************
1280 
1281 } // namespace blaze
1282 
1283 #endif
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatDMatAddExpr.h:302
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:356
#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.
ValueType value_type
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:203
Header file for auxiliary alias declarations.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatAddExpr.h:258
DMatDMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatAddExpr class.
Definition: DMatDMatAddExpr.h:458
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatAddExpr.h:233
ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatAddExpr.h:221
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatAddExpr.h:246
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:69
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatAddExpr.h:172
Header file for the IsUniUpper type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
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:949
Header file for basic type definitions.
Compile time check whether the given type is an operational expression template.This type trait class...
Definition: IsOperation.h:70
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:164
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
#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
ConstIterator_< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:209
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatAddExpr.h:176
Header file for the And class template.
Compile time value evaluation.The Maximum alias declaration selects the larger of the two given templ...
Definition: Maximum.h:73
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:87
Availability of a SIMD addition for the given data types.Depending on the available instruction set (...
Definition: HasSIMDAdd.h:171
Header file for the AddExprTrait class template.
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:182
Header file for the Computation base class.
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatDMatAddExpr.h:173
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:87
ReturnType_< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:112
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatAddExpr.h:598
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatAddExpr.h:553
Header file for the RequiresEvaluation type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:563
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
IfTrue_< useAssign, const ResultType, const DMatDMatAddExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatDMatAddExpr.h:179
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:133
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
ElementType_< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:116
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:363
Iterator over the elements of the dense matrix.
Definition: DMatDMatAddExpr.h:191
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.
Header file for the Maximum class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:71
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:433
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatDMatAddExpr.h:522
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatAddExpr.h:198
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:323
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatAddExpr.h:543
Expression object for dense matrix-dense matrix additions.The DMatDMatAddExpr class represents the co...
Definition: DMatDMatAddExpr.h:104
Header file for the IsTemporary type trait class.
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:115
Header file for the IsStrictlyUpper type trait.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatAddExpr.h:389
Header file for the IsSymmetric type trait.
ConstIterator_< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:212
typename AddExprTrait< T1, T2 >::Type AddExprTrait_
Auxiliary alias declaration for the AddExprTrait class template.The AddExprTrait_ alias declaration p...
Definition: AddExprTrait.h:112
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:292
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:102
Header file for the Or class template.
#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:280
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:474
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatAddExpr.h:171
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatDMatAddExpr.h:533
PointerType pointer
Pointer return type.
Definition: DMatDMatAddExpr.h:204
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:573
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:401
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:66
Header file for the IsOperation type trait class.
CompositeType_< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:114
Header file for the IsLower type trait.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:345
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:507
Header file for the IsAligned type trait.
Constraints on the storage order of matrix types.
ElementType_< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:117
AddExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatAddExpr.h:130
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:585
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:196
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
#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:107
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatAddExpr.h:489
Constraint on the data type.
Header file for all forward declarations for expression class templates.
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:627
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:312
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:608
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
AddTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatAddExpr.h:170
Header file for run time assertion macros.
Header file for the addition trait.
ReferenceType reference
Reference return type.
Definition: DMatDMatAddExpr.h:205
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:154
Constraint on the data type.
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:94
ReturnType_< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:113
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:110
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the MatMatAddExpr base class.
const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatAddExpr.h:270
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
#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:413
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:378
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatAddExpr.h:618
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:367
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatAddExpr.h:195
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:185
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatAddExpr.h:432
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatAddExpr.h:202
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ElementType * PointerType
Pointer return type.
Definition: DMatDMatAddExpr.h:197
Compile time logical &#39;or&#39; evaluation.The Or alias declaration performs at compile time a logical &#39;or&#39;...
Definition: Or.h:76
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:626
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:425
Compile time logical &#39;and&#39; evaluation.The And alias declaration performs at compile time a logical &#39;a...
Definition: And.h:76
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:334
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
System settings for the inline keywords.
Header file for the Size type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:291
#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
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:111
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:95
Header file for the IsExpression type trait class.
Header file for the function trace functionality.