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>
44 #include <blaze/math/Aliases.h>
47 #include <blaze/math/Exception.h>
53 #include <blaze/math/SIMD.h>
73 #include <blaze/system/Inline.h>
75 #include <blaze/util/Assert.h>
80 #include <blaze/util/EnableIf.h>
82 #include <blaze/util/InvalidType.h>
84 #include <blaze/util/mpl/And.h>
85 #include <blaze/util/mpl/If.h>
86 #include <blaze/util/mpl/Or.h>
87 #include <blaze/util/Types.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS DVECSCALARDIVEXPR
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
106 template< typename VT // Type of the left-hand side dense vector
107  , typename ST // Type of the right-hand side scalar value
108  , bool TF > // Transpose flag
109 class DVecScalarDivExpr : public DenseVector< DVecScalarDivExpr<VT,ST,TF>, TF >
110  , private VecScalarDivExpr
111  , private Computation
112 {
113  private:
114  //**Type definitions****************************************************************************
115  typedef ResultType_<VT> RT;
116  typedef ReturnType_<VT> RN;
119  //**********************************************************************************************
120 
121  //**Return type evaluation**********************************************************************
123 
128  enum : bool { returnExpr = !IsTemporary<RN>::value };
129 
132  //**********************************************************************************************
133 
134  //**Serial evaluation strategy******************************************************************
136 
142  enum : bool { useAssign = IsComputation<VT>::value && RequiresEvaluation<VT>::value };
143 
145  template< typename VT2 >
147  struct UseAssign {
148  enum : bool { value = useAssign };
149  };
151  //**********************************************************************************************
152 
153  //**Parallel evaluation strategy****************************************************************
155 
161  template< typename VT2 >
162  struct UseSMPAssign {
163  enum : bool { value = ( !VT2::smpAssignable || !VT::smpAssignable ) && useAssign };
164  };
166  //**********************************************************************************************
167 
168  public:
169  //**Type definitions****************************************************************************
174 
177 
180 
182  typedef If_< IsExpression<VT>, const VT, const VT& > LeftOperand;
183 
185  typedef ST RightOperand;
186  //**********************************************************************************************
187 
188  //**ConstIterator class definition**************************************************************
192  {
193  public:
194  //**Type definitions*************************************************************************
195  typedef std::random_access_iterator_tag IteratorCategory;
196  typedef ElementType ValueType;
197  typedef ElementType* PointerType;
198  typedef ElementType& ReferenceType;
200 
201  // STL iterator requirements
202  typedef IteratorCategory iterator_category;
203  typedef ValueType value_type;
204  typedef PointerType pointer;
205  typedef ReferenceType reference;
206  typedef DifferenceType difference_type;
207 
210  //*******************************************************************************************
211 
212  //**Constructor******************************************************************************
218  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
219  : iterator_( iterator ) // Iterator to the current element
220  , scalar_ ( scalar ) // Scalar of the division expression
221  {}
222  //*******************************************************************************************
223 
224  //**Addition assignment operator*************************************************************
230  inline ConstIterator& operator+=( size_t inc ) {
231  iterator_ += inc;
232  return *this;
233  }
234  //*******************************************************************************************
235 
236  //**Subtraction assignment operator**********************************************************
242  inline ConstIterator& operator-=( size_t dec ) {
243  iterator_ -= dec;
244  return *this;
245  }
246  //*******************************************************************************************
247 
248  //**Prefix increment operator****************************************************************
254  ++iterator_;
255  return *this;
256  }
257  //*******************************************************************************************
258 
259  //**Postfix increment operator***************************************************************
264  inline const ConstIterator operator++( int ) {
265  return ConstIterator( iterator_++ );
266  }
267  //*******************************************************************************************
268 
269  //**Prefix decrement operator****************************************************************
275  --iterator_;
276  return *this;
277  }
278  //*******************************************************************************************
279 
280  //**Postfix decrement operator***************************************************************
285  inline const ConstIterator operator--( int ) {
286  return ConstIterator( iterator_-- );
287  }
288  //*******************************************************************************************
289 
290  //**Element access operator******************************************************************
295  inline ReturnType operator*() const {
296  return *iterator_ / scalar_;
297  }
298  //*******************************************************************************************
299 
300  //**Load function****************************************************************************
305  inline auto load() const noexcept {
306  return iterator_.load() / set( scalar_ );
307  }
308  //*******************************************************************************************
309 
310  //**Equality operator************************************************************************
316  inline bool operator==( const ConstIterator& rhs ) const {
317  return iterator_ == rhs.iterator_;
318  }
319  //*******************************************************************************************
320 
321  //**Inequality operator**********************************************************************
327  inline bool operator!=( const ConstIterator& rhs ) const {
328  return iterator_ != rhs.iterator_;
329  }
330  //*******************************************************************************************
331 
332  //**Less-than operator***********************************************************************
338  inline bool operator<( const ConstIterator& rhs ) const {
339  return iterator_ < rhs.iterator_;
340  }
341  //*******************************************************************************************
342 
343  //**Greater-than operator********************************************************************
349  inline bool operator>( const ConstIterator& rhs ) const {
350  return iterator_ > rhs.iterator_;
351  }
352  //*******************************************************************************************
353 
354  //**Less-or-equal-than operator**************************************************************
360  inline bool operator<=( const ConstIterator& rhs ) const {
361  return iterator_ <= rhs.iterator_;
362  }
363  //*******************************************************************************************
364 
365  //**Greater-or-equal-than operator***********************************************************
371  inline bool operator>=( const ConstIterator& rhs ) const {
372  return iterator_ >= rhs.iterator_;
373  }
374  //*******************************************************************************************
375 
376  //**Subtraction operator*********************************************************************
382  inline DifferenceType operator-( const ConstIterator& rhs ) const {
383  return iterator_ - rhs.iterator_;
384  }
385  //*******************************************************************************************
386 
387  //**Addition operator************************************************************************
394  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
395  return ConstIterator( it.iterator_ + inc );
396  }
397  //*******************************************************************************************
398 
399  //**Addition operator************************************************************************
406  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
407  return ConstIterator( it.iterator_ + inc );
408  }
409  //*******************************************************************************************
410 
411  //**Subtraction operator*********************************************************************
418  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
419  return ConstIterator( it.iterator_ - dec );
420  }
421  //*******************************************************************************************
422 
423  private:
424  //**Member variables*************************************************************************
425  IteratorType iterator_;
426  RightOperand scalar_;
427  //*******************************************************************************************
428  };
429  //**********************************************************************************************
430 
431  //**Compilation flags***************************************************************************
433  enum : bool { simdEnabled = VT::simdEnabled &&
436  HasSIMDDiv<UnderlyingElement_<ET>,ST>::value ) };
437 
439  enum : bool { smpAssignable = VT::smpAssignable };
440  //**********************************************************************************************
441 
442  //**SIMD properties*****************************************************************************
444  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
445  //**********************************************************************************************
446 
447  //**Constructor*********************************************************************************
453  explicit inline DVecScalarDivExpr( const VT& vector, ST scalar ) noexcept
454  : vector_( vector ) // Left-hand side dense vector of the division expression
455  , scalar_( scalar ) // Right-hand side scalar of the division expression
456  {}
457  //**********************************************************************************************
458 
459  //**Subscript operator**************************************************************************
465  inline ReturnType operator[]( size_t index ) const {
466  BLAZE_INTERNAL_ASSERT( index < vector_.size(), "Invalid vector access index" );
467  return vector_[index] / scalar_;
468  }
469  //**********************************************************************************************
470 
471  //**At function*********************************************************************************
478  inline ReturnType at( size_t index ) const {
479  if( index >= vector_.size() ) {
480  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
481  }
482  return (*this)[index];
483  }
484  //**********************************************************************************************
485 
486  //**Load function*******************************************************************************
492  BLAZE_ALWAYS_INLINE auto load( size_t index ) const noexcept {
493  BLAZE_INTERNAL_ASSERT( index < vector_.size() , "Invalid vector access index" );
494  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
495  return vector_.load( index ) / set( scalar_ );
496  }
497  //**********************************************************************************************
498 
499  //**Begin function******************************************************************************
504  inline ConstIterator begin() const {
505  return ConstIterator( vector_.begin(), scalar_ );
506  }
507  //**********************************************************************************************
508 
509  //**End function********************************************************************************
514  inline ConstIterator end() const {
515  return ConstIterator( vector_.end(), scalar_ );
516  }
517  //**********************************************************************************************
518 
519  //**Size function*******************************************************************************
524  inline size_t size() const noexcept {
525  return vector_.size();
526  }
527  //**********************************************************************************************
528 
529  //**Left operand access*************************************************************************
534  inline LeftOperand leftOperand() const noexcept {
535  return vector_;
536  }
537  //**********************************************************************************************
538 
539  //**Right operand access************************************************************************
544  inline RightOperand rightOperand() const noexcept {
545  return scalar_;
546  }
547  //**********************************************************************************************
548 
549  //**********************************************************************************************
555  template< typename T >
556  inline bool canAlias( const T* alias ) const noexcept {
557  return IsComputation<VT>::value && vector_.canAlias( alias );
558  }
559  //**********************************************************************************************
560 
561  //**********************************************************************************************
567  template< typename T >
568  inline bool isAliased( const T* alias ) const noexcept {
569  return vector_.isAliased( alias );
570  }
571  //**********************************************************************************************
572 
573  //**********************************************************************************************
578  inline bool isAligned() const noexcept {
579  return vector_.isAligned();
580  }
581  //**********************************************************************************************
582 
583  //**********************************************************************************************
588  inline bool canSMPAssign() const noexcept {
589  return vector_.canSMPAssign() || ( size() > SMP_DVECSCALARMULT_THRESHOLD );
590  }
591  //**********************************************************************************************
592 
593  private:
594  //**Member variables****************************************************************************
595  LeftOperand vector_;
596  RightOperand scalar_;
597  //**********************************************************************************************
598 
599  //**Assignment to dense vectors*****************************************************************
613  template< typename VT2 > // Type of the target dense vector
614  friend inline EnableIf_< UseAssign<VT2> >
615  assign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
616  {
618 
619  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
620 
621  assign( ~lhs, rhs.vector_ );
622  assign( ~lhs, (~lhs) / rhs.scalar_ );
623  }
625  //**********************************************************************************************
626 
627  //**Assignment to sparse vectors****************************************************************
641  template< typename VT2 > // Type of the target sparse vector
642  friend inline EnableIf_< UseAssign<VT2> >
643  assign( SparseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
644  {
646 
647  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
648 
649  assign( ~lhs, rhs.vector_ );
650  (~lhs) /= rhs.scalar_;
651  }
653  //**********************************************************************************************
654 
655  //**Addition assignment to dense vectors********************************************************
669  template< typename VT2 > // Type of the target dense vector
670  friend inline EnableIf_< UseAssign<VT2> >
671  addAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
672  {
674 
677  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
678 
679  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
680 
681  const ResultType tmp( serial( rhs ) );
682  addAssign( ~lhs, tmp );
683  }
685  //**********************************************************************************************
686 
687  //**Addition assignment to sparse vectors*******************************************************
688  // No special implementation for the addition assignment to sparse vectors.
689  //**********************************************************************************************
690 
691  //**Subtraction assignment to dense vectors*****************************************************
705  template< typename VT2 > // Type of the target dense vector
706  friend inline EnableIf_< UseAssign<VT2> >
707  subAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
708  {
710 
713  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
714 
715  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
716 
717  const ResultType tmp( serial( rhs ) );
718  subAssign( ~lhs, tmp );
719  }
721  //**********************************************************************************************
722 
723  //**Subtraction assignment to sparse vectors****************************************************
724  // No special implementation for the subtraction assignment to sparse vectors.
725  //**********************************************************************************************
726 
727  //**Multiplication assignment to dense vectors**************************************************
741  template< typename VT2 > // Type of the target dense vector
742  friend inline EnableIf_< UseAssign<VT2> >
743  multAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
744  {
746 
749  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
750 
751  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
752 
753  const ResultType tmp( serial( rhs ) );
754  multAssign( ~lhs, tmp );
755  }
757  //**********************************************************************************************
758 
759  //**Multiplication assignment to sparse vectors*************************************************
760  // No special implementation for the multiplication assignment to sparse vectors.
761  //**********************************************************************************************
762 
763  //**Division assignment to dense vectors********************************************************
777  template< typename VT2 > // Type of the target dense vector
778  friend inline EnableIf_< UseAssign<VT2> >
779  divAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
780  {
782 
785  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
786 
787  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
788 
789  const ResultType tmp( serial( rhs ) );
790  divAssign( ~lhs, tmp );
791  }
793  //**********************************************************************************************
794 
795  //**Division assignment to sparse vectors*******************************************************
796  // No special implementation for the division assignment to sparse vectors.
797  //**********************************************************************************************
798 
799  //**SMP assignment to dense vectors*************************************************************
813  template< typename VT2 > // Type of the target dense vector
814  friend inline EnableIf_< UseSMPAssign<VT2> >
815  smpAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
816  {
818 
819  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
820 
821  smpAssign( ~lhs, rhs.vector_ );
822  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
823  }
825  //**********************************************************************************************
826 
827  //**SMP assignment to sparse vectors************************************************************
841  template< typename VT2 > // Type of the target sparse vector
842  friend inline EnableIf_< UseSMPAssign<VT2> >
843  smpAssign( SparseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
844  {
846 
847  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
848 
849  smpAssign( ~lhs, rhs.vector_ );
850  (~lhs) /= rhs.scalar_;
851  }
853  //**********************************************************************************************
854 
855  //**SMP addition assignment to dense vectors****************************************************
869  template< typename VT2 > // Type of the target dense vector
870  friend inline EnableIf_< UseSMPAssign<VT2> >
871  smpAddAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
872  {
874 
877  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
878 
879  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
880 
881  const ResultType tmp( rhs );
882  smpAddAssign( ~lhs, tmp );
883  }
885  //**********************************************************************************************
886 
887  //**SMP addition assignment to sparse vectors***************************************************
888  // No special implementation for the SMP addition assignment to sparse vectors.
889  //**********************************************************************************************
890 
891  //**SMP subtraction assignment to dense vectors*************************************************
905  template< typename VT2 > // Type of the target dense vector
906  friend inline EnableIf_< UseSMPAssign<VT2> >
907  smpSubAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
908  {
910 
913  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
914 
915  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
916 
917  const ResultType tmp( rhs );
918  smpSubAssign( ~lhs, tmp );
919  }
921  //**********************************************************************************************
922 
923  //**SMP subtraction assignment to sparse vectors************************************************
924  // No special implementation for the SMP subtraction assignment to sparse vectors.
925  //**********************************************************************************************
926 
927  //**SMP multiplication assignment to dense vectors**********************************************
941  template< typename VT2 > // Type of the target dense vector
942  friend inline EnableIf_< UseSMPAssign<VT2> >
943  smpMultAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
944  {
946 
949  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
950 
951  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
952 
953  const ResultType tmp( rhs );
954  smpMultAssign( ~lhs, tmp );
955  }
957  //**********************************************************************************************
958 
959  //**SMP multiplication assignment to sparse vectors*********************************************
960  // No special implementation for the SMP multiplication assignment to sparse vectors.
961  //**********************************************************************************************
962 
963  //**SMP division assignment to dense vectors****************************************************
977  template< typename VT2 > // Type of the target dense vector
978  friend inline EnableIf_< UseSMPAssign<VT2> >
979  smpDivAssign( DenseVector<VT2,TF>& lhs, const DVecScalarDivExpr& rhs )
980  {
982 
985  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( CompositeType_<ResultType> );
986 
987  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
988 
989  const ResultType tmp( rhs );
990  smpDivAssign( ~lhs, tmp );
991  }
993  //**********************************************************************************************
994 
995  //**SMP division assignment to sparse vectors***************************************************
996  // No special implementation for the SMP division assignment to sparse vectors.
997  //**********************************************************************************************
998 
999  //**Compile time checks*************************************************************************
1006  BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE( ST, RightOperand );
1008  //**********************************************************************************************
1009 };
1010 //*************************************************************************************************
1011 
1012 
1013 
1014 
1015 //=================================================================================================
1016 //
1017 // GLOBAL BINARY ARITHMETIC OPERATORS
1018 //
1019 //=================================================================================================
1020 
1021 //*************************************************************************************************
1045 template< typename T1 // Type of the left-hand side dense vector
1046  , typename T2 // Type of the right-hand side scalar
1047  , bool TF > // Transpose flag
1048 inline const EnableIf_< IsNumeric<T2>, DivExprTrait_<T1,T2> >
1049  operator/( const DenseVector<T1,TF>& vec, T2 scalar )
1050 {
1052 
1053  BLAZE_USER_ASSERT( scalar != T2(0), "Division by zero detected" );
1054 
1056  typedef RightOperand_<ReturnType> ScalarType;
1057 
1059  return ReturnType( ~vec, ScalarType(1)/ScalarType(scalar) );
1060  }
1061  else {
1062  return ReturnType( ~vec, scalar );
1063  }
1064 }
1065 //*************************************************************************************************
1066 
1067 
1068 
1069 
1070 //=================================================================================================
1071 //
1072 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
1073 //
1074 //=================================================================================================
1075 
1076 //*************************************************************************************************
1089 template< typename VT // Type of the dense vector of the left-hand side expression
1090  , typename ST1 // Type of the scalar of the left-hand side expression
1091  , bool TF // Transpose flag of the dense vector
1092  , typename ST2 > // Type of the right-hand side scalar
1093 inline const EnableIf_< And< IsNumeric<ST2>, Or< IsInvertible<ST1>, IsInvertible<ST2> > >
1094  , MultExprTrait_< DVecScalarDivExpr<VT,ST1,TF>, ST2 > >
1095  operator*( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1096 {
1098 
1099  return vec.leftOperand() * ( scalar / vec.rightOperand() );
1100 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1118 template< typename ST1 // Type of the left-hand side scalar
1119  , typename VT // Type of the dense vector of the right-hand side expression
1120  , typename ST2 // Type of the scalar of the right-hand side expression
1121  , bool TF > // Transpose flag of the dense vector
1122 inline const EnableIf_< And< IsNumeric<ST1>, Or< IsInvertible<ST1>, IsInvertible<ST2> > >
1123  , MultExprTrait_< ST1, DVecScalarDivExpr<VT,ST2,TF> > >
1124  operator*( ST1 scalar, const DVecScalarDivExpr<VT,ST2,TF>& vec )
1125 {
1127 
1128  return vec.leftOperand() * ( scalar / vec.rightOperand() );
1129 }
1131 //*************************************************************************************************
1132 
1133 
1134 //*************************************************************************************************
1147 template< typename VT // Type of the dense vector of the left-hand side expression
1148  , typename ST1 // Type of the scalar of the left-hand side expression
1149  , bool TF // Transpose flag of the dense vector
1150  , typename ST2 > // Type of the right-hand side scalar
1151 inline const EnableIf_< IsNumeric<ST2>
1152  , DivExprTrait_< VT, MultTrait_<ST1,ST2> > >
1153  operator/( const DVecScalarDivExpr<VT,ST1,TF>& vec, ST2 scalar )
1154 {
1156 
1157  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1158 
1159  typedef MultTrait_<ST1,ST2> MultType;
1160  typedef DivExprTrait_<VT,MultType> ReturnType;
1161  typedef RightOperand_<ReturnType> ScalarType;
1162 
1163  if( IsMultExpr<ReturnType>::value ) {
1164  return ReturnType( vec.leftOperand(), ScalarType(1)/( vec.rightOperand() * scalar ) );
1165  }
1166  else {
1167  return ReturnType( vec.leftOperand(), vec.rightOperand() * scalar );
1168  }
1169 }
1171 //*************************************************************************************************
1172 
1173 
1174 
1175 
1176 //=================================================================================================
1177 //
1178 // SIZE SPECIALIZATIONS
1179 //
1180 //=================================================================================================
1181 
1182 //*************************************************************************************************
1184 template< typename VT, typename ST, bool TF >
1185 struct Size< DVecScalarDivExpr<VT,ST,TF> > : public Size<VT>
1186 {};
1188 //*************************************************************************************************
1189 
1190 
1191 
1192 
1193 //=================================================================================================
1194 //
1195 // ISALIGNED SPECIALIZATIONS
1196 //
1197 //=================================================================================================
1198 
1199 //*************************************************************************************************
1201 template< typename VT, typename ST, bool TF >
1202 struct IsAligned< DVecScalarDivExpr<VT,ST,TF> >
1203  : public BoolConstant< IsAligned<VT>::value >
1204 {};
1206 //*************************************************************************************************
1207 
1208 
1209 
1210 
1211 //=================================================================================================
1212 //
1213 // ISPADDED SPECIALIZATIONS
1214 //
1215 //=================================================================================================
1216 
1217 //*************************************************************************************************
1219 template< typename VT, typename ST, bool TF >
1220 struct IsPadded< DVecScalarDivExpr<VT,ST,TF> >
1221  : public BoolConstant< IsPadded<VT>::value >
1222 {};
1224 //*************************************************************************************************
1225 
1226 
1227 
1228 
1229 //=================================================================================================
1230 //
1231 // DVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1232 //
1233 //=================================================================================================
1234 
1235 //*************************************************************************************************
1237 template< typename VT, typename ST1, typename ST2 >
1238 struct DVecScalarMultExprTrait< DVecScalarDivExpr<VT,ST1,false>, ST2 >
1239 {
1240  private:
1241  //**********************************************************************************************
1242  typedef DivTrait_<ST2,ST1> ScalarType;
1243  //**********************************************************************************************
1244 
1245  public:
1246  //**********************************************************************************************
1247  using Type = If_< And< IsDenseVector<VT>, IsColumnVector<VT>
1248  , IsNumeric<ST1>, IsNumeric<ST2> >
1249  , If_< IsInvertible<ScalarType>
1250  , DVecScalarMultExprTrait_<VT,ScalarType>
1251  , DVecScalarMultExpr< DVecScalarDivExpr<VT,ST1,false>, ST2, false > >
1252  , INVALID_TYPE >;
1253  //**********************************************************************************************
1254 };
1256 //*************************************************************************************************
1257 
1258 
1259 
1260 
1261 //=================================================================================================
1262 //
1263 // TDVECSCALARMULTEXPRTRAIT SPECIALIZATIONS
1264 //
1265 //=================================================================================================
1266 
1267 //*************************************************************************************************
1269 template< typename VT, typename ST1, typename ST2 >
1270 struct TDVecScalarMultExprTrait< DVecScalarDivExpr<VT,ST1,true>, ST2 >
1271 {
1272  private:
1273  //**********************************************************************************************
1274  typedef DivTrait_<ST2,ST1> ScalarType;
1275  //**********************************************************************************************
1276 
1277  public:
1278  //**********************************************************************************************
1279  using Type = If_< And< IsDenseVector<VT>, IsRowVector<VT>
1280  , IsNumeric<ST1>, IsNumeric<ST2> >
1281  , If_< IsInvertible<ScalarType>
1282  , DVecScalarMultExprTrait_<VT,ScalarType>
1283  , DVecScalarMultExpr< DVecScalarDivExpr<VT,ST1,true>, ST2, true > >
1284  , INVALID_TYPE >;
1285  //**********************************************************************************************
1286 };
1288 //*************************************************************************************************
1289 
1290 
1291 
1292 
1293 //=================================================================================================
1294 //
1295 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
1296 //
1297 //=================================================================================================
1298 
1299 //*************************************************************************************************
1301 template< typename VT, typename ST, bool TF, bool AF >
1302 struct SubvectorExprTrait< DVecScalarDivExpr<VT,ST,TF>, AF >
1303 {
1304  public:
1305  //**********************************************************************************************
1306  using Type = DivExprTrait_< SubvectorExprTrait_<const VT,AF>, ST >;
1307  //**********************************************************************************************
1308 };
1310 //*************************************************************************************************
1311 
1312 } // namespace blaze
1313 
1314 #endif
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DVecScalarDivExpr.h:596
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
Data type constraint.
Compile time check whether the given type is a computational expression template.This type trait clas...
Definition: IsComputation.h:72
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Constraint on the data type.
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecScalarDivExpr.h:172
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:70
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarDivExpr.h:492
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 constant is set to true, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to false, Type is FalseType, and the class derives from FalseType.
Definition: IsMultExpr.h:73
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:514
ElementType & ReferenceType
Reference return type.
Definition: DVecScalarDivExpr.h:198
RightOperand scalar_
Scalar of the division expression.
Definition: DVecScalarDivExpr.h:426
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the serial shim.
LeftOperand vector_
Left-hand side dense vector of the division expression.
Definition: DVecScalarDivExpr.h:595
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecScalarDivExpr.h:578
const IfTrue_< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecScalarDivExpr.h:176
If_< IsExpression< VT >, const VT, const VT & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecScalarDivExpr.h:182
Header file for the IsRowVector type trait.
Header file for the VecScalarDivExpr base class.
EnableIf_< IsDenseVector< VT1 > > 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:193
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecScalarDivExpr.h:199
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DVecScalarDivExpr.h:218
Header file for the And class template.
Header file for the DenseVector base class.
DVecScalarDivExpr(const VT &vector, ST scalar) noexcept
Constructor for the DVecScalarDivExpr class.
Definition: DVecScalarDivExpr.h:453
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
Header file for the Computation base class.
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
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:316
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecScalarDivExpr.h:253
Constraint on the data type.
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:343
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecScalarDivExpr.h:195
Header file for the DivExprTrait class template.
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecScalarDivExpr.h:406
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:360
DifferenceType difference_type
Difference between two iterators.
Definition: DVecScalarDivExpr.h:206
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecScalarDivExpr.h:264
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
IfTrue_< useAssign, const ResultType, const DVecScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecScalarDivExpr.h:179
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
const EnableIf_< IsNumeric< T2 >, DivExprTrait_< T1, T2 > > operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:966
Header file for the IsTemporary type trait class.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecScalarDivExpr.h:568
Header file for the multiplication 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 If class template.
Header file for the IsMultExpr type trait class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
EnableIf_< IsDenseMatrix< MT1 > > 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
Header file for the Or class template.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecScalarDivExpr.h:556
Iterator over the elements of the dense vector.
Definition: DVecScalarDivExpr.h:191
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
ElementType ValueType
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:196
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecScalarDivExpr.h:305
Availability of a SIMD division for the given data types.Depending on the available instruction set (...
Definition: HasSIMDDiv.h:144
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:71
Header file for the IsAligned type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DVecScalarDivExpr.h:544
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DVecScalarDivExpr.h:185
Constraint on the data type.
DivExprTrait_< RN, ST > ExprReturnType
Expression return type for the subscript operator.
Definition: DVecScalarDivExpr.h:131
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:60
ConstIterator_< VT > IteratorType
ConstIterator type of the dense vector expression.
Definition: DVecScalarDivExpr.h:209
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecScalarDivExpr.h:465
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecScalarDivExpr.h:534
ReturnType_< VT > RN
Return type of the dense vector expression.
Definition: DVecScalarDivExpr.h:116
Constraint on the data type.
Header file for the exception macros of the math module.
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecScalarDivExpr.h:230
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecScalarDivExpr.h:588
IteratorType iterator_
Iterator to the current element.
Definition: DVecScalarDivExpr.h:425
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:478
ValueType value_type
Type of the underlying elements.
Definition: DVecScalarDivExpr.h:203
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DVecScalarDivExpr.h:173
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
PointerType pointer
Pointer return type.
Definition: DVecScalarDivExpr.h:204
Header file for run time assertion macros.
Utility type for generic codes.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecScalarDivExpr.h:504
DVecScalarDivExpr< VT, ST, TF > This
Type of this DVecScalarDivExpr instance.
Definition: DVecScalarDivExpr.h:170
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:371
DivTrait_< RT, ST > ResultType
Result type for expression template evaluations.
Definition: DVecScalarDivExpr.h:171
Header file for the division trait.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecScalarDivExpr.h:274
IteratorCategory iterator_category
The iterator category.
Definition: DVecScalarDivExpr.h:202
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:418
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
Header file for the IsInvertible type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
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:81
ElementType_< VT > ET
Element type of the dense vector expression.
Definition: DVecScalarDivExpr.h:117
Expression object for divisions of a dense vector by a scalar.The DVecScalarDivExpr class represents ...
Definition: DVecScalarDivExpr.h:109
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#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:61
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecScalarDivExpr.h:242
Header file for the HasSIMDDiv type trait.
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecScalarDivExpr.h:394
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecScalarDivExpr.h:295
Header file for the IsComputation type trait class.
typename DivExprTrait< T1, T2 >::Type DivExprTrait_
Auxiliary alias declaration for the DivExprTrait class template.The DivExprTrait_ alias declaration p...
Definition: DivExprTrait.h:196
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
Header file for the IntegralConstant class template.
ResultType_< VT > RT
Result type of the dense vector expression.
Definition: DVecScalarDivExpr.h:115
ElementType * PointerType
Pointer return type.
Definition: DVecScalarDivExpr.h:197
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:327
Header file for the SubvectorExprTrait class template.
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecScalarDivExpr.h:285
typename T::RightOperand RightOperand_
Alias declaration for nested RightOperand type definitions.The RightOperand_ alias declaration provid...
Definition: Aliases.h:363
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:403
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecScalarDivExpr.h:382
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecScalarDivExpr.h:524
Header file for the IsColumnVector type trait.
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecScalarDivExpr.h:349
System settings for the inline keywords.
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:63
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:338
CompositeType_< VT > CT
Composite type of the dense vector expression.
Definition: DVecScalarDivExpr.h:118
Header file for the IsExpression type trait class.
ReferenceType reference
Reference return type.
Definition: DVecScalarDivExpr.h:205
Header file for the FunctionTrace class.