SMatTSMatAddExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATTSMATADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATTSMATADDEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
76 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/mpl/And.h>
82 #include <blaze/util/mpl/If.h>
83 #include <blaze/util/mpl/Max.h>
84 #include <blaze/util/mpl/Or.h>
85 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS SMATTSMATADDEXPR
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
104 template< typename MT1 // Type of the left-hand side sparse matrix
105  , typename MT2 > // Type of the right-hand side sparse matrix
106 class SMatTSMatAddExpr : public SparseMatrix< SMatTSMatAddExpr<MT1,MT2>, false >
107  , private MatMatAddExpr
108  , private Computation
109 {
110  private:
111  //**Type definitions****************************************************************************
118  //**********************************************************************************************
119 
120  //**Return type evaluation**********************************************************************
122 
127  enum : bool { returnExpr = !IsTemporary<RN1>::value && !IsTemporary<RN2>::value };
128 
131  //**********************************************************************************************
132 
133  //**Serial evaluation strategy******************************************************************
135 
141  template< typename T1, typename T2 >
142  struct UseSymmetricKernel {
144  enum : bool { value = IsSymmetric<T2>::value };
145  };
147  //**********************************************************************************************
148 
149  //**Parallel evaluation strategy****************************************************************
151 
156  template< typename MT >
157  struct UseSMPAssign {
158  enum : bool { value = MT::smpAssignable };
159  };
161  //**********************************************************************************************
162 
163  public:
164  //**Type definitions****************************************************************************
170 
173 
175  typedef const ResultType CompositeType;
176 
178  typedef If_< IsExpression<MT1>, const MT1, const MT1& > LeftOperand;
179 
181  typedef If_< IsExpression<MT2>, const MT2, const MT2& > RightOperand;
182  //**********************************************************************************************
183 
184  //**Compilation flags***************************************************************************
186  enum : bool { smpAssignable = false };
187  //**********************************************************************************************
188 
189  //**Constructor*********************************************************************************
195  explicit inline SMatTSMatAddExpr( const MT1& lhs, const MT2& rhs ) noexcept
196  : lhs_( lhs ) // Left-hand side sparse matrix of the addition expression
197  , rhs_( rhs ) // Right-hand side sparse matrix of the addition expression
198  {
199  BLAZE_INTERNAL_ASSERT( lhs.rows() == rhs.rows() , "Invalid number of rows" );
200  BLAZE_INTERNAL_ASSERT( lhs.columns() == rhs.columns(), "Invalid number of columns" );
201  }
202  //**********************************************************************************************
203 
204  //**Access operator*****************************************************************************
211  inline ReturnType operator()( size_t i, size_t j ) const {
212  BLAZE_INTERNAL_ASSERT( i < lhs_.rows() , "Invalid row access index" );
213  BLAZE_INTERNAL_ASSERT( j < lhs_.columns(), "Invalid column access index" );
214  return lhs_(i,j) + rhs_(i,j);
215  }
216  //**********************************************************************************************
217 
218  //**At function*********************************************************************************
226  inline ReturnType at( size_t i, size_t j ) const {
227  if( i >= lhs_.rows() ) {
228  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
229  }
230  if( j >= lhs_.columns() ) {
231  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
232  }
233  return (*this)(i,j);
234  }
235  //**********************************************************************************************
236 
237  //**Rows function*******************************************************************************
242  inline size_t rows() const noexcept {
243  return lhs_.rows();
244  }
245  //**********************************************************************************************
246 
247  //**Columns function****************************************************************************
252  inline size_t columns() const noexcept {
253  return lhs_.columns();
254  }
255  //**********************************************************************************************
256 
257  //**NonZeros function***************************************************************************
262  inline size_t nonZeros() const {
263  return lhs_.nonZeros() + rhs_.nonZeros();
264  }
265  //**********************************************************************************************
266 
267  //**NonZeros function***************************************************************************
273  inline size_t nonZeros( size_t i ) const {
274  return lhs_.nonZeros(i) + rhs_.nonZeros(i);
275  }
276  //**********************************************************************************************
277 
278  //**Left operand access*************************************************************************
283  inline LeftOperand leftOperand() const noexcept {
284  return lhs_;
285  }
286  //**********************************************************************************************
287 
288  //**Right operand access************************************************************************
293  inline RightOperand rightOperand() const noexcept {
294  return rhs_;
295  }
296  //**********************************************************************************************
297 
298  //**********************************************************************************************
304  template< typename T >
305  inline bool canAlias( const T* alias ) const noexcept {
306  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
307  }
308  //**********************************************************************************************
309 
310  //**********************************************************************************************
316  template< typename T >
317  inline bool isAliased( const T* alias ) const noexcept {
318  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
319  }
320  //**********************************************************************************************
321 
322  private:
323  //**Member variables****************************************************************************
324  LeftOperand lhs_;
325  RightOperand rhs_;
326  //**********************************************************************************************
327 
328  //**Assignment to dense matrices****************************************************************
340  template< typename MT // Type of the target dense matrix
341  , bool SO > // Storage order of the target dense matrix
342  friend inline void assign( DenseMatrix<MT,SO>& lhs, const SMatTSMatAddExpr& rhs )
343  {
345 
346  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
347  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
348 
349  typedef ConstIterator_< RemoveReference_<CT2> > RightIterator;
350 
351  assign( ~lhs, rhs.lhs_ );
352 
353  if( !IsResizable< ElementType_<MT> >::value ) {
354  addAssign( ~lhs, rhs.rhs_ );
355  }
356  else
357  {
358  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side sparse matrix operand
359 
360  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
361  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
362  BLAZE_INTERNAL_ASSERT( B.rows() == (~lhs).rows() , "Invalid number of rows" );
363  BLAZE_INTERNAL_ASSERT( B.columns() == (~lhs).columns() , "Invalid number of columns" );
364 
365  for( size_t j=0UL; j<(~lhs).columns(); ++j ) {
366  const RightIterator end( B.end(j) );
367  for( RightIterator element=B.begin(j); element!=end; ++element ) {
368  if( isDefault( (~lhs)(element->index(),j) ) )
369  (~lhs)(element->index(),j) = element->value();
370  else
371  (~lhs)(element->index(),j) += element->value();
372  }
373  }
374  }
375  }
377  //**********************************************************************************************
378 
379  //**Assignment to row-major sparse matrices*****************************************************
392  template< typename MT > // Type of the target sparse matrix
394  assign( SparseMatrix<MT,false>& lhs, const SMatTSMatAddExpr& rhs )
395  {
397 
398  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
399  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
400 
401  typedef ConstIterator_< RemoveReference_<CT1> > LeftIterator;
402  typedef ConstIterator_< OppositeType_<RT2> > RightIterator;
403 
404  // Evaluation of the left-hand side sparse matrix operand
405  CT1 A( serial( rhs.lhs_ ) );
406 
407  // Evaluation of the right-hand side sparse matrix operand
408  const OppositeType_<RT2> B( serial( rhs.rhs_ ) );
409 
410  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
411  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
412  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
413  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
414  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
415  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
416 
417  // Final memory allocation (based on the evaluated operands)
418  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
419 
420  // Performing the matrix addition
421  for( size_t i=0UL; i<(~lhs).rows(); ++i )
422  {
423  const LeftIterator lend( A.end(i) );
424  const RightIterator rend( B.end(i) );
425 
426  LeftIterator l( A.begin(i) );
427  RightIterator r( B.begin(i) );
428 
429  while( l != lend && r != rend )
430  {
431  if( l->index() < r->index() ) {
432  (~lhs).append( i, l->index(), l->value() );
433  ++l;
434  }
435  else if( l->index() > r->index() ) {
436  (~lhs).append( i, r->index(), r->value() );
437  ++r;
438  }
439  else {
440  (~lhs).append( i, l->index(), l->value()+r->value() );
441  ++l;
442  ++r;
443  }
444  }
445 
446  while( l != lend ) {
447  (~lhs).append( i, l->index(), l->value() );
448  ++l;
449  }
450 
451  while( r != rend ) {
452  (~lhs).append( i, r->index(), r->value() );
453  ++r;
454  }
455 
456  (~lhs).finalize( i );
457  }
458  }
460  //**********************************************************************************************
461 
462  //**Assignment to row-major sparse matrices*****************************************************
475  template< typename MT > // Type of the target sparse matrix
476  friend inline EnableIf_< UseSymmetricKernel<MT,MT2> >
477  assign( SparseMatrix<MT,false>& lhs, const SMatTSMatAddExpr& rhs )
478  {
480 
481  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
482  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
483 
484  assign( ~lhs, rhs.lhs_ + trans( rhs.rhs_ ) );
485  }
487  //**********************************************************************************************
488 
489  //**Assignment to column-major sparse matrices**************************************************
502  template< typename MT > // Type of the target sparse matrix
503  friend inline DisableIf_< UseSymmetricKernel<MT,MT1> >
504  assign( SparseMatrix<MT,true>& lhs, const SMatTSMatAddExpr& rhs )
505  {
507 
509 
510  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
511  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
512 
513  typedef ConstIterator_< OppositeType_<RT1> > LeftIterator;
514  typedef ConstIterator_< RemoveReference_<CT2> > RightIterator;
515 
516  // Evaluation of the left-hand side sparse matrix operand
517  const OppositeType_<RT1> A( serial( rhs.lhs_ ) );
518 
519  // Evaluation of the right-hand side sparse matrix operand
520  CT2 B( serial( rhs.rhs_ ) );
521 
522  BLAZE_INTERNAL_ASSERT( A.rows() == rhs.lhs_.rows() , "Invalid number of rows" );
523  BLAZE_INTERNAL_ASSERT( A.columns() == rhs.lhs_.columns(), "Invalid number of columns" );
524  BLAZE_INTERNAL_ASSERT( B.rows() == rhs.rhs_.rows() , "Invalid number of rows" );
525  BLAZE_INTERNAL_ASSERT( B.columns() == rhs.rhs_.columns(), "Invalid number of columns" );
526  BLAZE_INTERNAL_ASSERT( A.rows() == (~lhs).rows() , "Invalid number of rows" );
527  BLAZE_INTERNAL_ASSERT( A.columns() == (~lhs).columns() , "Invalid number of columns" );
528 
529  // Final memory allocation (based on the evaluated operands)
530  (~lhs).reserve( A.nonZeros() + B.nonZeros() );
531 
532  // Performing the matrix addition
533  for( size_t j=0UL; j<(~lhs).columns(); ++j )
534  {
535  const LeftIterator lend( A.end(j) );
536  const RightIterator rend( B.end(j) );
537 
538  LeftIterator l( A.begin(j) );
539  RightIterator r( B.begin(j) );
540 
541  while( l != lend && r != rend )
542  {
543  if( l->index() < r->index() ) {
544  (~lhs).append( l->index(), j, l->value() );
545  ++l;
546  }
547  else if( l->index() > r->index() ) {
548  (~lhs).append( r->index(), j, r->value() );
549  ++r;
550  }
551  else {
552  (~lhs).append( l->index(), j, l->value()+r->value() );
553  ++l;
554  ++r;
555  }
556  }
557 
558  while( l != lend ) {
559  (~lhs).append( l->index(), j, l->value() );
560  ++l;
561  }
562 
563  while( r != rend ) {
564  (~lhs).append( r->index(), j, r->value() );
565  ++r;
566  }
567 
568  (~lhs).finalize( j );
569  }
570  }
572  //**********************************************************************************************
573 
574  //**Assignment to column-major sparse matrices**************************************************
587  template< typename MT > // Type of the target sparse matrix
588  friend inline EnableIf_< UseSymmetricKernel<MT,MT1> >
589  assign( SparseMatrix<MT,true>& lhs, const SMatTSMatAddExpr& rhs )
590  {
592 
594 
595  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
596  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
597 
598  assign( ~lhs, trans( rhs.lhs_ ) + rhs.rhs_ );
599  }
601  //**********************************************************************************************
602 
603  //**Addition assignment to dense matrices*******************************************************
616  template< typename MT // Type of the target dense matrix
617  , bool SO > // Storage order of the target dense matrix
618  friend inline void addAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatAddExpr& rhs )
619  {
621 
622  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
623  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
624 
625  addAssign( ~lhs, rhs.lhs_ );
626  addAssign( ~lhs, rhs.rhs_ );
627  }
629  //**********************************************************************************************
630 
631  //**Addition assignment to sparse matrices******************************************************
632  // No special implementation for the addition assignment to sparse matrices.
633  //**********************************************************************************************
634 
635  //**Subtraction assignment to dense matrices****************************************************
648  template< typename MT // Type of the target dense matrix
649  , bool SO > // Storage order of the target dense matrix
650  friend inline void subAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatAddExpr& rhs )
651  {
653 
654  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
655  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
656 
657  subAssign( ~lhs, rhs.lhs_ );
658  subAssign( ~lhs, rhs.rhs_ );
659  }
661  //**********************************************************************************************
662 
663  //**Subtraction assignment to sparse matrices***************************************************
664  // No special implementation for the subtraction assignment to sparse matrices.
665  //**********************************************************************************************
666 
667  //**Multiplication assignment to dense matrices*************************************************
668  // No special implementation for the multiplication assignment to dense matrices.
669  //**********************************************************************************************
670 
671  //**Multiplication assignment to sparse matrices************************************************
672  // No special implementation for the multiplication assignment to sparse matrices.
673  //**********************************************************************************************
674 
675  //**SMP assignment to dense matrices************************************************************
676  // No special implementation for the SMP assignment to dense matrices.
677  //**********************************************************************************************
678 
679  //**SMP assignment to sparse matrices***********************************************************
680  // No special implementation for the SMP assignment to sparse matrices.
681  //**********************************************************************************************
682 
683  //**SMP addition assignment to dense matrices***************************************************
698  template< typename MT // Type of the target dense matrix
699  , bool SO > // Storage order of the target dense matrix
700  friend inline EnableIf_< UseSMPAssign<MT> >
701  smpAddAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatAddExpr& rhs )
702  {
704 
705  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
706  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
707 
708  smpAddAssign( ~lhs, rhs.lhs_ );
709  smpAddAssign( ~lhs, rhs.rhs_ );
710  }
712  //**********************************************************************************************
713 
714  //**SMP addition assignment to sparse matrices**************************************************
715  // No special implementation for the SMP addition assignment to sparse matrices.
716  //**********************************************************************************************
717 
718  //**SMP subtraction assignment to dense matrices************************************************
733  template< typename MT // Type of the target dense matrix
734  , bool SO > // Storage order of the target dense matrix
735  friend inline EnableIf_< UseSMPAssign<MT> >
736  smpSubAssign( DenseMatrix<MT,SO>& lhs, const SMatTSMatAddExpr& rhs )
737  {
739 
740  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
741  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
742 
743  smpSubAssign( ~lhs, rhs.lhs_ );
744  smpSubAssign( ~lhs, rhs.rhs_ );
745  }
747  //**********************************************************************************************
748 
749  //**SMP subtraction assignment to sparse matrices***********************************************
750  // No special implementation for the SMP subtraction assignment to sparse matrices.
751  //**********************************************************************************************
752 
753  //**SMP multiplication assignment to dense matrices*********************************************
754  // No special implementation for the SMP multiplication assignment to dense matrices.
755  //**********************************************************************************************
756 
757  //**SMP multiplication assignment to sparse matrices********************************************
758  // No special implementation for the SMP multiplication assignment to sparse matrices.
759  //**********************************************************************************************
760 
761  //**Compile time checks*************************************************************************
769  //**********************************************************************************************
770 };
771 //*************************************************************************************************
772 
773 
774 
775 
776 //=================================================================================================
777 //
778 // GLOBAL BINARY ARITHMETIC OPERATORS
779 //
780 //=================================================================================================
781 
782 //*************************************************************************************************
811 template< typename T1 // Type of the left-hand side sparse matrix
812  , typename T2 > // Type of the right-hand side sparse matrix
813 inline const SMatTSMatAddExpr<T1,T2>
815 {
817 
818  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
819  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
820  }
821 
822  return SMatTSMatAddExpr<T1,T2>( ~lhs, ~rhs );
823 }
824 //*************************************************************************************************
825 
826 
827 //*************************************************************************************************
856 template< typename T1 // Type of the left-hand side sparse matrix
857  , typename T2 > // Type of the right-hand side sparse matrix
858 inline const SMatTSMatAddExpr<T2,T1>
860 {
862 
863  if( (~lhs).rows() != (~rhs).rows() || (~lhs).columns() != (~rhs).columns() ) {
864  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
865  }
866 
867  return SMatTSMatAddExpr<T2,T1>( ~rhs, ~lhs );
868 }
869 //*************************************************************************************************
870 
871 
872 
873 
874 //=================================================================================================
875 //
876 // ROWS SPECIALIZATIONS
877 //
878 //=================================================================================================
879 
880 //*************************************************************************************************
882 template< typename MT1, typename MT2 >
883 struct Rows< SMatTSMatAddExpr<MT1,MT2> >
884  : public Max< Rows<MT1>, Rows<MT2> >
885 {};
887 //*************************************************************************************************
888 
889 
890 
891 
892 //=================================================================================================
893 //
894 // COLUMNS SPECIALIZATIONS
895 //
896 //=================================================================================================
897 
898 //*************************************************************************************************
900 template< typename MT1, typename MT2 >
901 struct Columns< SMatTSMatAddExpr<MT1,MT2> >
902  : public Max< Columns<MT1>, Columns<MT2> >
903 {};
905 //*************************************************************************************************
906 
907 
908 
909 
910 //=================================================================================================
911 //
912 // ISSYMMETRIC SPECIALIZATIONS
913 //
914 //=================================================================================================
915 
916 //*************************************************************************************************
918 template< typename MT1, typename MT2 >
919 struct IsSymmetric< SMatTSMatAddExpr<MT1,MT2> >
920  : public BoolConstant< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
921 {};
923 //*************************************************************************************************
924 
925 
926 
927 
928 //=================================================================================================
929 //
930 // ISHERMITIAN SPECIALIZATIONS
931 //
932 //=================================================================================================
933 
934 //*************************************************************************************************
936 template< typename MT1, typename MT2 >
937 struct IsHermitian< SMatTSMatAddExpr<MT1,MT2> >
938  : public BoolConstant< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
939 {};
941 //*************************************************************************************************
942 
943 
944 
945 
946 //=================================================================================================
947 //
948 // ISLOWER SPECIALIZATIONS
949 //
950 //=================================================================================================
951 
952 //*************************************************************************************************
954 template< typename MT1, typename MT2 >
955 struct IsLower< SMatTSMatAddExpr<MT1,MT2> >
956  : public BoolConstant< And< IsLower<MT1>, IsLower<MT2> >::value >
957 {};
959 //*************************************************************************************************
960 
961 
962 
963 
964 //=================================================================================================
965 //
966 // ISUNILOWER SPECIALIZATIONS
967 //
968 //=================================================================================================
969 
970 //*************************************************************************************************
972 template< typename MT1, typename MT2 >
973 struct IsUniLower< SMatTSMatAddExpr<MT1,MT2> >
974  : public BoolConstant< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
975  , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
976 {};
978 //*************************************************************************************************
979 
980 
981 
982 
983 //=================================================================================================
984 //
985 // ISSTRICTLYLOWER SPECIALIZATIONS
986 //
987 //=================================================================================================
988 
989 //*************************************************************************************************
991 template< typename MT1, typename MT2 >
992 struct IsStrictlyLower< SMatTSMatAddExpr<MT1,MT2> >
993  : public BoolConstant< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
994 {};
996 //*************************************************************************************************
997 
998 
999 
1000 
1001 //=================================================================================================
1002 //
1003 // ISUPPER SPECIALIZATIONS
1004 //
1005 //=================================================================================================
1006 
1007 //*************************************************************************************************
1009 template< typename MT1, typename MT2 >
1010 struct IsUpper< SMatTSMatAddExpr<MT1,MT2> >
1011  : public BoolConstant< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1012 {};
1014 //*************************************************************************************************
1015 
1016 
1017 
1018 
1019 //=================================================================================================
1020 //
1021 // ISUNIUPPER SPECIALIZATIONS
1022 //
1023 //=================================================================================================
1024 
1025 //*************************************************************************************************
1027 template< typename MT1, typename MT2 >
1028 struct IsUniUpper< SMatTSMatAddExpr<MT1,MT2> >
1029  : public BoolConstant< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1030  , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
1031 {};
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // ISSTRICTLYUPPER SPECIALIZATIONS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1046 template< typename MT1, typename MT2 >
1047 struct IsStrictlyUpper< SMatTSMatAddExpr<MT1,MT2> >
1048  : public BoolConstant< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1049 {};
1051 //*************************************************************************************************
1052 
1053 
1054 
1055 
1056 //=================================================================================================
1057 //
1058 // EXPRESSION TRAIT SPECIALIZATIONS
1059 //
1060 //=================================================================================================
1061 
1062 //*************************************************************************************************
1064 template< typename MT1, typename MT2, bool AF >
1065 struct SubmatrixExprTrait< SMatTSMatAddExpr<MT1,MT2>, AF >
1066 {
1067  public:
1068  //**********************************************************************************************
1069  using Type = AddExprTrait_< SubmatrixExprTrait_<const MT1,AF>
1070  , SubmatrixExprTrait_<const MT2,AF> >;
1071  //**********************************************************************************************
1072 };
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1079 template< typename MT1, typename MT2 >
1080 struct RowExprTrait< SMatTSMatAddExpr<MT1,MT2> >
1081 {
1082  public:
1083  //**********************************************************************************************
1084  using Type = AddExprTrait_< RowExprTrait_<const MT1>
1085  , RowExprTrait_<const MT2> >;
1086  //**********************************************************************************************
1087 };
1089 //*************************************************************************************************
1090 
1091 
1092 //*************************************************************************************************
1094 template< typename MT1, typename MT2 >
1095 struct ColumnExprTrait< SMatTSMatAddExpr<MT1,MT2> >
1096 {
1097  public:
1098  //**********************************************************************************************
1099  using Type = AddExprTrait_< ColumnExprTrait_<const MT1>
1100  , ColumnExprTrait_<const MT2> >;
1101  //**********************************************************************************************
1102 };
1104 //*************************************************************************************************
1105 
1106 } // namespace blaze
1107 
1108 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatTSMatAddExpr.h:305
Header file for auxiliary alias declarations.
Header file for the Max class template.
SMatTSMatAddExpr< MT1, MT2 > This
Type of this SMatTSMatAddExpr instance.
Definition: SMatTSMatAddExpr.h:165
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatTSMatAddExpr.h:283
Header file for basic type definitions.
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the serial shim.
Header file for the ColumnExprTrait class template.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatTSMatAddExpr.h:317
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
ResultType_< MT1 > RT1
Result type of the left-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:112
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the And class template.
Header file for the AddExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
Header file for the Computation base class.
Constraints on the storage order of matrix types.
Header file for the IsUniLower type trait.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatTSMatAddExpr.h:242
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > 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
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatTSMatAddExpr.h:226
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:109
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatTSMatAddExpr.h:273
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
LeftOperand lhs_
Left-hand side sparse matrix of the addition expression.
Definition: SMatTSMatAddExpr.h:324
If_< IsExpression< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:181
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
Header file for the SparseMatrix base class.
Constraint on the data type.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
ReturnType_< MT1 > RN1
Evaluation type of the left-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:114
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.
typename AddExprTrait< T1, T2 >::Type AddExprTrait_
Auxiliary alias declaration for the AddExprTrait class template.The AddExprTrait_ alias declaration p...
Definition: AddExprTrait.h:219
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatTSMatAddExpr.h:252
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatTSMatAddExpr.h:168
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
AddExprTrait_< RN1, RN2 > ExprReturnType
Expression return type for the subscript operator.
Definition: SMatTSMatAddExpr.h:130
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
Header file for the exception macros of the math module.
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:254
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatAddExpr.h:109
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SMatTSMatAddExpr.h:169
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
If_< IsExpression< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:178
#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:106
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatTSMatAddExpr.h:167
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatTSMatAddExpr.h:172
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: SMatTSMatAddExpr.h:175
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatTSMatAddExpr.h:211
#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:79
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
Header file for run time assertion macros.
ResultType_< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:113
Header file for the addition trait.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatTSMatAddExpr.h:262
CompositeType_< MT2 > CT2
Composite type of the right-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:117
AddTrait_< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: SMatTSMatAddExpr.h:166
Header file for the isDefault shim.
RightOperand rhs_
Right-hand side sparse matrix of the addition expression.
Definition: SMatTSMatAddExpr.h:325
Constraint on the data type.
Constraints on the storage order of matrix types.
Header file for the MatMatAddExpr base class.
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
Header file for the RemoveReference type trait.
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
Expression object for sparse matrix-transpose sparse matrix additions.The SMatTSMatAddExpr class repr...
Definition: Forward.h:106
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
SMatTSMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the SMatTSMatAddExpr class.
Definition: SMatTSMatAddExpr.h:195
CompositeType_< MT1 > CT1
Composite type of the left-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:116
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:950
Header file for the IsComputation type trait class.
#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
Header file for the IntegralConstant class template.
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose sparse matrix operand.
Definition: SMatTSMatAddExpr.h:293
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
#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:61
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
ReturnType_< MT2 > RN2
Evaluation type of the right-hand side sparse matrix expression.
Definition: SMatTSMatAddExpr.h:115