SMatScalarDivExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
79 #include <blaze/util/Assert.h>
84 #include <blaze/util/EnableIf.h>
86 #include <blaze/util/InvalidType.h>
88 #include <blaze/util/mpl/And.h>
89 #include <blaze/util/mpl/If.h>
90 #include <blaze/util/mpl/Or.h>
91 #include <blaze/util/Types.h>
94 
95 
96 namespace blaze {
97 
98 //=================================================================================================
99 //
100 // CLASS SMATSCALARDIVEXPR
101 //
102 //=================================================================================================
103 
104 //*************************************************************************************************
111 template< typename MT // Type of the left-hand side sparse matrix
112  , typename ST // Type of the right-hand side scalar value
113  , bool SO > // Storage order
114 class SMatScalarDivExpr : public SparseMatrix< SMatScalarDivExpr<MT,ST,SO>, SO >
115  , private MatScalarDivExpr
116  , private Computation
117 {
118  private:
119  //**Type definitions****************************************************************************
120  typedef ResultType_<MT> RT;
121  typedef ReturnType_<MT> RN;
123  //**********************************************************************************************
124 
125  //**Return type evaluation**********************************************************************
127 
132  enum : bool { returnExpr = !IsTemporary<RN>::value };
133 
136  //**********************************************************************************************
137 
138  //**Serial evaluation strategy******************************************************************
140 
146  enum : bool { useAssign = RequiresEvaluation<MT>::value };
147 
149  template< typename MT2 >
151  struct UseAssign {
152  enum : bool { value = useAssign };
153  };
155  //**********************************************************************************************
156 
157  //**Parallel evaluation strategy****************************************************************
159 
165  template< typename MT2 >
166  struct UseSMPAssign {
167  enum : bool { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
168  };
170  //**********************************************************************************************
171 
172  public:
173  //**Type definitions****************************************************************************
179 
182 
185 
187  typedef If_< IsExpression<MT>, const MT, const MT& > LeftOperand;
188 
190  typedef ST RightOperand;
191  //**********************************************************************************************
192 
193  //**ConstIterator class definition**************************************************************
197  {
198  public:
199  //**Type definitions*************************************************************************
202 
205 
206  typedef std::forward_iterator_tag IteratorCategory;
207  typedef Element ValueType;
208  typedef ValueType* PointerType;
209  typedef ValueType& ReferenceType;
211 
212  // STL iterator requirements
213  typedef IteratorCategory iterator_category;
214  typedef ValueType value_type;
215  typedef PointerType pointer;
216  typedef ReferenceType reference;
217  typedef DifferenceType difference_type;
218  //*******************************************************************************************
219 
220  //**Constructor******************************************************************************
223  inline ConstIterator( IteratorType matrix, RightOperand scalar )
224  : matrix_( matrix ) // Iterator over the elements of the left-hand side sparse matrix expression
225  , scalar_( scalar ) // Right-hand side scalar of the division expression
226  {}
227  //*******************************************************************************************
228 
229  //**Prefix increment operator****************************************************************
235  ++matrix_;
236  return *this;
237  }
238  //*******************************************************************************************
239 
240  //**Element access operator******************************************************************
245  inline const Element operator*() const {
246  return Element( matrix_->value() / scalar_, matrix_->index() );
247  }
248  //*******************************************************************************************
249 
250  //**Element access operator******************************************************************
255  inline const ConstIterator* operator->() const {
256  return this;
257  }
258  //*******************************************************************************************
259 
260  //**Value function***************************************************************************
265  inline ReturnType value() const {
266  return matrix_->value() / scalar_;
267  }
268  //*******************************************************************************************
269 
270  //**Index function***************************************************************************
275  inline size_t index() const {
276  return matrix_->index();
277  }
278  //*******************************************************************************************
279 
280  //**Equality operator************************************************************************
286  inline bool operator==( const ConstIterator& rhs ) const {
287  return matrix_ == rhs.matrix_;
288  }
289  //*******************************************************************************************
290 
291  //**Inequality operator**********************************************************************
297  inline bool operator!=( const ConstIterator& rhs ) const {
298  return matrix_ != rhs.matrix_;
299  }
300  //*******************************************************************************************
301 
302  //**Subtraction operator*********************************************************************
308  inline DifferenceType operator-( const ConstIterator& rhs ) const {
309  return matrix_ - rhs.matrix_;
310  }
311  //*******************************************************************************************
312 
313  private:
314  //**Member variables*************************************************************************
315  IteratorType matrix_;
316  RightOperand scalar_;
317  //*******************************************************************************************
318  };
319  //**********************************************************************************************
320 
321  //**Compilation flags***************************************************************************
323  enum : bool { smpAssignable = false };
324  //**********************************************************************************************
325 
326  //**Constructor*********************************************************************************
332  explicit inline SMatScalarDivExpr( const MT& matrix, ST scalar ) noexcept
333  : matrix_( matrix ) // Left-hand side sparse matrix of the division expression
334  , scalar_( scalar ) // Right-hand side scalar of the division expression
335  {}
336  //**********************************************************************************************
337 
338  //**Access operator*****************************************************************************
345  inline ReturnType operator()( size_t i, size_t j ) const {
346  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
347  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
348  return matrix_(i,j) / scalar_;
349  }
350  //**********************************************************************************************
351 
352  //**At function*********************************************************************************
360  inline ReturnType at( size_t i, size_t j ) const {
361  if( i >= matrix_.rows() ) {
362  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
363  }
364  if( j >= matrix_.columns() ) {
365  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
366  }
367  return (*this)(i,j);
368  }
369  //**********************************************************************************************
370 
371  //**Begin function******************************************************************************
377  inline ConstIterator begin( size_t i ) const {
378  return ConstIterator( matrix_.begin(i), scalar_ );
379  }
380  //**********************************************************************************************
381 
382  //**End function********************************************************************************
388  inline ConstIterator end( size_t i ) const {
389  return ConstIterator( matrix_.end(i), scalar_ );
390  }
391  //**********************************************************************************************
392 
393  //**Rows function*******************************************************************************
398  inline size_t rows() const noexcept {
399  return matrix_.rows();
400  }
401  //**********************************************************************************************
402 
403  //**Columns function****************************************************************************
408  inline size_t columns() const noexcept {
409  return matrix_.columns();
410  }
411  //**********************************************************************************************
412 
413  //**NonZeros function***************************************************************************
418  inline size_t nonZeros() const {
419  return matrix_.nonZeros();
420  }
421  //**********************************************************************************************
422 
423  //**NonZeros function***************************************************************************
429  inline size_t nonZeros( size_t i ) const {
430  return matrix_.nonZeros(i);
431  }
432  //**********************************************************************************************
433 
434  //**Find function*******************************************************************************
441  inline ConstIterator find( size_t i, size_t j ) const {
443  return ConstIterator( matrix_.find( i, j ), scalar_ );
444  }
445  //**********************************************************************************************
446 
447  //**LowerBound function*************************************************************************
454  inline ConstIterator lowerBound( size_t i, size_t j ) const {
456  return ConstIterator( matrix_.lowerBound( i, j ), scalar_ );
457  }
458  //**********************************************************************************************
459 
460  //**UpperBound function*************************************************************************
467  inline ConstIterator upperBound( size_t i, size_t j ) const {
469  return ConstIterator( matrix_.upperBound( i, j ), scalar_ );
470  }
471  //**********************************************************************************************
472 
473  //**Left operand access*************************************************************************
478  inline LeftOperand leftOperand() const noexcept {
479  return matrix_;
480  }
481  //**********************************************************************************************
482 
483  //**Right operand access************************************************************************
488  inline RightOperand rightOperand() const noexcept {
489  return scalar_;
490  }
491  //**********************************************************************************************
492 
493  //**********************************************************************************************
499  template< typename T >
500  inline bool canAlias( const T* alias ) const noexcept {
501  return matrix_.canAlias( alias );
502  }
503  //**********************************************************************************************
504 
505  //**********************************************************************************************
511  template< typename T >
512  inline bool isAliased( const T* alias ) const noexcept {
513  return matrix_.isAliased( alias );
514  }
515  //**********************************************************************************************
516 
517  private:
518  //**Member variables****************************************************************************
519  LeftOperand matrix_;
520  RightOperand scalar_;
521  //**********************************************************************************************
522 
523  //**Assignment to dense matrices****************************************************************
537  template< typename MT2 // Type of the target dense matrix
538  , bool SO2 > // Storage order of the target dense matrix
539  friend inline EnableIf_< UseAssign<MT2> >
540  assign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
541  {
543 
544  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
545  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
546 
547  assign( ~lhs, rhs.matrix_ );
548  (~lhs) /= rhs.scalar_;
549  }
551  //**********************************************************************************************
552 
553  //**Assignment to sparse matrices***************************************************************
567  template< typename MT2 // Type of the target sparse matrix
568  , bool SO2 > // Storage order of the target sparse matrix
569  friend inline EnableIf_< UseAssign<MT2> >
570  assign( SparseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
571  {
573 
574  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
575  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
576 
577  assign( ~lhs, rhs.matrix_ );
578  (~lhs) /= rhs.scalar_;
579  }
581  //**********************************************************************************************
582 
583  //**Addition assignment to dense matrices*******************************************************
597  template< typename MT2 // Type of the target dense matrix
598  , bool SO2 > // Storage order of the target dense matrix
599  friend inline EnableIf_< UseAssign<MT2> >
600  addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
601  {
603 
605  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
606 
607  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
608  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
609 
610  const ResultType tmp( serial( rhs ) );
611  addAssign( ~lhs, tmp );
612  }
614  //**********************************************************************************************
615 
616  //**Addition assignment to sparse matrices******************************************************
617  // No special implementation for the addition assignment to sparse matrices.
618  //**********************************************************************************************
619 
620  //**Subtraction assignment to dense matrices****************************************************
634  template< typename MT2 // Type of the target dense matrix
635  , bool SO2 > // Storage order of the target dense matrix
636  friend inline EnableIf_< UseAssign<MT2> >
637  subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
638  {
640 
642  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
643 
644  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
645  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
646 
647  const ResultType tmp( serial( rhs ) );
648  subAssign( ~lhs, tmp );
649  }
651  //**********************************************************************************************
652 
653  //**Subtraction assignment to sparse matrices***************************************************
654  // No special implementation for the subtraction assignment to sparse matrices.
655  //**********************************************************************************************
656 
657  //**Multiplication assignment to dense matrices*************************************************
658  // No special implementation for the multiplication assignment to dense matrices.
659  //**********************************************************************************************
660 
661  //**Multiplication assignment to sparse matrices************************************************
662  // No special implementation for the multiplication assignment to sparse matrices.
663  //**********************************************************************************************
664 
665  //**SMP assignment to dense matrices************************************************************
666  // No special implementation for the SMP assignment to dense matrices.
667  //**********************************************************************************************
668 
669  //**SMP assignment to sparse matrices***********************************************************
670  // No special implementation for the SMP assignment to sparse matrices.
671  //**********************************************************************************************
672 
673  //**SMP addition assignment to dense matrices***************************************************
687  template< typename MT2 // Type of the target dense matrix
688  , bool SO2 > // Storage order of the target dense matrix
689  friend inline EnableIf_< UseSMPAssign<MT2> >
690  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
691  {
693 
695  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
696 
697  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
698  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
699 
700  const ResultType tmp( rhs );
701  smpAddAssign( ~lhs, tmp );
702  }
704  //**********************************************************************************************
705 
706  //**SMP addition assignment to sparse matrices**************************************************
707  // No special implementation for the SMP addition assignment to sparse matrices.
708  //**********************************************************************************************
709 
710  //**SMP subtraction assignment to dense matrices************************************************
724  template< typename MT2 // Type of the target dense matrix
725  , bool SO2 > // Storage order of the target dense matrix
726  friend inline EnableIf_< UseSMPAssign<MT2> >
727  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
728  {
730 
732  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
733 
734  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
735  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
736 
737  const ResultType tmp( rhs );
738  smpSubAssign( ~lhs, tmp );
739  }
741  //**********************************************************************************************
742 
743  //**SMP subtraction assignment to sparse matrices***********************************************
744  // No special implementation for the SMP subtraction assignment to sparse matrices.
745  //**********************************************************************************************
746 
747  //**Multiplication assignment to dense matrices*************************************************
748  // No special implementation for the SMP multiplication assignment to dense matrices.
749  //**********************************************************************************************
750 
751  //**SMP multiplication assignment to sparse matrices********************************************
752  // No special implementation for the SMP multiplication assignment to sparse matrices.
753  //**********************************************************************************************
754 
755  //**Compile time checks*************************************************************************
762  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
764  //**********************************************************************************************
765 };
766 //*************************************************************************************************
767 
768 
769 
770 
771 //=================================================================================================
772 //
773 // GLOBAL BINARY ARITHMETIC OPERATORS
774 //
775 //=================================================================================================
776 
777 //*************************************************************************************************
799 template< typename T1 // Type of the left-hand side sparse matrix
800  , bool SO // Storage order of the left-hand side sparse matrix
801  , typename T2 > // Type of the right-hand side scalar
802 inline const EnableIf_< IsNumeric<T2>, DivExprTrait_<T1,T2> >
803  operator/( const SparseMatrix<T1,SO>& mat, T2 scalar )
804 {
806 
807  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
808 
810  typedef RightOperand_<ReturnType> ScalarType;
811 
813  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
814  }
815  else {
816  return ReturnType( ~mat, scalar );
817  }
818 }
819 //*************************************************************************************************
820 
821 
822 
823 
824 //=================================================================================================
825 //
826 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
827 //
828 //=================================================================================================
829 
830 //*************************************************************************************************
843 template< typename MT // Type of the sparse matrix of the left-hand side expression
844  , typename ST1 // Type of the scalar of the left-hand side expression
845  , bool SO // Storage order of the sparse matrix
846  , typename ST2 > // Type of the right-hand side scalar
847 inline const EnableIf_< And< IsNumeric<ST2>, Or< IsInvertible<ST1>, IsInvertible<ST2> > >
848  , MultExprTrait_< SMatScalarDivExpr<MT,ST1,SO>, ST2 > >
849  operator*( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
850 {
852 
853  return mat.leftOperand() * ( scalar / mat.rightOperand() );
854 }
856 //*************************************************************************************************
857 
858 
859 //*************************************************************************************************
872 template< typename ST1 // Type of the left-hand side scalar
873  , typename MT // Type of the sparse matrix of the right-hand side expression
874  , typename ST2 // Type of the scalar of the right-hand side expression
875  , bool SO > // Storage order of the sparse matrix
876 inline const EnableIf_< And< IsNumeric<ST1>, Or< IsInvertible<ST1>, IsInvertible<ST2> > >
877  , MultExprTrait_< ST1, SMatScalarDivExpr<MT,ST2,SO> > >
878  operator*( ST1 scalar, const SMatScalarDivExpr<MT,ST2,SO>& mat )
879 {
881 
882  return mat.leftOperand() * ( scalar / mat.rightOperand() );
883 }
885 //*************************************************************************************************
886 
887 
888 //*************************************************************************************************
901 template< typename MT // Type of the sparse matrix of the left-hand side expression
902  , typename ST1 // Type of the scalar of the left-hand side expression
903  , bool SO // Storage order of the sparse matrix
904  , typename ST2 > // Type of the right-hand side scalar
905 inline const EnableIf_< IsNumeric<ST2>
906  , DivExprTrait_< MT, MultTrait_<ST1,ST2> > >
907  operator/( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
908 {
910 
911  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
912 
913  typedef MultTrait_<ST1,ST2> MultType;
914  typedef DivExprTrait_<MT,MultType> ReturnType;
915  typedef RightOperand_<ReturnType> ScalarType;
916 
917  if( IsMultExpr<ReturnType>::value ) {
918  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
919  }
920  else {
921  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
922  }
923 }
925 //*************************************************************************************************
926 
927 
928 
929 
930 //=================================================================================================
931 //
932 // ROWS SPECIALIZATIONS
933 //
934 //=================================================================================================
935 
936 //*************************************************************************************************
938 template< typename MT, typename ST, bool SO >
939 struct Rows< SMatScalarDivExpr<MT,ST,SO> > : public Columns<MT>
940 {};
942 //*************************************************************************************************
943 
944 
945 
946 
947 //=================================================================================================
948 //
949 // COLUMNS SPECIALIZATIONS
950 //
951 //=================================================================================================
952 
953 //*************************************************************************************************
955 template< typename MT, typename ST, bool SO >
956 struct Columns< SMatScalarDivExpr<MT,ST,SO> > : public Rows<MT>
957 {};
959 //*************************************************************************************************
960 
961 
962 
963 
964 //=================================================================================================
965 //
966 // ISSYMMETRIC SPECIALIZATIONS
967 //
968 //=================================================================================================
969 
970 //*************************************************************************************************
972 template< typename MT, typename ST, bool SO >
973 struct IsSymmetric< SMatScalarDivExpr<MT,ST,SO> >
974  : public BoolConstant< IsSymmetric<MT>::value >
975 {};
977 //*************************************************************************************************
978 
979 
980 
981 
982 //=================================================================================================
983 //
984 // ISHERMITIAN SPECIALIZATIONS
985 //
986 //=================================================================================================
987 
988 //*************************************************************************************************
990 template< typename MT, typename ST, bool SO >
991 struct IsHermitian< SMatScalarDivExpr<MT,ST,SO> >
992  : public BoolConstant< IsHermitian<MT>::value >
993 {};
995 //*************************************************************************************************
996 
997 
998 
999 
1000 //=================================================================================================
1001 //
1002 // ISLOWER SPECIALIZATIONS
1003 //
1004 //=================================================================================================
1005 
1006 //*************************************************************************************************
1008 template< typename MT, typename ST, bool SO >
1009 struct IsLower< SMatScalarDivExpr<MT,ST,SO> >
1010  : public BoolConstant< IsLower<MT>::value >
1011 {};
1013 //*************************************************************************************************
1014 
1015 
1016 
1017 
1018 //=================================================================================================
1019 //
1020 // ISSTRICTLYLOWER SPECIALIZATIONS
1021 //
1022 //=================================================================================================
1023 
1024 //*************************************************************************************************
1026 template< typename MT, typename ST, bool SO >
1027 struct IsStrictlyLower< SMatScalarDivExpr<MT,ST,SO> >
1028  : public BoolConstant< IsStrictlyLower<MT>::value >
1029 {};
1031 //*************************************************************************************************
1032 
1033 
1034 
1035 
1036 //=================================================================================================
1037 //
1038 // ISUPPER SPECIALIZATIONS
1039 //
1040 //=================================================================================================
1041 
1042 //*************************************************************************************************
1044 template< typename MT, typename ST, bool SO >
1045 struct IsUpper< SMatScalarDivExpr<MT,ST,SO> >
1046  : public BoolConstant< IsUpper<MT>::value >
1047 {};
1049 //*************************************************************************************************
1050 
1051 
1052 
1053 
1054 //=================================================================================================
1055 //
1056 // ISSTRICTLYUPPER SPECIALIZATIONS
1057 //
1058 //=================================================================================================
1059 
1060 //*************************************************************************************************
1062 template< typename MT, typename ST, bool SO >
1063 struct IsStrictlyUpper< SMatScalarDivExpr<MT,ST,SO> >
1064  : public BoolConstant< IsStrictlyUpper<MT>::value >
1065 {};
1067 //*************************************************************************************************
1068 
1069 
1070 
1071 
1072 //=================================================================================================
1073 //
1074 // SMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1075 //
1076 //=================================================================================================
1077 
1078 //*************************************************************************************************
1080 template< typename MT, typename ST1, typename ST2 >
1081 struct SMatScalarMultExprTrait< SMatScalarDivExpr<MT,ST1,false>, ST2 >
1082 {
1083  private:
1084  //**********************************************************************************************
1085  using ScalarType = DivTrait_<ST2,ST1>;
1086  //**********************************************************************************************
1087 
1088  public:
1089  //**********************************************************************************************
1090  using Type = If_< And< IsSparseMatrix<MT>, IsRowMajorMatrix<MT>
1091  , IsNumeric<ST1>, IsNumeric<ST2> >
1092  , If_< IsInvertible<ScalarType>
1093  , SMatScalarMultExprTrait_<MT,ScalarType>
1094  , SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,false>, ST2, false > >
1095  , INVALID_TYPE >;
1096  //**********************************************************************************************
1097 };
1099 //*************************************************************************************************
1100 
1101 
1102 
1103 
1104 //=================================================================================================
1105 //
1106 // TSMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1107 //
1108 //=================================================================================================
1109 
1110 //*************************************************************************************************
1112 template< typename MT, typename ST1, typename ST2 >
1113 struct TSMatScalarMultExprTrait< SMatScalarDivExpr<MT,ST1,true>, ST2 >
1114 {
1115  private:
1116  //**********************************************************************************************
1117  using ScalarType = DivTrait_<ST2,ST1>;
1118  //**********************************************************************************************
1119 
1120  public:
1121  //**********************************************************************************************
1122  using Type = If_< And< IsSparseMatrix<MT>, IsColumnMajorMatrix<MT>
1123  , IsNumeric<ST1>, IsNumeric<ST2> >
1124  , If_< IsInvertible<ScalarType>
1125  , SMatScalarMultExprTrait_<MT,ScalarType>
1126  , SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,true>, ST2, true > >
1127  , INVALID_TYPE >;
1128  //**********************************************************************************************
1129 };
1131 //*************************************************************************************************
1132 
1133 
1134 
1135 
1136 //=================================================================================================
1137 //
1138 // SUBMATRIXEXPRTRAIT SPECIALIZATIONS
1139 //
1140 //=================================================================================================
1141 
1142 //*************************************************************************************************
1144 template< typename MT, typename ST, bool SO, bool AF >
1145 struct SubmatrixExprTrait< SMatScalarDivExpr<MT,ST,SO>, AF >
1146 {
1147  public:
1148  //**********************************************************************************************
1149  using Type = DivExprTrait_< SubmatrixExprTrait_<const MT,AF>, ST >;
1150  //**********************************************************************************************
1151 };
1153 //*************************************************************************************************
1154 
1155 
1156 
1157 
1158 //=================================================================================================
1159 //
1160 // ROWEXPRTRAIT SPECIALIZATIONS
1161 //
1162 //=================================================================================================
1163 
1164 //*************************************************************************************************
1166 template< typename MT, typename ST, bool SO >
1167 struct RowExprTrait< SMatScalarDivExpr<MT,ST,SO> >
1168 {
1169  public:
1170  //**********************************************************************************************
1171  using Type = DivExprTrait_< RowExprTrait_<const MT>, ST >;
1172  //**********************************************************************************************
1173 };
1175 //*************************************************************************************************
1176 
1177 
1178 
1179 
1180 //=================================================================================================
1181 //
1182 // COLUMNEXPRTRAIT SPECIALIZATIONS
1183 //
1184 //=================================================================================================
1185 
1186 //*************************************************************************************************
1188 template< typename MT, typename ST, bool SO >
1189 struct ColumnExprTrait< SMatScalarDivExpr<MT,ST,SO> >
1190 {
1191  public:
1192  //**********************************************************************************************
1193  using Type = DivExprTrait_< ColumnExprTrait_<const MT>, ST >;
1194  //**********************************************************************************************
1195 };
1197 //*************************************************************************************************
1198 
1199 } // namespace blaze
1200 
1201 #endif
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarDivExpr.h:315
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Data type constraint.
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarDivExpr.h:223
Constraint on the data type.
ReturnType_< MT > RN
Return type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:121
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
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.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
PointerType pointer
Pointer return type.
Definition: SMatScalarDivExpr.h:215
Header file for basic type definitions.
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatScalarDivExpr.h:181
Compile time check whether the given type is a multiplication expression template.This type trait class tests whether or not the given type Type is a multiplication expression template (i.e. an expression representing an element-wise vector multiplication, a matrix/vector multiplication, a vector/matrix multiplication, or a matrix multiplication). In order to qualify as a valid multiplication expression template, the given type has to derive (publicly or privately) from the MultExpr base class. In case the given type is a valid multiplication expression template, the value member constant is set to true, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to false, Type is FalseType, and the class derives from FalseType.
Definition: IsMultExpr.h:73
ElementType_< ResultType > ElementType
Resulting element type.
Definition: SMatScalarDivExpr.h:178
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SMatScalarDivExpr.h:488
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 IsSparseMatrix type trait.
Header file for the serial shim.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
If_< IsExpression< MT >, const MT, const MT & > LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:187
ConstIterator_< RemoveReference_< LeftOperand > > IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:204
Header file for the ColumnExprTrait class template.
Header file for the IsColumnMajorMatrix type trait.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatScalarDivExpr.h:398
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarDivExpr.h:308
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarDivExpr.h:512
Header file for the And class template.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarDivExpr.h:190
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
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatScalarDivExpr.h:467
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Header file for the Computation base class.
ResultType_< MT > RT
Result type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:120
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SMatScalarDivExpr.h:454
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarDivExpr.h:176
Header file for the RequiresEvaluation type trait.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:297
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
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
ValueType * PointerType
Pointer return type.
Definition: SMatScalarDivExpr.h:208
Constraint on the data type.
IfTrue_< useAssign, const ResultType, const SMatScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatScalarDivExpr.h:184
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
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:255
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarDivExpr.h:418
Header file for the SparseMatrix base class.
Header file for the DivExprTrait class template.
Constraint on the data type.
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
ReferenceType reference
Reference return type.
Definition: SMatScalarDivExpr.h:216
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
const EnableIf_< IsNumeric< T2 >, DivExprTrait_< T1, T2 > > operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:966
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatScalarDivExpr.h:388
Header file for the ValueIndexPair class.
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarDivExpr.h:213
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatScalarDivExpr.h:265
Header file for the If class template.
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:207
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatScalarDivExpr.h:377
Iterator over the elements of the sparse matrix/scalar division expression.
Definition: SMatScalarDivExpr.h:196
Header file for the IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
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.
SMatScalarDivExpr< MT, ST, SO > This
Type of this SMatScalarDivExpr instance.
Definition: SMatScalarDivExpr.h:174
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.In case the two types A and B are not the same (ignoring all cv-qualifiers of bo...
Definition: SameType.h:71
Header file for the IsLower type trait.
LeftOperand matrix_
Left-hand side sparse matrix of the division expression.
Definition: SMatScalarDivExpr.h:519
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:286
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarDivExpr.h:210
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:316
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:60
Constraints on the storage order of matrix types.
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:245
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the IsNumeric type trait.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatScalarDivExpr.h:360
Header file for the SubmatrixExprTrait class template.
ValueType value_type
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:214
Header file for run time assertion macros.
Utility type for generic codes.
Header file for the division trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarDivExpr.h:234
Expression object for sparse matrix-scalar divisions.The SMatScalarMult class represents the compile ...
Definition: Forward.h:95
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
SMatScalarDivExpr(const MT &matrix, ST scalar) noexcept
Constructor for the SMatScalarDivExpr class.
Definition: SMatScalarDivExpr.h:332
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarDivExpr.h:500
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarDivExpr.h:441
DivExprTrait_< RN, ST > ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarDivExpr.h:135
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
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.
Header file for the IsInvertible type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:243
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is a floating point data type...
Definition: FloatingPoint.h:81
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:201
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarDivExpr.h:209
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarDivExpr.h:478
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
typename DivExprTrait< T1, T2 >::Type DivExprTrait_
Auxiliary alias declaration for the DivExprTrait class template.The DivExprTrait_ alias declaration p...
Definition: DivExprTrait.h:196
CompositeType_< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:122
#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.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarDivExpr.h:206
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatScalarDivExpr.h:408
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:520
typename T::RightOperand RightOperand_
Alias declaration for nested RightOperand type definitions.The RightOperand_ alias declaration provid...
Definition: Aliases.h:363
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 MatScalarDivExpr base class.
MultTrait_< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SMatScalarDivExpr.h:175
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarDivExpr.h:429
DifferenceType difference_type
Difference between two iterators.
Definition: SMatScalarDivExpr.h:217
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarDivExpr.h:177
Header file for the IsHermitian type trait.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatScalarDivExpr.h:345
#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.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarDivExpr.h:275