DMatSMatAddExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSMATADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATSMATADDEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
74 #include <blaze/util/Assert.h>
76 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/mpl/And.h>
79 #include <blaze/util/mpl/Max.h>
80 #include <blaze/util/mpl/Or.h>
81 #include <blaze/util/SelectType.h>
82 #include <blaze/util/Types.h>
84 
85 
86 namespace blaze {
87 
88 //=================================================================================================
89 //
90 // CLASS DMATSMATADDEXPR
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
101 template< typename MT1 // Type of the left-hand side dense matrix
102  , typename MT2 // Type of the right-hand side sparse matrix
103  , bool SO > // Storage order
104 class DMatSMatAddExpr : public DenseMatrix< DMatSMatAddExpr<MT1,MT2,SO>, SO >
105  , private MatMatAddExpr
106  , private Computation
107 {
108  private:
109  //**Type definitions****************************************************************************
110  typedef typename MT1::ResultType RT1;
111  typedef typename MT2::ResultType RT2;
112  typedef typename MT1::ReturnType RN1;
113  typedef typename MT2::ReturnType RN2;
114  //**********************************************************************************************
115 
116  //**Return type evaluation**********************************************************************
118 
123  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
124 
127  //**********************************************************************************************
128 
129  //**Parallel evaluation strategy****************************************************************
131 
136  template< typename MT >
137  struct UseSMPAssign {
138  enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) };
139  };
141  //**********************************************************************************************
142 
143  public:
144  //**Type definitions****************************************************************************
150 
153 
155  typedef const ResultType CompositeType;
156 
158  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
159 
161  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
162  //**********************************************************************************************
163 
164  //**Compilation flags***************************************************************************
166  enum { vectorizable = 0 };
167 
169  enum { smpAssignable = 0 };
170  //**********************************************************************************************
171 
172  //**Constructor*********************************************************************************
178  explicit inline DMatSMatAddExpr( const MT1& lhs, const MT2& rhs )
179  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
180  , rhs_( rhs ) // Right-hand side sparse matrix of the addition expression
181  {
182  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
183  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
184  }
185  //**********************************************************************************************
186 
187  //**Access operator*****************************************************************************
194  inline ReturnType operator()( size_t i, size_t j ) const {
195  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
196  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
197  return lhs_(i,j) + rhs_(i,j);
198  }
199  //**********************************************************************************************
200 
201  //**Rows function*******************************************************************************
206  inline size_t rows() const {
207  return lhs_.rows();
208  }
209  //**********************************************************************************************
210 
211  //**Columns function****************************************************************************
216  inline size_t columns() const {
217  return lhs_.columns();
218  }
219  //**********************************************************************************************
220 
221  //**Left operand access*************************************************************************
226  inline LeftOperand leftOperand() const {
227  return lhs_;
228  }
229  //**********************************************************************************************
230 
231  //**Right operand access************************************************************************
236  inline RightOperand rightOperand() const {
237  return rhs_;
238  }
239  //**********************************************************************************************
240 
241  //**********************************************************************************************
247  template< typename T >
248  inline bool canAlias( const T* alias ) const {
249  return ( IsExpression<MT1>::value && lhs_.canAlias( alias ) ) ||
250  ( rhs_.canAlias( alias ) );
251  }
252  //**********************************************************************************************
253 
254  //**********************************************************************************************
260  template< typename T >
261  inline bool isAliased( const T* alias ) const {
262  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
263  }
264  //**********************************************************************************************
265 
266  private:
267  //**Member variables****************************************************************************
268  LeftOperand lhs_;
269  RightOperand rhs_;
270  //**********************************************************************************************
271 
272  //**Assignment to dense matrices****************************************************************
284  template< typename MT // Type of the target dense matrix
285  , bool SO2 > // Storage order of the target dense matrix
286  friend inline void assign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
287  {
289 
290  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
291  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
292 
293  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
294  addAssign( ~lhs, rhs.rhs_ );
295  }
296  else {
297  assign ( ~lhs, rhs.lhs_ );
298  addAssign( ~lhs, rhs.rhs_ );
299  }
300  }
302  //**********************************************************************************************
303 
304  //**Assignment to sparse matrices***************************************************************
316  template< typename MT // Type of the target sparse matrix
317  , bool SO2 > // Storage order of the target sparse matrix
318  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
319  {
321 
323 
330 
331  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
332  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
333 
334  const TmpType tmp( serial( rhs ) );
335  assign( ~lhs, tmp );
336  }
338  //**********************************************************************************************
339 
340  //**Addition assignment to dense matrices*******************************************************
352  template< typename MT // Type of the target dense matrix
353  , bool SO2 > // Storage order of the target dense matrix
354  friend inline void addAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
355  {
357 
358  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
359  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
360 
361  addAssign( ~lhs, rhs.lhs_ );
362  addAssign( ~lhs, rhs.rhs_ );
363  }
365  //**********************************************************************************************
366 
367  //**Addition assignment to sparse matrices******************************************************
368  // No special implementation for the addition assignment to sparse matrices.
369  //**********************************************************************************************
370 
371  //**Subtraction assignment to dense matrices****************************************************
383  template< typename MT // Type of the target dense matrix
384  , bool SO2 > // Storage order of the target dense matrix
385  friend inline void subAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
386  {
388 
389  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
390  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
391 
392  subAssign( ~lhs, rhs.lhs_ );
393  subAssign( ~lhs, rhs.rhs_ );
394  }
396  //**********************************************************************************************
397 
398  //**Subtraction assignment to sparse matrices***************************************************
399  // No special implementation for the subtraction assignment to sparse matrices.
400  //**********************************************************************************************
401 
402  //**Multiplication assignment to dense matrices*************************************************
403  // No special implementation for the multiplication assignment to dense matrices.
404  //**********************************************************************************************
405 
406  //**Multiplication assignment to sparse matrices************************************************
407  // No special implementation for the multiplication assignment to sparse matrices.
408  //**********************************************************************************************
409 
410  //**SMP assignment to dense matrices************************************************************
424  template< typename MT // Type of the target dense matrix
425  , bool SO2 > // Storage order of the target dense matrix
426  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
427  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
428  {
430 
431  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
432  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
433 
434  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
435  smpAddAssign( ~lhs, rhs.rhs_ );
436  }
437  else {
438  smpAssign ( ~lhs, rhs.lhs_ );
439  smpAddAssign( ~lhs, rhs.rhs_ );
440  }
441  }
443  //**********************************************************************************************
444 
445  //**SMP assignment to sparse matrices***********************************************************
459  template< typename MT // Type of the target sparse matrix
460  , bool SO2 > // Storage order of the target sparse matrix
461  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
462  smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
463  {
465 
466  typedef typename SelectType< SO == SO2, ResultType, OppositeType >::Type TmpType;
467 
474 
475  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
476  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
477 
478  const TmpType tmp( rhs );
479  smpAssign( ~lhs, tmp );
480  }
482  //**********************************************************************************************
483 
484  //**SMP addition assignment to dense matrices***************************************************
498  template< typename MT // Type of the target dense matrix
499  , bool SO2 > // Storage order of the target dense matrix
500  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
501  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
502  {
504 
505  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
506  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
507 
508  smpAddAssign( ~lhs, rhs.lhs_ );
509  smpAddAssign( ~lhs, rhs.rhs_ );
510  }
512  //**********************************************************************************************
513 
514  //**SMP addition assignment to sparse matrices**************************************************
515  // No special implementation for the SMP addition assignment to sparse matrices.
516  //**********************************************************************************************
517 
518  //**SMP subtraction assignment to dense matrices************************************************
532  template< typename MT // Type of the target dense matrix
533  , bool SO2 > // Storage order of the target dense matrix
534  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
535  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatAddExpr& rhs )
536  {
538 
539  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
540  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
541 
542  smpSubAssign( ~lhs, rhs.lhs_ );
543  smpSubAssign( ~lhs, rhs.rhs_ );
544  }
546  //**********************************************************************************************
547 
548  //**SMP subtraction assignment to sparse matrices***********************************************
549  // No special implementation for the SMP subtraction assignment to sparse matrices.
550  //**********************************************************************************************
551 
552  //**SMP multiplication assignment to dense matrices*********************************************
553  // No special implementation for the SMP multiplication assignment to dense matrices.
554  //**********************************************************************************************
555 
556  //**SMP multiplication assignment to sparse matrices********************************************
557  // No special implementation for the SMP multiplication assignment to sparse matrices.
558  //**********************************************************************************************
559 
560  //**Compile time checks*************************************************************************
567  //**********************************************************************************************
568 };
569 //*************************************************************************************************
570 
571 
572 
573 
574 //=================================================================================================
575 //
576 // GLOBAL BINARY ARITHMETIC OPERATORS
577 //
578 //=================================================================================================
579 
580 //*************************************************************************************************
606 template< typename T1 // Type of the left-hand side dense matrix
607  , typename T2 // Type of the right-hand side sparse matrix
608  , bool SO > // Storage order
609 inline const DMatSMatAddExpr<T1,T2,SO>
611 {
613 
614  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
615  throw std::invalid_argument( "Matrix sizes do not match" );
616 
617  return DMatSMatAddExpr<T1,T2,SO>( ~lhs, ~rhs );
618 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
648 template< typename T1 // Type of the left-hand side sparse matrix
649  , typename T2 // Type of the right-hand side dense matrix
650  , bool SO > // Storage order
651 inline const DMatSMatAddExpr<T2,T1,SO>
653 {
655 
656  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
657  throw std::invalid_argument( "Matrix sizes do not match" );
658 
659  return DMatSMatAddExpr<T2,T1,SO>( ~rhs, ~lhs );
660 }
661 //*************************************************************************************************
662 
663 
664 
665 
666 //=================================================================================================
667 //
668 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
669 //
670 //=================================================================================================
671 
672 //*************************************************************************************************
685 template< typename T1 // Type of the dense matrix of the left-hand side expression
686  , typename T2 // Type of the sparse matrix of the left-hand side expression
687  , bool SO1 // Storage order of the left-hand side expression
688  , typename T3 // Type of the right-hand side dense matrix
689  , bool SO2 > // Storage order of the right-hand side dense matrix
690 inline const typename AddExprTrait< DMatSMatAddExpr<T1,T2,SO1>, T3 >::Type
691  operator+( const DMatSMatAddExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
692 {
694 
695  return ( lhs.leftOperand() + (~rhs) ) + lhs.rightOperand();
696 }
698 //*************************************************************************************************
699 
700 
701 //*************************************************************************************************
714 template< typename T1 // Type of the dense matrix of the left-hand side expression
715  , typename T2 // Type of the sparse matrix of the left-hand side expression
716  , bool SO1 // Storage order of the left-hand side expression
717  , typename T3 // Type of the right-hand side dense matrix
718  , bool SO2 > // Storage order of the right-hand side dense matrix
719 inline const typename SubExprTrait< DMatSMatAddExpr<T1,T2,SO1>, T3 >::Type
720  operator-( const DMatSMatAddExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
721 {
723 
724  return ( lhs.leftOperand() - (~rhs) ) + lhs.rightOperand();
725 }
727 //*************************************************************************************************
728 
729 
730 
731 
732 //=================================================================================================
733 //
734 // ROWS SPECIALIZATIONS
735 //
736 //=================================================================================================
737 
738 //*************************************************************************************************
740 template< typename MT1, typename MT2, bool SO >
741 struct Rows< DMatSMatAddExpr<MT1,MT2,SO> >
742  : public Max< Rows<MT1>, Rows<MT2> >::Type
743 {};
745 //*************************************************************************************************
746 
747 
748 
749 
750 //=================================================================================================
751 //
752 // COLUMNS SPECIALIZATIONS
753 //
754 //=================================================================================================
755 
756 //*************************************************************************************************
758 template< typename MT1, typename MT2, bool SO >
759 struct Columns< DMatSMatAddExpr<MT1,MT2,SO> >
760  : public Max< Columns<MT1>, Columns<MT2> >::Type
761 {};
763 //*************************************************************************************************
764 
765 
766 
767 
768 //=================================================================================================
769 //
770 // ISSYMMETRIC SPECIALIZATIONS
771 //
772 //=================================================================================================
773 
774 //*************************************************************************************************
776 template< typename MT1, typename MT2, bool SO >
777 struct IsSymmetric< DMatSMatAddExpr<MT1,MT2,SO> >
778  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
779 {};
781 //*************************************************************************************************
782 
783 
784 
785 
786 //=================================================================================================
787 //
788 // ISLOWER SPECIALIZATIONS
789 //
790 //=================================================================================================
791 
792 //*************************************************************************************************
794 template< typename MT1, typename MT2, bool SO >
795 struct IsLower< DMatSMatAddExpr<MT1,MT2,SO> >
796  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
797 {};
799 //*************************************************************************************************
800 
801 
802 
803 
804 //=================================================================================================
805 //
806 // ISUNILOWER SPECIALIZATIONS
807 //
808 //=================================================================================================
809 
810 //*************************************************************************************************
812 template< typename MT1, typename MT2, bool SO >
813 struct IsUniLower< DMatSMatAddExpr<MT1,MT2,SO> >
814  : public IsTrue< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
815  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::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< DMatSMatAddExpr<MT1,MT2,SO> >
833  : public IsTrue< 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< DMatSMatAddExpr<MT1,MT2,SO> >
851  : public IsTrue< 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< DMatSMatAddExpr<MT1,MT2,SO> >
869  : public IsTrue< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
870  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
871 {};
873 //*************************************************************************************************
874 
875 
876 
877 
878 //=================================================================================================
879 //
880 // ISSTRICTLYUPPER SPECIALIZATIONS
881 //
882 //=================================================================================================
883 
884 //*************************************************************************************************
886 template< typename MT1, typename MT2, bool SO >
887 struct IsStrictlyUpper< DMatSMatAddExpr<MT1,MT2,SO> >
888  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
889 {};
891 //*************************************************************************************************
892 
893 
894 
895 
896 //=================================================================================================
897 //
898 // EXPRESSION TRAIT SPECIALIZATIONS
899 //
900 //=================================================================================================
901 
902 //*************************************************************************************************
904 template< typename MT1, typename MT2, typename MT3 >
905 struct DMatDMatAddExprTrait< DMatSMatAddExpr<MT1,MT2,false>, MT3 >
906 {
907  public:
908  //**********************************************************************************************
910  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
911  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
912  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
913  , typename DMatSMatAddExprTrait< typename DMatDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
914  , INVALID_TYPE >::Type Type;
916  //**********************************************************************************************
917 };
919 //*************************************************************************************************
920 
921 
922 //*************************************************************************************************
924 template< typename MT1, typename MT2, typename MT3 >
925 struct DMatTDMatAddExprTrait< DMatSMatAddExpr<MT1,MT2,false>, MT3 >
926 {
927  public:
928  //**********************************************************************************************
930  typedef typename SelectType< IsDenseMatrix <MT1>::value && IsRowMajorMatrix<MT1>::value &&
931  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
932  IsDenseMatrix <MT3>::value && IsColumnMajorMatrix<MT3>::value
933  , typename DMatSMatAddExprTrait< typename DMatTDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
934  , INVALID_TYPE >::Type Type;
936  //**********************************************************************************************
937 };
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
944 template< typename MT1, typename MT2, typename MT3 >
945 struct TDMatDMatAddExprTrait< DMatSMatAddExpr<MT1,MT2,true>, MT3 >
946 {
947  public:
948  //**********************************************************************************************
950  typedef typename SelectType< IsDenseMatrix <MT1>::value && IsColumnMajorMatrix<MT1>::value &&
951  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
952  IsDenseMatrix <MT3>::value && IsRowMajorMatrix<MT3>::value
953  , typename DMatTSMatAddExprTrait< typename TDMatDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
954  , INVALID_TYPE >::Type Type;
956  //**********************************************************************************************
957 };
959 //*************************************************************************************************
960 
961 
962 //*************************************************************************************************
964 template< typename MT1, typename MT2, typename MT3 >
965 struct TDMatTDMatAddExprTrait< DMatSMatAddExpr<MT1,MT2,true>, MT3 >
966 {
967  public:
968  //**********************************************************************************************
970  typedef typename SelectType< IsDenseMatrix <MT1>::value && IsColumnMajorMatrix<MT1>::value &&
971  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
972  IsDenseMatrix <MT3>::value && IsColumnMajorMatrix<MT3>::value
973  , typename TDMatTSMatAddExprTrait< typename TDMatTDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
974  , INVALID_TYPE >::Type Type;
976  //**********************************************************************************************
977 };
979 //*************************************************************************************************
980 
981 
982 //*************************************************************************************************
984 template< typename MT1, typename MT2, typename MT3 >
985 struct DMatDMatSubExprTrait< DMatSMatAddExpr<MT1,MT2,false>, MT3 >
986 {
987  public:
988  //**********************************************************************************************
990  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
991  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
992  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
993  , typename DMatSMatAddExprTrait< typename DMatDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
994  , INVALID_TYPE >::Type Type;
996  //**********************************************************************************************
997 };
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1004 template< typename MT1, typename MT2, typename MT3 >
1005 struct DMatTDMatSubExprTrait< DMatSMatAddExpr<MT1,MT2,false>, MT3 >
1006 {
1007  public:
1008  //**********************************************************************************************
1010  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
1011  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
1012  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
1013  , typename DMatSMatAddExprTrait< typename DMatTDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1014  , INVALID_TYPE >::Type Type;
1016  //**********************************************************************************************
1017 };
1019 //*************************************************************************************************
1020 
1021 
1022 //*************************************************************************************************
1024 template< typename MT1, typename MT2, typename MT3 >
1025 struct TDMatDMatSubExprTrait< DMatSMatAddExpr<MT1,MT2,true>, MT3 >
1026 {
1027  public:
1028  //**********************************************************************************************
1030  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
1031  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1032  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
1033  , typename DMatTSMatAddExprTrait< typename TDMatDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1034  , INVALID_TYPE >::Type Type;
1036  //**********************************************************************************************
1037 };
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1044 template< typename MT1, typename MT2, typename MT3 >
1045 struct TDMatTDMatSubExprTrait< DMatSMatAddExpr<MT1,MT2,true>, MT3 >
1046 {
1047  public:
1048  //**********************************************************************************************
1050  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
1051  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1052  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
1053  , typename TDMatTSMatAddExprTrait< typename TDMatTDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1054  , INVALID_TYPE >::Type Type;
1056  //**********************************************************************************************
1057 };
1059 //*************************************************************************************************
1060 
1061 
1062 //*************************************************************************************************
1064 template< typename MT1, typename MT2, bool SO, bool AF >
1065 struct SubmatrixExprTrait< DMatSMatAddExpr<MT1,MT2,SO>, AF >
1066 {
1067  public:
1068  //**********************************************************************************************
1069  typedef typename AddExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1070  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1071  //**********************************************************************************************
1072 };
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1079 template< typename MT1, typename MT2, bool SO >
1080 struct RowExprTrait< DMatSMatAddExpr<MT1,MT2,SO> >
1081 {
1082  public:
1083  //**********************************************************************************************
1084  typedef typename AddExprTrait< typename RowExprTrait<const MT1>::Type
1085  , typename RowExprTrait<const MT2>::Type >::Type Type;
1086  //**********************************************************************************************
1087 };
1089 //*************************************************************************************************
1090 
1091 
1092 //*************************************************************************************************
1094 template< typename MT1, typename MT2, bool SO >
1095 struct ColumnExprTrait< DMatSMatAddExpr<MT1,MT2,SO> >
1096 {
1097  public:
1098  //**********************************************************************************************
1099  typedef typename AddExprTrait< typename ColumnExprTrait<const MT1>::Type
1100  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1101  //**********************************************************************************************
1102 };
1104 //*************************************************************************************************
1105 
1106 } // namespace blaze
1107 
1108 #endif
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatSMatAddExpr.h:194
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DMatSMatAddExpr.h:146
Header file for the Max class template.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatAddExpr.h:161
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatSMatAddExpr.h:147
Evaluation of the return type of an addition expression.Via this type trait it is possible to evaluat...
Definition: AddExprTrait.h:104
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatSMatAddExpr.h:268
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatSMatAddExpr.h:126
Header file for basic type definitions.
Header file for the IsSparseMatrix type trait.
#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:242
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
#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:79
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
Header file for the ColumnExprTrait class template.
RightOperand rightOperand() const
Returns the right-hand side sparse matrix operand.
Definition: DMatSMatAddExpr.h:236
Header file for the IsColumnMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:261
Header file for the And class template.
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatSMatAddExpr.h:149
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:699
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatAddExpr.h:111
Header file for the Computation base class.
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatAddExpr.h:110
Header file for the IsUniLower type trait.
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:107
Constraint on the data type.
RightOperand rhs_
Right-hand side sparse matrix of the addition expression.
Definition: DMatSMatAddExpr.h:269
Constraint on the data type.
Constraint on the data type.
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the Or class template.
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Header file for the Columns type trait.
DMatSMatAddExpr< MT1, MT2, SO > This
Type of this DMatSMatAddExpr instance.
Definition: DMatSMatAddExpr.h:145
Base class for all matrix/matrix addition expression templates.The MatMatAddExpr class serves as a ta...
Definition: MatMatAddExpr.h:65
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
Header file for the IsLower type trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatSMatAddExpr.h:206
#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:78
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatAddExpr.h:155
Constraints on the storage order of matrix types.
MT1::ReturnType RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatSMatAddExpr.h:112
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatAddExpr.h:165
Header file for the SelectType class template.
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.
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: DMatSMatAddExpr.h:113
Header file for the serial shim.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DMatSMatAddExpr.h:261
EnableIf< IsDenseMatrix< MT1 > >::Type 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 SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:150
EnableIf< IsDenseMatrix< MT1 > >::Type 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
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Constraint on the data type.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
Header file for the MatMatAddExpr base class.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatSMatAddExpr.h:152
#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:283
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatAddExpr.h:158
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatSMatAddExpr.h:226
Header file for the IsRowMajorMatrix type trait.
Expression object for dense matrix-sparse matrix additions.The DMatSMatAddExpr class represents the c...
Definition: DMatSMatAddExpr.h:104
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
EnableIf< IsDenseMatrix< MT1 > >::Type 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
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatSMatAddExpr.h:248
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatAddExpr.h:148
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
Header file for the IsTrue value trait.
Header file for the IsUpper type trait.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatSMatAddExpr.h:216
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:79
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:87
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849
DMatSMatAddExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the DMatSMatAddExpr class.
Definition: DMatSMatAddExpr.h:178