DVecScalarDivExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECSCALARDIVEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
50 #include <blaze/math/Intrinsics.h>
70 #include <blaze/system/Inline.h>
72 #include <blaze/util/Assert.h>
77 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/Exception.h>
79 #include <blaze/util/InvalidType.h>
81 #include <blaze/util/mpl/And.h>
82 #include <blaze/util/SelectType.h>
83 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS DVECSCALARDIVEXPR
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
104 template< typename VT // Type of the left-hand side dense vector
105  , typename ST // Type of the right-hand side scalar value
106  , bool TF > // Transpose flag
107 class DVecScalarDivExpr : public DenseVector< DVecScalarDivExpr<VT,ST,TF>, TF >
108  , private VecScalarDivExpr
109  , private Computation
110 {
111  private:
112  //**Type definitions****************************************************************************
113  typedef typename VT::ResultType RT;
114  typedef typename VT::ReturnType RN;
115  typedef typename VT::ElementType ET;
116  typedef typename VT::CompositeType CT;
117  //**********************************************************************************************
118 
119  //**Return type evaluation**********************************************************************
121 
126  enum { returnExpr = !IsTemporary<RN>::value };
127 
130  //**********************************************************************************************
131 
132  //**Serial evaluation strategy******************************************************************
134 
141 
143  template< typename VT2 >
145  struct UseAssign {
146  enum { value = useAssign };
147  };
149  //**********************************************************************************************
150 
151  //**Parallel evaluation strategy****************************************************************
153 
159  template< typename VT2 >
160  struct UseSMPAssign {
161  enum { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
162  };
164  //**********************************************************************************************
165 
166  public:
167  //**Type definitions****************************************************************************
173 
176 
179 
181  typedef typename SelectType< IsExpression<VT>::value, const VT, const VT& >::Type LeftOperand;
182 
184  typedef ST RightOperand;
185  //**********************************************************************************************
186 
187  //**ConstIterator class definition**************************************************************
191  {
192  public:
193  //**Type definitions*************************************************************************
194  typedef std::random_access_iterator_tag IteratorCategory;
195  typedef ElementType ValueType;
196  typedef ElementType* PointerType;
197  typedef ElementType& ReferenceType;
199 
200  // STL iterator requirements
201  typedef IteratorCategory iterator_category;
202  typedef ValueType value_type;
203  typedef PointerType pointer;
204  typedef ReferenceType reference;
205  typedef DifferenceType difference_type;
206 
208  typedef typename VT::ConstIterator IteratorType;
209  //*******************************************************************************************
210 
211  //**Constructor******************************************************************************
217  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
218  : iterator_( iterator ) // Iterator to the current element
219  , scalar_ ( scalar ) // Scalar of the division expression
220  {}
221  //*******************************************************************************************
222 
223  //**Addition assignment operator*************************************************************
229  inline ConstIterator& operator+=( size_t inc ) {
230  iterator_ += inc;
231  return *this;
232  }
233  //*******************************************************************************************
234 
235  //**Subtraction assignment operator**********************************************************
241  inline ConstIterator& operator-=( size_t dec ) {
242  iterator_ -= dec;
243  return *this;
244  }
245  //*******************************************************************************************
246 
247  //**Prefix increment operator****************************************************************
253  ++iterator_;
254  return *this;
255  }
256  //*******************************************************************************************
257 
258  //**Postfix increment operator***************************************************************
263  inline const ConstIterator operator++( int ) {
264  return ConstIterator( iterator_++ );
265  }
266  //*******************************************************************************************
267 
268  //**Prefix decrement operator****************************************************************
274  --iterator_;
275  return *this;
276  }
277  //*******************************************************************************************
278 
279  //**Postfix decrement operator***************************************************************
284  inline const ConstIterator operator--( int ) {
285  return ConstIterator( iterator_-- );
286  }
287  //*******************************************************************************************
288 
289  //**Element access operator******************************************************************
294  inline ReturnType operator*() const {
295  return *iterator_ / scalar_;
296  }
297  //*******************************************************************************************
298 
299  //**Load function****************************************************************************
304  inline IntrinsicType load() const {
305  return iterator_.load() / set( scalar_ );
306  }
307  //*******************************************************************************************
308 
309  //**Equality operator************************************************************************
315  inline bool operator==( const ConstIterator& rhs ) const {
316  return iterator_ == rhs.iterator_;
317  }
318  //*******************************************************************************************
319 
320  //**Inequality operator**********************************************************************
326  inline bool operator!=( const ConstIterator& rhs ) const {
327  return iterator_ != rhs.iterator_;
328  }
329  //*******************************************************************************************
330 
331  //**Less-than operator***********************************************************************
337  inline bool operator<( const ConstIterator& rhs ) const {
338  return iterator_ < rhs.iterator_;
339  }
340  //*******************************************************************************************
341 
342  //**Greater-than operator********************************************************************
348  inline bool operator>( const ConstIterator& rhs ) const {
349  return iterator_ > rhs.iterator_;
350  }
351  //*******************************************************************************************
352 
353  //**Less-or-equal-than operator**************************************************************
359  inline bool operator<=( const ConstIterator& rhs ) const {
360  return iterator_ <= rhs.iterator_;
361  }
362  //*******************************************************************************************
363 
364  //**Greater-or-equal-than operator***********************************************************
370  inline bool operator>=( const ConstIterator& rhs ) const {
371  return iterator_ >= rhs.iterator_;
372  }
373  //*******************************************************************************************
374 
375  //**Subtraction operator*********************************************************************
381  inline DifferenceType operator-( const ConstIterator& rhs ) const {
382  return iterator_ - rhs.iterator_;
383  }
384  //*******************************************************************************************
385 
386  //**Addition operator************************************************************************
393  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
394  return ConstIterator( it.iterator_ + inc );
395  }
396  //*******************************************************************************************
397 
398  //**Addition operator************************************************************************
405  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
406  return ConstIterator( it.iterator_ + inc );
407  }
408  //*******************************************************************************************
409 
410  //**Subtraction operator*********************************************************************
417  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
418  return ConstIterator( it.iterator_ - dec );
419  }
420  //*******************************************************************************************
421 
422  private:
423  //**Member variables*************************************************************************
424  IteratorType iterator_;
425  RightOperand scalar_;
426  //*******************************************************************************************
427  };
428  //**********************************************************************************************
429 
430  //**Compilation flags***************************************************************************
432  enum { vectorizable = VT::vectorizable &&
435  IsSame<typename UnderlyingElement<ET>::Type,RightOperand>::value ) &&
437 
439  enum { smpAssignable = VT::smpAssignable };
440  //**********************************************************************************************
441 
442  //**Constructor*********************************************************************************
448  explicit inline DVecScalarDivExpr( const VT& vector, ST scalar )
449  : vector_( vector ) // Left-hand side dense vector of the division expression
450  , scalar_( scalar ) // Right-hand side scalar of the division expression
451  {}
452  //**********************************************************************************************
453 
454  //**Subscript operator**************************************************************************
460  inline ReturnType operator[]( size_t index ) const {
461  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
462  return vector_[index] / scalar_;
463  }
464  //**********************************************************************************************
465 
466  //**At function*********************************************************************************
473  inline ReturnType at( size_t index ) const {
474  if( index >= vector_.size() ) {
475  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
476  }
477  return (*this)[index];
478  }
479  //**********************************************************************************************
480 
481  //**Load function*******************************************************************************
487  BLAZE_ALWAYS_INLINE IntrinsicType load( size_t index ) const {
488  typedef IntrinsicTrait<ElementType> IT;
489  BLAZE_INTERNAL_ASSERT( index < vector_.size() , "Invalid vector access index" );
490  BLAZE_INTERNAL_ASSERT( index % IT::size == 0UL, "Invalid vector access index" );
491  return vector_.load( index ) / set( scalar_ );
492  }
493  //**********************************************************************************************
494 
495  //**Begin function******************************************************************************
500  inline ConstIterator begin() const {
501  return ConstIterator( vector_.begin(), scalar_ );
502  }
503  //**********************************************************************************************
504 
505  //**End function********************************************************************************
510  inline ConstIterator end() const {
511  return ConstIterator( vector_.end(), scalar_ );
512  }
513  //**********************************************************************************************
514 
515  //**Size function*******************************************************************************
520  inline size_t size() const {
521  return vector_.size();
522  }
523  //**********************************************************************************************
524 
525  //**Left operand access*************************************************************************
530  inline LeftOperand leftOperand() const {
531  return vector_;
532  }
533  //**********************************************************************************************
534 
535  //**Right operand access************************************************************************
540  inline RightOperand rightOperand() const {
541  return scalar_;
542  }
543  //**********************************************************************************************
544 
545  //**********************************************************************************************
551  template< typename T >
552  inline bool canAlias( const T* alias ) const {
553  return IsComputation<VT>::value && vector_.canAlias( alias );
554  }
555  //**********************************************************************************************
556 
557  //**********************************************************************************************
563  template< typename T >
564  inline bool isAliased( const T* alias ) const {
565  return vector_.isAliased( alias );
566  }
567  //**********************************************************************************************
568 
569  //**********************************************************************************************
574  inline bool isAligned() const {
575  return vector_.isAligned();
576  }
577  //**********************************************************************************************
578 
579  //**********************************************************************************************
584  inline bool canSMPAssign() const {
585  return vector_.canSMPAssign() || ( size() > SMP_DVECSCALARMULT_THRESHOLD );
586  }
587  //**********************************************************************************************
588 
589  private:
590  //**Member variables****************************************************************************
591  LeftOperand vector_;
592  RightOperand scalar_;
593  //**********************************************************************************************
594 
595  //**Assignment to dense vectors*****************************************************************
609  template< typename VT2 > // Type of the target dense vector
610  friend inline typename EnableIf< UseAssign<VT2> >::Type
611  assign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
612  {
614 
615  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
616 
617  assign( ~lhs, rhs.vector_ );
618  assign( ~lhs, (~lhs) / rhs.scalar_ );
619  }
621  //**********************************************************************************************
622 
623  //**Assignment to sparse vectors****************************************************************
637  template< typename VT2 > // Type of the target sparse vector
638  friend inline typename EnableIf< UseAssign<VT2> >::Type
639  assign( SparseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
640  {
642 
643  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
644 
645  assign( ~lhs, rhs.vector_ );
646  (~lhs) /= rhs.scalar_;
647  }
649  //**********************************************************************************************
650 
651  //**Addition assignment to dense vectors********************************************************
665  template< typename VT2 > // Type of the target dense vector
666  friend inline typename EnableIf< UseAssign<VT2> >::Type
667  addAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
668  {
670 
674 
675  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
676 
677  const ResultType tmp( serial( rhs ) );
678  addAssign( ~lhs, tmp );
679  }
681  //**********************************************************************************************
682 
683  //**Addition assignment to sparse vectors*******************************************************
684  // No special implementation for the addition assignment to sparse vectors.
685  //**********************************************************************************************
686 
687  //**Subtraction assignment to dense vectors*****************************************************
701  template< typename VT2 > // Type of the target dense vector
702  friend inline typename EnableIf< UseAssign<VT2> >::Type
703  subAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
704  {
706 
710 
711  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
712 
713  const ResultType tmp( serial( rhs ) );
714  subAssign( ~lhs, tmp );
715  }
717  //**********************************************************************************************
718 
719  //**Subtraction assignment to sparse vectors****************************************************
720  // No special implementation for the subtraction assignment to sparse vectors.
721  //**********************************************************************************************
722 
723  //**Multiplication assignment to dense vectors**************************************************
737  template< typename VT2 > // Type of the target dense vector
738  friend inline typename EnableIf< UseAssign<VT2> >::Type
739  multAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
740  {
742 
746 
747  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
748 
749  const ResultType tmp( serial( rhs ) );
750  multAssign( ~lhs, tmp );
751  }
753  //**********************************************************************************************
754 
755  //**Multiplication assignment to sparse vectors*************************************************
756  // No special implementation for the multiplication assignment to sparse vectors.
757  //**********************************************************************************************
758 
759  //**SMP assignment to dense vectors*************************************************************
773  template< typename VT2 > // Type of the target dense vector
774  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
775  smpAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
776  {
778 
779  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
780 
781  smpAssign( ~lhs, rhs.vector_ );
782  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
783  }
785  //**********************************************************************************************
786 
787  //**SMP assignment to sparse vectors************************************************************
801  template< typename VT2 > // Type of the target sparse vector
802  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
803  smpAssign( SparseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
804  {
806 
807  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
808 
809  smpAssign( ~lhs, rhs.vector_ );
810  (~lhs) /= rhs.scalar_;
811  }
813  //**********************************************************************************************
814 
815  //**SMP addition assignment to dense vectors****************************************************
829  template< typename VT2 > // Type of the target dense vector
830  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
831  smpAddAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
832  {
834 
838 
839  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
840 
841  const ResultType tmp( rhs );
842  smpAddAssign( ~lhs, tmp );
843  }
845  //**********************************************************************************************
846 
847  //**SMP addition assignment to sparse vectors***************************************************
848  // No special implementation for the SMP addition assignment to sparse vectors.
849  //**********************************************************************************************
850 
851  //**SMP subtraction assignment to dense vectors*************************************************
865  template< typename VT2 > // Type of the target dense vector
866  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
867  smpSubAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
868  {
870 
874 
875  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
876 
877  const ResultType tmp( rhs );
878  smpSubAssign( ~lhs, tmp );
879  }
881  //**********************************************************************************************
882 
883  //**SMP subtraction assignment to sparse vectors************************************************
884  // No special implementation for the SMP subtraction assignment to sparse vectors.
885  //**********************************************************************************************
886 
887  //**SMP multiplication assignment to dense vectors**********************************************
901  template< typename VT2 > // Type of the target dense vector
902  friend inline typename EnableIf< UseSMPAssign<VT2> >::Type
903  smpMultAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
904  {
906 
910 
911  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
912 
913  const ResultType tmp( rhs );
914  smpMultAssign( ~lhs, tmp );
915  }
917  //**********************************************************************************************
918 
919  //**SMP multiplication assignment to sparse vectors*********************************************
920  // No special implementation for the SMP multiplication assignment to sparse vectors.
921  //**********************************************************************************************
922 
923  //**Compile time checks*************************************************************************
930  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
932  //**********************************************************************************************
933 };
934 //*************************************************************************************************
935 
936 
937 
938 
939 //=================================================================================================
940 //
941 // GLOBAL BINARY ARITHMETIC OPERATORS
942 //
943 //=================================================================================================
944 
945 //*************************************************************************************************
969 template< typename T1 // Type of the left-hand side dense vector
970  , typename T2 // Type of the right-hand side scalar
971  , bool TF > // Transpose flag
972 inline const typename EnableIf< IsNumeric<T2>, typename DivExprTrait<T1,T2>::Type >::Type
973  operator/( const DenseVector<T1,TF>& vec, T2 scalar )
974 {
976 
977  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
978 
979  typedef typename DivExprTrait<T1,T2>::Type ReturnType;
980  typedef typename ReturnType::RightOperand ScalarType;
981 
983  return ReturnType( ~vec, ScalarType(1)/ScalarType(scalar) );
984  }
985  else {
986  return ReturnType( ~vec, scalar );
987  }
988 }
989 //*************************************************************************************************
990 
991 
992 
993 
994 //=================================================================================================
995 //
996 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
997 //
998 //=================================================================================================
999 
1000 //*************************************************************************************************
1013 template< typename VT // Type of the dense vector of the left-hand side expression
1014  , typename ST1 // Type of the scalar of the left-hand side expression
1015  , bool TF // Transpose flag of the dense vector
1016  , typename ST2 > // Type of the right-hand side scalar
1017 inline const typename EnableIf< And< IsNumeric<ST2>, IsInvertible<typename DivTrait<ST2,ST1>::Type > >
1018  , typename MultExprTrait< DVecScalarDivExpr<VT,ST1,TF>, ST2 >::Type >::Type
1019  operator*( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1020 {
1022 
1023  return vec.leftOperand() * ( scalar / vec.rightOperand() );
1024 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1042 template< typename ST1 // Type of the left-hand side scalar
1043  , typename VT // Type of the dense vector of the right-hand side expression
1044  , typename ST2 // Type of the scalar of the right-hand side expression
1045  , bool TF > // Transpose flag of the dense vector
1046 inline const typename EnableIf< And< IsNumeric<ST1>, IsInvertible< typename DivTrait<ST1,ST2>::Type > >
1047  , typename MultExprTrait< ST1, DVecScalarDivExpr<VT,ST2,TF> >::Type >::Type
1048  operator*( ST1 scalar, const DVecScalarDivExpr<VT,ST2,TF>& vec )
1049 {
1051 
1052  return vec.leftOperand() * ( scalar / vec.rightOperand() );
1053 }
1055 //*************************************************************************************************
1056 
1057 
1058 //*************************************************************************************************
1071 template< typename VT // Type of the dense vector of the left-hand side expression
1072  , typename ST1 // Type of the scalar of the left-hand side expression
1073  , bool TF // Transpose flag of the dense vector
1074  , typename ST2 > // Type of the right-hand side scalar
1075 inline const typename EnableIf< IsNumeric<ST2>
1076  , typename DivExprTrait<VT,typename MultTrait<ST1,ST2>::Type>::Type >::Type
1077  operator/( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1078 {
1080 
1081  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1082 
1083  typedef typename MultTrait<ST1,ST2>::Type MultType;
1084  typedef typename DivExprTrait<VT,MultType>::Type ReturnType;
1085  typedef typename ReturnType::RightOperand ScalarType;
1086 
1087  if( IsMultExpr<ReturnType>::value ) {
1088  return ReturnType( vec.leftOperand(), ScalarType(1)/( vec.rightOperand() * scalar ) );
1089  }
1090  else {
1091  return ReturnType( vec.leftOperand(), vec.rightOperand() * scalar );
1092  }
1093 }
1095 //*************************************************************************************************
1096 
1097 
1098 
1099 
1100 //=================================================================================================
1101 //
1102 // SIZE SPECIALIZATIONS
1103 //
1104 //=================================================================================================
1105 
1106 //*************************************************************************************************
1108 template< typename VT, typename ST, bool TF >
1109 struct Size< DVecScalarDivExpr<VT,ST,TF> > : public Size<VT>
1110 {};
1112 //*************************************************************************************************
1113 
1114 
1115 
1116 
1117 //=================================================================================================
1118 //
1119 // ISALIGNED SPECIALIZATIONS
1120 //
1121 //=================================================================================================
1122 
1123 //*************************************************************************************************
1125 template< typename VT, typename ST, bool TF >
1126 struct IsAligned< DVecScalarDivExpr<VT,ST,TF> > : public IsTrue< IsAligned<VT>::value >
1127 {};
1129 //*************************************************************************************************
1130 
1131 
1132 
1133 
1134 //=================================================================================================
1135 //
1136 // ISPADDED SPECIALIZATIONS
1137 //
1138 //=================================================================================================
1139 
1140 //*************************************************************************************************
1142 template< typename VT, typename ST, bool TF >
1143 struct IsPadded< DVecScalarDivExpr<VT,ST,TF> > : public IsTrue< IsPadded<VT>::value >
1144 {};
1146 //*************************************************************************************************
1147 
1148 
1149 
1150 
1151 //=================================================================================================
1152 //
1153 // DVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1154 //
1155 //=================================================================================================
1156 
1157 //*************************************************************************************************
1159 template< typename VT, typename ST1, typename ST2 >
1160 struct DVecScalarMultExprTrait< DVecScalarDivExpr<VT,ST1,false>, ST2 >
1161 {
1162  private:
1163  //**********************************************************************************************
1164  typedef typename DivTrait<ST2,ST1>::Type ScalarType;
1165  //**********************************************************************************************
1166 
1167  //**********************************************************************************************
1168  enum { condition = IsInvertible<ScalarType>::value };
1169  //**********************************************************************************************
1170 
1171  //**********************************************************************************************
1172  typedef typename DVecScalarMultExprTrait<VT,ScalarType>::Type T1;
1173  typedef DVecScalarMultExpr< DVecScalarDivExpr<VT,ST1,false>, ST2, false > T2;
1174  //**********************************************************************************************
1175 
1176  public:
1177  //**********************************************************************************************
1178  typedef typename SelectType< IsDenseVector<VT>::value && IsColumnVector<VT>::value &&
1179  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1180  , typename SelectType<condition,T1,T2>::Type
1181  , INVALID_TYPE >::Type Type;
1182  //**********************************************************************************************
1183 };
1185 //*************************************************************************************************
1186 
1187 
1188 
1189 
1190 //=================================================================================================
1191 //
1192 // TDVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1193 //
1194 //=================================================================================================
1195 
1196 //*************************************************************************************************
1198 template< typename VT, typename ST1, typename ST2 >
1199 struct TDVecScalarMultExprTrait< DVecScalarDivExpr<VT,ST1,true>, ST2 >
1200 {
1201  private:
1202  //**********************************************************************************************
1203  typedef typename DivTrait<ST2,ST1>::Type ScalarType;
1204  //**********************************************************************************************
1205 
1206  //**********************************************************************************************
1207  enum { condition = IsInvertible<ScalarType>::value };
1208  //**********************************************************************************************
1209 
1210  //**********************************************************************************************
1211  typedef typename DVecScalarMultExprTrait<VT,ScalarType>::Type T1;
1212  typedef DVecScalarMultExpr< DVecScalarDivExpr<VT,ST1,true>, ST2, true > T2;
1213  //**********************************************************************************************
1214 
1215  public:
1216  //**********************************************************************************************
1217  typedef typename SelectType< IsDenseVector<VT>::value && IsRowVector<VT>::value &&
1218  IsNumeric<ST1>::value && IsNumeric<ST2>::value
1219  , typename SelectType<condition,T1,T2>::Type
1220  , INVALID_TYPE >::Type Type;
1221  //**********************************************************************************************
1222 };
1224 //*************************************************************************************************
1225 
1226 
1227 
1228 
1229 //=================================================================================================
1230 //
1231 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
1232 //
1233 //=================================================================================================
1234 
1235 //*************************************************************************************************
1237 template< typename VT, typename ST, bool TF, bool AF >
1238 struct SubvectorExprTrait< DVecScalarDivExpr<VT,ST,TF>, AF >
1239 {
1240  public:
1241  //**********************************************************************************************
1242  typedef typename DivExprTrait< typename SubvectorExprTrait<const VT,AF>::Type, ST >::Type Type;
1243  //**********************************************************************************************
1244 };
1246 //*************************************************************************************************
1247 
1248 } // namespace blaze
1249 
1250 #endif
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DVecScalarDivExpr.h:592
Pointer difference type of the Blaze library.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Data type constraint.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:89
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DVecScalarDivExpr.h:170
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7820
const EnableIf< IsNumeric< T2 >, typename DivExprTrait< T1, T2 >::Type >::Type operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:962
Header file for basic type definitions.
VT::ReturnType RN
Return type of the dense vector expression.
Definition: DVecScalarDivExpr.h:114
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
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:510
ElementType & ReferenceType
Reference return type.
Definition: DVecScalarDivExpr.h:197
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DVecScalarDivExpr.h:552
RightOperand scalar_
Scalar of the division expression.
Definition: DVecScalarDivExpr.h:425
LeftOperand vector_
Left-hand side dense vector of the division expression.
Definition: DVecScalarDivExpr.h:591
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
Header file for the IsSame and IsStrictlySame type traits.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Header file for the IsRowVector type trait.
Header file for the VecScalarDivExpr base class.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecScalarDivExpr.h:198
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DVecScalarDivExpr.h:217
Header file for the And class template.
Header file for the DenseVector base class.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
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
Header file for the UnderlyingElement type trait.
Header file for the RequiresEvaluation type trait.
Base class for all vector/scalar division expression templates.The VecScalarDivExpr class serves as a...
Definition: VecScalarDivExpr.h:65
DivTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: DVecScalarDivExpr.h:169
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: DVecScalarDivExpr.h:540
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:315
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecScalarDivExpr.h:252
Constraint on the data type.
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecScalarDivExpr.h:194
Header file for the DivExprTrait class template.
Evaluation of the resulting expression type of a division.Via this type trait it is possible to evalu...
Definition: DivExprTrait.h:88
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecScalarDivExpr.h:405
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:359
DifferenceType difference_type
Difference between two iterators.
Definition: DVecScalarDivExpr.h:205
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecScalarDivExpr.h:263
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:261
bool isAligned() const
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecScalarDivExpr.h:574
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
VT::ConstIterator IteratorType
ConstIterator type of the dense vector expression.
Definition: DVecScalarDivExpr.h:208
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 IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
Iterator over the elements of the dense vector.
Definition: DVecScalarDivExpr.h:190
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
ResultType::ElementType ElementType
Resulting element type.
Definition: DVecScalarDivExpr.h:171
ElementType ValueType
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:195
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#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 IsAligned type trait.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DVecScalarDivExpr.h:184
Constraint on the data type.
size_t size() const
Returns the current size/dimension of the vector.
Definition: DVecScalarDivExpr.h:520
#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
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecScalarDivExpr.h:460
VT::CompositeType CT
Composite type of the dense vector expression.
Definition: DVecScalarDivExpr.h:116
Constraint on the data type.
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecScalarDivExpr.h:229
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DVecScalarDivExpr.h:564
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: DVecScalarDivExpr.h:584
IteratorType iterator_
Iterator to the current element.
Definition: DVecScalarDivExpr.h:424
Header file for the SelectType class template.
Header file for all forward declarations for expression class templates.
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecScalarDivExpr.h:473
ValueType value_type
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:202
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
Header file for the serial shim.
Header file for the IsNumeric type trait.
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:1232
LeftOperand leftOperand() const
Returns the left-hand side dense vector operand.
Definition: DVecScalarDivExpr.h:530
PointerType pointer
Pointer return type.
Definition: DVecScalarDivExpr.h:203
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.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:500
DVecScalarDivExpr< VT, ST, TF > This
Type of this DVecScalarDivExpr instance.
Definition: DVecScalarDivExpr.h:168
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:370
Header file for the division trait.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecScalarDivExpr.h:273
IteratorCategory iterator_category
The iterator category.
Definition: DVecScalarDivExpr.h:201
VT::ElementType ET
Element type of the dense vector expression.
Definition: DVecScalarDivExpr.h:115
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:417
IntrinsicTrait< ElementType >::Type IntrinsicType
Resulting intrinsic element type.
Definition: DVecScalarDivExpr.h:172
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t index) const
Access to the intrinsic elements of the vector.
Definition: DVecScalarDivExpr.h:487
Header file for the IsInvertible type trait.
Base template for the DivTrait class.
Definition: DivTrait.h:138
Header file for the IsDenseVector type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is a floating point data type...
Definition: FloatingPoint.h:118
Header file for all intrinsic functionality.
Expression object for divisions of a dense vector by a scalar.The DVecScalarDivExpr class represents ...
Definition: DVecScalarDivExpr.h:107
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecScalarDivExpr.h:241
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DVecScalarDivExpr.h:175
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:393
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecScalarDivExpr.h:294
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
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
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:118
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
IntrinsicType load() const
Access to the intrinsic elements of the vector.
Definition: DVecScalarDivExpr.h:304
ElementType * PointerType
Pointer return type.
Definition: DVecScalarDivExpr.h:196
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:326
Header file for the SubvectorExprTrait class template.
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecScalarDivExpr.h:284
DivExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DVecScalarDivExpr.h:129
Header file for exception macros.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecScalarDivExpr.h:381
Header file for the IsColumnVector type trait.
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:348
DVecScalarDivExpr(const VT &vector, ST scalar)
Constructor for the DVecScalarDivExpr class.
Definition: DVecScalarDivExpr.h:448
SelectType< IsExpression< VT >::value, const VT, const VT & >::Type LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecScalarDivExpr.h:181
System settings for the inline keywords.
EnableIf< IsDenseVector< VT1 > >::Type smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:189
Header file for the Size type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:81
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:337
SelectType< useAssign, const ResultType, const DVecScalarDivExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: DVecScalarDivExpr.h:178
Header file for the IsExpression type trait class.
VT::ResultType RT
Result type of the dense vector expression.
Definition: DVecScalarDivExpr.h:113
ReferenceType reference
Reference return type.
Definition: DVecScalarDivExpr.h:204
Header file for the FunctionTrace class.