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 <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/SelectType.h>
81 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS DMATSMATSUBEXPR
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
100 template< typename MT1 // Type of the left-hand side dense matrix
101  , typename MT2 // Type of the right-hand side sparse matrix
102  , bool SO > // Storage order
103 class DMatSMatSubExpr : public DenseMatrix< DMatSMatSubExpr<MT1,MT2,SO>, SO >
104  , private MatMatSubExpr
105  , private Computation
106 {
107  private:
108  //**Type definitions****************************************************************************
109  typedef typename MT1::ResultType RT1;
110  typedef typename MT2::ResultType RT2;
111  typedef typename MT1::ReturnType RN1;
112  typedef typename MT2::ReturnType RN2;
113  //**********************************************************************************************
114 
115  //**Return type evaluation**********************************************************************
117 
122  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
123 
126  //**********************************************************************************************
127 
128  //**Parallel evaluation strategy****************************************************************
130 
135  template< typename MT >
136  struct UseSMPAssign {
137  enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) };
138  };
140  //**********************************************************************************************
141 
142  public:
143  //**Type definitions****************************************************************************
149 
152 
154  typedef const ResultType CompositeType;
155 
157  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
158 
160  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
161  //**********************************************************************************************
162 
163  //**Compilation flags***************************************************************************
165  enum { vectorizable = 0 };
166 
168  enum { smpAssignable = 0 };
169  //**********************************************************************************************
170 
171  //**Constructor*********************************************************************************
177  explicit inline DMatSMatSubExpr( const MT1& lhs, const MT2& rhs )
178  : lhs_( lhs ) // Left-hand side dense matrix of the subtraction expression
179  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
180  {
181  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
182  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
183  }
184  //**********************************************************************************************
185 
186  //**Access operator*****************************************************************************
193  inline ReturnType operator()( size_t i, size_t j ) const {
194  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
195  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
196  return lhs_(i,j) - rhs_(i,j);
197  }
198  //**********************************************************************************************
199 
200  //**Rows function*******************************************************************************
205  inline size_t rows() const {
206  return lhs_.rows();
207  }
208  //**********************************************************************************************
209 
210  //**Columns function****************************************************************************
215  inline size_t columns() const {
216  return lhs_.columns();
217  }
218  //**********************************************************************************************
219 
220  //**Left operand access*************************************************************************
225  inline LeftOperand leftOperand() const {
226  return lhs_;
227  }
228  //**********************************************************************************************
229 
230  //**Right operand access************************************************************************
235  inline RightOperand rightOperand() const {
236  return rhs_;
237  }
238  //**********************************************************************************************
239 
240  //**********************************************************************************************
246  template< typename T >
247  inline bool canAlias( const T* alias ) const {
248  return ( IsExpression<MT1>::value && lhs_.canAlias( alias ) ) ||
249  ( rhs_.canAlias( alias ) );
250  }
251  //**********************************************************************************************
252 
253  //**********************************************************************************************
259  template< typename T >
260  inline bool isAliased( const T* alias ) const {
261  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
262  }
263  //**********************************************************************************************
264 
265  private:
266  //**Member variables****************************************************************************
267  LeftOperand lhs_;
268  RightOperand rhs_;
269  //**********************************************************************************************
270 
271  //**Assignment to dense matrices****************************************************************
283  template< typename MT // Type of the target dense matrix
284  , bool SO2 > // Storage order of the target dense matrix
285  friend inline void assign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
286  {
288 
289  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
290  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
291 
292  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
293  subAssign( ~lhs, rhs.rhs_ );
294  }
295  else {
296  assign ( ~lhs, rhs.lhs_ );
297  subAssign( ~lhs, rhs.rhs_ );
298  }
299  }
301  //**********************************************************************************************
302 
303  //**Assignment to sparse matrices***************************************************************
315  template< typename MT // Type of the target sparse matrix
316  , bool SO2 > // Storage order of the target sparse matrix
317  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
318  {
320 
322 
329 
330  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
331  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
332 
333  const TmpType tmp( serial( rhs ) );
334  assign( ~lhs, tmp );
335  }
337  //**********************************************************************************************
338 
339  //**Addition assignment to dense matrices*******************************************************
351  template< typename MT // Type of the target dense matrix
352  , bool SO2 > // Storage order of the target dense matrix
353  friend inline void addAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
354  {
356 
357  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
358  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
359 
360  addAssign( ~lhs, rhs.lhs_ );
361  subAssign( ~lhs, rhs.rhs_ );
362  }
364  //**********************************************************************************************
365 
366  //**Addition assignment to sparse matrices******************************************************
367  // No special implementation for the addition assignment to sparse matrices.
368  //**********************************************************************************************
369 
370  //**Subtraction assignment to dense matrices****************************************************
382  template< typename MT // Type of the target dense matrix
383  , bool SO2 > // Storage order of the target dense matrix
384  friend inline void subAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
385  {
387 
388  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
389  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
390 
391  subAssign( ~lhs, rhs.lhs_ );
392  addAssign( ~lhs, rhs.rhs_ );
393  }
395  //**********************************************************************************************
396 
397  //**Subtraction assignment to sparse matrices***************************************************
398  // No special implementation for the subtraction assignment to sparse matrices.
399  //**********************************************************************************************
400 
401  //**Multiplication assignment to dense matrices*************************************************
402  // No special implementation for the multiplication assignment to dense matrices.
403  //**********************************************************************************************
404 
405  //**Multiplication assignment to sparse matrices************************************************
406  // No special implementation for the multiplication assignment to sparse matrices.
407  //**********************************************************************************************
408 
409  //**SMP assignment to dense matrices************************************************************
423  template< typename MT // Type of the target dense matrix
424  , bool SO2 > // Storage order of the target dense matrix
425  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
426  smpAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
427  {
429 
430  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
431  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
432 
433  if( !IsExpression<MT1>::value && isSame( ~lhs, rhs.lhs_ ) ) {
434  smpSubAssign( ~lhs, rhs.rhs_ );
435  }
436  else {
437  smpAssign ( ~lhs, rhs.lhs_ );
438  smpSubAssign( ~lhs, rhs.rhs_ );
439  }
440  }
442  //**********************************************************************************************
443 
444  //**SMP assignment to sparse matrices***********************************************************
458  template< typename MT // Type of the target sparse matrix
459  , bool SO2 > // Storage order of the target sparse matrix
460  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
461  smpAssign( SparseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
462  {
464 
465  typedef typename SelectType< SO == SO2, ResultType, OppositeType >::Type TmpType;
466 
473 
474  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
475  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
476 
477  const TmpType tmp( rhs );
478  smpAssign( ~lhs, tmp );
479  }
481  //**********************************************************************************************
482 
483  //**SMP addition assignment to dense matrices***************************************************
497  template< typename MT // Type of the target dense matrix
498  , bool SO2 > // Storage order of the target dense matrix
499  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
500  smpAddAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
501  {
503 
504  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
505  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
506 
507  smpAddAssign( ~lhs, rhs.lhs_ );
508  smpSubAssign( ~lhs, rhs.rhs_ );
509  }
511  //**********************************************************************************************
512 
513  //**SMP addition assignment to sparse matrices**************************************************
514  // No special implementation for the SMP addition assignment to sparse matrices.
515  //**********************************************************************************************
516 
517  //**SMP subtraction assignment to dense matrices************************************************
531  template< typename MT // Type of the target dense matrix
532  , bool SO2 > // Storage order of the target dense matrix
533  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
534  smpSubAssign( DenseMatrix<MT,SO2>& lhs, const DMatSMatSubExpr& rhs )
535  {
537 
538  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
539  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
540 
541  smpSubAssign( ~lhs, rhs.lhs_ );
542  smpAddAssign( ~lhs, rhs.rhs_ );
543  }
545  //**********************************************************************************************
546 
547  //**SMP subtraction assignment to sparse matrices***********************************************
548  // No special implementation for the SMP subtraction assignment to sparse matrices.
549  //**********************************************************************************************
550 
551  //**SMP multiplication assignment to dense matrices*********************************************
552  // No special implementation for the SMP multiplication assignment to dense matrices.
553  //**********************************************************************************************
554 
555  //**SMP multiplication assignment to sparse matrices************************************************
556  // No special implementation for the SMP multiplication assignment to sparse matrices.
557  //**********************************************************************************************
558 
559  //**Compile time checks*************************************************************************
566  //**********************************************************************************************
567 };
568 //*************************************************************************************************
569 
570 
571 
572 
573 //=================================================================================================
574 //
575 // GLOBAL BINARY ARITHMETIC OPERATORS
576 //
577 //=================================================================================================
578 
579 //*************************************************************************************************
608 template< typename T1 // Type of the left-hand side dense matrix
609  , typename T2 // Type of the right-hand side sparse matrix
610  , bool SO > // Storage order
611 inline const DMatSMatSubExpr<T1,T2,SO>
613 {
615 
616  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
617  throw std::invalid_argument( "Matrix sizes do not match" );
618 
619  return DMatSMatSubExpr<T1,T2,SO>( ~lhs, ~rhs );
620 }
621 //*************************************************************************************************
622 
623 
624 
625 
626 //=================================================================================================
627 //
628 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
629 //
630 //=================================================================================================
631 
632 //*************************************************************************************************
645 template< typename T1 // Type of the dense matrix of the left-hand side expression
646  , typename T2 // Type of the sparse matrix of the left-hand side expression
647  , bool SO1 // Storage order of the left-hand side expression
648  , typename T3 // Type of the right-hand side dense matrix
649  , bool SO2 > // Storage order of the right-hand side dense matrix
650 inline const typename AddExprTrait< DMatSMatSubExpr<T1,T2,SO1>, T3 >::Type
651  operator+( const DMatSMatSubExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
652 {
654 
655  return ( lhs.leftOperand() + (~rhs) ) - lhs.rightOperand();
656 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
674 template< typename T1 // Type of the dense matrix of the left-hand side expression
675  , typename T2 // Type of the sparse matrix of the left-hand side expression
676  , bool SO1 // Storage order of the left-hand side expression
677  , typename T3 // Type of the right-hand side dense matrix
678  , bool SO2 > // Storage order of the right-hand side dense matrix
679 inline const typename SubExprTrait< DMatSMatSubExpr<T1,T2,SO1>, T3 >::Type
680  operator-( const DMatSMatSubExpr<T1,T2,SO1>& lhs, const DenseMatrix<T3,SO2>& rhs )
681 {
683 
684  return ( lhs.leftOperand() - (~rhs) ) - lhs.rightOperand();
685 }
687 //*************************************************************************************************
688 
689 
690 
691 
692 //=================================================================================================
693 //
694 // ROWS SPECIALIZATIONS
695 //
696 //=================================================================================================
697 
698 //*************************************************************************************************
700 template< typename MT1, typename MT2, bool SO >
701 struct Rows< DMatSMatSubExpr<MT1,MT2,SO> >
702  : public Max< Rows<MT1>, Rows<MT2> >::Type
703 {};
705 //*************************************************************************************************
706 
707 
708 
709 
710 //=================================================================================================
711 //
712 // COLUMNS SPECIALIZATIONS
713 //
714 //=================================================================================================
715 
716 //*************************************************************************************************
718 template< typename MT1, typename MT2, bool SO >
719 struct Columns< DMatSMatSubExpr<MT1,MT2,SO> >
720  : public Max< Columns<MT1>, Columns<MT2> >::Type
721 {};
723 //*************************************************************************************************
724 
725 
726 
727 
728 //=================================================================================================
729 //
730 // ISSYMMETRIC SPECIALIZATIONS
731 //
732 //=================================================================================================
733 
734 //*************************************************************************************************
736 template< typename MT1, typename MT2, bool SO >
737 struct IsSymmetric< DMatSMatSubExpr<MT1,MT2,SO> >
738  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
739 {};
741 //*************************************************************************************************
742 
743 
744 
745 
746 //=================================================================================================
747 //
748 // ISLOWER SPECIALIZATIONS
749 //
750 //=================================================================================================
751 
752 //*************************************************************************************************
754 template< typename MT1, typename MT2, bool SO >
755 struct IsLower< DMatSMatSubExpr<MT1,MT2,SO> >
756  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
757 {};
759 //*************************************************************************************************
760 
761 
762 
763 
764 //=================================================================================================
765 //
766 // ISUNILOWER SPECIALIZATIONS
767 //
768 //=================================================================================================
769 
770 //*************************************************************************************************
772 template< typename MT1, typename MT2, bool SO >
773 struct IsUniLower< DMatSMatSubExpr<MT1,MT2,SO> >
774  : public IsTrue< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >::value >
775 {};
777 //*************************************************************************************************
778 
779 
780 
781 
782 //=================================================================================================
783 //
784 // ISSTRICTLYLOWER SPECIALIZATIONS
785 //
786 //=================================================================================================
787 
788 //*************************************************************************************************
790 template< typename MT1, typename MT2, bool SO >
791 struct IsStrictlyLower< DMatSMatSubExpr<MT1,MT2,SO> >
792  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
793 {};
795 //*************************************************************************************************
796 
797 
798 
799 
800 //=================================================================================================
801 //
802 // ISUPPER SPECIALIZATIONS
803 //
804 //=================================================================================================
805 
806 //*************************************************************************************************
808 template< typename MT1, typename MT2, bool SO >
809 struct IsUpper< DMatSMatSubExpr<MT1,MT2,SO> >
810  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
811 {};
813 //*************************************************************************************************
814 
815 
816 
817 
818 //=================================================================================================
819 //
820 // ISUNIUPPER SPECIALIZATIONS
821 //
822 //=================================================================================================
823 
824 //*************************************************************************************************
826 template< typename MT1, typename MT2, bool SO >
827 struct IsUniUpper< DMatSMatSubExpr<MT1,MT2,SO> >
828  : public IsTrue< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >::value >
829 {};
831 //*************************************************************************************************
832 
833 
834 
835 
836 //=================================================================================================
837 //
838 // ISSTRICTLYUPPER SPECIALIZATIONS
839 //
840 //=================================================================================================
841 
842 //*************************************************************************************************
844 template< typename MT1, typename MT2, bool SO >
845 struct IsStrictlyUpper< DMatSMatSubExpr<MT1,MT2,SO> >
846  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
847 {};
849 //*************************************************************************************************
850 
851 
852 
853 
854 //=================================================================================================
855 //
856 // EXPRESSION TRAIT SPECIALIZATIONS
857 //
858 //=================================================================================================
859 
860 //*************************************************************************************************
862 template< typename MT1, typename MT2, typename MT3 >
863 struct DMatDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
864 {
865  public:
866  //**********************************************************************************************
868  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
869  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
870  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
871  , typename DMatSMatSubExprTrait< typename DMatDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
872  , INVALID_TYPE >::Type Type;
874  //**********************************************************************************************
875 };
877 //*************************************************************************************************
878 
879 
880 //*************************************************************************************************
882 template< typename MT1, typename MT2, typename MT3 >
883 struct DMatTDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
884 {
885  public:
886  //**********************************************************************************************
888  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
889  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
890  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
891  , typename DMatSMatSubExprTrait< typename DMatTDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
892  , INVALID_TYPE >::Type Type;
894  //**********************************************************************************************
895 };
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
902 template< typename MT1, typename MT2, typename MT3 >
903 struct TDMatDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
904 {
905  public:
906  //**********************************************************************************************
908  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
909  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
910  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
911  , typename DMatTSMatSubExprTrait< typename TDMatDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
912  , INVALID_TYPE >::Type Type;
914  //**********************************************************************************************
915 };
917 //*************************************************************************************************
918 
919 
920 //*************************************************************************************************
922 template< typename MT1, typename MT2, typename MT3 >
923 struct TDMatTDMatAddExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
924 {
925  public:
926  //**********************************************************************************************
928  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
929  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
930  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
931  , typename TDMatTSMatSubExprTrait< typename TDMatTDMatAddExprTrait<MT1,MT3>::Type, MT2 >::Type
932  , INVALID_TYPE >::Type Type;
934  //**********************************************************************************************
935 };
937 //*************************************************************************************************
938 
939 
940 //*************************************************************************************************
942 template< typename MT1, typename MT2, typename MT3 >
943 struct DMatDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
944 {
945  public:
946  //**********************************************************************************************
948  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
949  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
950  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
951  , typename DMatSMatSubExprTrait< typename DMatDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
952  , INVALID_TYPE >::Type Type;
954  //**********************************************************************************************
955 };
957 //*************************************************************************************************
958 
959 
960 //*************************************************************************************************
962 template< typename MT1, typename MT2, typename MT3 >
963 struct DMatTDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,false>, MT3 >
964 {
965  public:
966  //**********************************************************************************************
968  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsRowMajorMatrix<MT1>::value &&
969  IsSparseMatrix<MT2>::value && IsRowMajorMatrix<MT2>::value &&
970  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
971  , typename DMatSMatSubExprTrait< typename DMatTDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
972  , INVALID_TYPE >::Type Type;
974  //**********************************************************************************************
975 };
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
982 template< typename MT1, typename MT2, typename MT3 >
983 struct TDMatDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
984 {
985  public:
986  //**********************************************************************************************
988  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
989  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
990  IsDenseMatrix<MT3>::value && IsRowMajorMatrix<MT3>::value
991  , typename DMatTSMatSubExprTrait< typename TDMatDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
992  , INVALID_TYPE >::Type Type;
994  //**********************************************************************************************
995 };
997 //*************************************************************************************************
998 
999 
1000 //*************************************************************************************************
1002 template< typename MT1, typename MT2, typename MT3 >
1003 struct TDMatTDMatSubExprTrait< DMatSMatSubExpr<MT1,MT2,true>, MT3 >
1004 {
1005  public:
1006  //**********************************************************************************************
1008  typedef typename SelectType< IsDenseMatrix<MT1>::value && IsColumnMajorMatrix<MT1>::value &&
1009  IsSparseMatrix<MT2>::value && IsColumnMajorMatrix<MT2>::value &&
1010  IsDenseMatrix<MT3>::value && IsColumnMajorMatrix<MT3>::value
1011  , typename TDMatTSMatSubExprTrait< typename TDMatTDMatSubExprTrait<MT1,MT3>::Type, MT2 >::Type
1012  , INVALID_TYPE >::Type Type;
1014  //**********************************************************************************************
1015 };
1017 //*************************************************************************************************
1018 
1019 
1020 //*************************************************************************************************
1022 template< typename MT1, typename MT2, bool SO, bool AF >
1023 struct SubmatrixExprTrait< DMatSMatSubExpr<MT1,MT2,SO>, AF >
1024 {
1025  public:
1026  //**********************************************************************************************
1027  typedef typename SubExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1028  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1029  //**********************************************************************************************
1030 };
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1037 template< typename MT1, typename MT2, bool SO >
1038 struct RowExprTrait< DMatSMatSubExpr<MT1,MT2,SO> >
1039 {
1040  public:
1041  //**********************************************************************************************
1042  typedef typename SubExprTrait< typename RowExprTrait<const MT1>::Type
1043  , typename RowExprTrait<const MT2>::Type >::Type Type;
1044  //**********************************************************************************************
1045 };
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1052 template< typename MT1, typename MT2, bool SO >
1053 struct ColumnExprTrait< DMatSMatSubExpr<MT1,MT2,SO> >
1054 {
1055  public:
1056  //**********************************************************************************************
1057  typedef typename SubExprTrait< typename ColumnExprTrait<const MT1>::Type
1058  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1059  //**********************************************************************************************
1060 };
1062 //*************************************************************************************************
1063 
1064 } // namespace blaze
1065 
1066 #endif
Constraint on the data type.
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:268
Header file for the Max class template.
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:112
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.
Header file for the subtraction trait.
Header file for basic type definitions.
SubTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DMatSMatSubExpr.h:145
Header file for the IsSparseMatrix type trait.
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatSMatSubExpr.h:148
#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.
Header file for the IsColumnMajorMatrix type trait.
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:110
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.
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
Header file for the Computation base class.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatSMatSubExpr.h:247
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.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatSMatSubExpr.h:193
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.
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:267
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
DMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the DMatSMatSubExpr class.
Definition: DMatSMatSubExpr.h:177
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.
Header file for the MatMatSubExpr base class.
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatSubExpr.h:154
Header file for the IsLower type trait.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatSMatSubExpr.h:215
#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.
Evaluation of the return type of a subtraction expression.Via this type trait it is possible to evalu...
Definition: SubExprTrait.h:104
MT1::ReturnType RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:111
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.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DMatSMatSubExpr.h:260
Header file for the serial shim.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:160
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
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatSMatSubExpr.h:146
DMatSMatSubExpr< MT1, MT2, SO > This
Type of this DMatSMatSubExpr instance.
Definition: DMatSMatSubExpr.h:144
Header file for run time assertion macros.
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
Expression object for dense matrix-sparse matrix subtractions.The DMatSMatSubExpr class represents th...
Definition: DMatSMatSubExpr.h:103
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
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatSubExpr.h:147
SubExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatSMatSubExpr.h:125
RightOperand rightOperand() const
Returns the right-hand side dense matrix operand.
Definition: DMatSMatSubExpr.h:235
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:109
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:157
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatSMatSubExpr.h:225
#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
Header file for the IsRowMajorMatrix type trait.
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
#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.
#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:165
Base template for the SubTrait class.
Definition: SubTrait.h:150
Header file for the IsUpper type trait.
Header file for the SubExprTrait class template.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatSMatSubExpr.h:151
#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
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatSMatSubExpr.h:205
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