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>
77 #include <blaze/util/Assert.h>
82 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/Exception.h>
84 #include <blaze/util/InvalidType.h>
86 #include <blaze/util/mpl/And.h>
87 #include <blaze/util/SelectType.h>
88 #include <blaze/util/Types.h>
92 
93 
94 namespace blaze {
95 
96 //=================================================================================================
97 //
98 // CLASS SMATSCALARDIVEXPR
99 //
100 //=================================================================================================
101 
102 //*************************************************************************************************
109 template< typename MT // Type of the left-hand side sparse matrix
110  , typename ST // Type of the right-hand side scalar value
111  , bool SO > // Storage order
112 class SMatScalarDivExpr : public SparseMatrix< SMatScalarDivExpr<MT,ST,SO>, SO >
113  , private MatScalarDivExpr
114  , private Computation
115 {
116  private:
117  //**Type definitions****************************************************************************
118  typedef typename MT::ResultType RT;
119  typedef typename MT::ReturnType RN;
120  typedef typename MT::CompositeType CT;
121  //**********************************************************************************************
122 
123  //**Return type evaluation**********************************************************************
125 
130  enum { returnExpr = !IsTemporary<RN>::value };
131 
134  //**********************************************************************************************
135 
136  //**Serial evaluation strategy******************************************************************
138 
144  enum { useAssign = RequiresEvaluation<MT>::value };
145 
147  template< typename MT2 >
149  struct UseAssign {
150  enum { value = useAssign };
151  };
153  //**********************************************************************************************
154 
155  //**Parallel evaluation strategy****************************************************************
157 
163  template< typename MT2 >
164  struct UseSMPAssign {
165  enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
166  };
168  //**********************************************************************************************
169 
170  public:
171  //**Type definitions****************************************************************************
177 
180 
183 
185  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type LeftOperand;
186 
188  typedef ST RightOperand;
189  //**********************************************************************************************
190 
191  //**ConstIterator class definition**************************************************************
195  {
196  public:
197  //**Type definitions*************************************************************************
200 
203 
204  typedef std::forward_iterator_tag IteratorCategory;
205  typedef Element ValueType;
206  typedef ValueType* PointerType;
207  typedef ValueType& ReferenceType;
209 
210  // STL iterator requirements
211  typedef IteratorCategory iterator_category;
212  typedef ValueType value_type;
213  typedef PointerType pointer;
214  typedef ReferenceType reference;
215  typedef DifferenceType difference_type;
216  //*******************************************************************************************
217 
218  //**Constructor******************************************************************************
221  inline ConstIterator( IteratorType matrix, RightOperand scalar )
222  : matrix_( matrix ) // Iterator over the elements of the left-hand side sparse matrix expression
223  , scalar_( scalar ) // Right-hand side scalar of the division expression
224  {}
225  //*******************************************************************************************
226 
227  //**Prefix increment operator****************************************************************
233  ++matrix_;
234  return *this;
235  }
236  //*******************************************************************************************
237 
238  //**Element access operator******************************************************************
243  inline const Element operator*() const {
244  return Element( matrix_->value() / scalar_, matrix_->index() );
245  }
246  //*******************************************************************************************
247 
248  //**Element access operator******************************************************************
253  inline const ConstIterator* operator->() const {
254  return this;
255  }
256  //*******************************************************************************************
257 
258  //**Value function***************************************************************************
263  inline ReturnType value() const {
264  return matrix_->value() / scalar_;
265  }
266  //*******************************************************************************************
267 
268  //**Index function***************************************************************************
273  inline size_t index() const {
274  return matrix_->index();
275  }
276  //*******************************************************************************************
277 
278  //**Equality operator************************************************************************
284  inline bool operator==( const ConstIterator& rhs ) const {
285  return matrix_ == rhs.matrix_;
286  }
287  //*******************************************************************************************
288 
289  //**Inequality operator**********************************************************************
295  inline bool operator!=( const ConstIterator& rhs ) const {
296  return matrix_ != rhs.matrix_;
297  }
298  //*******************************************************************************************
299 
300  //**Subtraction operator*********************************************************************
306  inline DifferenceType operator-( const ConstIterator& rhs ) const {
307  return matrix_ - rhs.matrix_;
308  }
309  //*******************************************************************************************
310 
311  private:
312  //**Member variables*************************************************************************
313  IteratorType matrix_;
314  RightOperand scalar_;
315  //*******************************************************************************************
316  };
317  //**********************************************************************************************
318 
319  //**Compilation flags***************************************************************************
321  enum { smpAssignable = 0 };
322  //**********************************************************************************************
323 
324  //**Constructor*********************************************************************************
330  explicit inline SMatScalarDivExpr( const MT& matrix, ST scalar )
331  : matrix_( matrix ) // Left-hand side sparse matrix of the division expression
332  , scalar_( scalar ) // Right-hand side scalar of the division expression
333  {}
334  //**********************************************************************************************
335 
336  //**Access operator*****************************************************************************
343  inline ReturnType operator()( size_t i, size_t j ) const {
344  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
345  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
346  return matrix_(i,j) / scalar_;
347  }
348  //**********************************************************************************************
349 
350  //**At function*********************************************************************************
358  inline ReturnType at( size_t i, size_t j ) const {
359  if( i >= matrix_.rows() ) {
360  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
361  }
362  if( j >= matrix_.columns() ) {
363  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
364  }
365  return (*this)(i,j);
366  }
367  //**********************************************************************************************
368 
369  //**Begin function******************************************************************************
375  inline ConstIterator begin( size_t i ) const {
376  return ConstIterator( matrix_.begin(i), scalar_ );
377  }
378  //**********************************************************************************************
379 
380  //**End function********************************************************************************
386  inline ConstIterator end( size_t i ) const {
387  return ConstIterator( matrix_.end(i), scalar_ );
388  }
389  //**********************************************************************************************
390 
391  //**Rows function*******************************************************************************
396  inline size_t rows() const {
397  return matrix_.rows();
398  }
399  //**********************************************************************************************
400 
401  //**Columns function****************************************************************************
406  inline size_t columns() const {
407  return matrix_.columns();
408  }
409  //**********************************************************************************************
410 
411  //**NonZeros function***************************************************************************
416  inline size_t nonZeros() const {
417  return matrix_.nonZeros();
418  }
419  //**********************************************************************************************
420 
421  //**NonZeros function***************************************************************************
427  inline size_t nonZeros( size_t i ) const {
428  return matrix_.nonZeros(i);
429  }
430  //**********************************************************************************************
431 
432  //**Find function*******************************************************************************
439  inline ConstIterator find( size_t i, size_t j ) const {
441  return ConstIterator( matrix_.find( i, j ), scalar_ );
442  }
443  //**********************************************************************************************
444 
445  //**LowerBound function*************************************************************************
452  inline ConstIterator lowerBound( size_t i, size_t j ) const {
454  return ConstIterator( matrix_.lowerBound( i, j ), scalar_ );
455  }
456  //**********************************************************************************************
457 
458  //**UpperBound function*************************************************************************
465  inline ConstIterator upperBound( size_t i, size_t j ) const {
467  return ConstIterator( matrix_.upperBound( i, j ), scalar_ );
468  }
469  //**********************************************************************************************
470 
471  //**Left operand access*************************************************************************
476  inline LeftOperand leftOperand() const {
477  return matrix_;
478  }
479  //**********************************************************************************************
480 
481  //**Right operand access************************************************************************
486  inline RightOperand rightOperand() const {
487  return scalar_;
488  }
489  //**********************************************************************************************
490 
491  //**********************************************************************************************
497  template< typename T >
498  inline bool canAlias( const T* alias ) const {
499  return matrix_.canAlias( alias );
500  }
501  //**********************************************************************************************
502 
503  //**********************************************************************************************
509  template< typename T >
510  inline bool isAliased( const T* alias ) const {
511  return matrix_.isAliased( alias );
512  }
513  //**********************************************************************************************
514 
515  private:
516  //**Member variables****************************************************************************
517  LeftOperand matrix_;
518  RightOperand scalar_;
519  //**********************************************************************************************
520 
521  //**Assignment to dense matrices****************************************************************
535  template< typename MT2 // Type of the target dense matrix
536  , bool SO2 > // Storage order of the target dense matrix
537  friend inline typename EnableIf< UseAssign<MT2> >::Type
538  assign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
539  {
541 
542  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
543  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
544 
545  assign( ~lhs, rhs.matrix_ );
546  (~lhs) /= rhs.scalar_;
547  }
549  //**********************************************************************************************
550 
551  //**Assignment to sparse matrices***************************************************************
565  template< typename MT2 // Type of the target sparse matrix
566  , bool SO2 > // Storage order of the target sparse matrix
567  friend inline typename EnableIf< UseAssign<MT2> >::Type
568  assign( SparseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
569  {
571 
572  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
573  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
574 
575  assign( ~lhs, rhs.matrix_ );
576  (~lhs) /= rhs.scalar_;
577  }
579  //**********************************************************************************************
580 
581  //**Addition assignment to dense matrices*******************************************************
595  template< typename MT2 // Type of the target dense matrix
596  , bool SO2 > // Storage order of the target dense matrix
597  friend inline typename EnableIf< UseAssign<MT2> >::Type
598  addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
599  {
601 
604 
605  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
606  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
607 
608  const ResultType tmp( serial( rhs ) );
609  addAssign( ~lhs, tmp );
610  }
612  //**********************************************************************************************
613 
614  //**Addition assignment to sparse matrices******************************************************
615  // No special implementation for the addition assignment to sparse matrices.
616  //**********************************************************************************************
617 
618  //**Subtraction assignment to dense matrices****************************************************
632  template< typename MT2 // Type of the target dense matrix
633  , bool SO2 > // Storage order of the target dense matrix
634  friend inline typename EnableIf< UseAssign<MT2> >::Type
635  subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
636  {
638 
641 
642  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
643  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
644 
645  const ResultType tmp( serial( rhs ) );
646  subAssign( ~lhs, tmp );
647  }
649  //**********************************************************************************************
650 
651  //**Subtraction assignment to sparse matrices***************************************************
652  // No special implementation for the subtraction assignment to sparse matrices.
653  //**********************************************************************************************
654 
655  //**Multiplication assignment to dense matrices*************************************************
656  // No special implementation for the multiplication assignment to dense matrices.
657  //**********************************************************************************************
658 
659  //**Multiplication assignment to sparse matrices************************************************
660  // No special implementation for the multiplication assignment to sparse matrices.
661  //**********************************************************************************************
662 
663  //**SMP assignment to dense matrices************************************************************
664  // No special implementation for the SMP assignment to dense matrices.
665  //**********************************************************************************************
666 
667  //**SMP assignment to sparse matrices***********************************************************
668  // No special implementation for the SMP assignment to sparse matrices.
669  //**********************************************************************************************
670 
671  //**SMP addition assignment to dense matrices***************************************************
685  template< typename MT2 // Type of the target dense matrix
686  , bool SO2 > // Storage order of the target dense matrix
687  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
688  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
689  {
691 
694 
695  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
696  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
697 
698  const ResultType tmp( rhs );
699  smpAddAssign( ~lhs, tmp );
700  }
702  //**********************************************************************************************
703 
704  //**SMP addition assignment to sparse matrices**************************************************
705  // No special implementation for the SMP addition assignment to sparse matrices.
706  //**********************************************************************************************
707 
708  //**SMP subtraction assignment to dense matrices************************************************
722  template< typename MT2 // Type of the target dense matrix
723  , bool SO2 > // Storage order of the target dense matrix
724  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
725  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatScalarDivExpr& rhs )
726  {
728 
731 
732  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
733  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
734 
735  const ResultType tmp( rhs );
736  smpSubAssign( ~lhs, tmp );
737  }
739  //**********************************************************************************************
740 
741  //**SMP subtraction assignment to sparse matrices***********************************************
742  // No special implementation for the SMP subtraction assignment to sparse matrices.
743  //**********************************************************************************************
744 
745  //**Multiplication assignment to dense matrices*************************************************
746  // No special implementation for the SMP multiplication assignment to dense matrices.
747  //**********************************************************************************************
748 
749  //**SMP multiplication assignment to sparse matrices********************************************
750  // No special implementation for the SMP multiplication assignment to sparse matrices.
751  //**********************************************************************************************
752 
753  //**Compile time checks*************************************************************************
760  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
762  //**********************************************************************************************
763 };
764 //*************************************************************************************************
765 
766 
767 
768 
769 //=================================================================================================
770 //
771 // GLOBAL BINARY ARITHMETIC OPERATORS
772 //
773 //=================================================================================================
774 
775 //*************************************************************************************************
797 template< typename T1 // Type of the left-hand side sparse matrix
798  , bool SO // Storage order of the left-hand side sparse matrix
799  , typename T2 > // Type of the right-hand side scalar
800 inline const typename EnableIf< IsNumeric<T2>, typename DivExprTrait<T1,T2>::Type >::Type
801  operator/( const SparseMatrix<T1,SO>& mat, T2 scalar )
802 {
804 
805  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
806 
807  typedef typename DivExprTrait<T1,T2>::Type ReturnType;
808  typedef typename ReturnType::RightOperand ScalarType;
809 
811  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
812  }
813  else {
814  return ReturnType( ~mat, scalar );
815  }
816 }
817 //*************************************************************************************************
818 
819 
820 
821 
822 //=================================================================================================
823 //
824 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
825 //
826 //=================================================================================================
827 
828 //*************************************************************************************************
841 template< typename MT // Type of the sparse matrix of the left-hand side expression
842  , typename ST1 // Type of the scalar of the left-hand side expression
843  , bool SO // Storage order of the sparse matrix
844  , typename ST2 > // Type of the right-hand side scalar
845 inline const typename EnableIf< And< IsNumeric<ST2>, IsInvertible<typename DivTrait<ST2,ST1>::Type > >
846  , typename MultExprTrait< SMatScalarDivExpr<MT,ST1,SO>, ST2 >::Type >::Type
847  operator*( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
848 {
850 
851  return mat.leftOperand() * ( scalar / mat.rightOperand() );
852 }
854 //*************************************************************************************************
855 
856 
857 //*************************************************************************************************
870 template< typename ST1 // Type of the left-hand side scalar
871  , typename MT // Type of the sparse matrix of the right-hand side expression
872  , typename ST2 // Type of the scalar of the right-hand side expression
873  , bool SO > // Storage order of the sparse matrix
874 inline const typename EnableIf< And< IsNumeric<ST1>, IsInvertible<typename DivTrait<ST1,ST2>::Type > >
875  , typename MultExprTrait< ST1, SMatScalarDivExpr<MT,ST2,SO> >::Type >::Type
876  operator*( ST1 scalar, const SMatScalarDivExpr<MT,ST2,SO>& mat )
877 {
879 
880  return mat.leftOperand() * ( scalar / mat.rightOperand() );
881 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
899 template< typename MT // Type of the sparse matrix of the left-hand side expression
900  , typename ST1 // Type of the scalar of the left-hand side expression
901  , bool SO // Storage order of the sparse matrix
902  , typename ST2 > // Type of the right-hand side scalar
903 inline const typename EnableIf< IsNumeric<ST2>
904  , typename DivExprTrait<MT,typename MultTrait<ST1,ST2>::Type>::Type >::Type
905  operator/( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
906 {
908 
909  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
910 
911  typedef typename MultTrait<ST1,ST2>::Type MultType;
912  typedef typename DivExprTrait<MT,MultType>::Type ReturnType;
913  typedef typename ReturnType::RightOperand ScalarType;
914 
915  if( IsMultExpr<ReturnType>::value ) {
916  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
917  }
918  else {
919  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
920  }
921 }
923 //*************************************************************************************************
924 
925 
926 
927 
928 //=================================================================================================
929 //
930 // ROWS SPECIALIZATIONS
931 //
932 //=================================================================================================
933 
934 //*************************************************************************************************
936 template< typename MT, typename ST, bool SO >
937 struct Rows< SMatScalarDivExpr<MT,ST,SO> > : public Columns<MT>
938 {};
940 //*************************************************************************************************
941 
942 
943 
944 
945 //=================================================================================================
946 //
947 // COLUMNS SPECIALIZATIONS
948 //
949 //=================================================================================================
950 
951 //*************************************************************************************************
953 template< typename MT, typename ST, bool SO >
954 struct Columns< SMatScalarDivExpr<MT,ST,SO> > : public Rows<MT>
955 {};
957 //*************************************************************************************************
958 
959 
960 
961 
962 //=================================================================================================
963 //
964 // ISSYMMETRIC SPECIALIZATIONS
965 //
966 //=================================================================================================
967 
968 //*************************************************************************************************
970 template< typename MT, typename ST, bool SO >
971 struct IsSymmetric< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsSymmetric<MT>::value >
972 {};
974 //*************************************************************************************************
975 
976 
977 
978 
979 //=================================================================================================
980 //
981 // ISHERMITIAN SPECIALIZATIONS
982 //
983 //=================================================================================================
984 
985 //*************************************************************************************************
987 template< typename MT, typename ST, bool SO >
988 struct IsHermitian< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsHermitian<MT>::value >
989 {};
991 //*************************************************************************************************
992 
993 
994 
995 
996 //=================================================================================================
997 //
998 // ISLOWER SPECIALIZATIONS
999 //
1000 //=================================================================================================
1001 
1002 //*************************************************************************************************
1004 template< typename MT, typename ST, bool SO >
1005 struct IsLower< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsLower<MT>::value >
1006 {};
1008 //*************************************************************************************************
1009 
1010 
1011 
1012 
1013 //=================================================================================================
1014 //
1015 // ISSTRICTLYLOWER SPECIALIZATIONS
1016 //
1017 //=================================================================================================
1018 
1019 //*************************************************************************************************
1021 template< typename MT, typename ST, bool SO >
1022 struct IsStrictlyLower< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsStrictlyLower<MT>::value >
1023 {};
1025 //*************************************************************************************************
1026 
1027 
1028 
1029 
1030 //=================================================================================================
1031 //
1032 // ISUPPER SPECIALIZATIONS
1033 //
1034 //=================================================================================================
1035 
1036 //*************************************************************************************************
1038 template< typename MT, typename ST, bool SO >
1039 struct IsUpper< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsUpper<MT>::value >
1040 {};
1042 //*************************************************************************************************
1043 
1044 
1045 
1046 
1047 //=================================================================================================
1048 //
1049 // ISSTRICTLYUPPER SPECIALIZATIONS
1050 //
1051 //=================================================================================================
1052 
1053 //*************************************************************************************************
1055 template< typename MT, typename ST, bool SO >
1056 struct IsStrictlyUpper< SMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsStrictlyUpper<MT>::value >
1057 {};
1059 //*************************************************************************************************
1060 
1061 
1062 
1063 
1064 //=================================================================================================
1065 //
1066 // SMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1067 //
1068 //=================================================================================================
1069 
1070 //*************************************************************************************************
1072 template< typename MT, typename ST1, typename ST2 >
1073 struct SMatScalarMultExprTrait< SMatScalarDivExpr<MT,ST1,false>, ST2 >
1074 {
1075  private:
1076  //**********************************************************************************************
1077  typedef typename DivTrait<ST2,ST1>::Type ScalarType;
1078  //**********************************************************************************************
1079 
1080  //**********************************************************************************************
1081  enum { condition = IsInvertible<ScalarType>::value };
1082  //**********************************************************************************************
1083 
1084  //**********************************************************************************************
1085  typedef typename SMatScalarMultExprTrait<MT,ScalarType>::Type T1;
1086  typedef SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,false>, ST2, false > T2;
1087  //**********************************************************************************************
1088 
1089  public:
1090  //**********************************************************************************************
1091  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1092  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1093  , typename SelectType<condition,T1,T2>::Type
1094  , INVALID_TYPE >::Type Type;
1095  //**********************************************************************************************
1096 };
1098 //*************************************************************************************************
1099 
1100 
1101 
1102 
1103 //=================================================================================================
1104 //
1105 // TSMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1106 //
1107 //=================================================================================================
1108 
1109 //*************************************************************************************************
1111 template< typename MT, typename ST1, typename ST2 >
1112 struct TSMatScalarMultExprTrait< SMatScalarDivExpr<MT,ST1,true>, ST2 >
1113 {
1114  private:
1115  //**********************************************************************************************
1116  typedef typename DivTrait<ST2,ST1>::Type ScalarType;
1117  //**********************************************************************************************
1118 
1119  //**********************************************************************************************
1120  enum { condition = IsInvertible<ScalarType>::value };
1121  //**********************************************************************************************
1122 
1123  //**********************************************************************************************
1124  typedef typename SMatScalarMultExprTrait<MT,ScalarType>::Type T1;
1125  typedef SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,true>, ST2, true > T2;
1126  //**********************************************************************************************
1127 
1128  public:
1129  //**********************************************************************************************
1130  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1131  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1132  , typename SelectType<condition,T1,T2>::Type
1133  , INVALID_TYPE >::Type Type;
1134  //**********************************************************************************************
1135 };
1137 //*************************************************************************************************
1138 
1139 
1140 
1141 
1142 //=================================================================================================
1143 //
1144 // SUBMATRIXEXPRTRAIT SPECIALIZATIONS
1145 //
1146 //=================================================================================================
1147 
1148 //*************************************************************************************************
1150 template< typename MT, typename ST, bool SO, bool AF >
1151 struct SubmatrixExprTrait< SMatScalarDivExpr<MT,ST,SO>, AF >
1152 {
1153  public:
1154  //**********************************************************************************************
1155  typedef typename DivExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, ST >::Type Type;
1156  //**********************************************************************************************
1157 };
1159 //*************************************************************************************************
1160 
1161 
1162 
1163 
1164 //=================================================================================================
1165 //
1166 // ROWEXPRTRAIT SPECIALIZATIONS
1167 //
1168 //=================================================================================================
1169 
1170 //*************************************************************************************************
1172 template< typename MT, typename ST, bool SO >
1173 struct RowExprTrait< SMatScalarDivExpr<MT,ST,SO> >
1174 {
1175  public:
1176  //**********************************************************************************************
1177  typedef typename DivExprTrait< typename RowExprTrait<const MT>::Type, ST >::Type Type;
1178  //**********************************************************************************************
1179 };
1181 //*************************************************************************************************
1182 
1183 
1184 
1185 
1186 //=================================================================================================
1187 //
1188 // COLUMNEXPRTRAIT SPECIALIZATIONS
1189 //
1190 //=================================================================================================
1191 
1192 //*************************************************************************************************
1194 template< typename MT, typename ST, bool SO >
1195 struct ColumnExprTrait< SMatScalarDivExpr<MT,ST,SO> >
1196 {
1197  public:
1198  //**********************************************************************************************
1199  typedef typename DivExprTrait< typename ColumnExprTrait<const MT>::Type, ST >::Type Type;
1200  //**********************************************************************************************
1201 };
1203 //*************************************************************************************************
1204 
1205 } // namespace blaze
1206 
1207 #endif
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarDivExpr.h:313
Pointer difference type of the Blaze library.
Data type constraint.
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarDivExpr.h:221
Constraint on the data type.
#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:87
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:7820
const EnableIf< IsNumeric< T2 >, typename DivExprTrait< T1, T2 >::Type >::Type operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:962
PointerType pointer
Pointer return type.
Definition: SMatScalarDivExpr.h:213
Header file for basic type definitions.
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:119
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 enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsMultExpr.h:90
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarDivExpr.h:175
Header file for the IsSparseMatrix type trait.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarDivExpr.h:174
#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:81
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
Header file for the ColumnExprTrait class template.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatScalarDivExpr.h:396
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarDivExpr.h:498
Header file for the IsColumnMajorMatrix type trait.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarDivExpr.h:510
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarDivExpr.h:306
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
Header file for the And class template.
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:120
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarDivExpr.h:188
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatScalarDivExpr.h:465
Header file for the Computation base class.
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:452
Header file for the RequiresEvaluation type trait.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:295
SMatScalarDivExpr(const MT &matrix, ST scalar)
Constructor for the SMatScalarDivExpr class.
Definition: SMatScalarDivExpr.h:330
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:117
ValueType * PointerType
Pointer return type.
Definition: SMatScalarDivExpr.h:206
Constraint on the data type.
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:253
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarDivExpr.h:416
Header file for the SparseMatrix base class.
Header file for the DivExprTrait class template.
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:202
Evaluation of the resulting expression type of a division.Via this type trait it is possible to evalu...
Definition: DivExprTrait.h:88
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:90
ReferenceType reference
Reference return type.
Definition: SMatScalarDivExpr.h:214
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:261
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatScalarDivExpr.h:386
Header file for the ValueIndexPair class.
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarDivExpr.h:211
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the 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:263
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:205
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatScalarDivExpr.h:375
Iterator over the elements of the sparse matrix/scalar division expression.
Definition: SMatScalarDivExpr.h:194
MultTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: SMatScalarDivExpr.h:173
Header file for the IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
SMatScalarDivExpr< MT, ST, SO > This
Type of this SMatScalarDivExpr instance.
Definition: SMatScalarDivExpr.h:172
#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:89
Header file for the IsLower type trait.
LeftOperand matrix_
Left-hand side sparse matrix of the division expression.
Definition: SMatScalarDivExpr.h:517
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:284
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarDivExpr.h:208
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:314
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatScalarDivExpr.h:179
#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:78
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarDivExpr.h:476
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:243
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:185
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatScalarDivExpr.h:176
Constraint on the data type.
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
Header file for the IsNumeric type trait.
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:118
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatScalarDivExpr.h:358
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
ValueType value_type
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:212
Header file for run time assertion macros.
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:138
Header file for the division trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarDivExpr.h:232
Expression object for sparse matrix-scalar divisions.The SMatScalarMult class represents the compile ...
Definition: Forward.h:103
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
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:79
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarDivExpr.h:439
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SMatScalarDivExpr.h:486
#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:118
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
#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:118
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:199
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarDivExpr.h:207
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.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatScalarDivExpr.h:406
SelectType< useAssign, const ResultType, const SMatScalarDivExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatScalarDivExpr.h:182
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarDivExpr.h:204
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:518
DivExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarDivExpr.h:133
Header file for the IsUpper type trait.
Header file for exception macros.
Header file for the MatScalarDivExpr base class.
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarDivExpr.h:427
DifferenceType difference_type
Difference between two iterators.
Definition: SMatScalarDivExpr.h:215
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:343
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarDivExpr.h:273