All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMatScalarDivExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSCALARDIVEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATSCALARDIVEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
50 #include <blaze/math/Intrinsics.h>
74 #include <blaze/util/Assert.h>
79 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/InvalidType.h>
82 #include <blaze/util/SelectType.h>
83 #include <blaze/util/Types.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS DMATSCALARDIVEXPR
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
105 template< typename MT // Type of the left-hand side dense matrix
106  , typename ST // Type of the right-hand side scalar value
107  , bool SO > // Storage order
108 class DMatScalarDivExpr : public DenseMatrix< DMatScalarDivExpr<MT,ST,SO>, SO >
109  , private MatScalarDivExpr
110  , private Computation
111 {
112  private:
113  //**Type definitions****************************************************************************
114  typedef typename MT::ResultType RT;
115  typedef typename MT::ReturnType RN;
116  typedef typename MT::ElementType ET;
117  typedef typename MT::CompositeType CT;
118  //**********************************************************************************************
119 
120  //**Return type evaluation**********************************************************************
122 
127  enum { returnExpr = !IsTemporary<RN>::value };
128 
131  //**********************************************************************************************
132 
133  //**Serial evaluation strategy******************************************************************
135 
142 
144  template< typename MT2 >
146  struct UseAssign {
147  enum { value = useAssign };
148  };
150  //**********************************************************************************************
151 
152  //**Parallel evaluation strategy****************************************************************
154 
160  template< typename MT2 >
161  struct UseSMPAssign {
162  enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
163  };
165  //**********************************************************************************************
166 
167  public:
168  //**Type definitions****************************************************************************
175 
178 
181 
183  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type LeftOperand;
184 
186  typedef ST RightOperand;
187  //**********************************************************************************************
188 
189  //**ConstIterator class definition**************************************************************
193  {
194  public:
195  //**Type definitions*************************************************************************
196  typedef std::random_access_iterator_tag IteratorCategory;
201 
202  // STL iterator requirements
208 
210  typedef typename MT::ConstIterator IteratorType;
211  //*******************************************************************************************
212 
213  //**Constructor******************************************************************************
219  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
220  : iterator_( iterator ) // Iterator to the current element
221  , scalar_ ( scalar ) // Scalar of the multiplication expression
222  {}
223  //*******************************************************************************************
224 
225  //**Addition assignment operator*************************************************************
231  inline ConstIterator& operator+=( size_t inc ) {
232  iterator_ += inc;
233  return *this;
234  }
235  //*******************************************************************************************
236 
237  //**Subtraction assignment operator**********************************************************
243  inline ConstIterator& operator-=( size_t dec ) {
244  iterator_ -= dec;
245  return *this;
246  }
247  //*******************************************************************************************
248 
249  //**Prefix increment operator****************************************************************
255  ++iterator_;
256  return *this;
257  }
258  //*******************************************************************************************
259 
260  //**Postfix increment operator***************************************************************
265  inline const ConstIterator operator++( int ) {
266  return ConstIterator( iterator_++ );
267  }
268  //*******************************************************************************************
269 
270  //**Prefix decrement operator****************************************************************
276  --iterator_;
277  return *this;
278  }
279  //*******************************************************************************************
280 
281  //**Postfix decrement operator***************************************************************
286  inline const ConstIterator operator--( int ) {
287  return ConstIterator( iterator_-- );
288  }
289  //*******************************************************************************************
290 
291  //**Element access operator******************************************************************
296  inline ReturnType operator*() const {
297  return *iterator_ / scalar_;
298  }
299  //*******************************************************************************************
300 
301  //**Load function****************************************************************************
306  inline IntrinsicType load() const {
307  return iterator_.load() / set( scalar_ );
308  }
309  //*******************************************************************************************
310 
311  //**Equality operator************************************************************************
317  inline bool operator==( const ConstIterator& rhs ) const {
318  return iterator_ == rhs.iterator_;
319  }
320  //*******************************************************************************************
321 
322  //**Inequality operator**********************************************************************
328  inline bool operator!=( const ConstIterator& rhs ) const {
329  return iterator_ != rhs.iterator_;
330  }
331  //*******************************************************************************************
332 
333  //**Less-than operator***********************************************************************
339  inline bool operator<( const ConstIterator& rhs ) const {
340  return iterator_ < rhs.iterator_;
341  }
342  //*******************************************************************************************
343 
344  //**Greater-than operator********************************************************************
350  inline bool operator>( const ConstIterator& rhs ) const {
351  return iterator_ > rhs.iterator_;
352  }
353  //*******************************************************************************************
354 
355  //**Less-or-equal-than operator**************************************************************
361  inline bool operator<=( const ConstIterator& rhs ) const {
362  return iterator_ <= rhs.iterator_;
363  }
364  //*******************************************************************************************
365 
366  //**Greater-or-equal-than operator***********************************************************
372  inline bool operator>=( const ConstIterator& rhs ) const {
373  return iterator_ >= rhs.iterator_;
374  }
375  //*******************************************************************************************
376 
377  //**Subtraction operator*********************************************************************
383  inline DifferenceType operator-( const ConstIterator& rhs ) const {
384  return iterator_ - rhs.iterator_;
385  }
386  //*******************************************************************************************
387 
388  //**Addition operator************************************************************************
395  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
396  return ConstIterator( it.iterator_ + inc );
397  }
398  //*******************************************************************************************
399 
400  //**Addition operator************************************************************************
407  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
408  return ConstIterator( it.iterator_ + inc );
409  }
410  //*******************************************************************************************
411 
412  //**Subtraction operator*********************************************************************
419  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
420  return ConstIterator( it.iterator_ - dec );
421  }
422  //*******************************************************************************************
423 
424  private:
425  //**Member variables*************************************************************************
428  //*******************************************************************************************
429  };
430  //**********************************************************************************************
431 
432  //**Compilation flags***************************************************************************
434  enum { vectorizable = MT::vectorizable &&
437 
439  enum { smpAssignable = MT::smpAssignable };
440  //**********************************************************************************************
441 
442  //**Constructor*********************************************************************************
448  explicit inline DMatScalarDivExpr( const MT& matrix, ST scalar )
449  : matrix_( matrix ) // Left-hand side dense matrix of the division expression
450  , scalar_( scalar ) // Right-hand side scalar of the division expression
451  {}
452  //**********************************************************************************************
453 
454  //**Access operator*****************************************************************************
461  inline ReturnType operator()( size_t i, size_t j ) const {
462  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
463  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
464  return matrix_(i,j) / scalar_;
465  }
466  //**********************************************************************************************
467 
468  //**Load function*******************************************************************************
475  inline IntrinsicType load( size_t i, size_t j ) const {
476  typedef IntrinsicTrait<ElementType> IT;
477  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
478  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
479  BLAZE_INTERNAL_ASSERT( !SO || ( i % IT::size == 0UL ), "Invalid row access index" );
480  BLAZE_INTERNAL_ASSERT( SO || ( j % IT::size == 0UL ), "Invalid column access index" );
481  const IntrinsicType xmm1( matrix_.load(i,j) );
482  const IntrinsicType xmm2( set( scalar_ ) );
483  return xmm1 / xmm2;
484  }
485  //**********************************************************************************************
486 
487  //**Begin function******************************************************************************
493  inline ConstIterator begin( size_t i ) const {
494  return ConstIterator( matrix_.begin(i), scalar_ );
495  }
496  //**********************************************************************************************
497 
498  //**End function********************************************************************************
504  inline ConstIterator end( size_t i ) const {
505  return ConstIterator( matrix_.end(i), scalar_ );
506  }
507  //**********************************************************************************************
508 
509  //**Rows function*******************************************************************************
514  inline size_t rows() const {
515  return matrix_.rows();
516  }
517  //**********************************************************************************************
518 
519  //**Columns function****************************************************************************
524  inline size_t columns() const {
525  return matrix_.columns();
526  }
527  //**********************************************************************************************
528 
529  //**Left operand access*************************************************************************
534  inline LeftOperand leftOperand() const {
535  return matrix_;
536  }
537  //**********************************************************************************************
538 
539  //**Right operand access************************************************************************
544  inline RightOperand rightOperand() const {
545  return scalar_;
546  }
547  //**********************************************************************************************
548 
549  //**********************************************************************************************
555  template< typename T >
556  inline bool canAlias( const T* alias ) const {
557  return IsComputation<MT>::value && matrix_.canAlias( alias );
558  }
559  //**********************************************************************************************
560 
561  //**********************************************************************************************
567  template< typename T >
568  inline bool isAliased( const T* alias ) const {
569  return matrix_.isAliased( alias );
570  }
571  //**********************************************************************************************
572 
573  //**********************************************************************************************
578  inline bool isAligned() const {
579  return matrix_.isAligned();
580  }
581  //**********************************************************************************************
582 
583  //**********************************************************************************************
588  inline bool canSMPAssign() const {
589  return matrix_.canSMPAssign() ||
590  ( ( ( SO == rowMajor ) ? rows() : columns() ) > SMP_DMATSCALARMULT_THRESHOLD );
591  }
592  //**********************************************************************************************
593 
594  private:
595  //**Member variables****************************************************************************
598  //**********************************************************************************************
599 
600  //**Assignment to dense matrices****************************************************************
614  template< typename MT2 // Type of the target dense matrix
615  , bool SO2 > // Storage order of the target dense matrix
616  friend inline typename EnableIf< UseAssign<MT2> >::Type
617  assign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
618  {
620 
621  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
622  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
623 
624  assign( ~lhs, rhs.matrix_ );
625  assign( ~lhs, (~lhs) / rhs.scalar_ );
626  }
628  //**********************************************************************************************
629 
630  //**Assignment to sparse matrices***************************************************************
644  template< typename MT2 // Type of the target sparse matrix
645  , bool SO2 > // Storage order of the target sparse matrix
646  friend inline typename EnableIf< UseAssign<MT2> >::Type
648  {
650 
651  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
652  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
653 
654  assign( ~lhs, rhs.matrix_ );
655  (~lhs) /= rhs.scalar_;
656  }
658  //**********************************************************************************************
659 
660  //**Addition assignment to dense matrices*******************************************************
674  template< typename MT2 // Type of the target dense matrix
675  , bool SO2 > // Storage order of the target dense matrix
676  friend inline typename EnableIf< UseAssign<MT2> >::Type
677  addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
678  {
680 
684 
685  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
686  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
687 
688  const ResultType tmp( serial( rhs ) );
689  addAssign( ~lhs, tmp );
690  }
692  //**********************************************************************************************
693 
694  //**Addition assignment to sparse matrices******************************************************
695  // No special implementation for the addition assignment to sparse matrices.
696  //**********************************************************************************************
697 
698  //**Subtraction assignment to dense matrices****************************************************
712  template< typename MT2 // Type of the target dense matrix
713  , bool SO2 > // Storage order of the target dense matrix
714  friend inline typename EnableIf< UseAssign<MT2> >::Type
715  subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
716  {
718 
722 
723  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
724  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
725 
726  const ResultType tmp( serial( rhs ) );
727  subAssign( ~lhs, tmp );
728  }
730  //**********************************************************************************************
731 
732  //**Subtraction assignment to sparse matrices***************************************************
733  // No special implementation for the subtraction assignment to sparse matrices.
734  //**********************************************************************************************
735 
736  //**Multiplication assignment to dense matrices*************************************************
737  // No special implementation for the multiplication assignment to dense matrices.
738  //**********************************************************************************************
739 
740  //**Multiplication assignment to sparse matrices************************************************
741  // No special implementation for the multiplication assignment to sparse matrices.
742  //**********************************************************************************************
743 
744  //**SMP assignment to dense matrices************************************************************
758  template< typename MT2 // Type of the target dense matrix
759  , bool SO2 > // Storage order of the target dense matrix
760  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
761  smpAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
762  {
764 
765  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
766  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
767 
768  smpAssign( ~lhs, rhs.matrix_ );
769  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
770  }
772  //**********************************************************************************************
773 
774  //**SMP assignment to sparse matrices***********************************************************
788  template< typename MT2 // Type of the target sparse matrix
789  , bool SO2 > // Storage order of the target sparse matrix
790  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
791  smpAssign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
792  {
794 
795  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
796  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
797 
798  smpAssign( ~lhs, rhs.matrix_ );
799  (~lhs) /= rhs.scalar_;
800  }
802  //**********************************************************************************************
803 
804  //**SMP addition assignment to dense matrices***************************************************
818  template< typename MT2 // Type of the target dense matrix
819  , bool SO2 > // Storage order of the target dense matrix
820  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
821  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
822  {
824 
828 
829  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
830  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
831 
832  const ResultType tmp( rhs );
833  smpAddAssign( ~lhs, tmp );
834  }
836  //**********************************************************************************************
837 
838  //**SMP addition assignment to sparse matrices**************************************************
839  // No special implementation for the SMP addition assignment to sparse matrices.
840  //**********************************************************************************************
841 
842  //**SMP subtraction assignment to dense matrices************************************************
856  template< typename MT2 // Type of the target dense matrix
857  , bool SO2 > // Storage order of the target dense matrix
858  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
859  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
860  {
862 
866 
867  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
868  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
869 
870  const ResultType tmp( rhs );
871  smpSubAssign( ~lhs, tmp );
872  }
874  //**********************************************************************************************
875 
876  //**SMP subtraction assignment to sparse matrices***********************************************
877  // No special implementation for the SMP subtraction assignment to sparse matrices.
878  //**********************************************************************************************
879 
880  //**SMP multiplication assignment to dense matrices*********************************************
881  // No special implementation for the SMP multiplication assignment to dense matrices.
882  //**********************************************************************************************
883 
884  //**SMP multiplication assignment to sparse matrices********************************************
885  // No special implementation for the SMP multiplication assignment to sparse matrices.
886  //**********************************************************************************************
887 
888  //**Compile time checks*************************************************************************
897  //**********************************************************************************************
898 };
899 //*************************************************************************************************
900 
901 
902 
903 
904 //=================================================================================================
905 //
906 // GLOBAL BINARY ARITHMETIC OPERATORS
907 //
908 //=================================================================================================
909 
910 //*************************************************************************************************
932 template< typename T1 // Type of the left-hand side dense matrix
933  , bool SO // Storage order of the left-hand side dense matrix
934  , typename T2 > // Type of the right-hand side scalar
935 inline const typename EnableIf< IsNumeric<T2>, typename DivExprTrait<T1,T2>::Type >::Type
936  operator/( const DenseMatrix<T1,SO>& mat, T2 scalar )
937 {
939 
940  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
941 
942  typedef typename DivExprTrait<T1,T2>::Type ReturnType;
943  typedef typename ReturnType::RightOperand ScalarType;
944 
946  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
947  }
948  else {
949  return ReturnType( ~mat, scalar );
950  }
951 }
952 //*************************************************************************************************
953 
954 
955 
956 
957 //=================================================================================================
958 //
959 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
960 //
961 //=================================================================================================
962 
963 //*************************************************************************************************
976 template< typename MT // Type of the dense matrix of the left-hand side expression
977  , typename ST1 // Type of the scalar of the left-hand side expression
978  , bool SO // Storage order of the dense matrix
979  , typename ST2 > // Type of the right-hand side scalar
980 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST2,ST1>::Type >
981  , typename MultExprTrait< DMatScalarDivExpr<MT,ST1,SO>, ST2 >::Type >::Type
982  operator*( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
983 {
985 
986  return mat.leftOperand() * ( scalar / mat.rightOperand() );
987 }
989 //*************************************************************************************************
990 
991 
992 //*************************************************************************************************
1005 template< typename ST1 // Type of the left-hand side scalar
1006  , typename MT // Type of the dense matrix of the right-hand side expression
1007  , typename ST2 // Type of the scalar of the right-hand side expression
1008  , bool SO > // Storage order of the dense matrix
1009 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST1,ST2>::Type >
1010  , typename MultExprTrait< ST1, DMatScalarDivExpr<MT,ST2,SO> >::Type >::Type
1011  operator*( ST1 scalar, const DMatScalarDivExpr<MT,ST2,SO>& mat )
1012 {
1014 
1015  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1016 }
1018 //*************************************************************************************************
1019 
1020 
1021 //*************************************************************************************************
1034 template< typename MT // Type of the dense matrix of the left-hand side expression
1035  , typename ST1 // Type of the scalar of the left-hand side expression
1036  , bool SO // Storage order of the dense matrix
1037  , typename ST2 > // Type of the right-hand side scalar
1038 inline const typename EnableIf< IsNumeric<ST2>
1039  , typename DivExprTrait<MT,typename MultTrait<ST1,ST2>::Type>::Type >::Type
1040  operator/( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1041 {
1043 
1044  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1045 
1046  typedef typename MultTrait<ST1,ST2>::Type MultType;
1047  typedef typename DivExprTrait<MT,MultType>::Type ReturnType;
1048  typedef typename ReturnType::RightOperand ScalarType;
1049 
1050  if( IsMultExpr<ReturnType>::value ) {
1051  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
1052  }
1053  else {
1054  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
1055  }
1056 }
1058 //*************************************************************************************************
1059 
1060 
1061 
1062 
1063 //=================================================================================================
1064 //
1065 // ROWS SPECIALIZATIONS
1066 //
1067 //=================================================================================================
1068 
1069 //*************************************************************************************************
1071 template< typename MT, typename ST, bool SO >
1072 struct Rows< DMatScalarDivExpr<MT,ST,SO> > : public Columns<MT>
1073 {};
1075 //*************************************************************************************************
1076 
1077 
1078 
1079 
1080 //=================================================================================================
1081 //
1082 // COLUMNS SPECIALIZATIONS
1083 //
1084 //=================================================================================================
1085 
1086 //*************************************************************************************************
1088 template< typename MT, typename ST, bool SO >
1089 struct Columns< DMatScalarDivExpr<MT,ST,SO> > : public Rows<MT>
1090 {};
1092 //*************************************************************************************************
1093 
1094 
1095 
1096 
1097 //=================================================================================================
1098 //
1099 // ISSYMMETRIC SPECIALIZATIONS
1100 //
1101 //=================================================================================================
1102 
1103 //*************************************************************************************************
1105 template< typename MT, typename ST, bool SO >
1106 struct IsSymmetric< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsSymmetric<MT>::value >
1107 {};
1109 //*************************************************************************************************
1110 
1111 
1112 
1113 
1114 //=================================================================================================
1115 //
1116 // ISLOWER SPECIALIZATIONS
1117 //
1118 //=================================================================================================
1119 
1120 //*************************************************************************************************
1122 template< typename MT, typename ST, bool SO >
1123 struct IsLower< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsLower<MT>::value >
1124 {};
1126 //*************************************************************************************************
1127 
1128 
1129 
1130 
1131 //=================================================================================================
1132 //
1133 // ISUPPER SPECIALIZATIONS
1134 //
1135 //=================================================================================================
1136 
1137 //*************************************************************************************************
1139 template< typename MT, typename ST, bool SO >
1140 struct IsUpper< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsUpper<MT>::value >
1141 {};
1143 //*************************************************************************************************
1144 
1145 
1146 
1147 
1148 //=================================================================================================
1149 //
1150 // DMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1151 //
1152 //=================================================================================================
1153 
1154 //*************************************************************************************************
1156 template< typename MT, typename ST1, typename ST2 >
1157 struct DMatScalarMultExprTrait< DMatScalarDivExpr<MT,ST1,false>, ST2 >
1158 {
1159  private:
1160  //**********************************************************************************************
1161  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1162  //**********************************************************************************************
1163 
1164  //**********************************************************************************************
1165  typedef typename DMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1166  typedef DMatScalarMultExpr< DMatScalarDivExpr<MT,ST1,false>, ST2, false > T2;
1167  //**********************************************************************************************
1168 
1169  public:
1170  //**********************************************************************************************
1171  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1172  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1173  , typename SelectType<condition,T1,T2>::Type
1174  , INVALID_TYPE >::Type Type;
1175  //**********************************************************************************************
1176 };
1178 //*************************************************************************************************
1179 
1180 
1181 
1182 
1183 //=================================================================================================
1184 //
1185 // TDMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1186 //
1187 //=================================================================================================
1188 
1189 //*************************************************************************************************
1191 template< typename MT, typename ST1, typename ST2 >
1192 struct TDMatScalarMultExprTrait< DMatScalarDivExpr<MT,ST1,true>, ST2 >
1193 {
1194  private:
1195  //**********************************************************************************************
1196  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1197  //**********************************************************************************************
1198 
1199  //**********************************************************************************************
1200  typedef typename DMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1201  typedef DMatScalarMultExpr< DMatScalarDivExpr<MT,ST1,true>, ST2, true > T2;
1202  //**********************************************************************************************
1203 
1204  public:
1205  //**********************************************************************************************
1206  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1207  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1208  , typename SelectType<condition,T1,T2>::Type
1209  , INVALID_TYPE >::Type Type;
1210  //**********************************************************************************************
1211 };
1213 //*************************************************************************************************
1214 
1215 
1216 
1217 
1218 //=================================================================================================
1219 //
1220 // SUBMATRIXEXPRTRAIT SPECIALIZATIONS
1221 //
1222 //=================================================================================================
1223 
1224 //*************************************************************************************************
1226 template< typename MT, typename ST, bool SO, bool AF >
1227 struct SubmatrixExprTrait< DMatScalarDivExpr<MT,ST,SO>, AF >
1228 {
1229  public:
1230  //**********************************************************************************************
1231  typedef typename DivExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, ST >::Type Type;
1232  //**********************************************************************************************
1233 };
1235 //*************************************************************************************************
1236 
1237 
1238 
1239 
1240 //=================================================================================================
1241 //
1242 // ROWEXPRTRAIT SPECIALIZATIONS
1243 //
1244 //=================================================================================================
1245 
1246 //*************************************************************************************************
1248 template< typename MT, typename ST, bool SO >
1249 struct RowExprTrait< DMatScalarDivExpr<MT,ST,SO> >
1250 {
1251  public:
1252  //**********************************************************************************************
1253  typedef typename DivExprTrait< typename RowExprTrait<const MT>::Type, ST >::Type Type;
1254  //**********************************************************************************************
1255 };
1257 //*************************************************************************************************
1258 
1259 
1260 
1261 
1262 //=================================================================================================
1263 //
1264 // COLUMNEXPRTRAIT SPECIALIZATIONS
1265 //
1266 //=================================================================================================
1267 
1268 //*************************************************************************************************
1270 template< typename MT, typename ST, bool SO >
1271 struct ColumnExprTrait< DMatScalarDivExpr<MT,ST,SO> >
1272 {
1273  public:
1274  //**********************************************************************************************
1275  typedef typename DivExprTrait< typename ColumnExprTrait<const MT>::Type, ST >::Type Type;
1276  //**********************************************************************************************
1277 };
1279 //*************************************************************************************************
1280 
1281 } // namespace blaze
1282 
1283 #endif
Pointer difference type of the Blaze library.
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: DMatScalarDivExpr.h:588
Data type constraint.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
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
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: DMatScalarDivExpr.h:544
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:4838
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:936
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
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
ValueType value_type
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:204
Base class for all matrix/scalar divsion expression templates.The MatScalarDivExpr class serves as a ...
Definition: MatScalarDivExpr.h:65
ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatScalarDivExpr.h:275
#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:242
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:328
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
Header file for the ColumnExprTrait class template.
IntrinsicType load() const
Access to the intrinsic elements of the matrix.
Definition: DMatScalarDivExpr.h:306
Header file for the IsSame and IsStrictlySame type traits.
const size_t SMP_DMATSCALARMULT_THRESHOLD
SMP dense matrix/scalar multiplication/division threshold.This threshold specifies when a dense matri...
Definition: Thresholds.h:811
DMatScalarDivExpr< MT, ST, SO > This
Type of this DMatScalarDivExpr instance.
Definition: DMatScalarDivExpr.h:169
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:350
Header file for the IsColumnMajorMatrix type trait.
MT::CompositeType CT
Composite type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:117
Iterator over the elements of the dense matrix.
Definition: DMatScalarDivExpr.h:192
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatScalarDivExpr.h:383
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
Expression object for divisions of a dense matrix by a scalar.The DMatScalarDivExpr class represents ...
Definition: DMatScalarDivExpr.h:108
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatScalarDivExpr.h:231
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
Header file for the Computation base class.
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then 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: IsSame.h:158
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DMatScalarDivExpr.h:568
Header file for the RequiresEvaluation type trait.
ElementType ValueType
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:197
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatScalarDivExpr.h:173
Constraint on the data type.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatScalarDivExpr.h:243
Header file for the DivExprTrait class template.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatScalarDivExpr.h:200
Evaluation of the resulting expression type of a division.Via this type trait it is possible to evalu...
Definition: DivExprTrait.h:88
MT::ResultType RT
Result type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:114
Constraint on the data type.
Header file for the MultExprTrait class template.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatScalarDivExpr.h:177
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:259
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
DivTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: DMatScalarDivExpr.h:170
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
ElementType & ReferenceType
Reference return type.
Definition: DMatScalarDivExpr.h:199
Header file for the IsSymmetric type trait.
IntrinsicType load(size_t i, size_t j) const
Access to the intrinsic elements of the matrix.
Definition: DMatScalarDivExpr.h:475
Header file for the IsFloatingPoint type trait.
ReferenceType reference
Reference return type.
Definition: DMatScalarDivExpr.h:206
Header file for the IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Header file for the Columns type trait.
#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.
IteratorType iterator_
Iterator to the current element.
Definition: DMatScalarDivExpr.h:426
#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
const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatScalarDivExpr.h:265
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatScalarDivExpr.h:171
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatScalarDivExpr.h:286
Constraints on the storage order of matrix types.
MT::ElementType ET
Element type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:116
PointerType pointer
Pointer return type.
Definition: DMatScalarDivExpr.h:205
ElementType * PointerType
Pointer return type.
Definition: DMatScalarDivExpr.h:198
RightOperand scalar_
Scalar of the multiplication expression.
Definition: DMatScalarDivExpr.h:427
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
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 IsDenseMatrix type trait.
DivExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatScalarDivExpr.h:130
Header file for the EnableIf class template.
Header file for the serial shim.
Header file for the BaseElementType type trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatScalarDivExpr.h:254
Header file for the IsNumeric type trait.
DMatScalarDivExpr(const MT &matrix, ST scalar)
Constructor for the DMatScalarDivExpr class.
Definition: DMatScalarDivExpr.h:448
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatScalarDivExpr.h:183
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:372
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
LeftOperand matrix_
Left-hand side dense matrix of the division expression.
Definition: DMatScalarDivExpr.h:596
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatScalarDivExpr.h:556
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
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DMatScalarDivExpr.h:597
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DMatScalarDivExpr.h:219
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Utility type for generic codes.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the division trait.
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatScalarDivExpr.h:419
SelectType< useAssign, const ResultType, const DMatScalarDivExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: DMatScalarDivExpr.h:180
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
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatScalarDivExpr.h:514
IteratorCategory iterator_category
The iterator category.
Definition: DMatScalarDivExpr.h:203
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DMatScalarDivExpr.h:186
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatScalarDivExpr.h:172
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatScalarDivExpr.h:493
Base template for the DivTrait class.
Definition: DivTrait.h:142
#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
Header file for all intrinsic functionality.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:339
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatScalarDivExpr.h:196
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatScalarDivExpr.h:524
bool isAligned() const
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatScalarDivExpr.h:578
Header file for the IsRowMajorMatrix type trait.
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:361
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Header file for the IsComputation type trait class.
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatScalarDivExpr.h:461
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
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatScalarDivExpr.h:504
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatScalarDivExpr.h:395
#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
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:317
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
Header file for the IsTrue value trait.
Header file for basic type definitions.
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatScalarDivExpr.h:407
MT::ConstIterator IteratorType
ConstIterator type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:210
Header file for the IsUpper type trait.
Header file for the MatScalarDivExpr base class.
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatScalarDivExpr.h:534
MT::ReturnType RN
Return type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:115
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
DifferenceType difference_type
Difference between two iterators.
Definition: DMatScalarDivExpr.h:207
#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
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatScalarDivExpr.h:296
IntrinsicTrait< ElementType >::Type IntrinsicType
Resulting intrinsic element type.
Definition: DMatScalarDivExpr.h:174
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849