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 
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 TSMATSMATSUBEXPR
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 TSMatSMatSubExpr : public SparseMatrix< TSMatSMatSubExpr<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 
137  template< typename T1, typename T2 >
138  struct UseSymmetricKernel {
140  enum { value = IsSymmetric<T2>::value };
141  };
143  //**********************************************************************************************
144 
145  //**Parallel evaluation strategy****************************************************************
147 
152  template< typename MT >
153  struct UseSMPAssign {
154  enum { value = MT::smpAssignable };
155  };
157  //**********************************************************************************************
158 
159  public:
160  //**Type definitions****************************************************************************
166 
169 
171  typedef const ResultType CompositeType;
172 
174  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
175 
177  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
178  //**********************************************************************************************
179 
180  //**Compilation flags***************************************************************************
182  enum { smpAssignable = 0 };
183  //**********************************************************************************************
184 
185  //**Constructor*********************************************************************************
191  explicit inline TSMatSMatSubExpr( const MT1& lhs, const MT2& rhs )
192  : lhs_( lhs ) // Left-hand side sparse matrix of the subtraction expression
193  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
194  {
195  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
196  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
197  }
198  //**********************************************************************************************
199 
200  //**Access operator*****************************************************************************
207  inline ReturnType operator()( size_t i, size_t j ) const {
208  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
209  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
210  return lhs_(i,j) - rhs_(i,j);
211  }
212  //**********************************************************************************************
213 
214  //**Rows function*******************************************************************************
219  inline size_t rows() const {
220  return lhs_.rows();
221  }
222  //**********************************************************************************************
223 
224  //**Columns function****************************************************************************
229  inline size_t columns() const {
230  return lhs_.columns();
231  }
232  //**********************************************************************************************
233 
234  //**NonZeros function***************************************************************************
239  inline size_t nonZeros() const {
240  return lhs_.nonZeros() + rhs_.nonZeros();
241  }
242  //**********************************************************************************************
243 
244  //**NonZeros function***************************************************************************
250  inline size_t nonZeros( size_t i ) const {
251  return lhs_.nonZeros(i) + rhs_.nonZeros(i);
252  }
253  //**********************************************************************************************
254 
255  //**Left operand access*************************************************************************
260  inline LeftOperand leftOperand() const {
261  return lhs_;
262  }
263  //**********************************************************************************************
264 
265  //**Right operand access************************************************************************
270  inline RightOperand rightOperand() const {
271  return rhs_;
272  }
273  //**********************************************************************************************
274 
275  //**********************************************************************************************
281  template< typename T >
282  inline bool canAlias( const T* alias ) const {
283  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
284  }
285  //**********************************************************************************************
286 
287  //**********************************************************************************************
293  template< typename T >
294  inline bool isAliased( const T* alias ) const {
295  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
296  }
297  //**********************************************************************************************
298 
299  private:
300  //**Member variables****************************************************************************
301  LeftOperand lhs_;
302  RightOperand rhs_;
303  //**********************************************************************************************
304 
305  //**Assignment to dense matrices****************************************************************
317  template< typename MT // Type of the target dense matrix
318  , bool SO > // Storage order of the target dense matrix
319  friend inline void assign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
320  {
322 
323  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
324  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
325 
326  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
327 
328  assign( ~lhs, rhs.lhs_ );
329 
331  subAssign( ~lhs, rhs.rhs_ );
332  }
333  else
334  {
335  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
336 
337  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
338  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
339  BLAZE_INTERNAL_ASSERT( B.rows() == (~lhs).rows() , "Invalid number of rows" );
340  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
341 
342  for( size_t i=0UL; i<(~lhs).rows(); ++i ) {
343  const RightIterator end( B.end(i) );
344  for( RightIterator element=B.begin(i); element!=end; ++element ) {
345  if( isDefault( (~lhs)(i,element->index()) ) )
346  (~lhs)(i,element->index()) = -element->value();
347  else
348  (~lhs)(i,element->index()) -= element->value();
349  }
350  }
351  }
352  }
354  //**********************************************************************************************
355 
356  //**Assignment to row-major sparse matrices*****************************************************
369  template< typename MT > // Type of the target sparse matrix
370  friend inline typename DisableIf< UseSymmetricKernel<MT,MT1> >::Type
372  {
374 
375  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
376  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
377 
378  typedef typename RT1::OppositeType::ConstIterator LeftIterator;
379  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
380 
381  // Evaluation of the left-hand side sparse matrix operand
382  const typename RT1::OppositeType A( serial( rhs.lhs_ ) );
383 
384  // Evaluation of the right-hand side sparse matrix operand
385  CT2 B( serial( rhs.rhs_ ) );
386 
387  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
388  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
389  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
390  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
391  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
392  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
393 
394  // Final memory allocation (based on the evaluated operands)
395  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
396 
397  // Performing the matrix subtraction
398  for( size_t i=0UL; i<(~lhs).rows(); ++i )
399  {
400  const LeftIterator lend( A.end(i) );
401  const RightIterator rend( B.end(i) );
402 
403  LeftIterator l( A.begin(i) );
404  RightIterator r( B.begin(i) );
405 
406  while( l != lend && r != rend )
407  {
408  if( l->index() < r->index() ) {
409  (~lhs).append( i, l->index(), l->value() );
410  ++l;
411  }
412  else if( l->index() > r->index() ) {
413  (~lhs).append( i, r->index(), -r->value() );
414  ++r;
415  }
416  else {
417  (~lhs).append( i, l->index(), l->value()-r->value() );
418  ++l;
419  ++r;
420  }
421  }
422 
423  while( l != lend ) {
424  (~lhs).append( i, l->index(), l->value() );
425  ++l;
426  }
427 
428  while( r != rend ) {
429  (~lhs).append( i, r->index(), -r->value() );
430  ++r;
431  }
432 
433  (~lhs).finalize( i );
434  }
435  }
437  //**********************************************************************************************
438 
439  //**Assignment to row-major sparse matrices*****************************************************
452  template< typename MT > // Type of the target sparse matrix
453  friend inline typename EnableIf< UseSymmetricKernel<MT,MT1> >::Type
454  assign( SparseMatrix<MT,false>& lhs, const TSMatSMatSubExpr& rhs )
455  {
457 
458  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
459  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
460 
461  assign( ~lhs, trans( rhs.lhs_ ) - rhs.rhs_ );
462  }
464  //**********************************************************************************************
465 
466  //**Assignment to column-major sparse matrices**************************************************
479  template< typename MT > // Type of the target sparse matrix
480  friend inline typename DisableIf< UseSymmetricKernel<MT,MT2> >::Type
481  assign( SparseMatrix<MT,true>& lhs, const TSMatSMatSubExpr& rhs )
482  {
484 
486 
487  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
488  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
489 
490  typedef typename RemoveReference<CT1>::Type::ConstIterator LeftIterator;
491  typedef typename RT2::OppositeType::ConstIterator RightIterator;
492 
493  // Evaluation of the left-hand side sparse matrix operand
494  CT1 A( serial( rhs.lhs_ ) );
495 
496  // Evaluation of the right-hand side sparse matrix operand
497  const typename RT2::OppositeType B( serial( rhs.rhs_ ) );
498 
499  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
500  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
501  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
502  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
503  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
504  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
505 
506  // Final memory allocation (based on the evaluated operands)
507  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
508 
509  // Performing the matrix subtraction
510  for( size_t j=0UL; j<(~lhs).columns(); ++j )
511  {
512  const LeftIterator lend( A.end(j) );
513  const RightIterator rend( B.end(j) );
514 
515  LeftIterator l( A.begin(j) );
516  RightIterator r( B.begin(j) );
517 
518  while( l != lend && r != rend )
519  {
520  if( l->index() < r->index() ) {
521  (~lhs).append( l->index(), j, l->value() );
522  ++l;
523  }
524  else if( l->index() > r->index() ) {
525  (~lhs).append( r->index(), j, -r->value() );
526  ++r;
527  }
528  else {
529  (~lhs).append( l->index(), j, l->value()-r->value() );
530  ++l;
531  ++r;
532  }
533  }
534 
535  while( l != lend ) {
536  (~lhs).append( l->index(), j, l->value() );
537  ++l;
538  }
539 
540  while( r != rend ) {
541  (~lhs).append( r->index(), j, -r->value() );
542  ++r;
543  }
544 
545  (~lhs).finalize( j );
546  }
547  }
549  //**********************************************************************************************
550 
551  //**Assignment to column-major sparse matrices**************************************************
564  template< typename MT > // Type of the target sparse matrix
565  friend inline typename EnableIf< UseSymmetricKernel<MT,MT2> >::Type
566  assign( SparseMatrix<MT,true>& lhs, const TSMatSMatSubExpr& rhs )
567  {
569 
571 
572  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
573  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
574 
575  assign( ~lhs, rhs.lhs_ - trans( rhs.rhs_ ) );
576  }
578  //**********************************************************************************************
579 
580  //**Addition assignment to dense matrices*******************************************************
593  template< typename MT // Type of the target dense matrix
594  , bool SO > // Storage order of the target dense matrix
595  friend inline void addAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
596  {
598 
599  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
600  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
601 
602  addAssign( ~lhs, rhs.lhs_ );
603  subAssign( ~lhs, rhs.rhs_ );
604  }
606  //**********************************************************************************************
607 
608  //**Addition assignment to sparse matrices******************************************************
609  // No special implementation for the addition assignment to sparse matrices.
610  //**********************************************************************************************
611 
612  //**Subtraction assignment to dense matrices****************************************************
625  template< typename MT // Type of the target dense matrix
626  , bool SO > // Storage order of the target dense matrix
627  friend inline void subAssign( DenseMatrix<MT,SO>& lhs, const TSMatSMatSubExpr& rhs )
628  {
630 
631  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
632  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
633 
634  subAssign( ~lhs, rhs.lhs_ );
635  addAssign( ~lhs, rhs.rhs_ );
636  }
638  //**********************************************************************************************
639 
640  //**Subtraction assignment to sparse matrices***************************************************
641  // No special implementation for the subtraction assignment to sparse matrices.
642  //**********************************************************************************************
643 
644  //**Multiplication assignment to dense matrices*************************************************
645  // No special implementation for the multiplication assignment to dense matrices.
646  //**********************************************************************************************
647 
648  //**Multiplication assignment to sparse matrices************************************************
649  // No special implementation for the multiplication assignment to sparse matrices.
650  //**********************************************************************************************
651 
652  //**SMP assignment to dense matrices************************************************************
653  // No special implementation for the SMP assignment to dense matrices.
654  //**********************************************************************************************
655 
656  //**SMP assignment to sparse matrices***********************************************************
657  // No special implementation for the SMP assignment to sparse matrices.
658  //**********************************************************************************************
659 
660  //**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 TSMatSMatSubExpr& 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 TSMatSMatSubExpr& 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 //*************************************************************************************************
788 template< typename T1 // Type of the left-hand side sparse matrix
789  , typename T2 > // Type of the right-hand side sparse matrix
790 inline const TSMatSMatSubExpr<T1,T2>
792 {
794 
795  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() )
796  throw std::invalid_argument( "Matrix sizes do not match" );
797 
798  return TSMatSMatSubExpr<T1,T2>( ~lhs, ~rhs );
799 }
800 //*************************************************************************************************
801 
802 
803 
804 
805 //=================================================================================================
806 //
807 // ROWS SPECIALIZATIONS
808 //
809 //=================================================================================================
810 
811 //*************************************************************************************************
813 template< typename MT1, typename MT2 >
814 struct Rows< TSMatSMatSubExpr<MT1,MT2> >
815  : public Max< Rows<MT1>, Rows<MT2> >::Type
816 {};
818 //*************************************************************************************************
819 
820 
821 
822 
823 //=================================================================================================
824 //
825 // COLUMNS SPECIALIZATIONS
826 //
827 //=================================================================================================
828 
829 //*************************************************************************************************
831 template< typename MT1, typename MT2 >
832 struct Columns< TSMatSMatSubExpr<MT1,MT2> >
833  : public Max< Columns<MT1>, Columns<MT2> >::Type
834 {};
836 //*************************************************************************************************
837 
838 
839 
840 
841 //=================================================================================================
842 //
843 // ISSYMMETRIC SPECIALIZATIONS
844 //
845 //=================================================================================================
846 
847 //*************************************************************************************************
849 template< typename MT1, typename MT2 >
850 struct IsSymmetric< TSMatSMatSubExpr<MT1,MT2> >
851  : public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
852 {};
854 //*************************************************************************************************
855 
856 
857 
858 
859 //=================================================================================================
860 //
861 // ISLOWER SPECIALIZATIONS
862 //
863 //=================================================================================================
864 
865 //*************************************************************************************************
867 template< typename MT1, typename MT2 >
868 struct IsLower< TSMatSMatSubExpr<MT1,MT2> >
869  : public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
870 {};
872 //*************************************************************************************************
873 
874 
875 
876 
877 //=================================================================================================
878 //
879 // ISUNILOWER SPECIALIZATIONS
880 //
881 //=================================================================================================
882 
883 //*************************************************************************************************
885 template< typename MT1, typename MT2 >
886 struct IsUniLower< TSMatSMatSubExpr<MT1,MT2> >
887  : public IsTrue< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >::value >
888 {};
890 //*************************************************************************************************
891 
892 
893 
894 
895 //=================================================================================================
896 //
897 // ISSTRICTLYLOWER SPECIALIZATIONS
898 //
899 //=================================================================================================
900 
901 //*************************************************************************************************
903 template< typename MT1, typename MT2 >
904 struct IsStrictlyLower< TSMatSMatSubExpr<MT1,MT2> >
905  : public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
906 {};
908 //*************************************************************************************************
909 
910 
911 
912 
913 //=================================================================================================
914 //
915 // ISUPPER SPECIALIZATIONS
916 //
917 //=================================================================================================
918 
919 //*************************************************************************************************
921 template< typename MT1, typename MT2 >
922 struct IsUpper< TSMatSMatSubExpr<MT1,MT2> >
923  : public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
924 {};
926 //*************************************************************************************************
927 
928 
929 
930 
931 //=================================================================================================
932 //
933 // ISUNIUPPER SPECIALIZATIONS
934 //
935 //=================================================================================================
936 
937 //*************************************************************************************************
939 template< typename MT1, typename MT2 >
940 struct IsUniUpper< TSMatSMatSubExpr<MT1,MT2> >
941  : public IsTrue< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >::value >
942 {};
944 //*************************************************************************************************
945 
946 
947 
948 
949 //=================================================================================================
950 //
951 // ISSTRICTLYUPPER SPECIALIZATIONS
952 //
953 //=================================================================================================
954 
955 //*************************************************************************************************
957 template< typename MT1, typename MT2 >
958 struct IsStrictlyUpper< TSMatSMatSubExpr<MT1,MT2> >
959  : public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
960 {};
962 //*************************************************************************************************
963 
964 
965 
966 
967 //=================================================================================================
968 //
969 // EXPRESSION TRAIT SPECIALIZATIONS
970 //
971 //=================================================================================================
972 
973 //*************************************************************************************************
975 template< typename MT1, typename MT2, bool AF >
976 struct SubmatrixExprTrait< TSMatSMatSubExpr<MT1,MT2>, AF >
977 {
978  public:
979  //**********************************************************************************************
980  typedef typename SubExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
981  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
982  //**********************************************************************************************
983 };
985 //*************************************************************************************************
986 
987 
988 //*************************************************************************************************
990 template< typename MT1, typename MT2 >
991 struct RowExprTrait< TSMatSMatSubExpr<MT1,MT2> >
992 {
993  public:
994  //**********************************************************************************************
995  typedef typename SubExprTrait< typename RowExprTrait<const MT1>::Type
996  , typename RowExprTrait<const MT2>::Type >::Type Type;
997  //**********************************************************************************************
998 };
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1005 template< typename MT1, typename MT2 >
1006 struct ColumnExprTrait< TSMatSMatSubExpr<MT1,MT2> >
1007 {
1008  public:
1009  //**********************************************************************************************
1010  typedef typename SubExprTrait< typename ColumnExprTrait<const MT1>::Type
1011  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
1012  //**********************************************************************************************
1013 };
1015 //*************************************************************************************************
1016 
1017 } // namespace blaze
1018 
1019 #endif
Constraint on the data type.
TSMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the TSMatSMatSubExpr class.
Definition: TSMatSMatSubExpr.h:191
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:258
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:112
size_t rows() const
Returns the current number of rows of the matrix.
Definition: TSMatSMatSubExpr.h:219
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: TSMatSMatSubExpr.h:239
Header file for the ColumnExprTrait class template.
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
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: TSMatSMatSubExpr.h:250
SubTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatSMatSubExpr.h:162
Header file for the And class template.
RightOperand rightOperand() const
Returns the right-hand side sparse matrix operand.
Definition: TSMatSMatSubExpr.h:270
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:113
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:174
Header file for the IsUniLower type trait.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2503
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.
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:108
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatSMatSubExpr.h:282
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
SubExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: TSMatSMatSubExpr.h:126
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.
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:109
MT1::ReturnType RN1
Return type of the left-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:110
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:171
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:325
size_t columns() const
Returns the current number of columns of the matrix.
Definition: TSMatSMatSubExpr.h:229
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.
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
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatSMatSubExpr.h:207
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatSMatSubExpr.h:260
Header file for the isDefault shim.
Constraint on the data type.
LeftOperand lhs_
Left-hand side sparse matrix of the subtraction expression.
Definition: TSMatSMatSubExpr.h:301
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:168
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatSMatSubExpr.h:163
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatSMatSubExpr.h:294
TSMatSMatSubExpr< MT1, MT2 > This
Type of this TSMatSMatSubExpr instance.
Definition: TSMatSMatSubExpr.h:161
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.
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:164
#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
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:177
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: TSMatSMatSubExpr.h:111
#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.
Expression object for transpose sparse matrix-sparse matrix subtractions.The TSMatSMatSubExpr class r...
Definition: Forward.h:141
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatSMatSubExpr.h:165
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:302
#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.
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