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 <utility>
45 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
56 #include <blaze/math/SIMD.h>
65 #include <blaze/system/Inline.h>
67 #include <blaze/util/Assert.h>
68 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/mpl/If.h>
72 #include <blaze/util/Types.h>
73 
74 
75 namespace blaze {
76 
77 //=================================================================================================
78 //
79 // CLASS DMATDMATADDEXPR
80 //
81 //=================================================================================================
82 
83 //*************************************************************************************************
90 template< typename MT1 // Type of the left-hand side dense matrix
91  , typename MT2 // Type of the right-hand side dense matrix
92  , bool SO > // Storage order
94  : public MatMatAddExpr< DenseMatrix< DMatDMatAddExpr<MT1,MT2,SO>, SO > >
95  , private Computation
96 {
97  private:
98  //**Type definitions****************************************************************************
107  //**********************************************************************************************
108 
109  //**Return type evaluation**********************************************************************
111 
116  static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
117 
119  using ExprReturnType = decltype( std::declval<RN1>() + std::declval<RN2>() );
120  //**********************************************************************************************
121 
122  //**Serial evaluation strategy******************************************************************
124 
130  static constexpr bool useAssign =
131  ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> || !returnExpr );
132 
134  template< typename MT >
136  static constexpr bool UseAssign_v = useAssign;
138  //**********************************************************************************************
139 
140  //**Parallel evaluation strategy****************************************************************
142 
148  template< typename MT >
149  static constexpr bool UseSMPAssign_v =
152  //**********************************************************************************************
153 
154  public:
155  //**Type definitions****************************************************************************
162 
165 
168 
170  using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
171 
173  using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
174  //**********************************************************************************************
175 
176  //**ConstIterator class definition**************************************************************
180  {
181  public:
182  //**Type definitions*************************************************************************
183  using IteratorCategory = std::random_access_iterator_tag;
188 
189  // STL iterator requirements
195 
198 
201  //*******************************************************************************************
202 
203  //**Constructor******************************************************************************
209  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right )
210  : left_ ( left ) // Iterator to the current left-hand side element
211  , right_( right ) // Iterator to the current right-hand side element
212  {}
213  //*******************************************************************************************
214 
215  //**Addition assignment operator*************************************************************
221  inline ConstIterator& operator+=( size_t inc ) {
222  left_ += inc;
223  right_ += inc;
224  return *this;
225  }
226  //*******************************************************************************************
227 
228  //**Subtraction assignment operator**********************************************************
234  inline ConstIterator& operator-=( size_t dec ) {
235  left_ -= dec;
236  right_ -= dec;
237  return *this;
238  }
239  //*******************************************************************************************
240 
241  //**Prefix increment operator****************************************************************
247  ++left_;
248  ++right_;
249  return *this;
250  }
251  //*******************************************************************************************
252 
253  //**Postfix increment operator***************************************************************
258  inline const ConstIterator operator++( int ) {
259  return ConstIterator( left_++, right_++ );
260  }
261  //*******************************************************************************************
262 
263  //**Prefix decrement operator****************************************************************
269  --left_;
270  --right_;
271  return *this;
272  }
273  //*******************************************************************************************
274 
275  //**Postfix decrement operator***************************************************************
280  inline const ConstIterator operator--( int ) {
281  return ConstIterator( left_--, right_-- );
282  }
283  //*******************************************************************************************
284 
285  //**Element access operator******************************************************************
290  inline ReturnType operator*() const {
291  return (*left_) + (*right_);
292  }
293  //*******************************************************************************************
294 
295  //**Load function****************************************************************************
300  inline auto load() const noexcept {
301  return left_.load() + right_.load();
302  }
303  //*******************************************************************************************
304 
305  //**Equality operator************************************************************************
311  inline bool operator==( const ConstIterator& rhs ) const {
312  return left_ == rhs.left_;
313  }
314  //*******************************************************************************************
315 
316  //**Inequality operator**********************************************************************
322  inline bool operator!=( const ConstIterator& rhs ) const {
323  return left_ != rhs.left_;
324  }
325  //*******************************************************************************************
326 
327  //**Less-than operator***********************************************************************
333  inline bool operator<( const ConstIterator& rhs ) const {
334  return left_ < rhs.left_;
335  }
336  //*******************************************************************************************
337 
338  //**Greater-than operator********************************************************************
344  inline bool operator>( const ConstIterator& rhs ) const {
345  return left_ > rhs.left_;
346  }
347  //*******************************************************************************************
348 
349  //**Less-or-equal-than operator**************************************************************
355  inline bool operator<=( const ConstIterator& rhs ) const {
356  return left_ <= rhs.left_;
357  }
358  //*******************************************************************************************
359 
360  //**Greater-or-equal-than operator***********************************************************
366  inline bool operator>=( const ConstIterator& rhs ) const {
367  return left_ >= rhs.left_;
368  }
369  //*******************************************************************************************
370 
371  //**Subtraction operator*********************************************************************
377  inline DifferenceType operator-( const ConstIterator& rhs ) const {
378  return left_ - rhs.left_;
379  }
380  //*******************************************************************************************
381 
382  //**Addition operator************************************************************************
389  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
390  return ConstIterator( it.left_ + inc, it.right_ + inc );
391  }
392  //*******************************************************************************************
393 
394  //**Addition operator************************************************************************
401  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
402  return ConstIterator( it.left_ + inc, it.right_ + inc );
403  }
404  //*******************************************************************************************
405 
406  //**Subtraction operator*********************************************************************
413  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
414  return ConstIterator( it.left_ - dec, it.right_ - dec );
415  }
416  //*******************************************************************************************
417 
418  private:
419  //**Member variables*************************************************************************
422  //*******************************************************************************************
423  };
424  //**********************************************************************************************
425 
426  //**Compilation flags***************************************************************************
428  static constexpr bool simdEnabled =
429  ( MT1::simdEnabled && MT2::simdEnabled && HasSIMDAdd_v<ET1,ET2> );
430 
432  static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
433  //**********************************************************************************************
434 
435  //**SIMD properties*****************************************************************************
437  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
438  //**********************************************************************************************
439 
440  //**Constructor*********************************************************************************
446  explicit inline DMatDMatAddExpr( const MT1& lhs, const MT2& rhs ) noexcept
447  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
448  , rhs_( rhs ) // Right-hand side dense matrix of the addition expression
449  {
450  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
451  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
452  }
453  //**********************************************************************************************
454 
455  //**Access operator*****************************************************************************
462  inline ReturnType operator()( size_t i, size_t j ) const {
463  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
464  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
465  return lhs_(i,j) + rhs_(i,j);
466  }
467  //**********************************************************************************************
468 
469  //**At function*********************************************************************************
477  inline ReturnType at( size_t i, size_t j ) const {
478  if( i >= lhs_.rows() ) {
479  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
480  }
481  if( j >= lhs_.columns() ) {
482  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
483  }
484  return (*this)(i,j);
485  }
486  //**********************************************************************************************
487 
488  //**Load function*******************************************************************************
495  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
496  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
497  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
498  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
499  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
500  return lhs_.load(i,j) + rhs_.load(i,j);
501  }
502  //**********************************************************************************************
503 
504  //**Begin function******************************************************************************
510  inline ConstIterator begin( size_t i ) const {
511  return ConstIterator( lhs_.begin(i), rhs_.begin(i) );
512  }
513  //**********************************************************************************************
514 
515  //**End function********************************************************************************
521  inline ConstIterator end( size_t i ) const {
522  return ConstIterator( lhs_.end(i), rhs_.end(i) );
523  }
524  //**********************************************************************************************
525 
526  //**Rows function*******************************************************************************
531  inline size_t rows() const noexcept {
532  return lhs_.rows();
533  }
534  //**********************************************************************************************
535 
536  //**Columns function****************************************************************************
541  inline size_t columns() const noexcept {
542  return lhs_.columns();
543  }
544  //**********************************************************************************************
545 
546  //**Left operand access*************************************************************************
551  inline LeftOperand leftOperand() const noexcept {
552  return lhs_;
553  }
554  //**********************************************************************************************
555 
556  //**Right operand access************************************************************************
561  inline RightOperand rightOperand() const noexcept {
562  return rhs_;
563  }
564  //**********************************************************************************************
565 
566  //**********************************************************************************************
572  template< typename T >
573  inline bool canAlias( const T* alias ) const noexcept {
574  return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
575  ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
576  }
577  //**********************************************************************************************
578 
579  //**********************************************************************************************
585  template< typename T >
586  inline bool isAliased( const T* alias ) const noexcept {
587  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
588  }
589  //**********************************************************************************************
590 
591  //**********************************************************************************************
596  inline bool isAligned() const noexcept {
597  return lhs_.isAligned() && rhs_.isAligned();
598  }
599  //**********************************************************************************************
600 
601  //**********************************************************************************************
606  inline bool canSMPAssign() const noexcept {
607  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
608  ( rows() * columns() >= SMP_DMATDMATADD_THRESHOLD );
609  }
610  //**********************************************************************************************
611 
612  private:
613  //**Member variables****************************************************************************
616  //**********************************************************************************************
617 
618  //**Assignment to dense matrices****************************************************************
632  template< typename MT // Type of the target dense matrix
633  , bool SO2 > // Storage order of the target dense matrix
634  friend inline auto assign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
636  {
638 
639  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
640  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
641 
642  if( !IsOperation_v<MT1> && isSame( ~lhs, rhs.lhs_ ) ) {
643  addAssign( ~lhs, rhs.rhs_ );
644  }
645  else if( !IsOperation_v<MT2> && isSame( ~lhs, rhs.rhs_ ) ) {
646  addAssign( ~lhs, rhs.lhs_ );
647  }
648  else if( !RequiresEvaluation_v<MT2> ) {
649  assign ( ~lhs, rhs.rhs_ );
650  addAssign( ~lhs, rhs.lhs_ );
651  }
652  else {
653  assign ( ~lhs, rhs.lhs_ );
654  addAssign( ~lhs, rhs.rhs_ );
655  }
656  }
658  //**********************************************************************************************
659 
660  //**Assignment to sparse matrices***************************************************************
674  template< typename MT // Type of the target sparse matrix
675  , bool SO2 > // Storage order of the target sparse matrix
676  friend inline auto assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
678  {
680 
682 
689 
690  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
691  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
692 
693  const TmpType tmp( serial( rhs ) );
694  assign( ~lhs, tmp );
695  }
697  //**********************************************************************************************
698 
699  //**Addition assignment to dense matrices*******************************************************
713  template< typename MT // Type of the target dense matrix
714  , bool SO2 > // Storage order of the target dense matrix
715  friend inline auto addAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
716  -> EnableIf_t< UseAssign_v<MT> >
717  {
719 
720  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
721  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
722 
723  if( !RequiresEvaluation_v<MT2> ) {
724  addAssign( ~lhs, rhs.rhs_ );
725  addAssign( ~lhs, rhs.lhs_ );
726  }
727  else {
728  addAssign( ~lhs, rhs.lhs_ );
729  addAssign( ~lhs, rhs.rhs_ );
730  }
731  }
733  //**********************************************************************************************
734 
735  //**Addition assignment to sparse matrices******************************************************
736  // No special implementation for the addition assignment to sparse matrices.
737  //**********************************************************************************************
738 
739  //**Subtraction assignment to dense matrices****************************************************
753  template< typename MT // Type of the target dense matrix
754  , bool SO2 > // Storage order of the target dense matrix
755  friend inline auto subAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
756  -> EnableIf_t< UseAssign_v<MT> >
757  {
759 
760  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
761  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
762 
763  if( !RequiresEvaluation_v<MT2> ) {
764  subAssign( ~lhs, rhs.rhs_ );
765  subAssign( ~lhs, rhs.lhs_ );
766  }
767  else {
768  subAssign( ~lhs, rhs.lhs_ );
769  subAssign( ~lhs, rhs.rhs_ );
770  }
771  }
773  //**********************************************************************************************
774 
775  //**Subtraction assignment to sparse matrices***************************************************
776  // No special implementation for the subtraction assignment to sparse matrices.
777  //**********************************************************************************************
778 
779  //**Schur product assignment to dense matrices**************************************************
793  template< typename MT // Type of the target dense matrix
794  , bool SO2 > // Storage order of the target dense matrix
795  friend inline auto schurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
796  -> EnableIf_t< UseAssign_v<MT> >
797  {
799 
803 
804  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
805  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
806 
807  const ResultType tmp( serial( rhs ) );
808  schurAssign( ~lhs, tmp );
809  }
811  //**********************************************************************************************
812 
813  //**Schur product assignment to sparse matrices*************************************************
814  // No special implementation for the Schur product assignment to sparse matrices.
815  //**********************************************************************************************
816 
817  //**Multiplication assignment to dense matrices*************************************************
818  // No special implementation for the multiplication assignment to dense matrices.
819  //**********************************************************************************************
820 
821  //**Multiplication assignment to sparse matrices************************************************
822  // No special implementation for the multiplication assignment to sparse matrices.
823  //**********************************************************************************************
824 
825  //**SMP assignment to dense matrices************************************************************
839  template< typename MT // Type of the target dense matrix
840  , bool SO2 > // Storage order of the target dense matrix
841  friend inline auto smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
842  -> EnableIf_t< UseSMPAssign_v<MT> >
843  {
845 
846  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
847  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
848 
849  if( !IsOperation_v<MT1> && isSame( ~lhs, rhs.lhs_ ) ) {
850  smpAddAssign( ~lhs, rhs.rhs_ );
851  }
852  else if( !IsOperation_v<MT2> && isSame( ~lhs, rhs.rhs_ ) ) {
853  smpAddAssign( ~lhs, rhs.lhs_ );
854  }
855  else if( !RequiresEvaluation_v<MT2> ) {
856  smpAssign ( ~lhs, rhs.rhs_ );
857  smpAddAssign( ~lhs, rhs.lhs_ );
858  }
859  else {
860  smpAssign ( ~lhs, rhs.lhs_ );
861  smpAddAssign( ~lhs, rhs.rhs_ );
862  }
863  }
865  //**********************************************************************************************
866 
867  //**SMP assignment to sparse matrices***********************************************************
881  template< typename MT // Type of the target sparse matrix
882  , bool SO2 > // Storage order of the target sparse matrix
883  friend inline auto smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
884  -> EnableIf_t< UseSMPAssign_v<MT> >
885  {
887 
888  using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
889 
896 
897  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
898  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
899 
900  const TmpType tmp( rhs );
901  smpAssign( ~lhs, tmp );
902  }
904  //**********************************************************************************************
905 
906  //**SMP addition assignment to dense matrices***************************************************
920  template< typename MT // Type of the target dense matrix
921  , bool SO2 > // Storage order of the target dense matrix
922  friend inline auto smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
923  -> EnableIf_t< UseSMPAssign_v<MT> >
924  {
926 
927  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
928  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
929 
930  if( !RequiresEvaluation_v<MT2> ) {
931  smpAddAssign( ~lhs, rhs.rhs_ );
932  smpAddAssign( ~lhs, rhs.lhs_ );
933  }
934  else {
935  smpAddAssign( ~lhs, rhs.lhs_ );
936  smpAddAssign( ~lhs, rhs.rhs_ );
937  }
938  }
940  //**********************************************************************************************
941 
942  //**SMP addition assignment to sparse matrices**************************************************
943  // No special implementation for the SMP addition assignment to sparse matrices.
944  //**********************************************************************************************
945 
946  //**SMP subtraction assignment to dense matrices************************************************
960  template< typename MT // Type of the target dense matrix
961  , bool SO2 > // Storage order of the target dense matrix
962  friend inline auto smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
963  -> EnableIf_t< UseSMPAssign_v<MT> >
964  {
966 
967  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
968  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
969 
970  if( !RequiresEvaluation_v<MT2> ) {
971  smpSubAssign( ~lhs, rhs.rhs_ );
972  smpSubAssign( ~lhs, rhs.lhs_ );
973  }
974  else {
975  smpSubAssign( ~lhs, rhs.lhs_ );
976  smpSubAssign( ~lhs, rhs.rhs_ );
977  }
978  }
980  //**********************************************************************************************
981 
982  //**SMP subtraction assignment to sparse matrices***********************************************
983  // No special implementation for the SMP subtraction assignment to sparse matrices.
984  //**********************************************************************************************
985 
986  //**SMP Schur product assignment to dense matrices**********************************************
1000  template< typename MT // Type of the target dense matrix
1001  , bool SO2 > // Storage order of the target dense matrix
1002  friend inline auto smpSchurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatAddExpr& rhs )
1003  -> EnableIf_t< UseSMPAssign_v<MT> >
1004  {
1006 
1010 
1011  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1012  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1013 
1014  const ResultType tmp( rhs );
1015  smpSchurAssign( ~lhs, tmp );
1016  }
1018  //**********************************************************************************************
1019 
1020  //**SMP Schur product assignment to sparse matrices*********************************************
1021  // No special implementation for the SMP Schur product assignment to sparse matrices.
1022  //**********************************************************************************************
1023 
1024  //**SMP multiplication assignment to dense matrices*********************************************
1025  // No special implementation for the SMP multiplication assignment to dense matrices.
1026  //**********************************************************************************************
1027 
1028  //**SMP multiplication assignment to sparse matrices********************************************
1029  // No special implementation for the SMP multiplication assignment to sparse matrices.
1030  //**********************************************************************************************
1031 
1032  //**Compile time checks*************************************************************************
1039  //**********************************************************************************************
1040 };
1041 //*************************************************************************************************
1042 
1043 
1044 
1045 
1046 //=================================================================================================
1047 //
1048 // GLOBAL BINARY ARITHMETIC OPERATORS
1049 //
1050 //=================================================================================================
1051 
1052 //*************************************************************************************************
1079 template< typename MT1 // Type of the left-hand side dense matrix
1080  , typename MT2 // Type of the right-hand side dense matrix
1081  , bool SO > // Storage order
1082 inline decltype(auto)
1083  operator+( const DenseMatrix<MT1,SO>& lhs, const DenseMatrix<MT2,SO>& rhs )
1084 {
1086 
1087  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
1088  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1089  }
1090 
1092  return ReturnType( ~lhs, ~rhs );
1093 }
1094 //*************************************************************************************************
1095 
1096 
1097 
1098 
1099 //=================================================================================================
1100 //
1101 // ISALIGNED SPECIALIZATIONS
1102 //
1103 //=================================================================================================
1104 
1105 //*************************************************************************************************
1107 template< typename MT1, typename MT2, bool SO >
1108 struct IsAligned< DMatDMatAddExpr<MT1,MT2,SO> >
1109  : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1110 {};
1112 //*************************************************************************************************
1113 
1114 
1115 
1116 
1117 //=================================================================================================
1118 //
1119 // ISPADDED SPECIALIZATIONS
1120 //
1121 //=================================================================================================
1122 
1123 //*************************************************************************************************
1125 template< typename MT1, typename MT2, bool SO >
1126 struct IsPadded< DMatDMatAddExpr<MT1,MT2,SO> >
1127  : public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
1128 {};
1130 //*************************************************************************************************
1131 
1132 } // namespace blaze
1133 
1134 #endif
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatDMatAddExpr.h:290
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:344
#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:191
Header file for auxiliary alias declarations.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatAddExpr.h:246
DMatDMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatAddExpr class.
Definition: DMatDMatAddExpr.h:446
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatAddExpr.h:221
ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatAddExpr.h:209
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatAddExpr.h:234
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:992
Header file for basic type definitions.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatAddExpr.h:159
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:100
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:106
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
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
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:224
#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
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatAddExpr.h:160
Header file for the Computation base class.
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatDMatAddExpr.h:428
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatAddExpr.h:586
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatAddExpr.h:541
ConstIterator_t< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:200
Header file for the RequiresEvaluation type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:551
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Iterator over the elements of the dense matrix.
Definition: DMatDMatAddExpr.h:179
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatAddExpr.h:119
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DMatDMatAddExpr.h:421
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatDMatAddExpr.h:510
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatAddExpr.h:186
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:311
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatAddExpr.h:531
Expression object for dense matrix-dense matrix additions.The DMatDMatAddExpr class represents the co...
Definition: DMatDMatAddExpr.h:93
Header file for the IsTemporary type trait class.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatAddExpr.h:377
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatDMatAddExpr.h:187
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:280
#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:268
Header file for the DenseMatrix base class.
If_t< IsExpression_v< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:170
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatAddExpr.h:462
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatDMatAddExpr.h:521
PointerType pointer
Pointer return type.
Definition: DMatDMatAddExpr.h:192
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:561
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:389
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.
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.The AddTrait_t alias declaration provides...
Definition: AddTrait.h:238
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:333
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:495
Header file for the IsAligned type trait.
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatAddExpr.h:158
Constraints on the storage order of matrix types.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatAddExpr.h:573
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:184
Header file for the exception macros of the math module.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the addition expression. ...
Definition: DMatDMatAddExpr.h:130
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:103
#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:103
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatAddExpr.h:477
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:615
Header file for the EnableIf class template.
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:300
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:596
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatDMatAddExpr.h:432
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:105
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatDMatAddExpr.h:161
Header file for the addition trait.
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatDMatAddExpr.h:116
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:99
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:104
ReferenceType reference
Reference return type.
Definition: DMatDMatAddExpr.h:193
Constraint on the data type.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
#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_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:101
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#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.
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:101
const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatAddExpr.h:258
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
ConstIterator_t< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:197
#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:401
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:366
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatAddExpr.h:606
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:355
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatAddExpr.h:183
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatAddExpr.h:420
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatAddExpr.h:190
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
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:185
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:614
Header file for the IntegralConstant class template.
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:413
If_t< useAssign, const ResultType, const DMatDMatAddExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatDMatAddExpr.h:167
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:322
If_t< IsExpression_v< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:173
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatAddExpr.h:164
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:102
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatDMatAddExpr.h:437