TDMatSMatAddExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TDMATSMATADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TDMATSMATADDEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
74 #include <blaze/util/Assert.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Exception.h>
78 #include <blaze/util/InvalidType.h>
80 #include <blaze/util/mpl/And.h>
81 #include <blaze/util/mpl/Max.h>
82 #include <blaze/util/mpl/Or.h>
83 #include <blaze/util/SelectType.h>
84 #include <blaze/util/Types.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // CLASS TDMATSMATADDEXPR
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 class TDMatSMatAddExpr : public DenseMatrix< TDMatSMatAddExpr<MT1,MT2>, true >
106  , private MatMatAddExpr
107  , private Computation
108 {
109  private:
110  //**Type definitions****************************************************************************
111  typedef typename MT1::ResultType RT1;
112  typedef typename MT2::ResultType RT2;
113  typedef typename MT1::ReturnType RN1;
114  typedef typename MT2::ReturnType RN2;
115  //**********************************************************************************************
116 
117  //**Return type evaluation**********************************************************************
119 
124  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
125 
128  //**********************************************************************************************
129 
130  //**Parallel evaluation strategy****************************************************************
132 
137  template< typename MT >
138  struct UseSMPAssign {
139  enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) };
140  };
142  //**********************************************************************************************
143 
144  public:
145  //**Type definitions****************************************************************************
151 
154 
156  typedef const ResultType CompositeType;
157 
159  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
160 
162  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
163  //**********************************************************************************************
164 
165  //**Compilation flags***************************************************************************
167  enum { vectorizable = 0 };
168 
170  enum { smpAssignable = 0 };
171  //**********************************************************************************************
172 
173  //**Constructor*********************************************************************************
179  explicit inline TDMatSMatAddExpr( const MT1& lhs, const MT2& rhs )
180  : lhs_( lhs ) // Left-hand side dense matrix of the addition expression
181  , rhs_( rhs ) // Right-hand side sparse matrix of the addition expression
182  {
183  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
184  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
185  }
186  //**********************************************************************************************
187 
188  //**Access operator*****************************************************************************
195  inline ReturnType operator()( size_t i, size_t j ) const {
196  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
197  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
198  return lhs_(i,j) + rhs_(i,j);
199  }
200  //**********************************************************************************************
201 
202  //**At function*********************************************************************************
210  inline ReturnType at( size_t i, size_t j ) const {
211  if( i >= lhs_.rows() ) {
212  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
213  }
214  if( j >= lhs_.columns() ) {
215  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
216  }
217  return (*this)(i,j);
218  }
219  //**********************************************************************************************
220 
221  //**Rows function*******************************************************************************
226  inline size_t rows() const {
227  return lhs_.rows();
228  }
229  //**********************************************************************************************
230 
231  //**Columns function****************************************************************************
236  inline size_t columns() const {
237  return lhs_.columns();
238  }
239  //**********************************************************************************************
240 
241  //**Left operand access*************************************************************************
246  inline LeftOperand leftOperand() const {
247  return lhs_;
248  }
249  //**********************************************************************************************
250 
251  //**Right operand access************************************************************************
256  inline RightOperand rightOperand() const {
257  return rhs_;
258  }
259  //**********************************************************************************************
260 
261  //**********************************************************************************************
267  template< typename T >
268  inline bool canAlias( const T* alias ) const {
269  return ( IsExpression<MT1>::value && lhs_.canAlias( alias ) ) ||
270  ( rhs_.canAlias( alias ) );
271  }
272  //**********************************************************************************************
273 
274  //**********************************************************************************************
280  template< typename T >
281  inline bool isAliased( const T* alias ) const {
282  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
283  }
284  //**********************************************************************************************
285 
286  private:
287  //**Member variables****************************************************************************
288  LeftOperand lhs_;
289  RightOperand rhs_;
290  //**********************************************************************************************
291 
292  //**Assignment to dense matrices****************************************************************
304  template< typename MT // Type of the target dense matrix
305  , bool SO2 > // Storage order of the target dense matrix
306  friend inline void assign( DenseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
307  {
309 
310  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
311  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
312 
313  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
314  addAssign( ~lhs, rhs.rhs_ );
315  }
316  else {
317  assign ( ~lhs, rhs.lhs_ );
318  addAssign( ~lhs, rhs.rhs_ );
319  }
320  }
322  //**********************************************************************************************
323 
324  //**Assignment to sparse matrices***************************************************************
336  template< typename MT // Type of the target sparse matrix
337  , bool SO2 > // Storage order of the target sparse matrix
338  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
339  {
341 
342  typedef typename SelectType< SO2, ResultType, OppositeType >::Type TmpType;
343 
350 
351  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
352  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
353 
354  const TmpType tmp( serial( rhs ) );
355  assign( ~lhs, tmp );
356  }
358  //**********************************************************************************************
359 
360  //**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 TDMatSMatAddExpr& 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  addAssign( ~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****************************************************
405  template< typename MT // Type of the target dense matrix
406  , bool SO2 > // Storage order of the target dense matrix
407  friend inline void subAssign( DenseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
408  {
410 
411  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
412  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
413 
414  subAssign( ~lhs, rhs.lhs_ );
415  subAssign( ~lhs, rhs.rhs_ );
416  }
418  //**********************************************************************************************
419 
420  //**Subtraction assignment to sparse matrices***************************************************
421  // No special implementation for the subtraction assignment to sparse matrices.
422  //**********************************************************************************************
423 
424  //**Multiplication assignment to dense matrices*************************************************
425  // No special implementation for the multiplication assignment to dense matrices.
426  //**********************************************************************************************
427 
428  //**Multiplication assignment to sparse matrices************************************************
429  // No special implementation for the multiplication assignment to sparse matrices.
430  //**********************************************************************************************
431 
432  //**SMP assignment to dense matrices************************************************************
446  template< typename MT // Type of the target dense matrix
447  , bool SO2 > // Storage order of the target dense matrix
448  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
449  smpAssign( DenseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
450  {
452 
453  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
454  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
455 
456  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
457  smpAddAssign( ~lhs, rhs.rhs_ );
458  }
459  else {
460  smpAssign ( ~lhs, rhs.lhs_ );
461  smpAddAssign( ~lhs, rhs.rhs_ );
462  }
463  }
465  //**********************************************************************************************
466 
467  //**SMP assignment to sparse matrices***********************************************************
481  template< typename MT // Type of the target sparse matrix
482  , bool SO2 > // Storage order of the target sparse matrix
483  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
484  smpAssign( SparseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
485  {
487 
488  typedef typename SelectType< SO2, ResultType, OppositeType >::Type TmpType;
489 
496 
497  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
498  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
499 
500  const TmpType tmp( rhs );
501  smpAssign( ~lhs, tmp );
502  }
504  //**********************************************************************************************
505 
506  //**SMP addition assignment to dense matrices***************************************************
521  template< typename MT // Type of the target dense matrix
522  , bool SO2 > // Storage order of the target dense matrix
523  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
524  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
525  {
527 
528  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
529  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
530 
531  smpAddAssign( ~lhs, rhs.lhs_ );
532  smpAddAssign( ~lhs, rhs.rhs_ );
533  }
535  //**********************************************************************************************
536 
537  //**SMP addition assignment to sparse matrices**************************************************
538  // No special implementation for the SMP addition assignment to sparse matrices.
539  //**********************************************************************************************
540 
541  //**SMP subtraction assignment to dense matrices************************************************
556  template< typename MT // Type of the target dense matrix
557  , bool SO2 > // Storage order of the target dense matrix
558  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
559  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const TDMatSMatAddExpr& rhs )
560  {
562 
563  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
564  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
565 
566  smpSubAssign( ~lhs, rhs.lhs_ );
567  smpSubAssign( ~lhs, rhs.rhs_ );
568  }
570  //**********************************************************************************************
571 
572  //**SMP subtraction assignment to sparse matrices***********************************************
573  // No special implementation for the SMP subtraction assignment to sparse matrices.
574  //**********************************************************************************************
575 
576  //**SMP multiplication assignment to dense matrices*********************************************
577  // No special implementation for the SMP multiplication assignment to dense matrices.
578  //**********************************************************************************************
579 
580  //**SMP multiplication assignment to sparse matrices********************************************
581  // No special implementation for the SMP multiplication assignment to sparse matrices.
582  //**********************************************************************************************
583 
584  //**Compile time checks*************************************************************************
592  //**********************************************************************************************
593 };
594 //*************************************************************************************************
595 
596 
597 
598 
599 //=================================================================================================
600 //
601 // GLOBAL BINARY ARITHMETIC OPERATORS
602 //
603 //=================================================================================================
604 
605 //*************************************************************************************************
636 template< typename T1 // Type of the left-hand side dense matrix
637  , typename T2 > // Type of the right-hand side sparse matrix
638 const TDMatSMatAddExpr<T1,T2>
640 {
642 
643  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
644  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
645  }
646 
647  return TDMatSMatAddExpr<T1,T2>( ~lhs, ~rhs );
648 }
649 //*************************************************************************************************
650 
651 
652 //*************************************************************************************************
683 template< typename T1 // Type of the left-hand side dense matrix
684  , typename T2 > // Type of the right-hand side sparse matrix
685 const TDMatSMatAddExpr<T1,T2>
687 {
689 
690  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
691  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
692  }
693 
694  return TDMatSMatAddExpr<T1,T2>( ~rhs, ~lhs );
695 }
696 //*************************************************************************************************
697 
698 
699 
700 
701 //=================================================================================================
702 //
703 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
704 //
705 //=================================================================================================
706 
707 //*************************************************************************************************
720 template< typename T1 // Type of the dense matrix of the left-hand side expression
721  , typename T2 // Type of the sparse matrix of the left-hand side expression
722  , typename T3 // Type of the right-hand side dense matrix
723  , bool SO > // Storage order of the right-hand side dense matrix
724 inline const typename AddExprTrait< TDMatSMatAddExpr<T1,T2>, T3 >::Type
725  operator+( const TDMatSMatAddExpr<T1,T2>& lhs, const DenseMatrix<T3,SO>& rhs )
726 {
728 
729  return ( lhs.leftOperand() + (~rhs) ) + lhs.rightOperand();
730 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
748 template< typename T1 // Type of the dense matrix of the left-hand side expression
749  , typename T2 // Type of the sparse matrix of the left-hand side expression
750  , typename T3 // Type of the right-hand side dense matrix
751  , bool SO > // Storage order of the right-hand side dense matrix
752 inline const typename SubExprTrait< TDMatSMatAddExpr<T1,T2>, T3 >::Type
753  operator-( const TDMatSMatAddExpr<T1,T2>& lhs, const DenseMatrix<T3,SO>& rhs )
754 {
756 
757  return ( lhs.leftOperand() - (~rhs) ) + lhs.rightOperand();
758 }
760 //*************************************************************************************************
761 
762 
763 
764 
765 //=================================================================================================
766 //
767 // ROWS SPECIALIZATIONS
768 //
769 //=================================================================================================
770 
771 //*************************************************************************************************
773 template< typename MT1, typename MT2 >
774 struct Rows< TDMatSMatAddExpr<MT1,MT2> >
775  : public Max< Rows<MT1>, Rows<MT2> >
776 {};
778 //*************************************************************************************************
779 
780 
781 
782 
783 //=================================================================================================
784 //
785 // COLUMNS SPECIALIZATIONS
786 //
787 //=================================================================================================
788 
789 //*************************************************************************************************
791 template< typename MT1, typename MT2 >
792 struct Columns< TDMatSMatAddExpr<MT1,MT2> >
793  : public Max< Columns<MT1>, Columns<MT2> >
794 {};
796 //*************************************************************************************************
797 
798 
799 
800 
801 //=================================================================================================
802 //
803 // ISSYMMETRIC SPECIALIZATIONS
804 //
805 //=================================================================================================
806 
807 //*************************************************************************************************
809 template< typename MT1, typename MT2 >
810 struct IsSymmetric< TDMatSMatAddExpr<MT1,MT2> >
811  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
812 {};
814 //*************************************************************************************************
815 
816 
817 
818 
819 //=================================================================================================
820 //
821 // ISHERMITIAN SPECIALIZATIONS
822 //
823 //=================================================================================================
824 
825 //*************************************************************************************************
827 template< typename MT1, typename MT2 >
828 struct IsHermitian< TDMatSMatAddExpr<MT1,MT2> >
829  : public IsTrue< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
830 {};
832 //*************************************************************************************************
833 
834 
835 
836 
837 //=================================================================================================
838 //
839 // ISLOWER SPECIALIZATIONS
840 //
841 //=================================================================================================
842 
843 //*************************************************************************************************
845 template< typename MT1, typename MT2 >
846 struct IsLower< TDMatSMatAddExpr<MT1,MT2> >
847  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
848 {};
850 //*************************************************************************************************
851 
852 
853 
854 
855 //=================================================================================================
856 //
857 // ISUNILOWER SPECIALIZATIONS
858 //
859 //=================================================================================================
860 
861 //*************************************************************************************************
863 template< typename MT1, typename MT2 >
864 struct IsUniLower< TDMatSMatAddExpr<MT1,MT2> >
865  : public IsTrue< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
866  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
867 {};
869 //*************************************************************************************************
870 
871 
872 
873 
874 //=================================================================================================
875 //
876 // ISSTRICTLYLOWER SPECIALIZATIONS
877 //
878 //=================================================================================================
879 
880 //*************************************************************************************************
882 template< typename MT1, typename MT2 >
883 struct IsStrictlyLower< TDMatSMatAddExpr<MT1,MT2> >
884  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
885 {};
887 //*************************************************************************************************
888 
889 
890 
891 
892 //=================================================================================================
893 //
894 // ISUPPER SPECIALIZATIONS
895 //
896 //=================================================================================================
897 
898 //*************************************************************************************************
900 template< typename MT1, typename MT2 >
901 struct IsUpper< TDMatSMatAddExpr<MT1,MT2> >
902  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
903 {};
905 //*************************************************************************************************
906 
907 
908 
909 
910 //=================================================================================================
911 //
912 // ISUNIUPPER SPECIALIZATIONS
913 //
914 //=================================================================================================
915 
916 //*************************************************************************************************
918 template< typename MT1, typename MT2 >
919 struct IsUniUpper< TDMatSMatAddExpr<MT1,MT2> >
920  : public IsTrue< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
921  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
922 {};
924 //*************************************************************************************************
925 
926 
927 
928 
929 //=================================================================================================
930 //
931 // ISSTRICTLYUPPER SPECIALIZATIONS
932 //
933 //=================================================================================================
934 
935 //*************************************************************************************************
937 template< typename MT1, typename MT2 >
938 struct IsStrictlyUpper< TDMatSMatAddExpr<MT1,MT2> >
939  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
940 {};
942 //*************************************************************************************************
943 
944 
945 
946 
947 //=================================================================================================
948 //
949 // EXPRESSION TRAIT SPECIALIZATIONS
950 //
951 //=================================================================================================
952 
953 //*************************************************************************************************
955 template< typename MT1, typename MT2, typename MT3 >
956 struct DMatDMatAddExprTrait< TDMatSMatAddExpr<MT1,MT2>, MT3 >
957 {
958  public:
959  //**********************************************************************************************
961  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
962  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
963  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
964  , typename DMatSMatAddExprTrait< typename TDMatDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
965  , INVALID_TYPE >::Type Type;
967  //**********************************************************************************************
968 };
970 //*************************************************************************************************
971 
972 
973 //*************************************************************************************************
975 template< typename MT1, typename MT2, typename MT3 >
976 struct DMatTDMatAddExprTrait< TDMatSMatAddExpr<MT1,MT2>, MT3 >
977 {
978  public:
979  //**********************************************************************************************
981  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
982  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
983  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
984  , typename TDMatSMatAddExprTrait< typename TDMatTDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
985  , INVALID_TYPE >::Type Type;
987  //**********************************************************************************************
988 };
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
995 template< typename MT1, typename MT2, typename MT3 >
996 struct DMatDMatSubExprTrait< TDMatSMatAddExpr<MT1,MT2>, MT3 >
997 {
998  public:
999  //**********************************************************************************************
1001  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
1002  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
1003  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
1004  , typename DMatSMatAddExprTrait< typename TDMatDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1005  , INVALID_TYPE >::Type Type;
1007  //**********************************************************************************************
1008 };
1010 //*************************************************************************************************
1011 
1012 
1013 //*************************************************************************************************
1015 template< typename MT1, typename MT2, typename MT3 >
1016 struct DMatTDMatSubExprTrait< TDMatSMatAddExpr<MT1,MT2>, MT3 >
1017 {
1018  public:
1019  //**********************************************************************************************
1021  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
1022  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
1023  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
1024  , typename TDMatSMatAddExprTrait< typename TDMatTDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1025  , INVALID_TYPE >::Type Type;
1027  //**********************************************************************************************
1028 };
1030 //*************************************************************************************************
1031 
1032 
1033 //*************************************************************************************************
1035 template< typename MT1, typename MT2, bool AF >
1036 struct SubmatrixExprTrait< TDMatSMatAddExpr<MT1,MT2>, AF >
1037 {
1038  public:
1039  //**********************************************************************************************
1040  typedef typename AddExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1041  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1042  //**********************************************************************************************
1043 };
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1050 template< typename MT1, typename MT2 >
1051 struct RowExprTrait< TDMatSMatAddExpr<MT1,MT2> >
1052 {
1053  public:
1054  //**********************************************************************************************
1055  typedef typename AddExprTrait< typename RowExprTrait<const MT1>::Type
1056  , typename RowExprTrait<const MT2>::Type >::Type Type;
1057  //**********************************************************************************************
1058 };
1060 //*************************************************************************************************
1061 
1062 
1063 //*************************************************************************************************
1065 template< typename MT1, typename MT2 >
1066 struct ColumnExprTrait< TDMatSMatAddExpr<MT1,MT2> >
1067 {
1068  public:
1069  //**********************************************************************************************
1070  typedef typename AddExprTrait< typename ColumnExprTrait<const MT1>::Type
1071  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1072  //**********************************************************************************************
1073 };
1075 //*************************************************************************************************
1076 
1077 } // namespace blaze
1078 
1079 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Header file for the Max class template.
Evaluation of the return type of an addition expression.Via this type trait it is possible to evaluat...
Definition: AddExprTrait.h:104
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.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TDMatSMatAddExpr.h:148
Header file for basic type definitions.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TDMatSMatAddExpr.h:268
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:114
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
#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:647
Header file for the ColumnExprTrait class template.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:149
Header file for the IsColumnMajorMatrix type trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: TDMatSMatAddExpr.h:226
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TDMatSMatAddExpr.h:281
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:721
Header file for the Computation base class.
Constraints on the storage order of matrix types.
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:147
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:111
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:117
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: TDMatSMatAddExpr.h:288
ResultType::ElementType ElementType
Resulting element type.
Definition: TDMatSMatAddExpr.h:150
Constraint on the data type.
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
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:79
RightOperand rhs_
Right-hand side sparse matrix of the addition expression.
Definition: TDMatSMatAddExpr.h:289
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
LeftOperand leftOperand() const
Returns the left-hand side transpose dense matrix operand.
Definition: TDMatSMatAddExpr.h:246
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Header file for the IsLower type trait.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TDMatSMatAddExpr.h:195
MT1::ReturnType RN1
Return type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:113
#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
Constraints on the storage order of matrix types.
#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 EnableIf class template.
Header file for the IsStrictlyLower type trait.
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:112
Header file for the serial shim.
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
const ResultType CompositeType
Data type for composite expression templates.
Definition: TDMatSMatAddExpr.h:156
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:138
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
Utility type for generic codes.
Header file for the addition trait.
Constraint on the data type.
TDMatSMatAddExpr< MT1, MT2 > This
Type of this TDMatSMatAddExpr instance.
Definition: TDMatSMatAddExpr.h:146
Constraints on the storage order of matrix types.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:153
Header file for the MatMatAddExpr base class.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: TDMatSMatAddExpr.h:236
#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:122
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TDMatSMatAddExpr.h:210
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: TDMatSMatAddExpr.h:127
Header file for the IsRowMajorMatrix type trait.
RightOperand rightOperand() const
Returns the right-hand side sparse matrix operand.
Definition: TDMatSMatAddExpr.h:256
TDMatSMatAddExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the TDMatSMatAddExpr class.
Definition: TDMatSMatAddExpr.h:179
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
Expression object for dense matrix-sparse matrix additions.The TDMatSMatAddExpr class represents the ...
Definition: Forward.h:140
#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:2583
Header file for the IsTrue value trait.
Header file for the IsUpper type trait.
Header file for exception macros.
Header file for the IsHermitian type trait.
Header file for the SubExprTrait class template.
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:159
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:162
#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.