Blaze  3.6
DMatDMatSubExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATSUBEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATDMATSUBEXPR_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>
66 #include <blaze/system/Inline.h>
68 #include <blaze/util/Assert.h>
69 #include <blaze/util/EnableIf.h>
72 #include <blaze/util/mpl/If.h>
73 #include <blaze/util/Types.h>
74 
75 
76 namespace blaze {
77 
78 //=================================================================================================
79 //
80 // CLASS DMATDMATSUBEXPR
81 //
82 //=================================================================================================
83 
84 //*************************************************************************************************
91 template< typename MT1 // Type of the left-hand side dense matrix
92  , typename MT2 // Type of the right-hand side dense matrix
93  , bool SO > // Storage order
95  : public MatMatSubExpr< DenseMatrix< DMatDMatSubExpr<MT1,MT2,SO>, SO > >
96  , private Computation
97 {
98  private:
99  //**Type definitions****************************************************************************
108  //**********************************************************************************************
109 
110  //**Return type evaluation**********************************************************************
112 
117  static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
118 
120  using ExprReturnType = decltype( std::declval<RN1>() - std::declval<RN2>() );
121  //**********************************************************************************************
122 
123  //**Serial evaluation strategy******************************************************************
125 
131  static constexpr bool useAssign =
132  ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> || !returnExpr );
133 
135  template< typename MT >
137  static constexpr bool UseAssign_v = useAssign;
139  //**********************************************************************************************
140 
141  //**Parallel evaluation strategy****************************************************************
143 
149  template< typename MT >
150  static constexpr bool UseSMPAssign_v =
151  ( ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign );
153  //**********************************************************************************************
154 
155  public:
156  //**Type definitions****************************************************************************
163 
166 
169 
171  using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
172 
174  using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
175  //**********************************************************************************************
176 
177  //**ConstIterator class definition**************************************************************
181  {
182  public:
183  //**Type definitions*************************************************************************
184  using IteratorCategory = std::random_access_iterator_tag;
189 
190  // STL iterator requirements
196 
199 
202  //*******************************************************************************************
203 
204  //**Constructor******************************************************************************
211  : left_ ( left ) // Iterator to the current left-hand side element
212  , right_( right ) // Iterator to the current right-hand side element
213  {}
214  //*******************************************************************************************
215 
216  //**Addition assignment operator*************************************************************
223  left_ += inc;
224  right_ += inc;
225  return *this;
226  }
227  //*******************************************************************************************
228 
229  //**Subtraction assignment operator**********************************************************
236  left_ -= dec;
237  right_ -= dec;
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Prefix increment operator****************************************************************
248  ++left_;
249  ++right_;
250  return *this;
251  }
252  //*******************************************************************************************
253 
254  //**Postfix increment operator***************************************************************
260  return ConstIterator( left_++, right_++ );
261  }
262  //*******************************************************************************************
263 
264  //**Prefix decrement operator****************************************************************
270  --left_;
271  --right_;
272  return *this;
273  }
274  //*******************************************************************************************
275 
276  //**Postfix decrement operator***************************************************************
282  return ConstIterator( left_--, right_-- );
283  }
284  //*******************************************************************************************
285 
286  //**Element access operator******************************************************************
291  inline ReturnType operator*() const {
292  return (*left_) - (*right_);
293  }
294  //*******************************************************************************************
295 
296  //**Load function****************************************************************************
301  inline auto load() const noexcept {
302  return left_.load() - right_.load();
303  }
304  //*******************************************************************************************
305 
306  //**Equality operator************************************************************************
312  inline BLAZE_DEVICE_CALLABLE bool operator==( const ConstIterator& rhs ) const {
313  return left_ == rhs.left_;
314  }
315  //*******************************************************************************************
316 
317  //**Inequality operator**********************************************************************
323  inline BLAZE_DEVICE_CALLABLE bool operator!=( const ConstIterator& rhs ) const {
324  return left_ != rhs.left_;
325  }
326  //*******************************************************************************************
327 
328  //**Less-than operator***********************************************************************
334  inline BLAZE_DEVICE_CALLABLE bool operator<( const ConstIterator& rhs ) const {
335  return left_ < rhs.left_;
336  }
337  //*******************************************************************************************
338 
339  //**Greater-than operator********************************************************************
345  inline BLAZE_DEVICE_CALLABLE bool operator>( const ConstIterator& rhs ) const {
346  return left_ > rhs.left_;
347  }
348  //*******************************************************************************************
349 
350  //**Less-or-equal-than operator**************************************************************
356  inline BLAZE_DEVICE_CALLABLE bool operator<=( const ConstIterator& rhs ) const {
357  return left_ <= rhs.left_;
358  }
359  //*******************************************************************************************
360 
361  //**Greater-or-equal-than operator***********************************************************
367  inline BLAZE_DEVICE_CALLABLE bool operator>=( const ConstIterator& rhs ) const {
368  return left_ >= rhs.left_;
369  }
370  //*******************************************************************************************
371 
372  //**Subtraction operator*********************************************************************
379  return left_ - rhs.left_;
380  }
381  //*******************************************************************************************
382 
383  //**Addition operator************************************************************************
390  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
391  return ConstIterator( it.left_ + inc, it.right_ + inc );
392  }
393  //*******************************************************************************************
394 
395  //**Addition operator************************************************************************
402  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
403  return ConstIterator( it.left_ + inc, it.right_ + inc );
404  }
405  //*******************************************************************************************
406 
407  //**Subtraction operator*********************************************************************
414  friend inline BLAZE_DEVICE_CALLABLE const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
415  return ConstIterator( it.left_ - dec, it.right_ - dec );
416  }
417  //*******************************************************************************************
418 
419  private:
420  //**Member variables*************************************************************************
423  //*******************************************************************************************
424  };
425  //**********************************************************************************************
426 
427  //**Compilation flags***************************************************************************
429  static constexpr bool simdEnabled =
430  ( MT1::simdEnabled && MT2::simdEnabled && HasSIMDSub_v<ET1,ET2> );
431 
433  static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
434  //**********************************************************************************************
435 
436  //**SIMD properties*****************************************************************************
438  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
439  //**********************************************************************************************
440 
441  //**Constructor*********************************************************************************
447  explicit inline DMatDMatSubExpr( const MT1& lhs, const MT2& rhs ) noexcept
448  : lhs_( lhs ) // Left-hand side dense matrix of the subtraction expression
449  , rhs_( rhs ) // Right-hand side dense matrix of the subtraction expression
450  {
451  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
452  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
453  }
454  //**********************************************************************************************
455 
456  //**Access operator*****************************************************************************
463  inline ReturnType operator()( size_t i, size_t j ) const {
464  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
465  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
466  return lhs_(i,j) - rhs_(i,j);
467  }
468  //**********************************************************************************************
469 
470  //**At function*********************************************************************************
478  inline ReturnType at( size_t i, size_t j ) const {
479  if( i >= lhs_.rows() ) {
480  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
481  }
482  if( j >= lhs_.columns() ) {
483  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
484  }
485  return (*this)(i,j);
486  }
487  //**********************************************************************************************
488 
489  //**Load function*******************************************************************************
496  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
497  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
498  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
499  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
500  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
501  return lhs_.load(i,j) - rhs_.load(i,j);
502  }
503  //**********************************************************************************************
504 
505  //**Begin function******************************************************************************
511  inline ConstIterator begin( size_t i ) const {
512  return ConstIterator( lhs_.begin(i), rhs_.begin(i) );
513  }
514  //**********************************************************************************************
515 
516  //**End function********************************************************************************
522  inline ConstIterator end( size_t i ) const {
523  return ConstIterator( lhs_.end(i), rhs_.end(i) );
524  }
525  //**********************************************************************************************
526 
527  //**Rows function*******************************************************************************
532  inline size_t rows() const noexcept {
533  return lhs_.rows();
534  }
535  //**********************************************************************************************
536 
537  //**Columns function****************************************************************************
542  inline size_t columns() const noexcept {
543  return lhs_.columns();
544  }
545  //**********************************************************************************************
546 
547  //**Left operand access*************************************************************************
552  inline LeftOperand leftOperand() const noexcept {
553  return lhs_;
554  }
555  //**********************************************************************************************
556 
557  //**Right operand access************************************************************************
562  inline RightOperand rightOperand() const noexcept {
563  return rhs_;
564  }
565  //**********************************************************************************************
566 
567  //**********************************************************************************************
573  template< typename T >
574  inline bool canAlias( const T* alias ) const noexcept {
575  return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
576  ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
577  }
578  //**********************************************************************************************
579 
580  //**********************************************************************************************
586  template< typename T >
587  inline bool isAliased( const T* alias ) const noexcept {
588  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
589  }
590  //**********************************************************************************************
591 
592  //**********************************************************************************************
597  inline bool isAligned() const noexcept {
598  return lhs_.isAligned() && rhs_.isAligned();
599  }
600  //**********************************************************************************************
601 
602  //**********************************************************************************************
607  inline bool canSMPAssign() const noexcept {
608  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
609  ( rows() * columns() >= SMP_DMATDMATSUB_THRESHOLD );
610  }
611  //**********************************************************************************************
612 
613  private:
614  //**Member variables****************************************************************************
617  //**********************************************************************************************
618 
619  //**Assignment to dense matrices****************************************************************
633  template< typename MT // Type of the target dense matrix
634  , bool SO2 > // Storage order of the target dense matrix
635  friend inline auto assign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
637  {
639 
640  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
641  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
642 
643  if( !IsOperation_v<MT1> && isSame( ~lhs, rhs.lhs_ ) ) {
644  subAssign( ~lhs, rhs.rhs_ );
645  }
646  else if( ( !IsOperation_v<MT2> && isSame( ~lhs, rhs.rhs_ ) ) ||
647  ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(~lhs) ) ) ) {
648  assign ( ~lhs, -rhs.rhs_ );
649  addAssign( ~lhs, rhs.lhs_ );
650  }
651  else {
652  assign ( ~lhs, rhs.lhs_ );
653  subAssign( ~lhs, rhs.rhs_ );
654  }
655  }
657  //**********************************************************************************************
658 
659  //**Assignment to sparse matrices***************************************************************
673  template< typename MT // Type of the target sparse matrix
674  , bool SO2 > // Storage order of the target sparse matrix
675  friend inline auto assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
677  {
679 
681 
688 
689  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
690  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
691 
692  const TmpType tmp( serial( rhs ) );
693  assign( ~lhs, tmp );
694  }
696  //**********************************************************************************************
697 
698  //**Addition assignment to dense matrices*******************************************************
712  template< typename MT // Type of the target dense matrix
713  , bool SO2 > // Storage order of the target dense matrix
714  friend inline auto addAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
715  -> EnableIf_t< UseAssign_v<MT> >
716  {
718 
719  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
720  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
721 
722  if( !RequiresEvaluation_v<MT2> ) {
723  subAssign( ~lhs, rhs.rhs_ );
724  addAssign( ~lhs, rhs.lhs_ );
725  }
726  else {
727  addAssign( ~lhs, rhs.lhs_ );
728  subAssign( ~lhs, rhs.rhs_ );
729  }
730  }
732  //**********************************************************************************************
733 
734  //**Addition assignment to sparse matrices******************************************************
735  // No special implementation for the addition assignment to sparse matrices.
736  //**********************************************************************************************
737 
738  //**Subtraction assignment to dense matrices****************************************************
752  template< typename MT // Type of the target dense matrix
753  , bool SO2 > // Storage order of the target dense matrix
754  friend inline auto subAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
755  -> EnableIf_t< UseAssign_v<MT> >
756  {
758 
759  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
760  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
761 
762  if( !RequiresEvaluation_v<MT2> ) {
763  addAssign( ~lhs, rhs.rhs_ );
764  subAssign( ~lhs, rhs.lhs_ );
765  }
766  else {
767  subAssign( ~lhs, rhs.lhs_ );
768  addAssign( ~lhs, rhs.rhs_ );
769  }
770  }
772  //**********************************************************************************************
773 
774  //**Subtraction assignment to sparse matrices***************************************************
775  // No special implementation for the subtraction assignment to sparse matrices.
776  //**********************************************************************************************
777 
778  //**Schur product assignment to dense matrices**************************************************
792  template< typename MT // Type of the target dense matrix
793  , bool SO2 > // Storage order of the target dense matrix
794  friend inline auto schurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
795  -> EnableIf_t< UseAssign_v<MT> >
796  {
798 
802 
803  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
804  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
805 
806  const ResultType tmp( serial( rhs ) );
807  schurAssign( ~lhs, tmp );
808  }
810  //**********************************************************************************************
811 
812  //**Schur product assignment to sparse matrices*************************************************
813  // No special implementation for the Schur product assignment to sparse matrices.
814  //**********************************************************************************************
815 
816  //**Multiplication assignment to dense matrices*************************************************
817  // No special implementation for the multiplication assignment to dense matrices.
818  //**********************************************************************************************
819 
820  //**Multiplication assignment to sparse matrices************************************************
821  // No special implementation for the multiplication assignment to sparse matrices.
822  //**********************************************************************************************
823 
824  //**SMP assignment to dense matrices************************************************************
838  template< typename MT // Type of the target dense matrix
839  , bool SO2 > // Storage order of the target dense matrix
840  friend inline auto smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
841  -> EnableIf_t< UseSMPAssign_v<MT> >
842  {
844 
845  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
846  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
847 
848  if( !IsOperation_v<MT1> && isSame( ~lhs, rhs.lhs_ ) ) {
849  smpSubAssign( ~lhs, rhs.rhs_ );
850  }
851  else if( ( !IsOperation_v<MT2> && isSame( ~lhs, rhs.rhs_ ) ) ||
852  ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(~lhs) ) ) ) {
853  smpAssign ( ~lhs, -rhs.rhs_ );
854  smpAddAssign( ~lhs, rhs.lhs_ );
855  }
856  else {
857  smpAssign ( ~lhs, rhs.lhs_ );
858  smpSubAssign( ~lhs, rhs.rhs_ );
859  }
860  }
862  //**********************************************************************************************
863 
864  //**SMP assignment to sparse matrices***********************************************************
878  template< typename MT // Type of the target sparse matrix
879  , bool SO2 > // Storage order of the target sparse matrix
880  friend inline auto smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
881  -> EnableIf_t< UseSMPAssign_v<MT> >
882  {
884 
885  using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
886 
893 
894  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
895  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
896 
897  const TmpType tmp( rhs );
898  smpAssign( ~lhs, tmp );
899  }
901  //**********************************************************************************************
902 
903  //**SMP addition assignment to dense matrices***************************************************
917  template< typename MT // Type of the target dense matrix
918  , bool SO2 > // Storage order of the target dense matrix
919  friend inline auto smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
920  -> EnableIf_t< UseAssign_v<MT> >
921  {
923 
924  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
925  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
926 
927  if( !RequiresEvaluation_v<MT2> ) {
928  smpSubAssign( ~lhs, rhs.rhs_ );
929  smpAddAssign( ~lhs, rhs.lhs_ );
930  }
931  else {
932  smpAddAssign( ~lhs, rhs.lhs_ );
933  smpSubAssign( ~lhs, rhs.rhs_ );
934  }
935  }
937  //**********************************************************************************************
938 
939  //**SMP addition assignment to sparse matrices**************************************************
940  // No special implementation for the SMP addition assignment to sparse matrices.
941  //**********************************************************************************************
942 
943  //**SMP subtraction assignment to dense matrices************************************************
957  template< typename MT // Type of the target dense matrix
958  , bool SO2 > // Storage order of the target dense matrix
959  friend inline auto smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
960  -> EnableIf_t< UseSMPAssign_v<MT> >
961  {
963 
964  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
965  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
966 
967  if( !RequiresEvaluation_v<MT2> ) {
968  smpAddAssign( ~lhs, rhs.rhs_ );
969  smpSubAssign( ~lhs, rhs.lhs_ );
970  }
971  else {
972  smpSubAssign( ~lhs, rhs.lhs_ );
973  smpAddAssign( ~lhs, rhs.rhs_ );
974  }
975  }
977  //**********************************************************************************************
978 
979  //**SMP subtraction assignment to sparse matrices***********************************************
980  // No special implementation for the SMP subtraction assignment to sparse matrices.
981  //**********************************************************************************************
982 
983  //**SMP Schur product assignment to dense matrices**********************************************
998  template< typename MT // Type of the target dense matrix
999  , bool SO2 > // Storage order of the target dense matrix
1000  friend inline auto smpSchurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
1001  -> EnableIf_t< UseSMPAssign_v<MT> >
1002  {
1004 
1008 
1009  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
1010  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
1011 
1012  const ResultType tmp( rhs );
1013  smpSchurAssign( ~lhs, tmp );
1014  }
1016  //**********************************************************************************************
1017 
1018  //**SMP Schur product assignment to sparse matrices*********************************************
1019  // No special implementation for the SMP Schur product assignment to sparse matrices.
1020  //**********************************************************************************************
1021 
1022  //**SMP multiplication assignment to dense matrices*********************************************
1023  // No special implementation for the SMP multiplication assignment to dense matrices.
1024  //**********************************************************************************************
1025 
1026  //**SMP multiplication assignment to sparse matrices********************************************
1027  // No special implementation for the SMP multiplication assignment to sparse matrices.
1028  //**********************************************************************************************
1029 
1030  //**Compile time checks*************************************************************************
1036  //**********************************************************************************************
1037 };
1038 //*************************************************************************************************
1039 
1040 
1041 
1042 
1043 //=================================================================================================
1044 //
1045 // GLOBAL BINARY ARITHMETIC OPERATORS
1046 //
1047 //=================================================================================================
1048 
1049 //*************************************************************************************************
1074 template< typename MT1 // Type of the left-hand side dense matrix
1075  , typename MT2 // Type of the right-hand side dense matrix
1076  , bool SO > // Storage order
1077 inline decltype(auto)
1078  operator-( const DenseMatrix<MT1,SO>& lhs, const DenseMatrix<MT2,SO>& rhs )
1079 {
1081 
1082  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
1083  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1084  }
1085 
1086  using ReturnType = const DMatDMatSubExpr<MT1,MT2,SO>;
1087  return ReturnType( ~lhs, ~rhs );
1088 }
1089 //*************************************************************************************************
1090 
1091 
1092 
1093 
1094 //=================================================================================================
1095 //
1096 // ISALIGNED SPECIALIZATIONS
1097 //
1098 //=================================================================================================
1099 
1100 //*************************************************************************************************
1102 template< typename MT1, typename MT2, bool SO >
1103 struct IsAligned< DMatDMatSubExpr<MT1,MT2,SO> >
1104  : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1105 {};
1107 //*************************************************************************************************
1108 
1109 
1110 
1111 
1112 //=================================================================================================
1113 //
1114 // ISPADDED SPECIALIZATIONS
1115 //
1116 //=================================================================================================
1117 
1118 //*************************************************************************************************
1120 template< typename MT1, typename MT2, bool SO >
1121 struct IsPadded< DMatDMatSubExpr<MT1,MT2,SO> >
1122  : public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
1123 {};
1125 //*************************************************************************************************
1126 
1127 } // namespace blaze
1128 
1129 #endif
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatSubExpr.h:378
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:104
ElementType * PointerType
Pointer return type.
Definition: DMatDMatSubExpr.h:186
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.The SubTrait_t alias declaration provides...
Definition: SubTrait.h:238
Header file for the subtraction trait.
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.
ConstIterator_t< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:201
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:106
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatSubExpr.h:222
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
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatDMatSubExpr.h:269
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatSubExpr.h:187
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatSubExpr.h:235
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:334
ReturnType operator *() const
Direct access to the element at the current iterator position.
Definition: DMatDMatSubExpr.h:291
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatSubExpr.h:532
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:312
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatSubExpr.h:301
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
PointerType pointer
Pointer return type.
Definition: DMatDMatSubExpr.h:193
ReferenceType reference
Reference return type.
Definition: DMatDMatSubExpr.h:194
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:81
Iterator over the elements of the dense matrix.
Definition: DMatDMatSubExpr.h:180
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
ValueType value_type
Type of the underlying elements.
Definition: DMatDMatSubExpr.h:192
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatDMatSubExpr.h:429
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
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatSubExpr.h:496
ConstIterator_t< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:198
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:171
RightOperand rhs_
Right-hand side dense matrix of the subtraction expression.
Definition: DMatDMatSubExpr.h:616
Expression object for dense matrix-dense matrix subtractions.The DMatDMatSubExpr class represents the...
Definition: DMatDMatSubExpr.h:94
Header file for the IsTemporary type trait class.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatDMatSubExpr.h:188
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:102
Base class for all matrix/matrix subtraction expression templates.The MatMatSubExpr class serves as a...
Definition: MatMatSubExpr.h:67
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
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatSubExpr.h:161
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatSubExpr.h:165
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:356
Header file for the If class template.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the subtraction expression.
Definition: DMatDMatSubExpr.h:131
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatDMatSubExpr.h:433
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatDMatSubExpr.h:511
#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 DenseMatrix base class.
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:105
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DMatDMatSubExpr.h:422
Header file for all SIMD functionality.
Header file for the MatMatSubExpr base class.
If_t< useAssign, const ResultType, const DMatDMatSubExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatDMatSubExpr.h:168
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatSubExpr.h:414
Header file for the IsOperation type trait class.
Header file for the IsAligned type trait.
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatSubExpr.h:259
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:174
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatSubExpr.h:160
Constraint on the data type.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatSubExpr.h:607
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:345
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
decltype(std::declval< RN1 >() - std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatSubExpr.h:120
DMatDMatSubExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatSubExpr class.
Definition: DMatDMatSubExpr.h:447
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatSubExpr.h:574
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
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
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatDMatSubExpr.h:117
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatDMatSubExpr.h:402
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatDMatSubExpr.h:162
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
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatDMatSubExpr.h:438
Header file for all forward declarations for expression class templates.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatSubExpr.h:478
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
Header file for the HasSIMDSub type trait.
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:101
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:103
#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
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant alias template represents ...
Definition: IntegralConstant.h:110
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
BLAZE_DEVICE_CALLABLE ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatSubExpr.h:210
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatSubExpr.h:562
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatSubExpr.h:542
#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
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:323
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatSubExpr.h:587
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatSubExpr.h:191
Macro for CUDA compatibility.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDMatSubExpr.h:597
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatSubExpr.h:552
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatDMatSubExpr.h:281
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
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:100
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatSubExpr.h:421
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:367
Header file for the IntegralConstant class template.
SubTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatSubExpr.h:159
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATSUBEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatSubExpr.h:103
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatDMatSubExpr.h:615
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatSubExpr.h:390
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatSubExpr.h:247
System settings for the inline keywords.
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatSubExpr.h:184
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,...
Definition: Assert.h:101
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatSubExpr.h:185
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:107
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatSubExpr.h:463
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatDMatSubExpr.h:522