DMatSMatSubExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSMATSUBEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATSMATSUBEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
76 #include <blaze/util/Assert.h>
78 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/InvalidType.h>
82 #include <blaze/util/mpl/And.h>
83 #include <blaze/util/mpl/If.h>
84 #include <blaze/util/mpl/Max.h>
85 #include <blaze/util/Types.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // CLASS DMATSMATSUBEXPR
93 //
94 //=================================================================================================
95 
96 //*************************************************************************************************
103 template< typename MT1 // Type of the left-hand side dense matrix
104  , typename MT2 // Type of the right-hand side sparse matrix
105  , bool SO > // Storage order
106 class DMatSMatSubExpr : public DenseMatrix< DMatSMatSubExpr<MT1,MT2,SO>, SO >
107  , private MatMatSubExpr
108  , private Computation
109 {
110  private:
111  //**Type definitions****************************************************************************
116  //**********************************************************************************************
117 
118  //**Return type evaluation**********************************************************************
120 
125  enum : bool { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
126 
129  //**********************************************************************************************
130 
131  //**Parallel evaluation strategy****************************************************************
133 
138  template< typename MT >
139  struct UseSMPAssign {
140  enum : bool { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) };
141  };
143  //**********************************************************************************************
144 
145  public:
146  //**Type definitions****************************************************************************
152 
155 
157  typedef const ResultType CompositeType;
158 
160  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
161 
163  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
164  //**********************************************************************************************
165 
166  //**Compilation flags***************************************************************************
168  enum : bool { simdEnabled = false };
169 
171  enum : bool { smpAssignable = false };
172  //**********************************************************************************************
173 
174  //**Constructor*********************************************************************************
180  explicit inline DMatSMatSubExpr( const MT1& lhs, const MT2& rhs ) noexcept
181  : lhs_( lhs ) // Left-hand side dense matrix of the subtraction expression
182  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
183  {
184  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
185  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
186  }
187  //**********************************************************************************************
188 
189  //**Access operator*****************************************************************************
196  inline ReturnType operator()( size_t i, size_t j ) const {
197  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
198  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
199  return lhs_(i,j) - rhs_(i,j);
200  }
201  //**********************************************************************************************
202 
203  //**At function*********************************************************************************
211  inline ReturnType at( size_t i, size_t j ) const {
212  if( i >= lhs_.rows() ) {
213  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
214  }
215  if( j >= lhs_.columns() ) {
216  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
217  }
218  return (*this)(i,j);
219  }
220  //**********************************************************************************************
221 
222  //**Rows function*******************************************************************************
227  inline size_t rows() const noexcept {
228  return lhs_.rows();
229  }
230  //**********************************************************************************************
231 
232  //**Columns function****************************************************************************
237  inline size_t columns() const noexcept {
238  return lhs_.columns();
239  }
240  //**********************************************************************************************
241 
242  //**Left operand access*************************************************************************
247  inline LeftOperand leftOperand() const noexcept {
248  return lhs_;
249  }
250  //**********************************************************************************************
251 
252  //**Right operand access************************************************************************
257  inline RightOperand rightOperand() const noexcept {
258  return rhs_;
259  }
260  //**********************************************************************************************
261 
262  //**********************************************************************************************
268  template< typename T >
269  inline bool canAlias( const T* alias ) const noexcept {
270  return ( IsExpression<MT1>::value && lhs_.canAlias( alias ) ) ||
271  ( rhs_.canAlias( alias ) );
272  }
273  //**********************************************************************************************
274 
275  //**********************************************************************************************
281  template< typename T >
282  inline bool isAliased( const T* alias ) const noexcept {
283  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
284  }
285  //**********************************************************************************************
286 
287  private:
288  //**Member variables****************************************************************************
289  LeftOperand lhs_;
290  RightOperand rhs_;
291  //**********************************************************************************************
292 
293  //**Assignment to dense matrices****************************************************************
305  template< typename MT // Type of the target dense matrix
306  , bool SO2 > // Storage order of the target dense matrix
307  friend inline void assign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
308  {
310 
311  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
312  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
313 
314  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
315  subAssign( ~lhs, rhs.rhs_ );
316  }
317  else {
318  assign ( ~lhs, rhs.lhs_ );
319  subAssign( ~lhs, rhs.rhs_ );
320  }
321  }
323  //**********************************************************************************************
324 
325  //**Assignment to sparse matrices***************************************************************
337  template< typename MT // Type of the target sparse matrix
338  , bool SO2 > // Storage order of the target sparse matrix
339  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
340  {
342 
344 
351 
352  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
353  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
354 
355  const TmpType tmp( serial( rhs ) );
356  assign( ~lhs, tmp );
357  }
359  //**********************************************************************************************
360 
361  //**Addition assignment to dense matrices*******************************************************
373  template< typename MT // Type of the target dense matrix
374  , bool SO2 > // Storage order of the target dense matrix
375  friend inline void addAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
376  {
378 
379  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
380  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
381 
382  addAssign( ~lhs, rhs.lhs_ );
383  subAssign( ~lhs, rhs.rhs_ );
384  }
386  //**********************************************************************************************
387 
388  //**Addition assignment to sparse matrices******************************************************
389  // No special implementation for the addition assignment to sparse matrices.
390  //**********************************************************************************************
391 
392  //**Subtraction assignment to dense matrices****************************************************
404  template< typename MT // Type of the target dense matrix
405  , bool SO2 > // Storage order of the target dense matrix
406  friend inline void subAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
407  {
409 
410  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
411  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
412 
413  subAssign( ~lhs, rhs.lhs_ );
414  addAssign( ~lhs, rhs.rhs_ );
415  }
417  //**********************************************************************************************
418 
419  //**Subtraction assignment to sparse matrices***************************************************
420  // No special implementation for the subtraction assignment to sparse matrices.
421  //**********************************************************************************************
422 
423  //**Multiplication assignment to dense matrices*************************************************
424  // No special implementation for the multiplication assignment to dense matrices.
425  //**********************************************************************************************
426 
427  //**Multiplication assignment to sparse matrices************************************************
428  // No special implementation for the multiplication assignment to sparse matrices.
429  //**********************************************************************************************
430 
431  //**SMP assignment to dense matrices************************************************************
445  template< typename MT // Type of the target dense matrix
446  , bool SO2 > // Storage order of the target dense matrix
447  friend inline EnableIf_< UseSMPAssign<MT> >
448  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
449  {
451 
452  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
453  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
454 
455  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
456  smpSubAssign( ~lhs, rhs.rhs_ );
457  }
458  else {
459  smpAssign ( ~lhs, rhs.lhs_ );
460  smpSubAssign( ~lhs, rhs.rhs_ );
461  }
462  }
464  //**********************************************************************************************
465 
466  //**SMP assignment to sparse matrices***********************************************************
480  template< typename MT // Type of the target sparse matrix
481  , bool SO2 > // Storage order of the target sparse matrix
482  friend inline EnableIf_< UseSMPAssign<MT> >
483  smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
484  {
486 
487  typedef IfTrue_< SO == SO2, ResultType, OppositeType > TmpType;
488 
494  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<TmpType> );
495 
496  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
497  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
498 
499  const TmpType tmp( rhs );
500  smpAssign( ~lhs, tmp );
501  }
503  //**********************************************************************************************
504 
505  //**SMP addition assignment to dense matrices***************************************************
519  template< typename MT // Type of the target dense matrix
520  , bool SO2 > // Storage order of the target dense matrix
521  friend inline EnableIf_< UseSMPAssign<MT> >
522  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
523  {
525 
526  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
527  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
528 
529  smpAddAssign( ~lhs, rhs.lhs_ );
530  smpSubAssign( ~lhs, rhs.rhs_ );
531  }
533  //**********************************************************************************************
534 
535  //**SMP addition assignment to sparse matrices**************************************************
536  // No special implementation for the SMP addition assignment to sparse matrices.
537  //**********************************************************************************************
538 
539  //**SMP subtraction assignment to dense matrices************************************************
553  template< typename MT // Type of the target dense matrix
554  , bool SO2 > // Storage order of the target dense matrix
555  friend inline EnableIf_< UseSMPAssign<MT> >
556  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
557  {
559 
560  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
561  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
562 
563  smpSubAssign( ~lhs, rhs.lhs_ );
564  smpAddAssign( ~lhs, rhs.rhs_ );
565  }
567  //**********************************************************************************************
568 
569  //**SMP subtraction assignment to sparse matrices***********************************************
570  // No special implementation for the SMP subtraction assignment to sparse matrices.
571  //**********************************************************************************************
572 
573  //**SMP multiplication assignment to dense matrices*********************************************
574  // No special implementation for the SMP multiplication assignment to dense matrices.
575  //**********************************************************************************************
576 
577  //**SMP multiplication assignment to sparse matrices************************************************
578  // No special implementation for the SMP multiplication assignment to sparse matrices.
579  //**********************************************************************************************
580 
581  //**Compile time checks*************************************************************************
588  //**********************************************************************************************
589 };
590 //*************************************************************************************************
591 
592 
593 
594 
595 //=================================================================================================
596 //
597 // GLOBAL BINARY ARITHMETIC OPERATORS
598 //
599 //=================================================================================================
600 
601 //*************************************************************************************************
630 template< typename T1 // Type of the left-hand side dense matrix
631  , typename T2 // Type of the right-hand side sparse matrix
632  , bool SO > // Storage order
633 inline const DMatSMatSubExpr<T1,T2,SO>
635 {
637 
638  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
639  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
640  }
641 
642  return DMatSMatSubExpr<T1,T2,SO>( ~lhs, ~rhs );
643 }
644 //*************************************************************************************************
645 
646 
647 
648 
649 //=================================================================================================
650 //
651 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
652 //
653 //=================================================================================================
654 
655 //*************************************************************************************************
668 template< typename T1 // Type of the dense matrix of the left-hand side expression
669  , typename T2 // Type of the sparse matrix of the left-hand side expression
670  , bool SO1 // Storage order of the left-hand side expression
671  , typename T3 // Type of the right-hand side dense matrix
672  , bool SO2 > // Storage order of the right-hand side dense matrix
673 inline const AddExprTrait_< DMatSMatSubExpr<T1,T2,SO1>, T3 >
674  operator+( const DMatSMatSubExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
675 {
677 
678  return ( lhs.leftOperand() + (~rhs) ) - lhs.rightOperand();
679 }
681 //*************************************************************************************************
682 
683 
684 //*************************************************************************************************
697 template< typename T1 // Type of the dense matrix of the left-hand side expression
698  , typename T2 // Type of the sparse matrix of the left-hand side expression
699  , bool SO1 // Storage order of the left-hand side expression
700  , typename T3 // Type of the right-hand side dense matrix
701  , bool SO2 > // Storage order of the right-hand side dense matrix
702 inline const SubExprTrait_< DMatSMatSubExpr<T1,T2,SO1>, T3 >
703  operator-( const DMatSMatSubExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
704 {
706 
707  return ( lhs.leftOperand() - (~rhs) ) - lhs.rightOperand();
708 }
710 //*************************************************************************************************
711 
712 
713 
714 
715 //=================================================================================================
716 //
717 // ROWS SPECIALIZATIONS
718 //
719 //=================================================================================================
720 
721 //*************************************************************************************************
723 template< typename MT1, typename MT2, bool SO >
724 struct Rows< DMatSMatSubExpr<MT1,MT2,SO> >
725  : public Max< Rows<MT1>, Rows<MT2> >
726 {};
728 //*************************************************************************************************
729 
730 
731 
732 
733 //=================================================================================================
734 //
735 // COLUMNS SPECIALIZATIONS
736 //
737 //=================================================================================================
738 
739 //*************************************************************************************************
741 template< typename MT1, typename MT2, bool SO >
742 struct Columns< DMatSMatSubExpr<MT1,MT2,SO> >
743  : public Max< Columns<MT1>, Columns<MT2> >
744 {};
746 //*************************************************************************************************
747 
748 
749 
750 
751 //=================================================================================================
752 //
753 // ISSYMMETRIC SPECIALIZATIONS
754 //
755 //=================================================================================================
756 
757 //*************************************************************************************************
759 template< typename MT1, typename MT2, bool SO >
760 struct IsSymmetric< DMatSMatSubExpr<MT1,MT2,SO> >
761  : public BoolConstant< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
762 {};
764 //*************************************************************************************************
765 
766 
767 
768 
769 //=================================================================================================
770 //
771 // ISHERMITIAN SPECIALIZATIONS
772 //
773 //=================================================================================================
774 
775 //*************************************************************************************************
777 template< typename MT1, typename MT2, bool SO >
778 struct IsHermitian< DMatSMatSubExpr<MT1,MT2,SO> >
779  : public BoolConstant< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
780 {};
782 //*************************************************************************************************
783 
784 
785 
786 
787 //=================================================================================================
788 //
789 // ISLOWER SPECIALIZATIONS
790 //
791 //=================================================================================================
792 
793 //*************************************************************************************************
795 template< typename MT1, typename MT2, bool SO >
796 struct IsLower< DMatSMatSubExpr<MT1,MT2,SO> >
797  : public BoolConstant< And< IsLower<MT1>, IsLower<MT2> >::value >
798 {};
800 //*************************************************************************************************
801 
802 
803 
804 
805 //=================================================================================================
806 //
807 // ISUNILOWER SPECIALIZATIONS
808 //
809 //=================================================================================================
810 
811 //*************************************************************************************************
813 template< typename MT1, typename MT2, bool SO >
814 struct IsUniLower< DMatSMatSubExpr<MT1,MT2,SO> >
815  : public BoolConstant< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >::value >
816 {};
818 //*************************************************************************************************
819 
820 
821 
822 
823 //=================================================================================================
824 //
825 // ISSTRICTLYLOWER SPECIALIZATIONS
826 //
827 //=================================================================================================
828 
829 //*************************************************************************************************
831 template< typename MT1, typename MT2, bool SO >
832 struct IsStrictlyLower< DMatSMatSubExpr<MT1,MT2,SO> >
833  : public BoolConstant< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
834 {};
836 //*************************************************************************************************
837 
838 
839 
840 
841 //=================================================================================================
842 //
843 // ISUPPER SPECIALIZATIONS
844 //
845 //=================================================================================================
846 
847 //*************************************************************************************************
849 template< typename MT1, typename MT2, bool SO >
850 struct IsUpper< DMatSMatSubExpr<MT1,MT2,SO> >
851  : public BoolConstant< And< IsUpper<MT1>, IsUpper<MT2> >::value >
852 {};
854 //*************************************************************************************************
855 
856 
857 
858 
859 //=================================================================================================
860 //
861 // ISUNIUPPER SPECIALIZATIONS
862 //
863 //=================================================================================================
864 
865 //*************************************************************************************************
867 template< typename MT1, typename MT2, bool SO >
868 struct IsUniUpper< DMatSMatSubExpr<MT1,MT2,SO> >
869  : public BoolConstant< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >::value >
870 {};
872 //*************************************************************************************************
873 
874 
875 
876 
877 //=================================================================================================
878 //
879 // ISSTRICTLYUPPER SPECIALIZATIONS
880 //
881 //=================================================================================================
882 
883 //*************************************************************************************************
885 template< typename MT1, typename MT2, bool SO >
886 struct IsStrictlyUpper< DMatSMatSubExpr<MT1,MT2,SO> >
887  : public BoolConstant< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
888 {};
890 //*************************************************************************************************
891 
892 
893 
894 
895 //=================================================================================================
896 //
897 // EXPRESSION TRAIT SPECIALIZATIONS
898 //
899 //=================================================================================================
900 
901 //*************************************************************************************************
903 template< typename MT1, typename MT2, typename MT3 >
904 struct DMatDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
905 {
906  public:
907  //**********************************************************************************************
909  using Type = If_< And< IsDenseMatrix<MT1>, IsRowMajorMatrix<MT1>
910  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
911  , IsDenseMatrix<MT3>, IsRowMajorMatrix<MT3> >
912  , DMatSMatSubExprTrait_< DMatDMatAddExprTrait_<MT1,MT3>, MT2 >
913  , INVALID_TYPE >;
915  //**********************************************************************************************
916 };
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
923 template< typename MT1, typename MT2, typename MT3 >
924 struct DMatTDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
925 {
926  public:
927  //**********************************************************************************************
929  using Type = If_< And< IsDenseMatrix<MT1>, IsRowMajorMatrix<MT1>
930  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
931  , IsDenseMatrix<MT3>, IsColumnMajorMatrix<MT3> >
932  , DMatSMatSubExprTrait_< DMatTDMatAddExprTrait_<MT1,MT3>, MT2 >
933  , INVALID_TYPE >;
935  //**********************************************************************************************
936 };
938 //*************************************************************************************************
939 
940 
941 //*************************************************************************************************
943 template< typename MT1, typename MT2, typename MT3 >
944 struct TDMatDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
945 {
946  public:
947  //**********************************************************************************************
949  using Type = If_< And< IsDenseMatrix<MT1>, IsColumnMajorMatrix<MT1>
950  , IsSparseMatrix<MT2>, IsColumnMajorMatrix<MT2>
951  , IsDenseMatrix<MT3>, IsRowMajorMatrix<MT3> >
952  , DMatTSMatSubExprTrait_< TDMatDMatAddExprTrait_<MT1,MT3>, MT2 >
953  , INVALID_TYPE >;
955  //**********************************************************************************************
956 };
958 //*************************************************************************************************
959 
960 
961 //*************************************************************************************************
963 template< typename MT1, typename MT2, typename MT3 >
964 struct TDMatTDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
965 {
966  public:
967  //**********************************************************************************************
969  using Type = If_< And< IsDenseMatrix<MT1>, IsColumnMajorMatrix<MT1>
970  , IsSparseMatrix<MT2>, IsColumnMajorMatrix<MT2>
971  , IsDenseMatrix<MT3>, IsColumnMajorMatrix<MT3> >
972  , TDMatTSMatSubExprTrait_< TDMatTDMatAddExprTrait_<MT1,MT3>, MT2 >
973  , INVALID_TYPE >;
975  //**********************************************************************************************
976 };
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
983 template< typename MT1, typename MT2, typename MT3 >
984 struct DMatDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
985 {
986  public:
987  //**********************************************************************************************
989  using Type = If_< And< IsDenseMatrix<MT1>, IsRowMajorMatrix<MT1>
990  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
991  , IsDenseMatrix<MT3>, IsRowMajorMatrix<MT3> >
992  , DMatSMatSubExprTrait_< DMatDMatSubExprTrait_<MT1,MT3>, MT2 >
993  , INVALID_TYPE >;
995  //**********************************************************************************************
996 };
998 //*************************************************************************************************
999 
1000 
1001 //*************************************************************************************************
1003 template< typename MT1, typename MT2, typename MT3 >
1004 struct DMatTDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
1005 {
1006  public:
1007  //**********************************************************************************************
1009  using Type = If_< And< IsDenseMatrix<MT1>, IsRowMajorMatrix<MT1>
1010  , IsSparseMatrix<MT2>, IsRowMajorMatrix<MT2>
1011  , IsDenseMatrix<MT3>, IsColumnMajorMatrix<MT3> >
1012  , DMatSMatSubExprTrait_< DMatTDMatSubExprTrait_<MT1,MT3>, MT2 >
1013  , INVALID_TYPE >;
1015  //**********************************************************************************************
1016 };
1018 //*************************************************************************************************
1019 
1020 
1021 //*************************************************************************************************
1023 template< typename MT1, typename MT2, typename MT3 >
1024 struct TDMatDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
1025 {
1026  public:
1027  //**********************************************************************************************
1029  using Type = If_< And< IsDenseMatrix<MT1>, IsColumnMajorMatrix<MT1>
1030  , IsSparseMatrix<MT2>, IsColumnMajorMatrix<MT2>
1031  , IsDenseMatrix<MT3>, IsRowMajorMatrix<MT3> >
1032  , DMatTSMatSubExprTrait_< TDMatDMatSubExprTrait_<MT1,MT3>, MT2 >
1033  , INVALID_TYPE >;
1035  //**********************************************************************************************
1036 };
1038 //*************************************************************************************************
1039 
1040 
1041 //*************************************************************************************************
1043 template< typename MT1, typename MT2, typename MT3 >
1044 struct TDMatTDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
1045 {
1046  public:
1047  //**********************************************************************************************
1049  using Type = If_< And< IsDenseMatrix<MT1>, IsColumnMajorMatrix<MT1>
1050  , IsSparseMatrix<MT2>, IsColumnMajorMatrix<MT2>
1051  , IsDenseMatrix<MT3>, IsColumnMajorMatrix<MT3> >
1052  , TDMatTSMatSubExprTrait_< TDMatTDMatSubExprTrait_<MT1,MT3>, MT2 >
1053  , INVALID_TYPE >;
1055  //**********************************************************************************************
1056 };
1058 //*************************************************************************************************
1059 
1060 
1061 //*************************************************************************************************
1063 template< typename MT1, typename MT2, bool SO, bool AF >
1064 struct SubmatrixExprTrait< DMatSMatSubExpr<MT1,MT2,SO>, AF >
1065 {
1066  public:
1067  //**********************************************************************************************
1068  using Type = SubExprTrait_< SubmatrixExprTrait_<const MT1,AF>
1069  , SubmatrixExprTrait_<const MT2,AF> >;
1070  //**********************************************************************************************
1071 };
1073 //*************************************************************************************************
1074 
1075 
1076 //*************************************************************************************************
1078 template< typename MT1, typename MT2, bool SO >
1079 struct RowExprTrait< DMatSMatSubExpr<MT1,MT2,SO> >
1080 {
1081  public:
1082  //**********************************************************************************************
1083  using Type = SubExprTrait_< RowExprTrait_<const MT1>
1084  , RowExprTrait_<const MT2> >;
1085  //**********************************************************************************************
1086 };
1088 //*************************************************************************************************
1089 
1090 
1091 //*************************************************************************************************
1093 template< typename MT1, typename MT2, bool SO >
1094 struct ColumnExprTrait< DMatSMatSubExpr<MT1,MT2,SO> >
1095 {
1096  public:
1097  //**********************************************************************************************
1098  using Type = SubExprTrait_< ColumnExprTrait_<const MT1>
1099  , ColumnExprTrait_<const MT2> >;
1100  //**********************************************************************************************
1101 };
1103 //*************************************************************************************************
1104 
1105 } // namespace blaze
1106 
1107 #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
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatSMatSubExpr.h:257
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:290
SubExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: DMatSMatSubExpr.h:128
Header file for auxiliary alias declarations.
Header file for the Max class template.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseMatrix type trait.
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
Header file for the ColumnExprTrait class template.
Header file for the IsColumnMajorMatrix type trait.
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
Header file for the And class template.
Header file for the AddExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
Header file for the Computation base class.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatSubExpr.h:150
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
If_< IsExpression< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:163
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:109
Constraint on the data type.
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatSMatSubExpr.h:196
typename SubExprTrait< T1, T2 >::Type SubExprTrait_
Auxiliary alias declaration for the SubExprTrait class template.The SubExprTrait_ alias declaration p...
Definition: SubExprTrait.h:220
Constraint on the data type.
Constraint on the data type.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:289
Header file for the IsSymmetric type trait.
Base class for all matrix/matrix subtraction expression templates.The MatMatSubExpr class serves as a...
Definition: MatMatSubExpr.h:65
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
#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.
Header file for the Columns type trait.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for the MatMatSubExpr base class.
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatSubExpr.h:157
Header file for the IsLower type trait.
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:60
Constraints on the storage order of matrix types.
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:112
Header file for the exception macros of the math module.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatSMatSubExpr.h:149
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
ReturnType_< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:115
ResultType_< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:113
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatSMatSubExpr.h:237
Header file for the SubmatrixExprTrait class template.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatSMatSubExpr.h:227
DMatSMatSubExpr< MT1, MT2, SO > This
Type of this DMatSMatSubExpr instance.
Definition: DMatSMatSubExpr.h:147
Header file for run time assertion macros.
Expression object for dense matrix-sparse matrix subtractions.The DMatSMatSubExpr class represents th...
Definition: DMatSMatSubExpr.h:106
Utility type for generic codes.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatSMatSubExpr.h:211
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatSMatSubExpr.h:154
ReturnType_< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:114
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatSMatSubExpr.h:269
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:84
If_< IsExpression< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:160
SubTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatSMatSubExpr.h:148
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatSMatSubExpr.h:282
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatSMatSubExpr.h:247
Header file for the IsRowMajorMatrix type trait.
DMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatSMatSubExpr class.
Definition: DMatSMatSubExpr.h:180
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
typename SubTrait< T1, T2 >::Type SubTrait_
Auxiliary alias declaration for the SubTrait class template.The SubTrait_ alias declaration provides ...
Definition: SubTrait.h:245
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatSMatSubExpr.h:151
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
Header file for the IntegralConstant class template.
#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:109
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
Header file for the SubExprTrait class template.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:71
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.