All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TSMatTSMatSubExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TSMATTSMATSUBEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TSMATTSMATSUBEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
69 #include <blaze/util/Assert.h>
70 #include <blaze/util/DisableIf.h>
71 #include <blaze/util/EnableIf.h>
73 #include <blaze/util/mpl/Max.h>
74 #include <blaze/util/SelectType.h>
75 #include <blaze/util/Types.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS TSMATTSMATSUBEXPR
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
95 template< typename MT1 // Type of the left-hand side sparse matrix
96  , typename MT2 > // Type of the right-hand side sparse matrix
97 class TSMatTSMatSubExpr : public SparseMatrix< TSMatTSMatSubExpr<MT1,MT2>, true >
98  , private MatMatSubExpr
99  , private Computation
100 {
101  private:
102  //**Type definitions****************************************************************************
103  typedef typename MT1::ResultType RT1;
104  typedef typename MT2::ResultType RT2;
105  typedef typename MT1::ReturnType RN1;
106  typedef typename MT2::ReturnType RN2;
107  typedef typename MT1::CompositeType CT1;
108  typedef typename MT2::CompositeType CT2;
109  //**********************************************************************************************
110 
111  //**Return type evaluation**********************************************************************
113 
118  enum { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
119 
122  //**********************************************************************************************
123 
124  //**Serial evaluation strategy******************************************************************
126 
131  template< typename T1, typename T2, typename T3 >
132  struct UseSymmetricKernel {
135  };
137  //**********************************************************************************************
138 
139  //**Parallel evaluation strategy****************************************************************
141 
146  template< typename MT >
147  struct UseSMPAssign {
148  enum { value = MT::smpAssignable };
149  };
151  //**********************************************************************************************
152 
153  public:
154  //**Type definitions****************************************************************************
160 
163 
165  typedef const ResultType CompositeType;
166 
168  typedef typename SelectType< IsExpression<MT1>::value, const MT1, const MT1& >::Type LeftOperand;
169 
171  typedef typename SelectType< IsExpression<MT2>::value, const MT2, const MT2& >::Type RightOperand;
172  //**********************************************************************************************
173 
174  //**Compilation flags***************************************************************************
176  enum { smpAssignable = 0 };
177  //**********************************************************************************************
178 
179  //**Constructor*********************************************************************************
185  explicit inline TSMatTSMatSubExpr( const MT1& lhs, const MT2& rhs )
186  : lhs_( lhs ) // Left-hand side sparse matrix of the subtraction expression
187  , rhs_( rhs ) // Right-hand side sparse matrix of the subtraction expression
188  {
189  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
190  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
191  }
192  //**********************************************************************************************
193 
194  //**Access operator*****************************************************************************
201  inline ReturnType operator()( size_t i, size_t j ) const {
202  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
203  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
204  return lhs_(i,j) - rhs_(i,j);
205  }
206  //**********************************************************************************************
207 
208  //**Rows function*******************************************************************************
213  inline size_t rows() const {
214  return lhs_.rows();
215  }
216  //**********************************************************************************************
217 
218  //**Columns function****************************************************************************
223  inline size_t columns() const {
224  return lhs_.columns();
225  }
226  //**********************************************************************************************
227 
228  //**NonZeros function***************************************************************************
233  inline size_t nonZeros() const {
234  return lhs_.nonZeros() + rhs_.nonZeros();
235  }
236  //**********************************************************************************************
237 
238  //**NonZeros function***************************************************************************
244  inline size_t nonZeros( size_t i ) const {
245  return lhs_.nonZeros(i) + rhs_.nonZeros(i);
246  }
247  //**********************************************************************************************
248 
249  //**Left operand access*************************************************************************
254  inline LeftOperand leftOperand() const {
255  return lhs_;
256  }
257  //**********************************************************************************************
258 
259  //**Right operand access************************************************************************
264  inline RightOperand rightOperand() const {
265  return rhs_;
266  }
267  //**********************************************************************************************
268 
269  //**********************************************************************************************
275  template< typename T >
276  inline bool canAlias( const T* alias ) const {
277  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
278  }
279  //**********************************************************************************************
280 
281  //**********************************************************************************************
287  template< typename T >
288  inline bool isAliased( const T* alias ) const {
289  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
290  }
291  //**********************************************************************************************
292 
293  private:
294  //**Member variables****************************************************************************
297  //**********************************************************************************************
298 
299  //**Assignment to dense matrices****************************************************************
312  template< typename MT // Type of the target dense matrix
313  , bool SO > // Storage order of the target dense matrix
314  friend inline void assign( DenseMatrix<MT,SO>& lhs, const TSMatTSMatSubExpr& rhs )
315  {
317 
318  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
319  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
320 
321  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
322 
323  assign( ~lhs, rhs.lhs_ );
324 
326  subAssign( ~lhs, rhs.rhs_ );
327  }
328  else
329  {
330  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
331 
332  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
333  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
334  BLAZE_INTERNAL_ASSERT( B.rows() == (~lhs).rows() , "Invalid number of rows" );
335  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
336 
337  for( size_t j=0UL; j<(~lhs).columns(); ++j ) {
338  const RightIterator end( B.end(j) );
339  for( RightIterator element=B.begin(j); element!=end; ++element ) {
340  if( isDefault( (~lhs)(element->index(),j) ) )
341  (~lhs)(element->index(),j) = -element->value();
342  else
343  (~lhs)(element->index(),j) -= element->value();
344  }
345  }
346  }
347  }
349  //**********************************************************************************************
350 
351  //**Assignment to row-major sparse matrices*****************************************************
364  template< typename MT > // Type of the target sparse matrix
365  friend inline typename DisableIf< UseSymmetricKernel<MT,MT1,MT2> >::Type
367  {
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  const size_t m( rhs.rows() );
389  const size_t n( rhs.columns() );
390 
391  // Counting the number of elements per column
392  std::vector<size_t> nonzeros( m, 0UL );
393  for( size_t j=0UL; j<n; ++j )
394  {
395  const LeftIterator lend( A.end(j) );
396  const RightIterator rend( B.end(j) );
397 
398  LeftIterator l( A.begin(j) );
399  RightIterator r( B.begin(j) );
400 
401  while( l != lend && r != rend )
402  {
403  if( l->index() < r->index() ) {
404  ++nonzeros[l->index()];
405  ++l;
406  }
407  else if( l->index() > r->index() ) {
408  ++nonzeros[r->index()];
409  ++r;
410  }
411  else {
412  ++nonzeros[l->index()];
413  ++l;
414  ++r;
415  }
416  }
417 
418  while( l != lend ) {
419  ++nonzeros[l->index()];
420  ++l;
421  }
422 
423  while( r != rend ) {
424  ++nonzeros[r->index()];
425  ++r;
426  }
427  }
428 
429  // Resizing the left-hand side sparse matrix
430  for( size_t i=0UL; i<m; ++i ) {
431  (~lhs).reserve( i, nonzeros[i] );
432  }
433 
434  // Performing the matrix subtraction
435  for( size_t j=0UL; j<n; ++j )
436  {
437  const LeftIterator lend( A.end(j) );
438  const RightIterator rend( B.end(j) );
439 
440  LeftIterator l( A.begin(j) );
441  RightIterator r( B.begin(j) );
442 
443  while( l != lend && r != rend )
444  {
445  if( l->index() < r->index() ) {
446  (~lhs).append( l->index(), j, l->value() );
447  ++l;
448  }
449  else if( l->index() > r->index() ) {
450  (~lhs).append( r->index(), j, -r->value() );
451  ++r;
452  }
453  else {
454  (~lhs).append( l->index(), j, l->value()-r->value() );
455  ++l;
456  ++r;
457  }
458  }
459 
460  while( l != lend ) {
461  (~lhs).append( l->index(), j, l->value() );
462  ++l;
463  }
464 
465  while( r != rend ) {
466  (~lhs).append( r->index(), j, -r->value() );
467  ++r;
468  }
469  }
470  }
472  //**********************************************************************************************
473 
474  //**Assignment to row-major sparse matrices*****************************************************
487  template< typename MT > // Type of the target sparse matrix
488  friend inline typename EnableIf< UseSymmetricKernel<MT,MT1,MT2> >::Type
489  assign( SparseMatrix<MT,false>& lhs, const TSMatTSMatSubExpr& rhs )
490  {
492 
494 
495  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
496  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
497 
498  assign( ~lhs, trans( rhs.lhs_ ) - trans( rhs.rhs_ ) );
499  }
501  //**********************************************************************************************
502 
503  //**Assignment to column-major sparse matrices**************************************************
516  template< typename MT > // Type of the target sparse matrix
517  friend inline void assign( SparseMatrix<MT,true>& lhs, const TSMatTSMatSubExpr& rhs )
518  {
520 
521  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
522  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
523 
524  typedef typename RemoveReference<CT1>::Type::ConstIterator LeftIterator;
525  typedef typename RemoveReference<CT2>::Type::ConstIterator RightIterator;
526 
527  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side sparse matrix operand
528  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
529 
530  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
531  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
532  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
533  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
534  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
535  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
536 
537  // Final memory allocation (based on the evaluated operands)
538  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
539 
540  // Performing the matrix subtraction
541  for( size_t j=0UL; j<(~lhs).columns(); ++j )
542  {
543  const LeftIterator lend( A.end(j) );
544  const RightIterator rend( B.end(j) );
545 
546  LeftIterator l( A.begin(j) );
547  RightIterator r( B.begin(j) );
548 
549  while( l != lend && r != rend )
550  {
551  if( l->index() < r->index() ) {
552  (~lhs).append( l->index(), j, l->value() );
553  ++l;
554  }
555  else if( l->index() > r->index() ) {
556  (~lhs).append( r->index(), j, -r->value() );
557  ++r;
558  }
559  else {
560  (~lhs).append( l->index(), j, l->value()-r->value() );
561  ++l;
562  ++r;
563  }
564  }
565 
566  while( l != lend ) {
567  (~lhs).append( l->index(), j, l->value() );
568  ++l;
569  }
570 
571  while( r != rend ) {
572  (~lhs).append( r->index(), j, -r->value() );
573  ++r;
574  }
575 
576  (~lhs).finalize( j );
577  }
578  }
580  //**********************************************************************************************
581 
582  //**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 TSMatTSMatSubExpr& 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****************************************************
627  template< typename MT // Type of the target dense matrix
628  , bool SO > // Storage order of the target dense matrix
629  friend inline void subAssign( DenseMatrix<MT,SO>& lhs, const TSMatTSMatSubExpr& rhs )
630  {
632 
633  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
634  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
635 
636  subAssign( ~lhs, rhs.lhs_ );
637  addAssign( ~lhs, rhs.rhs_ );
638  }
640  //**********************************************************************************************
641 
642  //**Subtraction assignment to sparse matrices***************************************************
643  // No special implementation for the subtraction assignment to sparse matrices.
644  //**********************************************************************************************
645 
646  //**Multiplication assignment to dense matrices*************************************************
647  // No special implementation for the multiplication assignment to dense matrices.
648  //**********************************************************************************************
649 
650  //**Multiplication assignment to sparse matrices************************************************
651  // No special implementation for the multiplication assignment to sparse matrices.
652  //**********************************************************************************************
653 
654  //**SMP assignment to dense matrices************************************************************
655  // No special implementation for the SMP assignment to dense matrices.
656  //**********************************************************************************************
657 
658  //**SMP assignment to sparse matrices***********************************************************
659  // No special implementation for the SMP assignment to sparse matrices.
660  //**********************************************************************************************
661 
662  //**SMP addition assignment to dense matrices***************************************************
677  template< typename MT // Type of the target dense matrix
678  , bool SO > // Storage order of the target dense matrix
679  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
680  smpAddAssign( DenseMatrix<MT,SO>& lhs, const TSMatTSMatSubExpr& rhs )
681  {
683 
684  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
685  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
686 
687  smpAddAssign( ~lhs, rhs.lhs_ );
688  smpSubAssign( ~lhs, rhs.rhs_ );
689  }
691  //**********************************************************************************************
692 
693  //**SMP addition assignment to sparse matrices**************************************************
694  // No special implementation for the SMP addition assignment to sparse matrices.
695  //**********************************************************************************************
696 
697  //**SMP subtraction assignment to dense matrices************************************************
712  template< typename MT // Type of the target dense matrix
713  , bool SO > // Storage order of the target dense matrix
714  friend inline typename EnableIf< UseSMPAssign<MT> >::Type
715  smpSubAssign( DenseMatrix<MT,SO>& lhs, const TSMatTSMatSubExpr& rhs )
716  {
718 
719  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
720  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
721 
722  smpSubAssign( ~lhs, rhs.lhs_ );
723  smpAddAssign( ~lhs, rhs.rhs_ );
724  }
726  //**********************************************************************************************
727 
728  //**SMP subtraction assignment to sparse matrices***********************************************
729  // No special implementation for the SMP subtraction assignment to sparse matrices.
730  //**********************************************************************************************
731 
732  //**SMP multiplication assignment to dense matrices*********************************************
733  // No special implementation for the SMP multiplication assignment to dense matrices.
734  //**********************************************************************************************
735 
736  //**SMP multiplication assignment to sparse matrices********************************************
737  // No special implementation for the SMP multiplication assignment to sparse matrices.
738  //**********************************************************************************************
739 
740  //**Compile time checks*************************************************************************
748  //**********************************************************************************************
749 };
750 //*************************************************************************************************
751 
752 
753 
754 
755 //=================================================================================================
756 //
757 // GLOBAL BINARY ARITHMETIC OPERATORS
758 //
759 //=================================================================================================
760 
761 //*************************************************************************************************
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 TSMatTSMatSubExpr<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 TSMatTSMatSubExpr<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< TSMatTSMatSubExpr<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< TSMatTSMatSubExpr<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< TSMatTSMatSubExpr<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< TSMatTSMatSubExpr<MT1,MT2> >
869  : public IsTrue< IsLower<MT1>::value && IsLower<MT2>::value >
870 {};
872 //*************************************************************************************************
873 
874 
875 
876 
877 //=================================================================================================
878 //
879 // ISUPPER SPECIALIZATIONS
880 //
881 //=================================================================================================
882 
883 //*************************************************************************************************
885 template< typename MT1, typename MT2 >
886 struct IsUpper< TSMatTSMatSubExpr<MT1,MT2> >
887  : public IsTrue< IsUpper<MT1>::value && IsUpper<MT2>::value >
888 {};
890 //*************************************************************************************************
891 
892 
893 
894 
895 //=================================================================================================
896 //
897 // EXPRESSION TRAIT SPECIALIZATIONS
898 //
899 //=================================================================================================
900 
901 //*************************************************************************************************
903 template< typename MT1, typename MT2, bool AF >
904 struct SubmatrixExprTrait< TSMatTSMatSubExpr<MT1,MT2>, AF >
905 {
906  public:
907  //**********************************************************************************************
908  typedef typename SubExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
909  , typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
910  //**********************************************************************************************
911 };
913 //*************************************************************************************************
914 
915 
916 //*************************************************************************************************
918 template< typename MT1, typename MT2 >
919 struct RowExprTrait< TSMatTSMatSubExpr<MT1,MT2> >
920 {
921  public:
922  //**********************************************************************************************
923  typedef typename SubExprTrait< typename RowExprTrait<const MT1>::Type
924  , typename RowExprTrait<const MT2>::Type >::Type Type;
925  //**********************************************************************************************
926 };
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
933 template< typename MT1, typename MT2 >
934 struct ColumnExprTrait< TSMatTSMatSubExpr<MT1,MT2> >
935 {
936  public:
937  //**********************************************************************************************
938  typedef typename SubExprTrait< typename ColumnExprTrait<const MT1>::Type
939  , typename ColumnExprTrait<const MT2>::Type >::Type Type;
940  //**********************************************************************************************
941 };
943 //*************************************************************************************************
944 
945 } // namespace blaze
946 
947 #endif
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
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: TSMatTSMatSubExpr.h:288
Header file for the Rows type trait.
Header file for the subtraction trait.
LeftOperand leftOperand() const
Returns the left-hand side transpose sparse matrix operand.
Definition: TSMatTSMatSubExpr.h:254
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
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TSMatTSMatSubExpr.h:157
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
Header file for the ColumnExprTrait class template.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: TSMatTSMatSubExpr.h:233
MT1::CompositeType CT1
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:107
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
MT1::ReturnType RN1
Return type of the left-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:105
SubTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: TSMatTSMatSubExpr.h:156
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
Header file for the Computation base class.
TSMatTSMatSubExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the TSMatTSMatSubExpr class.
Definition: TSMatTSMatSubExpr.h:185
Header file for the RequiresEvaluation 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
ResultType::ElementType ElementType
Resulting element type.
Definition: TSMatTSMatSubExpr.h:159
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.
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: TSMatTSMatSubExpr.h:296
TSMatTSMatSubExpr< MT1, MT2 > This
Type of this TSMatTSMatSubExpr instance.
Definition: TSMatTSMatSubExpr.h:155
Header file for the IsSymmetric type trait.
RightOperand rightOperand() const
Returns the right-hand side transpose sparse matrix operand.
Definition: TSMatTSMatSubExpr.h:264
#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 SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: TSMatTSMatSubExpr.h:162
MT2::ResultType RT2
Result type of the right-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:104
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
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.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: TSMatTSMatSubExpr.h:223
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: TSMatTSMatSubExpr.h:244
Header file for the IsLower type trait.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: TSMatTSMatSubExpr.h:158
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.
Header file for the EnableIf class template.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: TSMatTSMatSubExpr.h:276
Header file for the serial shim.
MT2::CompositeType CT2
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:108
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
const ResultType CompositeType
Data type for composite expression templates.
Definition: TSMatTSMatSubExpr.h:165
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:2477
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
MT1::ResultType RT1
Result type of the left-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:103
Header file for run time assertion macros.
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:168
Expression object for transpose sparse matrix-transpose sparse matrix subtractions.The TSMatTSMatSubExpr class represents the compile time expression for subtractions between two column-major sparse matrices.
Definition: Forward.h:146
SubExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: TSMatTSMatSubExpr.h:121
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
size_t rows() const
Returns the current number of rows of the matrix.
Definition: TSMatTSMatSubExpr.h:213
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:171
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 DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
Header file for the IsComputation type trait class.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TSMatTSMatSubExpr.h:201
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:2473
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
Header file for basic type definitions.
MT2::ReturnType RN2
Return type of the right-hand side sparse matrix expression.
Definition: TSMatTSMatSubExpr.h:106
#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:142
Header file for the IsUpper type trait.
LeftOperand lhs_
Left-hand side sparse matrix of the subtraction expression.
Definition: TSMatTSMatSubExpr.h:295
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
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