Blaze 3.9
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>
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
76namespace blaze {
77
78//=================================================================================================
79//
80// CLASS DMATDMATSUBEXPR
81//
82//=================================================================================================
83
84//*************************************************************************************************
91template< 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
136 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****************************************************************************
159
162
167
170
173
175 using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
176
178 using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
179 //**********************************************************************************************
180
181 //**ConstIterator class definition**************************************************************
185 {
186 public:
187 //**Type definitions*************************************************************************
188 using IteratorCategory = std::random_access_iterator_tag;
192 using DifferenceType = ptrdiff_t;
193
194 // STL iterator requirements
200
203
206 //*******************************************************************************************
207
208 //**Constructor******************************************************************************
215 : left_ ( left ) // Iterator to the current left-hand side element
216 , right_( right ) // Iterator to the current right-hand side element
217 {}
218 //*******************************************************************************************
219
220 //**Addition assignment operator*************************************************************
227 left_ += inc;
228 right_ += inc;
229 return *this;
230 }
231 //*******************************************************************************************
232
233 //**Subtraction assignment operator**********************************************************
240 left_ -= dec;
241 right_ -= dec;
242 return *this;
243 }
244 //*******************************************************************************************
245
246 //**Prefix increment operator****************************************************************
252 ++left_;
253 ++right_;
254 return *this;
255 }
256 //*******************************************************************************************
257
258 //**Postfix increment operator***************************************************************
264 return ConstIterator( left_++, right_++ );
265 }
266 //*******************************************************************************************
267
268 //**Prefix decrement operator****************************************************************
274 --left_;
275 --right_;
276 return *this;
277 }
278 //*******************************************************************************************
279
280 //**Postfix decrement operator***************************************************************
286 return ConstIterator( left_--, right_-- );
287 }
288 //*******************************************************************************************
289
290 //**Element access operator******************************************************************
295 inline ReturnType operator*() const {
296 return (*left_) - (*right_);
297 }
298 //*******************************************************************************************
299
300 //**Load function****************************************************************************
305 inline auto load() const noexcept {
306 return left_.load() - right_.load();
307 }
308 //*******************************************************************************************
309
310 //**Equality operator************************************************************************
316 inline BLAZE_DEVICE_CALLABLE bool operator==( const ConstIterator& rhs ) const {
317 return left_ == rhs.left_;
318 }
319 //*******************************************************************************************
320
321 //**Inequality operator**********************************************************************
327 inline BLAZE_DEVICE_CALLABLE bool operator!=( const ConstIterator& rhs ) const {
328 return left_ != rhs.left_;
329 }
330 //*******************************************************************************************
331
332 //**Less-than operator***********************************************************************
338 inline BLAZE_DEVICE_CALLABLE bool operator<( const ConstIterator& rhs ) const {
339 return left_ < rhs.left_;
340 }
341 //*******************************************************************************************
342
343 //**Greater-than operator********************************************************************
349 inline BLAZE_DEVICE_CALLABLE bool operator>( const ConstIterator& rhs ) const {
350 return left_ > rhs.left_;
351 }
352 //*******************************************************************************************
353
354 //**Less-or-equal-than operator**************************************************************
360 inline BLAZE_DEVICE_CALLABLE bool operator<=( const ConstIterator& rhs ) const {
361 return left_ <= rhs.left_;
362 }
363 //*******************************************************************************************
364
365 //**Greater-or-equal-than operator***********************************************************
371 inline BLAZE_DEVICE_CALLABLE bool operator>=( const ConstIterator& rhs ) const {
372 return left_ >= rhs.left_;
373 }
374 //*******************************************************************************************
375
376 //**Subtraction operator*********************************************************************
383 return left_ - rhs.left_;
384 }
385 //*******************************************************************************************
386
387 //**Addition operator************************************************************************
394 friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
395 return ConstIterator( it.left_ + inc, it.right_ + inc );
396 }
397 //*******************************************************************************************
398
399 //**Addition operator************************************************************************
406 friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
407 return ConstIterator( it.left_ + inc, it.right_ + inc );
408 }
409 //*******************************************************************************************
410
411 //**Subtraction operator*********************************************************************
418 friend inline BLAZE_DEVICE_CALLABLE const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
419 return ConstIterator( it.left_ - dec, it.right_ - dec );
420 }
421 //*******************************************************************************************
422
423 private:
424 //**Member variables*************************************************************************
427 //*******************************************************************************************
428 };
429 //**********************************************************************************************
430
431 //**Compilation flags***************************************************************************
433 static constexpr bool simdEnabled =
434 ( MT1::simdEnabled && MT2::simdEnabled && HasSIMDSub_v<ET1,ET2> );
435
437 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
438 //**********************************************************************************************
439
440 //**SIMD properties*****************************************************************************
442 static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
443 //**********************************************************************************************
444
445 //**Constructor*********************************************************************************
451 inline DMatDMatSubExpr( const MT1& lhs, const MT2& rhs ) noexcept
452 : lhs_( lhs ) // Left-hand side dense matrix of the subtraction expression
453 , rhs_( rhs ) // Right-hand side dense matrix of the subtraction expression
454 {
455 BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
456 BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
457 }
458 //**********************************************************************************************
459
460 //**Access operator*****************************************************************************
467 inline ReturnType operator()( size_t i, size_t j ) const {
468 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
469 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
470 return lhs_(i,j) - rhs_(i,j);
471 }
472 //**********************************************************************************************
473
474 //**At function*********************************************************************************
482 inline ReturnType at( size_t i, size_t j ) const {
483 if( i >= lhs_.rows() ) {
484 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
485 }
486 if( j >= lhs_.columns() ) {
487 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
488 }
489 return (*this)(i,j);
490 }
491 //**********************************************************************************************
492
493 //**Load function*******************************************************************************
500 BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
501 BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
502 BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
503 BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
504 BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
505 return lhs_.load(i,j) - rhs_.load(i,j);
506 }
507 //**********************************************************************************************
508
509 //**Begin function******************************************************************************
515 inline ConstIterator begin( size_t i ) const {
516 return ConstIterator( lhs_.begin(i), rhs_.begin(i) );
517 }
518 //**********************************************************************************************
519
520 //**End function********************************************************************************
526 inline ConstIterator end( size_t i ) const {
527 return ConstIterator( lhs_.end(i), rhs_.end(i) );
528 }
529 //**********************************************************************************************
530
531 //**Rows function*******************************************************************************
536 inline size_t rows() const noexcept {
537 return lhs_.rows();
538 }
539 //**********************************************************************************************
540
541 //**Columns function****************************************************************************
546 inline size_t columns() const noexcept {
547 return lhs_.columns();
548 }
549 //**********************************************************************************************
550
551 //**Left operand access*************************************************************************
556 inline LeftOperand leftOperand() const noexcept {
557 return lhs_;
558 }
559 //**********************************************************************************************
560
561 //**Right operand access************************************************************************
566 inline RightOperand rightOperand() const noexcept {
567 return rhs_;
568 }
569 //**********************************************************************************************
570
571 //**********************************************************************************************
577 template< typename T >
578 inline bool canAlias( const T* alias ) const noexcept {
579 return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
580 ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
581 }
582 //**********************************************************************************************
583
584 //**********************************************************************************************
590 template< typename T >
591 inline bool isAliased( const T* alias ) const noexcept {
592 return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
593 }
594 //**********************************************************************************************
595
596 //**********************************************************************************************
601 inline bool isAligned() const noexcept {
602 return lhs_.isAligned() && rhs_.isAligned();
603 }
604 //**********************************************************************************************
605
606 //**********************************************************************************************
611 inline bool canSMPAssign() const noexcept {
612 return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
613 ( rows() * columns() >= SMP_DMATDMATSUB_THRESHOLD );
614 }
615 //**********************************************************************************************
616
617 private:
618 //**Member variables****************************************************************************
621 //**********************************************************************************************
622
623 //**Assignment to dense matrices****************************************************************
637 template< typename MT // Type of the target dense matrix
638 , bool SO2 > // Storage order of the target dense matrix
639 friend inline auto assign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
641 {
643
644 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
645 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
646
647 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
648 subAssign( *lhs, rhs.rhs_ );
649 }
650 else if( ( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) ||
651 ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(*lhs) ) ) ) {
652 assign ( *lhs, -rhs.rhs_ );
653 addAssign( *lhs, rhs.lhs_ );
654 }
655 else {
656 assign ( *lhs, rhs.lhs_ );
657 subAssign( *lhs, rhs.rhs_ );
658 }
659 }
661 //**********************************************************************************************
662
663 //**Assignment to sparse matrices***************************************************************
677 template< typename MT // Type of the target sparse matrix
678 , bool SO2 > // Storage order of the target sparse matrix
679 friend inline auto assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
681 {
683
685
692
693 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
694 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
695
696 const TmpType tmp( serial( rhs ) );
697 assign( *lhs, tmp );
698 }
700 //**********************************************************************************************
701
702 //**Addition assignment to dense matrices*******************************************************
716 template< typename MT // Type of the target dense matrix
717 , bool SO2 > // Storage order of the target dense matrix
718 friend inline auto addAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
719 -> EnableIf_t< UseAssign_v<MT> >
720 {
722
723 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
724 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
725
726 if( !RequiresEvaluation_v<MT2> ) {
727 subAssign( *lhs, rhs.rhs_ );
728 addAssign( *lhs, rhs.lhs_ );
729 }
730 else {
731 addAssign( *lhs, rhs.lhs_ );
732 subAssign( *lhs, rhs.rhs_ );
733 }
734 }
736 //**********************************************************************************************
737
738 //**Addition assignment to sparse matrices******************************************************
739 // No special implementation for the addition assignment to sparse matrices.
740 //**********************************************************************************************
741
742 //**Subtraction assignment to dense matrices****************************************************
756 template< typename MT // Type of the target dense matrix
757 , bool SO2 > // Storage order of the target dense matrix
758 friend inline auto subAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
759 -> EnableIf_t< UseAssign_v<MT> >
760 {
762
763 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
764 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
765
766 if( !RequiresEvaluation_v<MT2> ) {
767 addAssign( *lhs, rhs.rhs_ );
768 subAssign( *lhs, rhs.lhs_ );
769 }
770 else {
771 subAssign( *lhs, rhs.lhs_ );
772 addAssign( *lhs, rhs.rhs_ );
773 }
774 }
776 //**********************************************************************************************
777
778 //**Subtraction assignment to sparse matrices***************************************************
779 // No special implementation for the subtraction assignment to sparse matrices.
780 //**********************************************************************************************
781
782 //**Schur product assignment to dense matrices**************************************************
796 template< typename MT // Type of the target dense matrix
797 , bool SO2 > // Storage order of the target dense matrix
798 friend inline auto schurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
799 -> EnableIf_t< UseAssign_v<MT> >
800 {
802
806
807 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
808 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
809
810 const ResultType tmp( serial( rhs ) );
811 schurAssign( *lhs, tmp );
812 }
814 //**********************************************************************************************
815
816 //**Schur product assignment to sparse matrices*************************************************
817 // No special implementation for the Schur product assignment to sparse matrices.
818 //**********************************************************************************************
819
820 //**Multiplication assignment to dense matrices*************************************************
821 // No special implementation for the multiplication assignment to dense matrices.
822 //**********************************************************************************************
823
824 //**Multiplication assignment to sparse matrices************************************************
825 // No special implementation for the multiplication assignment to sparse matrices.
826 //**********************************************************************************************
827
828 //**SMP assignment to dense matrices************************************************************
842 template< typename MT // Type of the target dense matrix
843 , bool SO2 > // Storage order of the target dense matrix
844 friend inline auto smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
845 -> EnableIf_t< UseSMPAssign_v<MT> >
846 {
848
849 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
850 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
851
852 if( !IsOperation_v<MT1> && isSame( *lhs, rhs.lhs_ ) ) {
853 smpSubAssign( *lhs, rhs.rhs_ );
854 }
855 else if( ( !IsOperation_v<MT2> && isSame( *lhs, rhs.rhs_ ) ) ||
856 ( !RequiresEvaluation_v<MT2> && rhs.rhs_.isAliased( &(*lhs) ) ) ) {
857 smpAssign ( *lhs, -rhs.rhs_ );
858 smpAddAssign( *lhs, rhs.lhs_ );
859 }
860 else {
861 smpAssign ( *lhs, rhs.lhs_ );
862 smpSubAssign( *lhs, rhs.rhs_ );
863 }
864 }
866 //**********************************************************************************************
867
868 //**SMP assignment to sparse matrices***********************************************************
882 template< typename MT // Type of the target sparse matrix
883 , bool SO2 > // Storage order of the target sparse matrix
884 friend inline auto smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
885 -> EnableIf_t< UseSMPAssign_v<MT> >
886 {
888
889 using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
890
897
898 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
899 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
900
901 const TmpType tmp( rhs );
902 smpAssign( *lhs, tmp );
903 }
905 //**********************************************************************************************
906
907 //**SMP addition assignment to dense matrices***************************************************
921 template< typename MT // Type of the target dense matrix
922 , bool SO2 > // Storage order of the target dense matrix
923 friend inline auto smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
924 -> EnableIf_t< UseAssign_v<MT> >
925 {
927
928 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
929 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
930
931 if( !RequiresEvaluation_v<MT2> ) {
932 smpSubAssign( *lhs, rhs.rhs_ );
933 smpAddAssign( *lhs, rhs.lhs_ );
934 }
935 else {
936 smpAddAssign( *lhs, rhs.lhs_ );
937 smpSubAssign( *lhs, rhs.rhs_ );
938 }
939 }
941 //**********************************************************************************************
942
943 //**SMP addition assignment to sparse matrices**************************************************
944 // No special implementation for the SMP addition assignment to sparse matrices.
945 //**********************************************************************************************
946
947 //**SMP subtraction assignment to dense matrices************************************************
961 template< typename MT // Type of the target dense matrix
962 , bool SO2 > // Storage order of the target dense matrix
963 friend inline auto smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
964 -> EnableIf_t< UseSMPAssign_v<MT> >
965 {
967
968 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
969 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
970
971 if( !RequiresEvaluation_v<MT2> ) {
972 smpAddAssign( *lhs, rhs.rhs_ );
973 smpSubAssign( *lhs, rhs.lhs_ );
974 }
975 else {
976 smpSubAssign( *lhs, rhs.lhs_ );
977 smpAddAssign( *lhs, rhs.rhs_ );
978 }
979 }
981 //**********************************************************************************************
982
983 //**SMP subtraction assignment to sparse matrices***********************************************
984 // No special implementation for the SMP subtraction assignment to sparse matrices.
985 //**********************************************************************************************
986
987 //**SMP Schur product assignment to dense matrices**********************************************
1002 template< typename MT // Type of the target dense matrix
1003 , bool SO2 > // Storage order of the target dense matrix
1004 friend inline auto smpSchurAssign( DenseMatrix<MT,SO2>& lhs, const DMatDMatSubExpr& rhs )
1005 -> EnableIf_t< UseSMPAssign_v<MT> >
1006 {
1008
1012
1013 BLAZE_INTERNAL_ASSERT( (*lhs).rows() == rhs.rows() , "Invalid number of rows" );
1014 BLAZE_INTERNAL_ASSERT( (*lhs).columns() == rhs.columns(), "Invalid number of columns" );
1015
1016 const ResultType tmp( rhs );
1017 smpSchurAssign( *lhs, tmp );
1018 }
1020 //**********************************************************************************************
1021
1022 //**SMP Schur product assignment to sparse matrices*********************************************
1023 // No special implementation for the SMP Schur product assignment to sparse matrices.
1024 //**********************************************************************************************
1025
1026 //**SMP multiplication assignment to dense matrices*********************************************
1027 // No special implementation for the SMP multiplication assignment to dense matrices.
1028 //**********************************************************************************************
1029
1030 //**SMP multiplication assignment to sparse matrices********************************************
1031 // No special implementation for the SMP multiplication assignment to sparse matrices.
1032 //**********************************************************************************************
1033
1034 //**Compile time checks*************************************************************************
1040 //**********************************************************************************************
1041};
1042//*************************************************************************************************
1043
1044
1045
1046
1047//=================================================================================================
1048//
1049// GLOBAL BINARY ARITHMETIC OPERATORS
1050//
1051//=================================================================================================
1052
1053//*************************************************************************************************
1078template< typename MT1 // Type of the left-hand side dense matrix
1079 , typename MT2 // Type of the right-hand side dense matrix
1080 , bool SO > // Storage order
1081inline decltype(auto)
1082 operator-( const DenseMatrix<MT1,SO>& lhs, const DenseMatrix<MT2,SO>& rhs )
1083{
1085
1086 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1087 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1088 }
1089
1090 using ReturnType = const DMatDMatSubExpr<MT1,MT2,SO>;
1091 return ReturnType( *lhs, *rhs );
1092}
1093//*************************************************************************************************
1094
1095
1096
1097
1098//=================================================================================================
1099//
1100// ISALIGNED SPECIALIZATIONS
1101//
1102//=================================================================================================
1103
1104//*************************************************************************************************
1106template< typename MT1, typename MT2, bool SO >
1107struct IsAligned< DMatDMatSubExpr<MT1,MT2,SO> >
1108 : public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1109{};
1111//*************************************************************************************************
1112
1113
1114
1115
1116//=================================================================================================
1117//
1118// ISPADDED SPECIALIZATIONS
1119//
1120//=================================================================================================
1121
1122//*************************************************************************************************
1124template< typename MT1, typename MT2, bool SO >
1125struct IsPadded< DMatDMatSubExpr<MT1,MT2,SO> >
1126 : public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
1127{};
1129//*************************************************************************************************
1130
1131} // namespace blaze
1132
1133#endif
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition: Aliases.h:130
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasSIMDSub type trait.
Macro for CUDA compatibility.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsExpression type trait class.
Header file for the IsOperation type trait class.
Header file for the IsPadded type trait.
Header file for the IsTemporary type trait class.
Header file for all SIMD functionality.
Header file for the subtraction trait.
Iterator over the elements of the dense matrix.
Definition: DMatDMatSubExpr.h:185
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatDMatSubExpr.h:192
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatSubExpr.h:195
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatDMatSubExpr.h:295
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatDMatSubExpr.h:285
ConstIterator_t< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:205
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatSubExpr.h:251
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:349
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:371
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatDMatSubExpr.h:273
PointerType pointer
Pointer return type.
Definition: DMatDMatSubExpr.h:197
ConstIterator_t< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:202
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatSubExpr.h:189
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatSubExpr.h:263
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatSubExpr.h:394
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatSubExpr.h:239
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:316
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DMatDMatSubExpr.h:426
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatSubExpr.h:382
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatSubExpr.h:188
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatSubExpr.h:191
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatDMatSubExpr.h:406
DifferenceType difference_type
Difference between two iterators.
Definition: DMatDMatSubExpr.h:199
BLAZE_DEVICE_CALLABLE ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatSubExpr.h:214
ValueType value_type
Type of the underlying elements.
Definition: DMatDMatSubExpr.h:196
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:338
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatSubExpr.h:305
ElementType * PointerType
Pointer return type.
Definition: DMatDMatSubExpr.h:190
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:360
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatSubExpr.h:425
ReferenceType reference
Reference return type.
Definition: DMatDMatSubExpr.h:198
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatSubExpr.h:226
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatSubExpr.h:418
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatSubExpr.h:327
Expression object for dense matrix-dense matrix subtractions.
Definition: DMatDMatSubExpr.h:97
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:105
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatSubExpr.h:164
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:178
SubTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatSubExpr.h:163
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:102
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatSubExpr.h:482
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatSubExpr.h:546
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatDMatSubExpr.h:117
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:100
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatDMatSubExpr.h:515
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatSubExpr.h:556
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:103
If_t< useAssign, const ResultType, const DMatDMatSubExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatDMatSubExpr.h:172
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatSubExpr.h:536
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatDMatSubExpr.h:437
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:106
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatSubExpr.h:591
RightOperand rhs_
Right-hand side dense matrix of the subtraction expression.
Definition: DMatDMatSubExpr.h:620
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:104
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:451
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatSubExpr.h:578
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatSubExpr.h:611
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatSubExpr.h:467
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatSubExpr.h:165
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatDMatSubExpr.h:433
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:107
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:175
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatDMatSubExpr.h:166
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatSubExpr.h:169
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatDMatSubExpr.h:526
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDMatSubExpr.h:601
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatSubExpr.h:566
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatDMatSubExpr.h:442
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the subtraction expression.
Definition: DMatDMatSubExpr.h:131
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatSubExpr.h:500
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatDMatSubExpr.h:619
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatSubExpr.h:101
Base class for dense matrices.
Definition: DenseMatrix.h:82
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseMatrix base class.
Header file for the MatMatSubExpr base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition: StorageOrder.h:84
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATSUBEXPR(T1, T2)
Constraint on the data type.
Definition: MatMatSubExpr.h:103
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.
Definition: SubTrait.h:163
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:1424
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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
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
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
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all matrix/matrix subtraction expression templates.
Definition: MatMatSubExpr.h:69
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.