SMatSMatSubExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSMATSUBEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSMATSUBEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
73 #include <blaze/util/Assert.h>
74 #include <blaze/util/DisableIf.h>
75 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/mpl/And.h>
78 #include <blaze/util/mpl/Max.h>
79 #include <blaze/util/SelectType.h>
80 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS SMATSMATSUBEXPR
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
100 template< typename MT1 // Type of the left-hand side sparse matrix
101  , typename MT2 > // Type of the right-hand side sparse matrix
102 class SMatSMatSubExpr : public SparseMatrix< SMatSMatSubExpr<MT1,MT2>, false >
103  , private MatMatSubExpr
104  , private Computation
105 {
106  private:
107  //**Type definitions****************************************************************************
108  typedef typename MT1::ResultType RT1;
109  typedef typename MT2::ResultType RT2;
110  typedef typename MT1::ReturnType RN1;
111  typedef typename MT2::ReturnType RN2;
112  typedef typename MT1::CompositeType CT1;
113  typedef typename MT2::CompositeType CT2;
114  //**********************************************************************************************
115 
116  //**Return type evaluation**********************************************************************
118 
123  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
124 
127  //**********************************************************************************************
128 
129  //**Serial evaluation strategy******************************************************************
131 
136  template< typename T1, typename T2, typename T3 >
137  struct UseSymmetricKernel {
140  };
142  //**********************************************************************************************
143 
144  //**Parallel evaluation strategy****************************************************************
146 
151  template< typename MT >
152  struct UseSMPAssign {
153  enum { value = MT::smpAssignable };
154  };
156  //**********************************************************************************************
157 
158  public:
159  //**Type definitions****************************************************************************
165 
168 
170  typedef const ResultType CompositeType;
171 
173  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
174 
176  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
177  //**********************************************************************************************
178 
179  //**Compilation flags***************************************************************************
181  enum { smpAssignable = 0 };
182  //**********************************************************************************************
183 
184  //**Constructor*********************************************************************************
190  explicit inline SMatSMatSubExpr( const MT1& lhs, const MT2& rhs )
191  : lhs_( lhs ) // Left-hand side sparse matrix of the subtraction expression
192  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
193  {
194  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
195  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
196  }
197  //**********************************************************************************************
198 
199  //**Access operator*****************************************************************************
206  inline ReturnType operator()( size_t i, size_t j ) const {
207  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
208  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
209  return lhs_(i,j) - rhs_(i,j);
210  }
211  //**********************************************************************************************
212 
213  //**Rows function*******************************************************************************
218  inline size_t rows() const {
219  return lhs_.rows();
220  }
221  //**********************************************************************************************
222 
223  //**Columns function****************************************************************************
228  inline size_t columns() const {
229  return lhs_.columns();
230  }
231  //**********************************************************************************************
232 
233  //**NonZeros function***************************************************************************
238  inline size_t nonZeros() const {
239  return lhs_.nonZeros() + rhs_.nonZeros();
240  }
241  //**********************************************************************************************
242 
243  //**NonZeros function***************************************************************************
249  inline size_t nonZeros( size_t i ) const {
250  return lhs_.nonZeros(i) + rhs_.nonZeros(i);
251  }
252  //**********************************************************************************************
253 
254  //**Left operand access*************************************************************************
259  inline LeftOperand leftOperand() const {
260  return lhs_;
261  }
262  //**********************************************************************************************
263 
264  //**Right operand access************************************************************************
269  inline RightOperand rightOperand() const {
270  return rhs_;
271  }
272  //**********************************************************************************************
273 
274  //**********************************************************************************************
280  template< typename T >
281  inline bool canAlias( const T* alias ) const {
282  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
283  }
284  //**********************************************************************************************
285 
286  //**********************************************************************************************
292  template< typename T >
293  inline bool isAliased( const T* alias ) const {
294  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
295  }
296  //**********************************************************************************************
297 
298  private:
299  //**Member variables****************************************************************************
300  LeftOperand lhs_;
301  RightOperand rhs_;
302  //**********************************************************************************************
303 
304  //**Assignment to dense matrices****************************************************************
316  template< typename MT // Type of the target dense matrix
317  , bool SO > // Storage order of the target dense matrix
318  friend inline void assign( DenseMatrix<MT,SO>& lhs, const SMatSMatSubExpr& rhs )
319  {
321 
322  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
323  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
324 
325  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
326 
327  assign( ~lhs, rhs.lhs_ );
328 
330  subAssign( ~lhs, rhs.rhs_ );
331  }
332  else
333  {
334  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
335 
336  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
337  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
338  BLAZE_INTERNAL_ASSERT( B.rows() == (~lhs).rows() , "Invalid number of rows" );
339  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
340 
341  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
342  const RightIterator end( B.end(i) );
343  for( RightIterator element=B.begin(i); element!=end; ++element ) {
344  if( isDefault( (~lhs)(i,element->index()) ) )
345  (~lhs)(i,element->index()) = -element->value();
346  else
347  (~lhs)(i,element->index()) -= element->value();
348  }
349  }
350  }
351  }
353  //**********************************************************************************************
354 
355  //**Assignment to row-major sparse matrices*****************************************************
367  template< typename MT > // Type of the target sparse matrix
368  friend inline void assign( SparseMatrix<MT,false>& lhs, const SMatSMatSubExpr& rhs )
369  {
371 
372  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
373  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
374 
375  typedef typename RemoveReference<CT1>::Type::ConstIterator LeftIterator;
376  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
377 
378  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
379  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
380 
381  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
382  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
383  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
384  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
385  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
386  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
387 
388  // Final memory allocation (based on the evaluated operands)
389  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
390 
391  // Performing the matrix subtraction
392  for( size_t i=0UL; i<(~lhs).rows(); ++i )
393  {
394  const LeftIterator lend( A.end(i) );
395  const RightIterator rend( B.end(i) );
396 
397  LeftIterator l( A.begin(i) );
398  RightIterator r( B.begin(i) );
399 
400  while( l != lend && r != rend )
401  {
402  if( l->index() < r->index() ) {
403  (~lhs).append( i, l->index(), l->value() );
404  ++l;
405  }
406  else if( l->index() > r->index() ) {
407  (~lhs).append( i, r->index(), -r->value() );
408  ++r;
409  }
410  else {
411  (~lhs).append( i, l->index(), l->value()-r->value() );
412  ++l;
413  ++r;
414  }
415  }
416 
417  while( l != lend ) {
418  (~lhs).append( i, l->index(), l->value() );
419  ++l;
420  }
421 
422  while( r != rend ) {
423  (~lhs).append( i, r->index(), -r->value() );
424  ++r;
425  }
426 
427  (~lhs).finalize( i );
428  }
429  }
431  //**********************************************************************************************
432 
433  //**Assignment to column-major sparse matrices**************************************************
445  template< typename MT > // Type of the target sparse matrix
446  friend inline typename DisableIf< UseSymmetricKernel<MT,MT1,MT2> >::Type
447  assign( SparseMatrix<MT,true>& lhs, const SMatSMatSubExpr& rhs )
448  {
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  typedef typename RemoveReference<CT1>::Type::ConstIterator LeftIterator;
457  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
458 
459  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
460  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
461 
462  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
463  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
464  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
465  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
466  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
467  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
468 
469  const size_t m( rhs.rows() );
470  const size_t n( rhs.columns() );
471 
472  // Counting the number of elements per column
473  std::vector<size_t> nonzeros( n, 0UL );
474  for( size_t i=0UL; i<m; ++i )
475  {
476  const LeftIterator lend( A.end(i) );
477  const RightIterator rend( B.end(i) );
478 
479  LeftIterator l( A.begin(i) );
480  RightIterator r( B.begin(i) );
481 
482  while( l != lend && r != rend )
483  {
484  if( l->index() < r->index() ) {
485  ++nonzeros[l->index()];
486  ++l;
487  }
488  else if( l->index() > r->index() ) {
489  ++nonzeros[r->index()];
490  ++r;
491  }
492  else {
493  ++nonzeros[l->index()];
494  ++l;
495  ++r;
496  }
497  }
498 
499  while( l != lend ) {
500  ++nonzeros[l->index()];
501  ++l;
502  }
503 
504  while( r != rend ) {
505  ++nonzeros[r->index()];
506  ++r;
507  }
508  }
509 
510  // Resizing the left-hand side sparse matrix
511  for( size_t j=0UL; j<n; ++j ) {
512  (~lhs).reserve( j, nonzeros[j] );
513  }
514 
515  // Performing the matrix subtraction
516  for( size_t i=0UL; i<m; ++i )
517  {
518  const LeftIterator lend( A.end(i) );
519  const RightIterator rend( B.end(i) );
520 
521  LeftIterator l( A.begin(i) );
522  RightIterator r( B.begin(i) );
523 
524  while( l != lend && r != rend )
525  {
526  if( l->index() < r->index() ) {
527  (~lhs).append( i, l->index(), l->value() );
528  ++l;
529  }
530  else if( l->index() > r->index() ) {
531  (~lhs).append( i, r->index(), -r->value() );
532  ++r;
533  }
534  else {
535  (~lhs).append( i, l->index(), l->value()-r->value() );
536  ++l;
537  ++r;
538  }
539  }
540 
541  while( l != lend ) {
542  (~lhs).append( i, l->index(), l->value() );
543  ++l;
544  }
545 
546  while( r != rend ) {
547  (~lhs).append( i, r->index(), -r->value() );
548  ++r;
549  }
550  }
551  }
553  //**********************************************************************************************
554 
555  //**Assignment to column-major sparse matrices**************************************************
567  template< typename MT > // Type of the target sparse matrix
568  friend inline typename EnableIf< UseSymmetricKernel<MT,MT1,MT2> >::Type
569  assign( SparseMatrix<MT,true>& lhs, const SMatSMatSubExpr& rhs )
570  {
572 
574 
575  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
576  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
577 
578  assign( ~lhs, trans( rhs.lhs_ ) - trans( rhs.rhs_ ) );
579  }
581  //**********************************************************************************************
582 
583  //**Addition assignment to dense matrices*******************************************************
595  template< typename MT // Type of the target dense matrix
596  , bool SO > // Storage order of the target dense matrix
597  friend inline void addAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatSubExpr& rhs )
598  {
600 
601  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
602  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
603 
604  addAssign( ~lhs, rhs.lhs_ );
605  subAssign( ~lhs, rhs.rhs_ );
606  }
608  //**********************************************************************************************
609 
610  //**Addition assignment to sparse matrices******************************************************
611  // No special implementation for the addition assignment to sparse matrices.
612  //**********************************************************************************************
613 
614  //**Subtraction assignment to dense matrices****************************************************
626  template< typename MT // Type of the target dense matrix
627  , bool SO > // Storage order of the target dense matrix
628  friend inline void subAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatSubExpr& rhs )
629  {
631 
632  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
633  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
634 
635  subAssign( ~lhs, rhs.lhs_ );
636  addAssign( ~lhs, rhs.rhs_ );
637  }
639  //**********************************************************************************************
640 
641  //**Subtraction assignment to sparse matrices***************************************************
642  // No special implementation for the subtraction assignment to sparse matrices.
643  //**********************************************************************************************
644 
645  //**Multiplication assignment to dense matrices*************************************************
646  // No special implementation for the multiplication assignment to dense matrices.
647  //**********************************************************************************************
648 
649  //**Multiplication assignment to sparse matrices************************************************
650  // No special implementation for the multiplication assignment to sparse matrices.
651  //**********************************************************************************************
652 
653  //**SMP assignment to dense matrices************************************************************
654  // No special implementation for the SMP assignment to dense matrices.
655  //**********************************************************************************************
656 
657  //**SMP assignment to sparse matrices***********************************************************
658  // No special implementation for the SMP assignment to sparse matrices.
659  //**********************************************************************************************
660 
661  //**SMP addition assignment to dense matrices***************************************************
675  template< typename MT // Type of the target dense matrix
676  , bool SO > // Storage order of the target dense matrix
677  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
678  smpAddAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatSubExpr& rhs )
679  {
681 
682  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
683  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
684 
685  smpAddAssign( ~lhs, rhs.lhs_ );
686  smpSubAssign( ~lhs, rhs.rhs_ );
687  }
689  //**********************************************************************************************
690 
691  //**SMP addition assignment to sparse matrices**************************************************
692  // No special implementation for the SMP addition assignment to sparse matrices.
693  //**********************************************************************************************
694 
695  //**SMP subtraction assignment to dense matrices************************************************
710  template< typename MT // Type of the target dense matrix
711  , bool SO > // Storage order of the target dense matrix
712  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
713  smpSubAssign( DenseMatrix<MT,SO>& lhs, const SMatSMatSubExpr& rhs )
714  {
716 
717  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
718  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
719 
720  smpSubAssign( ~lhs, rhs.lhs_ );
721  smpAddAssign( ~lhs, rhs.rhs_ );
722  }
724  //**********************************************************************************************
725 
726  //**SMP subtraction assignment to sparse matrices***********************************************
727  // No special implementation for the SMP subtraction assignment to sparse matrices.
728  //**********************************************************************************************
729 
730  //**SMP multiplication assignment to dense matrices*********************************************
731  // No special implementation for the SMP multiplication assignment to dense matrices.
732  //**********************************************************************************************
733 
734  //**SMP multiplication assignment to sparse matrices********************************************
735  // No special implementation for the SMP multiplication assignment to sparse matrices.
736  //**********************************************************************************************
737 
738  //**Compile time checks*************************************************************************
746  //**********************************************************************************************
747 };
748 //*************************************************************************************************
749 
750 
751 
752 
753 //=================================================================================================
754 //
755 // GLOBAL BINARY ARITHMETIC OPERATORS
756 //
757 //=================================================================================================
758 
759 //*************************************************************************************************
785 template< typename T1 // Type of the left-hand side sparse matrix
786  , typename T2 > // Type of the right-hand side sparse matrix
787 inline const SMatSMatSubExpr<T1,T2>
789 {
791 
792  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
793  throw std::invalid_argument( "Matrix sizes do not match" );
794 
795  return SMatSMatSubExpr<T1,T2>( ~lhs, ~rhs );
796 }
797 //*************************************************************************************************
798 
799 
800 
801 
802 //=================================================================================================
803 //
804 // ROWS SPECIALIZATIONS
805 //
806 //=================================================================================================
807 
808 //*************************************************************************************************
810 template< typename MT1, typename MT2 >
811 struct Rows< SMatSMatSubExpr<MT1,MT2> >
812  : public Max< Rows<MT1>, Rows<MT2> >::Type
813 {};
815 //*************************************************************************************************
816 
817 
818 
819 
820 //=================================================================================================
821 //
822 // COLUMNS SPECIALIZATIONS
823 //
824 //=================================================================================================
825 
826 //*************************************************************************************************
828 template< typename MT1, typename MT2 >
829 struct Columns< SMatSMatSubExpr<MT1,MT2> >
830  : public Max< Columns<MT1>, Columns<MT2> >::Type
831 {};
833 //*************************************************************************************************
834 
835 
836 
837 
838 //=================================================================================================
839 //
840 // ISSYMMETRIC SPECIALIZATIONS
841 //
842 //=================================================================================================
843 
844 //*************************************************************************************************
846 template< typename MT1, typename MT2 >
847 struct IsSymmetric< SMatSMatSubExpr<MT1,MT2> >
848  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
849 {};
851 //*************************************************************************************************
852 
853 
854 
855 
856 //=================================================================================================
857 //
858 // ISLOWER SPECIALIZATIONS
859 //
860 //=================================================================================================
861 
862 //*************************************************************************************************
864 template< typename MT1, typename MT2 >
865 struct IsLower< SMatSMatSubExpr<MT1,MT2> >
866  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
867 {};
869 //*************************************************************************************************
870 
871 
872 
873 
874 //=================================================================================================
875 //
876 // ISUNILOWER SPECIALIZATIONS
877 //
878 //=================================================================================================
879 
880 //*************************************************************************************************
882 template< typename MT1, typename MT2 >
883 struct IsUniLower< SMatSMatSubExpr<MT1,MT2> >
884  : public IsTrue< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >::value >
885 {};
887 //*************************************************************************************************
888 
889 
890 
891 
892 //=================================================================================================
893 //
894 // ISSTRICTLYLOWER SPECIALIZATIONS
895 //
896 //=================================================================================================
897 
898 //*************************************************************************************************
900 template< typename MT1, typename MT2 >
901 struct IsStrictlyLower< SMatSMatSubExpr<MT1,MT2> >
902  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
903 {};
905 //*************************************************************************************************
906 
907 
908 
909 
910 //=================================================================================================
911 //
912 // ISUPPER SPECIALIZATIONS
913 //
914 //=================================================================================================
915 
916 //*************************************************************************************************
918 template< typename MT1, typename MT2 >
919 struct IsUpper< SMatSMatSubExpr<MT1,MT2> >
920  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
921 {};
923 //*************************************************************************************************
924 
925 
926 
927 
928 //=================================================================================================
929 //
930 // ISUNIUPPER SPECIALIZATIONS
931 //
932 //=================================================================================================
933 
934 //*************************************************************************************************
936 template< typename MT1, typename MT2 >
937 struct IsUniUpper< SMatSMatSubExpr<MT1,MT2> >
938  : public IsTrue< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >::value >
939 {};
941 //*************************************************************************************************
942 
943 
944 
945 
946 //=================================================================================================
947 //
948 // ISSTRICTLYUPPER SPECIALIZATIONS
949 //
950 //=================================================================================================
951 
952 //*************************************************************************************************
954 template< typename MT1, typename MT2 >
955 struct IsStrictlyUpper< SMatSMatSubExpr<MT1,MT2> >
956  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
957 {};
959 //*************************************************************************************************
960 
961 
962 
963 
964 //=================================================================================================
965 //
966 // EXPRESSION TRAIT SPECIALIZATIONS
967 //
968 //=================================================================================================
969 
970 //*************************************************************************************************
972 template< typename MT1, typename MT2, bool AF >
973 struct SubmatrixExprTrait< SMatSMatSubExpr<MT1,MT2>, AF >
974 {
975  public:
976  //**********************************************************************************************
977  typedef typename SubExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
978  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
979  //**********************************************************************************************
980 };
982 //*************************************************************************************************
983 
984 
985 //*************************************************************************************************
987 template< typename MT1, typename MT2 >
988 struct RowExprTrait< SMatSMatSubExpr<MT1,MT2> >
989 {
990  public:
991  //**********************************************************************************************
992  typedef typename SubExprTrait< typename RowExprTrait<const MT1>::Type
993  , typename RowExprTrait<const MT2>::Type >::Type Type;
994  //**********************************************************************************************
995 };
997 //*************************************************************************************************
998 
999 
1000 //*************************************************************************************************
1002 template< typename MT1, typename MT2 >
1003 struct ColumnExprTrait< SMatSMatSubExpr<MT1,MT2> >
1004 {
1005  public:
1006  //**********************************************************************************************
1007  typedef typename SubExprTrait< typename ColumnExprTrait<const MT1>::Type
1008  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1009  //**********************************************************************************************
1010 };
1012 //*************************************************************************************************
1013 
1014 } // namespace blaze
1015 
1016 #endif
RightOperand rightOperand() const
Returns the right-hand side sparse matrix operand.
Definition: SMatSMatSubExpr.h:269
Constraint on the data type.
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.
SubExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatSMatSubExpr.h:126
Header file for the subtraction trait.
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:113
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatSMatSubExpr.h:206
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:258
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatSMatSubExpr.h:170
SMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the SMatSMatSubExpr class.
Definition: SMatSMatSubExpr.h:190
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
MT2::ReturnType RN2
ReturnType type of the right-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:111
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatSMatSubExpr.h:293
Header file for the ColumnExprTrait class template.
SMatSMatSubExpr< MT1, MT2 > This
Type of this SMatSMatSubExpr instance.
Definition: SMatSMatSubExpr.h:160
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatSMatSubExpr.h:218
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatSMatSubExpr.h:163
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:261
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
Header file for the And class template.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatSMatSubExpr.h:167
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.
Header file for the RequiresEvaluation type trait.
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:112
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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Header file for the SparseMatrix base class.
Constraint on the data type.
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatSMatSubExpr.h:164
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatSMatSubExpr.h:281
SubTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: SMatSMatSubExpr.h:161
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.
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: StorageOrder.h:161
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:109
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.
Header file for the IsLower type trait.
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:108
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
LeftOperand lhs_
Left-hand side sparse matrix of the subtraction expression.
Definition: SMatSMatSubExpr.h:300
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.
Header file for the serial shim.
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: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
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.
Expression object for sparse matrix-sparse matrix subtractions.The SMatSMatSubExpr class represents t...
Definition: Forward.h:98
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
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: SMatSMatSubExpr.h:301
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:173
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatSMatSubExpr.h:228
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
Header file for the isDefault shim.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatSMatSubExpr.h:162
Constraint on the data type.
Header file for the RemoveReference type trait.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatSMatSubExpr.h:238
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatSMatSubExpr.h:259
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:937
Header file for the IsComputation type trait class.
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatSMatSubExpr.h:249
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.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
#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.
MT1::ReturnType RN1
ReturnType type of the left-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:110
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
#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
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatSMatSubExpr.h:176
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