TSMatSMatSubExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATSMATSUBEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATSMATSUBEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
74 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Exception.h>
79 #include <blaze/util/mpl/And.h>
80 #include <blaze/util/mpl/Max.h>
81 #include <blaze/util/SelectType.h>
82 #include <blaze/util/Types.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS TSMATSMATSUBEXPR
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
102 template< typename MT1 // Type of the left-hand side sparse matrix
103  , typename MT2 > // Type of the right-hand side sparse matrix
104 class TSMatSMatSubExpr : public SparseMatrix< TSMatSMatSubExpr<MT1,MT2>, false >
105  , private MatMatSubExpr
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  typedef typename MT1::CompositeType CT1;
115  typedef typename MT2::CompositeType CT2;
116  //**********************************************************************************************
117 
118  //**Return type evaluation**********************************************************************
120 
125  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
126 
129  //**********************************************************************************************
130 
131  //**Serial evaluation strategy******************************************************************
133 
139  template< typename T1, typename T2 >
140  struct UseSymmetricKernel {
142  enum { value = IsSymmetric<T2>::value };
143  };
145  //**********************************************************************************************
146 
147  //**Parallel evaluation strategy****************************************************************
149 
154  template< typename MT >
155  struct UseSMPAssign {
156  enum { value = MT::smpAssignable };
157  };
159  //**********************************************************************************************
160 
161  public:
162  //**Type definitions****************************************************************************
168 
171 
173  typedef const ResultType CompositeType;
174 
176  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
177 
179  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
180  //**********************************************************************************************
181 
182  //**Compilation flags***************************************************************************
184  enum { smpAssignable = 0 };
185  //**********************************************************************************************
186 
187  //**Constructor*********************************************************************************
193  explicit inline TSMatSMatSubExpr( const MT1& lhs, const MT2& rhs )
194  : lhs_( lhs ) // Left-hand side sparse matrix of the subtraction expression
195  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
196  {
197  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
198  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
199  }
200  //**********************************************************************************************
201 
202  //**Access operator*****************************************************************************
209  inline ReturnType operator()( size_t i, size_t j ) const {
210  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
211  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
212  return lhs_(i,j) - rhs_(i,j);
213  }
214  //**********************************************************************************************
215 
216  //**At function*********************************************************************************
224  inline ReturnType at( size_t i, size_t j ) const {
225  if( i >= lhs_.rows() ) {
226  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
227  }
228  if( j >= lhs_.columns() ) {
229  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
230  }
231  return (*this)(i,j);
232  }
233  //**********************************************************************************************
234 
235  //**Rows function*******************************************************************************
240  inline size_t rows() const {
241  return lhs_.rows();
242  }
243  //**********************************************************************************************
244 
245  //**Columns function****************************************************************************
250  inline size_t columns() const {
251  return lhs_.columns();
252  }
253  //**********************************************************************************************
254 
255  //**NonZeros function***************************************************************************
260  inline size_t nonZeros() const {
261  return lhs_.nonZeros() + rhs_.nonZeros();
262  }
263  //**********************************************************************************************
264 
265  //**NonZeros function***************************************************************************
271  inline size_t nonZeros( size_t i ) const {
272  return lhs_.nonZeros(i) + rhs_.nonZeros(i);
273  }
274  //**********************************************************************************************
275 
276  //**Left operand access*************************************************************************
281  inline LeftOperand leftOperand() const {
282  return lhs_;
283  }
284  //**********************************************************************************************
285 
286  //**Right operand access************************************************************************
291  inline RightOperand rightOperand() const {
292  return rhs_;
293  }
294  //**********************************************************************************************
295 
296  //**********************************************************************************************
302  template< typename T >
303  inline bool canAlias( const T* alias ) const {
304  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
305  }
306  //**********************************************************************************************
307 
308  //**********************************************************************************************
314  template< typename T >
315  inline bool isAliased( const T* alias ) const {
316  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
317  }
318  //**********************************************************************************************
319 
320  private:
321  //**Member variables****************************************************************************
322  LeftOperand lhs_;
323  RightOperand rhs_;
324  //**********************************************************************************************
325 
326  //**Assignment to dense matrices****************************************************************
338  template< typename MT // Type of the target dense matrix
339  , bool SO > // Storage order of the target dense matrix
340  friend inline void assign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
341  {
343 
344  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
345  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
346 
347  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
348 
349  assign( ~lhs, rhs.lhs_ );
350 
352  subAssign( ~lhs, rhs.rhs_ );
353  }
354  else
355  {
356  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
357 
358  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
359  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
360  BLAZE_INTERNAL_ASSERT( B.rows() == (~lhs).rows() , "Invalid number of rows" );
361  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
362 
363  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
364  const RightIterator end( B.end(i) );
365  for( RightIterator element=B.begin(i); element!=end; ++element ) {
366  if( isDefault( (~lhs)(i,element->index()) ) )
367  (~lhs)(i,element->index()) = -element->value();
368  else
369  (~lhs)(i,element->index()) -= element->value();
370  }
371  }
372  }
373  }
375  //**********************************************************************************************
376 
377  //**Assignment to row-major sparse matrices*****************************************************
390  template< typename MT > // Type of the target sparse matrix
391  friend inline typename DisableIf< UseSymmetricKernel<MT,MT1> >::Type
392  assign( SparseMatrix<MT,false>& lhs, const TSMatSMatSubExpr& rhs )
393  {
395 
396  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
397  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
398 
399  typedef typename RT1::OppositeType::ConstIterator LeftIterator;
400  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
401 
402  // Evaluation of the left-hand side sparse matrix operand
403  const typename RT1::OppositeType A( serial( rhs.lhs_ ) );
404 
405  // Evaluation of the right-hand side sparse matrix operand
406  CT2 B( serial( rhs.rhs_ ) );
407 
408  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
409  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
410  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
411  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
412  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
413  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
414 
415  // Final memory allocation (based on the evaluated operands)
416  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
417 
418  // Performing the matrix subtraction
419  for( size_t i=0UL; i<(~lhs).rows(); ++i )
420  {
421  const LeftIterator lend( A.end(i) );
422  const RightIterator rend( B.end(i) );
423 
424  LeftIterator l( A.begin(i) );
425  RightIterator r( B.begin(i) );
426 
427  while( l != lend && r != rend )
428  {
429  if( l->index() < r->index() ) {
430  (~lhs).append( i, l->index(), l->value() );
431  ++l;
432  }
433  else if( l->index() > r->index() ) {
434  (~lhs).append( i, r->index(), -r->value() );
435  ++r;
436  }
437  else {
438  (~lhs).append( i, l->index(), l->value()-r->value() );
439  ++l;
440  ++r;
441  }
442  }
443 
444  while( l != lend ) {
445  (~lhs).append( i, l->index(), l->value() );
446  ++l;
447  }
448 
449  while( r != rend ) {
450  (~lhs).append( i, r->index(), -r->value() );
451  ++r;
452  }
453 
454  (~lhs).finalize( i );
455  }
456  }
458  //**********************************************************************************************
459 
460  //**Assignment to row-major sparse matrices*****************************************************
473  template< typename MT > // Type of the target sparse matrix
474  friend inline typename EnableIf< UseSymmetricKernel<MT,MT1> >::Type
475  assign( SparseMatrix<MT,false>& lhs, const TSMatSMatSubExpr& rhs )
476  {
478 
479  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
480  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
481 
482  assign( ~lhs, trans( rhs.lhs_ ) - rhs.rhs_ );
483  }
485  //**********************************************************************************************
486 
487  //**Assignment to column-major sparse matrices**************************************************
500  template< typename MT > // Type of the target sparse matrix
501  friend inline typename DisableIf< UseSymmetricKernel<MT,MT2> >::Type
502  assign( SparseMatrix<MT,true>& lhs, const TSMatSMatSubExpr& rhs )
503  {
505 
507 
508  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
509  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
510 
511  typedef typename RemoveReference<CT1>::Type::ConstIterator LeftIterator;
512  typedef typename RT2::OppositeType::ConstIterator RightIterator;
513 
514  // Evaluation of the left-hand side sparse matrix operand
515  CT1 A( serial( rhs.lhs_ ) );
516 
517  // Evaluation of the right-hand side sparse matrix operand
518  const typename RT2::OppositeType B( serial( rhs.rhs_ ) );
519 
520  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
521  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
522  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
523  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
524  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
525  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
526 
527  // Final memory allocation (based on the evaluated operands)
528  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
529 
530  // Performing the matrix subtraction
531  for( size_t j=0UL; j<(~lhs).columns(); ++j )
532  {
533  const LeftIterator lend( A.end(j) );
534  const RightIterator rend( B.end(j) );
535 
536  LeftIterator l( A.begin(j) );
537  RightIterator r( B.begin(j) );
538 
539  while( l != lend && r != rend )
540  {
541  if( l->index() < r->index() ) {
542  (~lhs).append( l->index(), j, l->value() );
543  ++l;
544  }
545  else if( l->index() > r->index() ) {
546  (~lhs).append( r->index(), j, -r->value() );
547  ++r;
548  }
549  else {
550  (~lhs).append( l->index(), j, l->value()-r->value() );
551  ++l;
552  ++r;
553  }
554  }
555 
556  while( l != lend ) {
557  (~lhs).append( l->index(), j, l->value() );
558  ++l;
559  }
560 
561  while( r != rend ) {
562  (~lhs).append( r->index(), j, -r->value() );
563  ++r;
564  }
565 
566  (~lhs).finalize( j );
567  }
568  }
570  //**********************************************************************************************
571 
572  //**Assignment to column-major sparse matrices**************************************************
585  template< typename MT > // Type of the target sparse matrix
586  friend inline typename EnableIf< UseSymmetricKernel<MT,MT2> >::Type
587  assign( SparseMatrix<MT,true>& lhs, const TSMatSMatSubExpr& rhs )
588  {
590 
592 
593  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
594  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
595 
596  assign( ~lhs, rhs.lhs_ - trans( rhs.rhs_ ) );
597  }
599  //**********************************************************************************************
600 
601  //**Addition assignment to dense matrices*******************************************************
614  template< typename MT // Type of the target dense matrix
615  , bool SO > // Storage order of the target dense matrix
616  friend inline void addAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
617  {
619 
620  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
621  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
622 
623  addAssign( ~lhs, rhs.lhs_ );
624  subAssign( ~lhs, rhs.rhs_ );
625  }
627  //**********************************************************************************************
628 
629  //**Addition assignment to sparse matrices******************************************************
630  // No special implementation for the addition assignment to sparse matrices.
631  //**********************************************************************************************
632 
633  //**Subtraction assignment to dense matrices****************************************************
646  template< typename MT // Type of the target dense matrix
647  , bool SO > // Storage order of the target dense matrix
648  friend inline void subAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
649  {
651 
652  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
653  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
654 
655  subAssign( ~lhs, rhs.lhs_ );
656  addAssign( ~lhs, rhs.rhs_ );
657  }
659  //**********************************************************************************************
660 
661  //**Subtraction assignment to sparse matrices***************************************************
662  // No special implementation for the subtraction assignment to sparse matrices.
663  //**********************************************************************************************
664 
665  //**Multiplication assignment to dense matrices*************************************************
666  // No special implementation for the multiplication assignment to dense matrices.
667  //**********************************************************************************************
668 
669  //**Multiplication assignment to sparse matrices************************************************
670  // No special implementation for the multiplication assignment to sparse matrices.
671  //**********************************************************************************************
672 
673  //**SMP assignment to dense matrices************************************************************
674  // No special implementation for the SMP assignment to dense matrices.
675  //**********************************************************************************************
676 
677  //**SMP assignment to sparse matrices***********************************************************
678  // No special implementation for the SMP assignment to sparse matrices.
679  //**********************************************************************************************
680 
681  //**SMP addition assignment to dense matrices*******************************************************
696  template< typename MT // Type of the target dense matrix
697  , bool SO > // Storage order of the target dense matrix
698  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
699  smpAddAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
700  {
702 
703  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
704  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
705 
706  smpAddAssign( ~lhs, rhs.lhs_ );
707  smpSubAssign( ~lhs, rhs.rhs_ );
708  }
710  //**********************************************************************************************
711 
712  //**SMP addition assignment to sparse matrices**************************************************
713  // No special implementation for the SMP addition assignment to sparse matrices.
714  //**********************************************************************************************
715 
716  //**SMP subtraction assignment to dense matrices************************************************
731  template< typename MT // Type of the target dense matrix
732  , bool SO > // Storage order of the target dense matrix
733  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
734  smpSubAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
735  {
737 
738  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
739  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
740 
741  smpSubAssign( ~lhs, rhs.lhs_ );
742  smpAddAssign( ~lhs, rhs.rhs_ );
743  }
745  //**********************************************************************************************
746 
747  //**SMP subtraction assignment to sparse matrices***********************************************
748  // No special implementation for the SMP subtraction assignment to sparse matrices.
749  //**********************************************************************************************
750 
751  //**SMP multiplication assignment to dense matrices*********************************************
752  // No special implementation for the SMP multiplication assignment to dense matrices.
753  //**********************************************************************************************
754 
755  //**SMP multiplication assignment to sparse matrices********************************************
756  // No special implementation for the SMP multiplication assignment to sparse matrices.
757  //**********************************************************************************************
758 
759  //**Compile time checks*************************************************************************
767  //**********************************************************************************************
768 };
769 //*************************************************************************************************
770 
771 
772 
773 
774 //=================================================================================================
775 //
776 // GLOBAL BINARY ARITHMETIC OPERATORS
777 //
778 //=================================================================================================
779 
780 //*************************************************************************************************
809 template< typename T1 // Type of the left-hand side sparse matrix
810  , typename T2 > // Type of the right-hand side sparse matrix
811 inline const TSMatSMatSubExpr<T1,T2>
813 {
815 
816  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
817  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
818  }
819 
820  return TSMatSMatSubExpr<T1,T2>( ~lhs, ~rhs );
821 }
822 //*************************************************************************************************
823 
824 
825 
826 
827 //=================================================================================================
828 //
829 // ROWS SPECIALIZATIONS
830 //
831 //=================================================================================================
832 
833 //*************************************************************************************************
835 template< typename MT1, typename MT2 >
836 struct Rows< TSMatSMatSubExpr<MT1,MT2> >
837  : public Max< Rows<MT1>, Rows<MT2> >
838 {};
840 //*************************************************************************************************
841 
842 
843 
844 
845 //=================================================================================================
846 //
847 // COLUMNS SPECIALIZATIONS
848 //
849 //=================================================================================================
850 
851 //*************************************************************************************************
853 template< typename MT1, typename MT2 >
854 struct Columns< TSMatSMatSubExpr<MT1,MT2> >
855  : public Max< Columns<MT1>, Columns<MT2> >
856 {};
858 //*************************************************************************************************
859 
860 
861 
862 
863 //=================================================================================================
864 //
865 // ISSYMMETRIC SPECIALIZATIONS
866 //
867 //=================================================================================================
868 
869 //*************************************************************************************************
871 template< typename MT1, typename MT2 >
872 struct IsSymmetric< TSMatSMatSubExpr<MT1,MT2> >
873  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
874 {};
876 //*************************************************************************************************
877 
878 
879 
880 
881 //=================================================================================================
882 //
883 // ISHERMITIAN SPECIALIZATIONS
884 //
885 //=================================================================================================
886 
887 //*************************************************************************************************
889 template< typename MT1, typename MT2 >
890 struct IsHermitian< TSMatSMatSubExpr<MT1,MT2> >
891  : public IsTrue< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
892 {};
894 //*************************************************************************************************
895 
896 
897 
898 
899 //=================================================================================================
900 //
901 // ISLOWER SPECIALIZATIONS
902 //
903 //=================================================================================================
904 
905 //*************************************************************************************************
907 template< typename MT1, typename MT2 >
908 struct IsLower< TSMatSMatSubExpr<MT1,MT2> >
909  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
910 {};
912 //*************************************************************************************************
913 
914 
915 
916 
917 //=================================================================================================
918 //
919 // ISUNILOWER SPECIALIZATIONS
920 //
921 //=================================================================================================
922 
923 //*************************************************************************************************
925 template< typename MT1, typename MT2 >
926 struct IsUniLower< TSMatSMatSubExpr<MT1,MT2> >
927  : public IsTrue< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >::value >
928 {};
930 //*************************************************************************************************
931 
932 
933 
934 
935 //=================================================================================================
936 //
937 // ISSTRICTLYLOWER SPECIALIZATIONS
938 //
939 //=================================================================================================
940 
941 //*************************************************************************************************
943 template< typename MT1, typename MT2 >
944 struct IsStrictlyLower< TSMatSMatSubExpr<MT1,MT2> >
945  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
946 {};
948 //*************************************************************************************************
949 
950 
951 
952 
953 //=================================================================================================
954 //
955 // ISUPPER SPECIALIZATIONS
956 //
957 //=================================================================================================
958 
959 //*************************************************************************************************
961 template< typename MT1, typename MT2 >
962 struct IsUpper< TSMatSMatSubExpr<MT1,MT2> >
963  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
964 {};
966 //*************************************************************************************************
967 
968 
969 
970 
971 //=================================================================================================
972 //
973 // ISUNIUPPER SPECIALIZATIONS
974 //
975 //=================================================================================================
976 
977 //*************************************************************************************************
979 template< typename MT1, typename MT2 >
980 struct IsUniUpper< TSMatSMatSubExpr<MT1,MT2> >
981  : public IsTrue< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >::value >
982 {};
984 //*************************************************************************************************
985 
986 
987 
988 
989 //=================================================================================================
990 //
991 // ISSTRICTLYUPPER SPECIALIZATIONS
992 //
993 //=================================================================================================
994 
995 //*************************************************************************************************
997 template< typename MT1, typename MT2 >
998 struct IsStrictlyUpper< TSMatSMatSubExpr<MT1,MT2> >
999  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1000 {};
1002 //*************************************************************************************************
1003 
1004 
1005 
1006 
1007 //=================================================================================================
1008 //
1009 // EXPRESSION TRAIT SPECIALIZATIONS
1010 //
1011 //=================================================================================================
1012 
1013 //*************************************************************************************************
1015 template< typename MT1, typename MT2, bool AF >
1016 struct SubmatrixExprTrait< TSMatSMatSubExpr<MT1,MT2>, AF >
1017 {
1018  public:
1019  //**********************************************************************************************
1020  typedef typename SubExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1021  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1022  //**********************************************************************************************
1023 };
1025 //*************************************************************************************************
1026 
1027 
1028 //*************************************************************************************************
1030 template< typename MT1, typename MT2 >
1031 struct RowExprTrait< TSMatSMatSubExpr<MT1,MT2> >
1032 {
1033  public:
1034  //**********************************************************************************************
1035  typedef typename SubExprTrait< typename RowExprTrait<const MT1>::Type
1036  , typename RowExprTrait<const MT2>::Type >::Type Type;
1037  //**********************************************************************************************
1038 };
1040 //*************************************************************************************************
1041 
1042 
1043 //*************************************************************************************************
1045 template< typename MT1, typename MT2 >
1046 struct ColumnExprTrait< TSMatSMatSubExpr<MT1,MT2> >
1047 {
1048  public:
1049  //**********************************************************************************************
1050  typedef typename SubExprTrait< typename ColumnExprTrait<const MT1>::Type
1051  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1052  //**********************************************************************************************
1053 };
1055 //*************************************************************************************************
1056 
1057 } // namespace blaze
1058 
1059 #endif
Constraint on the data type.
#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
TSMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the TSMatSMatSubExpr class.
Definition: TSMatSMatSubExpr.h:193
Header file for the Max class template.
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h: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.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:114
size_t rows() const
Returns the current number of rows of the matrix.
Definition: TSMatSMatSubExpr.h:240
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: TSMatSMatSubExpr.h:260
Header file for the ColumnExprTrait class template.
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
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: TSMatSMatSubExpr.h:271
SubTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSMatSubExpr.h:164
Header file for the And class template.
RightOperand rightOperand() const
Returns the right-hand side sparse matrix operand.
Definition: TSMatSMatSubExpr.h:291
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
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:115
Header file for the Computation base class.
Constraints on the storage order of matrix types.
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:176
Header file for the IsUniLower type trait.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Header file for the SparseMatrix base class.
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 DisableIf class template.
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:110
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSMatSubExpr.h:303
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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
SubExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: TSMatSMatSubExpr.h:128
#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
Header file for the Columns type trait.
Header file for the MatMatSubExpr base class.
Header file for the IsLower type trait.
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:111
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
MT1::ReturnType RN1
Return type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:112
Constraints on the storage order of matrix types.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
Evaluation of the return type of a subtraction expression.Via this type trait it is possible to evalu...
Definition: SubExprTrait.h:104
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatSMatSubExpr.h:173
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_DIFFERENT_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:164
size_t columns() const
Returns the current number of columns of the matrix.
Definition: TSMatSMatSubExpr.h:250
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
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
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatSMatSubExpr.h:209
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSMatSubExpr.h:281
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TSMatSMatSubExpr.h:224
Header file for the isDefault shim.
Constraint on the data type.
Constraints on the storage order of matrix types.
LeftOperand lhs_
Left-hand side sparse matrix of the subtraction expression.
Definition: TSMatSMatSubExpr.h:322
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: TSMatSMatSubExpr.h:170
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatSMatSubExpr.h:165
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSMatSubExpr.h:315
TSMatSMatSubExpr< MT1, MT2 > This
Type of this TSMatSMatSubExpr instance.
Definition: TSMatSMatSubExpr.h:163
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
Header file for the IsComputation type trait class.
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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatSMatSubExpr.h:166
#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.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:179
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:113
#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:138
Header file for the IsUpper type trait.
Header file for exception macros.
Expression object for transpose sparse matrix-sparse matrix subtractions.The TSMatSMatSubExpr class r...
Definition: Forward.h:154
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSMatSubExpr.h:167
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the SubExprTrait class template.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: TSMatSMatSubExpr.h:323
#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
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.