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>
75 #include <blaze/system/Inline.h>
77 #include <blaze/util/Assert.h>
82 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/InvalidType.h>
85 #include <blaze/util/SelectType.h>
86 #include <blaze/util/Types.h>
91 
92 
93 namespace blaze {
94 
95 //=================================================================================================
96 //
97 // CLASS DMATSCALARDIVEXPR
98 //
99 //=================================================================================================
100 
101 //*************************************************************************************************
108 template< typename MT // Type of the left-hand side dense matrix
109  , typename ST // Type of the right-hand side scalar value
110  , bool SO > // Storage order
111 class DMatScalarDivExpr : public DenseMatrix< DMatScalarDivExpr<MT,ST,SO>, SO >
112  , private MatScalarDivExpr
113  , private Computation
114 {
115  private:
116  //**Type definitions****************************************************************************
117  typedef typename MT::ResultType RT;
118  typedef typename MT::ReturnType RN;
119  typedef typename MT::ElementType ET;
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 
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****************************************************************************
178 
181 
184 
186  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type LeftOperand;
187 
189  typedef ST RightOperand;
190  //**********************************************************************************************
191 
192  //**ConstIterator class definition**************************************************************
196  {
197  public:
198  //**Type definitions*************************************************************************
199  typedef std::random_access_iterator_tag IteratorCategory;
200  typedef ElementType ValueType;
201  typedef ElementType* PointerType;
202  typedef ElementType& ReferenceType;
204 
205  // STL iterator requirements
206  typedef IteratorCategory iterator_category;
207  typedef ValueType value_type;
208  typedef PointerType pointer;
209  typedef ReferenceType reference;
210  typedef DifferenceType difference_type;
211 
213  typedef typename MT::ConstIterator IteratorType;
214  //*******************************************************************************************
215 
216  //**Constructor******************************************************************************
222  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
223  : iterator_( iterator ) // Iterator to the current element
224  , scalar_ ( scalar ) // Scalar of the multiplication expression
225  {}
226  //*******************************************************************************************
227 
228  //**Addition assignment operator*************************************************************
234  inline ConstIterator& operator+=( size_t inc ) {
235  iterator_ += inc;
236  return *this;
237  }
238  //*******************************************************************************************
239 
240  //**Subtraction assignment operator**********************************************************
246  inline ConstIterator& operator-=( size_t dec ) {
247  iterator_ -= dec;
248  return *this;
249  }
250  //*******************************************************************************************
251 
252  //**Prefix increment operator****************************************************************
258  ++iterator_;
259  return *this;
260  }
261  //*******************************************************************************************
262 
263  //**Postfix increment operator***************************************************************
268  inline const ConstIterator operator++( int ) {
269  return ConstIterator( iterator_++ );
270  }
271  //*******************************************************************************************
272 
273  //**Prefix decrement operator****************************************************************
279  --iterator_;
280  return *this;
281  }
282  //*******************************************************************************************
283 
284  //**Postfix decrement operator***************************************************************
289  inline const ConstIterator operator--( int ) {
290  return ConstIterator( iterator_-- );
291  }
292  //*******************************************************************************************
293 
294  //**Element access operator******************************************************************
299  inline ReturnType operator*() const {
300  return *iterator_ / scalar_;
301  }
302  //*******************************************************************************************
303 
304  //**Load function****************************************************************************
309  inline IntrinsicType load() const {
310  return iterator_.load() / set( scalar_ );
311  }
312  //*******************************************************************************************
313 
314  //**Equality operator************************************************************************
320  inline bool operator==( const ConstIterator& rhs ) const {
321  return iterator_ == rhs.iterator_;
322  }
323  //*******************************************************************************************
324 
325  //**Inequality operator**********************************************************************
331  inline bool operator!=( const ConstIterator& rhs ) const {
332  return iterator_ != rhs.iterator_;
333  }
334  //*******************************************************************************************
335 
336  //**Less-than operator***********************************************************************
342  inline bool operator<( const ConstIterator& rhs ) const {
343  return iterator_ < rhs.iterator_;
344  }
345  //*******************************************************************************************
346 
347  //**Greater-than operator********************************************************************
353  inline bool operator>( const ConstIterator& rhs ) const {
354  return iterator_ > rhs.iterator_;
355  }
356  //*******************************************************************************************
357 
358  //**Less-or-equal-than operator**************************************************************
364  inline bool operator<=( const ConstIterator& rhs ) const {
365  return iterator_ <= rhs.iterator_;
366  }
367  //*******************************************************************************************
368 
369  //**Greater-or-equal-than operator***********************************************************
375  inline bool operator>=( const ConstIterator& rhs ) const {
376  return iterator_ >= rhs.iterator_;
377  }
378  //*******************************************************************************************
379 
380  //**Subtraction operator*********************************************************************
386  inline DifferenceType operator-( const ConstIterator& rhs ) const {
387  return iterator_ - rhs.iterator_;
388  }
389  //*******************************************************************************************
390 
391  //**Addition operator************************************************************************
398  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
399  return ConstIterator( it.iterator_ + inc, it.scalar_ );
400  }
401  //*******************************************************************************************
402 
403  //**Addition operator************************************************************************
410  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
411  return ConstIterator( it.iterator_ + inc, it.scalar_ );
412  }
413  //*******************************************************************************************
414 
415  //**Subtraction operator*********************************************************************
422  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
423  return ConstIterator( it.iterator_ - dec, it.scalar_ );
424  }
425  //*******************************************************************************************
426 
427  private:
428  //**Member variables*************************************************************************
429  IteratorType iterator_;
430  RightOperand scalar_;
431  //*******************************************************************************************
432  };
433  //**********************************************************************************************
434 
435  //**Compilation flags***************************************************************************
437  enum { vectorizable = MT::vectorizable &&
440 
442  enum { smpAssignable = MT::smpAssignable };
443  //**********************************************************************************************
444 
445  //**Constructor*********************************************************************************
451  explicit inline DMatScalarDivExpr( const MT& matrix, ST scalar )
452  : matrix_( matrix ) // Left-hand side dense matrix of the division expression
453  , scalar_( scalar ) // Right-hand side scalar of the division expression
454  {}
455  //**********************************************************************************************
456 
457  //**Access operator*****************************************************************************
464  inline ReturnType operator()( size_t i, size_t j ) const {
465  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
466  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
467  return matrix_(i,j) / scalar_;
468  }
469  //**********************************************************************************************
470 
471  //**Load function*******************************************************************************
478  BLAZE_ALWAYS_INLINE IntrinsicType load( size_t i, size_t j ) const {
479  typedef IntrinsicTrait<ElementType> IT;
480  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
481  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
482  BLAZE_INTERNAL_ASSERT( !SO || ( i % IT::size == 0UL ), "Invalid row access index" );
483  BLAZE_INTERNAL_ASSERT( SO || ( j % IT::size == 0UL ), "Invalid column access index" );
484  const IntrinsicType xmm1( matrix_.load(i,j) );
485  const IntrinsicType xmm2( set( scalar_ ) );
486  return xmm1 / xmm2;
487  }
488  //**********************************************************************************************
489 
490  //**Begin function******************************************************************************
496  inline ConstIterator begin( size_t i ) const {
497  return ConstIterator( matrix_.begin(i), scalar_ );
498  }
499  //**********************************************************************************************
500 
501  //**End function********************************************************************************
507  inline ConstIterator end( size_t i ) const {
508  return ConstIterator( matrix_.end(i), scalar_ );
509  }
510  //**********************************************************************************************
511 
512  //**Rows function*******************************************************************************
517  inline size_t rows() const {
518  return matrix_.rows();
519  }
520  //**********************************************************************************************
521 
522  //**Columns function****************************************************************************
527  inline size_t columns() const {
528  return matrix_.columns();
529  }
530  //**********************************************************************************************
531 
532  //**Left operand access*************************************************************************
537  inline LeftOperand leftOperand() const {
538  return matrix_;
539  }
540  //**********************************************************************************************
541 
542  //**Right operand access************************************************************************
547  inline RightOperand rightOperand() const {
548  return scalar_;
549  }
550  //**********************************************************************************************
551 
552  //**********************************************************************************************
558  template< typename T >
559  inline bool canAlias( const T* alias ) const {
560  return IsComputation<MT>::value && matrix_.canAlias( alias );
561  }
562  //**********************************************************************************************
563 
564  //**********************************************************************************************
570  template< typename T >
571  inline bool isAliased( const T* alias ) const {
572  return matrix_.isAliased( alias );
573  }
574  //**********************************************************************************************
575 
576  //**********************************************************************************************
581  inline bool isAligned() const {
582  return matrix_.isAligned();
583  }
584  //**********************************************************************************************
585 
586  //**********************************************************************************************
591  inline bool canSMPAssign() const {
592  return matrix_.canSMPAssign() ||
593  ( ( ( SO == rowMajor ) ? rows() : columns() ) > SMP_DMATSCALARMULT_THRESHOLD );
594  }
595  //**********************************************************************************************
596 
597  private:
598  //**Member variables****************************************************************************
599  LeftOperand matrix_;
600  RightOperand scalar_;
601  //**********************************************************************************************
602 
603  //**Assignment to dense matrices****************************************************************
617  template< typename MT2 // Type of the target dense matrix
618  , bool SO2 > // Storage order of the target dense matrix
619  friend inline typename EnableIf< UseAssign<MT2> >::Type
620  assign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
621  {
623 
624  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
625  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
626 
627  assign( ~lhs, rhs.matrix_ );
628  assign( ~lhs, (~lhs) / rhs.scalar_ );
629  }
631  //**********************************************************************************************
632 
633  //**Assignment to sparse matrices***************************************************************
647  template< typename MT2 // Type of the target sparse matrix
648  , bool SO2 > // Storage order of the target sparse matrix
649  friend inline typename EnableIf< UseAssign<MT2> >::Type
651  {
653 
654  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
655  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
656 
657  assign( ~lhs, rhs.matrix_ );
658  (~lhs) /= rhs.scalar_;
659  }
661  //**********************************************************************************************
662 
663  //**Addition assignment to dense matrices*******************************************************
677  template< typename MT2 // Type of the target dense matrix
678  , bool SO2 > // Storage order of the target dense matrix
679  friend inline typename EnableIf< UseAssign<MT2> >::Type
680  addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
681  {
683 
687 
688  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
689  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
690 
691  const ResultType tmp( serial( rhs ) );
692  addAssign( ~lhs, tmp );
693  }
695  //**********************************************************************************************
696 
697  //**Addition assignment to sparse matrices******************************************************
698  // No special implementation for the addition assignment to sparse matrices.
699  //**********************************************************************************************
700 
701  //**Subtraction assignment to dense matrices****************************************************
715  template< typename MT2 // Type of the target dense matrix
716  , bool SO2 > // Storage order of the target dense matrix
717  friend inline typename EnableIf< UseAssign<MT2> >::Type
718  subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
719  {
721 
725 
726  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
727  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
728 
729  const ResultType tmp( serial( rhs ) );
730  subAssign( ~lhs, tmp );
731  }
733  //**********************************************************************************************
734 
735  //**Subtraction assignment to sparse matrices***************************************************
736  // No special implementation for the subtraction assignment to sparse matrices.
737  //**********************************************************************************************
738 
739  //**Multiplication assignment to dense matrices*************************************************
740  // No special implementation for the multiplication assignment to dense matrices.
741  //**********************************************************************************************
742 
743  //**Multiplication assignment to sparse matrices************************************************
744  // No special implementation for the multiplication assignment to sparse matrices.
745  //**********************************************************************************************
746 
747  //**SMP assignment to dense matrices************************************************************
761  template< typename MT2 // Type of the target dense matrix
762  , bool SO2 > // Storage order of the target dense matrix
763  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
764  smpAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
765  {
767 
768  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
769  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
770 
771  smpAssign( ~lhs, rhs.matrix_ );
772  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
773  }
775  //**********************************************************************************************
776 
777  //**SMP assignment to sparse matrices***********************************************************
791  template< typename MT2 // Type of the target sparse matrix
792  , bool SO2 > // Storage order of the target sparse matrix
793  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
794  smpAssign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
795  {
797 
798  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
799  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
800 
801  smpAssign( ~lhs, rhs.matrix_ );
802  (~lhs) /= rhs.scalar_;
803  }
805  //**********************************************************************************************
806 
807  //**SMP addition assignment to dense matrices***************************************************
821  template< typename MT2 // Type of the target dense matrix
822  , bool SO2 > // Storage order of the target dense matrix
823  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
824  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
825  {
827 
831 
832  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
833  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
834 
835  const ResultType tmp( rhs );
836  smpAddAssign( ~lhs, tmp );
837  }
839  //**********************************************************************************************
840 
841  //**SMP addition assignment to sparse matrices**************************************************
842  // No special implementation for the SMP addition assignment to sparse matrices.
843  //**********************************************************************************************
844 
845  //**SMP subtraction assignment to dense matrices************************************************
859  template< typename MT2 // Type of the target dense matrix
860  , bool SO2 > // Storage order of the target dense matrix
861  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
862  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
863  {
865 
869 
870  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
871  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
872 
873  const ResultType tmp( rhs );
874  smpSubAssign( ~lhs, tmp );
875  }
877  //**********************************************************************************************
878 
879  //**SMP subtraction assignment to sparse matrices***********************************************
880  // No special implementation for the SMP subtraction assignment to sparse matrices.
881  //**********************************************************************************************
882 
883  //**SMP multiplication assignment to dense matrices*********************************************
884  // No special implementation for the SMP multiplication assignment to dense matrices.
885  //**********************************************************************************************
886 
887  //**SMP multiplication assignment to sparse matrices********************************************
888  // No special implementation for the SMP multiplication assignment to sparse matrices.
889  //**********************************************************************************************
890 
891  //**Compile time checks*************************************************************************
898  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
900  //**********************************************************************************************
901 };
902 //*************************************************************************************************
903 
904 
905 
906 
907 //=================================================================================================
908 //
909 // GLOBAL BINARY ARITHMETIC OPERATORS
910 //
911 //=================================================================================================
912 
913 //*************************************************************************************************
935 template< typename T1 // Type of the left-hand side dense matrix
936  , bool SO // Storage order of the left-hand side dense matrix
937  , typename T2 > // Type of the right-hand side scalar
938 inline const typename EnableIf< IsNumeric<T2>, typename DivExprTrait<T1,T2>::Type >::Type
939  operator/( const DenseMatrix<T1,SO>& mat, T2 scalar )
940 {
942 
943  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
944 
945  typedef typename DivExprTrait<T1,T2>::Type ReturnType;
946  typedef typename ReturnType::RightOperand ScalarType;
947 
949  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
950  }
951  else {
952  return ReturnType( ~mat, scalar );
953  }
954 }
955 //*************************************************************************************************
956 
957 
958 
959 
960 //=================================================================================================
961 //
962 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
963 //
964 //=================================================================================================
965 
966 //*************************************************************************************************
979 template< typename MT // Type of the dense matrix of the left-hand side expression
980  , typename ST1 // Type of the scalar of the left-hand side expression
981  , bool SO // Storage order of the dense matrix
982  , typename ST2 > // Type of the right-hand side scalar
983 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST2,ST1>::Type >
984  , typename MultExprTrait< DMatScalarDivExpr<MT,ST1,SO>, ST2 >::Type >::Type
985  operator*( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
986 {
988 
989  return mat.leftOperand() * ( scalar / mat.rightOperand() );
990 }
992 //*************************************************************************************************
993 
994 
995 //*************************************************************************************************
1008 template< typename ST1 // Type of the left-hand side scalar
1009  , typename MT // Type of the dense matrix of the right-hand side expression
1010  , typename ST2 // Type of the scalar of the right-hand side expression
1011  , bool SO > // Storage order of the dense matrix
1012 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST1,ST2>::Type >
1013  , typename MultExprTrait< ST1, DMatScalarDivExpr<MT,ST2,SO> >::Type >::Type
1014  operator*( ST1 scalar, const DMatScalarDivExpr<MT,ST2,SO>& mat )
1015 {
1017 
1018  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1019 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1037 template< typename MT // Type of the dense matrix of the left-hand side expression
1038  , typename ST1 // Type of the scalar of the left-hand side expression
1039  , bool SO // Storage order of the dense matrix
1040  , typename ST2 > // Type of the right-hand side scalar
1041 inline const typename EnableIf< IsNumeric<ST2>
1042  , typename DivExprTrait<MT,typename MultTrait<ST1,ST2>::Type>::Type >::Type
1043  operator/( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1044 {
1046 
1047  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1048 
1049  typedef typename MultTrait<ST1,ST2>::Type MultType;
1050  typedef typename DivExprTrait<MT,MultType>::Type ReturnType;
1051  typedef typename ReturnType::RightOperand ScalarType;
1052 
1053  if( IsMultExpr<ReturnType>::value ) {
1054  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
1055  }
1056  else {
1057  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
1058  }
1059 }
1061 //*************************************************************************************************
1062 
1063 
1064 
1065 
1066 //=================================================================================================
1067 //
1068 // ROWS SPECIALIZATIONS
1069 //
1070 //=================================================================================================
1071 
1072 //*************************************************************************************************
1074 template< typename MT, typename ST, bool SO >
1075 struct Rows< DMatScalarDivExpr<MT,ST,SO> > : public Columns<MT>
1076 {};
1078 //*************************************************************************************************
1079 
1080 
1081 
1082 
1083 //=================================================================================================
1084 //
1085 // COLUMNS SPECIALIZATIONS
1086 //
1087 //=================================================================================================
1088 
1089 //*************************************************************************************************
1091 template< typename MT, typename ST, bool SO >
1092 struct Columns< DMatScalarDivExpr<MT,ST,SO> > : public Rows<MT>
1093 {};
1095 //*************************************************************************************************
1096 
1097 
1098 
1099 
1100 //=================================================================================================
1101 //
1102 // ISSYMMETRIC SPECIALIZATIONS
1103 //
1104 //=================================================================================================
1105 
1106 //*************************************************************************************************
1108 template< typename MT, typename ST, bool SO >
1109 struct IsSymmetric< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsSymmetric<MT>::value >
1110 {};
1112 //*************************************************************************************************
1113 
1114 
1115 
1116 
1117 //=================================================================================================
1118 //
1119 // ISLOWER SPECIALIZATIONS
1120 //
1121 //=================================================================================================
1122 
1123 //*************************************************************************************************
1125 template< typename MT, typename ST, bool SO >
1126 struct IsLower< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsLower<MT>::value >
1127 {};
1129 //*************************************************************************************************
1130 
1131 
1132 
1133 
1134 //=================================================================================================
1135 //
1136 // ISSTRICTLYLOWER SPECIALIZATIONS
1137 //
1138 //=================================================================================================
1139 
1140 //*************************************************************************************************
1142 template< typename MT, typename ST, bool SO >
1143 struct IsStrictlyLower< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsStrictlyLower<MT>::value >
1144 {};
1146 //*************************************************************************************************
1147 
1148 
1149 
1150 
1151 //=================================================================================================
1152 //
1153 // ISUPPER SPECIALIZATIONS
1154 //
1155 //=================================================================================================
1156 
1157 //*************************************************************************************************
1159 template< typename MT, typename ST, bool SO >
1160 struct IsUpper< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsUpper<MT>::value >
1161 {};
1163 //*************************************************************************************************
1164 
1165 
1166 
1167 
1168 //=================================================================================================
1169 //
1170 // ISSTRICTLYUPPER SPECIALIZATIONS
1171 //
1172 //=================================================================================================
1173 
1174 //*************************************************************************************************
1176 template< typename MT, typename ST, bool SO >
1177 struct IsStrictlyUpper< DMatScalarDivExpr<MT,ST,SO> > : public IsTrue< IsStrictlyUpper<MT>::value >
1178 {};
1180 //*************************************************************************************************
1181 
1182 
1183 
1184 
1185 //=================================================================================================
1186 //
1187 // DMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1188 //
1189 //=================================================================================================
1190 
1191 //*************************************************************************************************
1193 template< typename MT, typename ST1, typename ST2 >
1194 struct DMatScalarMultExprTrait< DMatScalarDivExpr<MT,ST1,false>, ST2 >
1195 {
1196  private:
1197  //**********************************************************************************************
1198  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1199  //**********************************************************************************************
1200 
1201  //**********************************************************************************************
1202  typedef typename DMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1203  typedef DMatScalarMultExpr< DMatScalarDivExpr<MT,ST1,false>, ST2, false > T2;
1204  //**********************************************************************************************
1205 
1206  public:
1207  //**********************************************************************************************
1208  typedef typename SelectType< IsDenseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1209  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1210  , typename SelectType<condition,T1,T2>::Type
1211  , INVALID_TYPE >::Type Type;
1212  //**********************************************************************************************
1213 };
1215 //*************************************************************************************************
1216 
1217 
1218 
1219 
1220 //=================================================================================================
1221 //
1222 // TDMATSCALARMULTEXPRTRAIT SPECIALIZATIONS
1223 //
1224 //=================================================================================================
1225 
1226 //*************************************************************************************************
1228 template< typename MT, typename ST1, typename ST2 >
1229 struct TDMatScalarMultExprTrait< DMatScalarDivExpr<MT,ST1,true>, ST2 >
1230 {
1231  private:
1232  //**********************************************************************************************
1233  enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1234  //**********************************************************************************************
1235 
1236  //**********************************************************************************************
1237  typedef typename DMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1238  typedef DMatScalarMultExpr< DMatScalarDivExpr<MT,ST1,true>, ST2, true > T2;
1239  //**********************************************************************************************
1240 
1241  public:
1242  //**********************************************************************************************
1243  typedef typename SelectType< IsDenseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1244  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1245  , typename SelectType<condition,T1,T2>::Type
1246  , INVALID_TYPE >::Type Type;
1247  //**********************************************************************************************
1248 };
1250 //*************************************************************************************************
1251 
1252 
1253 
1254 
1255 //=================================================================================================
1256 //
1257 // SUBMATRIXEXPRTRAIT SPECIALIZATIONS
1258 //
1259 //=================================================================================================
1260 
1261 //*************************************************************************************************
1263 template< typename MT, typename ST, bool SO, bool AF >
1264 struct SubmatrixExprTrait< DMatScalarDivExpr<MT,ST,SO>, AF >
1265 {
1266  public:
1267  //**********************************************************************************************
1268  typedef typename DivExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, ST >::Type Type;
1269  //**********************************************************************************************
1270 };
1272 //*************************************************************************************************
1273 
1274 
1275 
1276 
1277 //=================================================================================================
1278 //
1279 // ROWEXPRTRAIT SPECIALIZATIONS
1280 //
1281 //=================================================================================================
1282 
1283 //*************************************************************************************************
1285 template< typename MT, typename ST, bool SO >
1286 struct RowExprTrait< DMatScalarDivExpr<MT,ST,SO> >
1287 {
1288  public:
1289  //**********************************************************************************************
1290  typedef typename DivExprTrait< typename RowExprTrait<const MT>::Type, ST >::Type Type;
1291  //**********************************************************************************************
1292 };
1294 //*************************************************************************************************
1295 
1296 
1297 
1298 
1299 //=================================================================================================
1300 //
1301 // COLUMNEXPRTRAIT SPECIALIZATIONS
1302 //
1303 //=================================================================================================
1304 
1305 //*************************************************************************************************
1307 template< typename MT, typename ST, bool SO >
1308 struct ColumnExprTrait< DMatScalarDivExpr<MT,ST,SO> >
1309 {
1310  public:
1311  //**********************************************************************************************
1312  typedef typename DivExprTrait< typename ColumnExprTrait<const MT>::Type, ST >::Type Type;
1313  //**********************************************************************************************
1314 };
1316 //*************************************************************************************************
1317 
1318 } // namespace blaze
1319 
1320 #endif
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Access to the intrinsic elements of the matrix.
Definition: DMatScalarDivExpr.h:478
Pointer difference type of the Blaze library.
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: DMatScalarDivExpr.h:591
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:547
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:8247
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:939
Header file for basic type definitions.
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:264
ValueType value_type
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:207
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:278
#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:209
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:331
#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:309
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:172
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:353
Header file for the IsColumnMajorMatrix type trait.
MT::CompositeType CT
Composite type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:120
Iterator over the elements of the dense matrix.
Definition: DMatScalarDivExpr.h:195
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatScalarDivExpr.h:386
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:261
Expression object for divisions of a dense matrix by a scalar.The DMatScalarDivExpr class represents ...
Definition: DMatScalarDivExpr.h:111
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatScalarDivExpr.h:234
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
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:571
Header file for the RequiresEvaluation type trait.
ElementType ValueType
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:200
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:176
Constraint on the data type.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatScalarDivExpr.h:246
Header file for the DivExprTrait class template.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatScalarDivExpr.h:203
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:117
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:180
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:263
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:173
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
ElementType & ReferenceType
Reference return type.
Definition: DMatScalarDivExpr.h:202
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the IsFloatingPoint type trait.
ReferenceType reference
Reference return type.
Definition: DMatScalarDivExpr.h:209
Header file for the IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
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:429
#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:268
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatScalarDivExpr.h:174
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatScalarDivExpr.h:289
Constraints on the storage order of matrix types.
MT::ElementType ET
Element type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:119
PointerType pointer
Pointer return type.
Definition: DMatScalarDivExpr.h:208
ElementType * PointerType
Pointer return type.
Definition: DMatScalarDivExpr.h:201
RightOperand scalar_
Scalar of the multiplication expression.
Definition: DMatScalarDivExpr.h:430
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
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:133
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
Header file for the BaseElementType type trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatScalarDivExpr.h:257
Header file for the IsNumeric type trait.
DMatScalarDivExpr(const MT &matrix, ST scalar)
Constructor for the DMatScalarDivExpr class.
Definition: DMatScalarDivExpr.h:451
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatScalarDivExpr.h:186
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:375
LeftOperand matrix_
Left-hand side dense matrix of the division expression.
Definition: DMatScalarDivExpr.h:599
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatScalarDivExpr.h:559
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:600
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DMatScalarDivExpr.h:222
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
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:422
SelectType< useAssign, const ResultType, const DMatScalarDivExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: DMatScalarDivExpr.h:183
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:517
IteratorCategory iterator_category
The iterator category.
Definition: DMatScalarDivExpr.h:206
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DMatScalarDivExpr.h:189
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatScalarDivExpr.h:175
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatScalarDivExpr.h:496
Base template for the DivTrait class.
Definition: DivTrait.h:150
#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:342
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatScalarDivExpr.h:199
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatScalarDivExpr.h:527
bool isAligned() const
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatScalarDivExpr.h:581
Header file for the IsRowMajorMatrix type trait.
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:364
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:464
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:507
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatScalarDivExpr.h:398
#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:320
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
Header file for the IsTrue value trait.
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatScalarDivExpr.h:410
MT::ConstIterator IteratorType
ConstIterator type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:213
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:537
MT::ReturnType RN
Return type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:118
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
DifferenceType difference_type
Difference between two iterators.
Definition: DMatScalarDivExpr.h:210
#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:299
IntrinsicTrait< ElementType >::Type IntrinsicType
Resulting intrinsic element type.
Definition: DMatScalarDivExpr.h:177
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