Blaze  3.6
DVecDVecMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECDVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECDVECMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
56 #include <blaze/math/SIMD.h>
67 #include <blaze/system/Inline.h>
69 #include <blaze/util/Assert.h>
70 #include <blaze/util/EnableIf.h>
73 #include <blaze/util/mpl/If.h>
74 #include <blaze/util/Types.h>
75 
76 
77 namespace blaze {
78 
79 //=================================================================================================
80 //
81 // CLASS DVECDVECMULTEXPR
82 //
83 //=================================================================================================
84 
85 //*************************************************************************************************
92 template< typename VT1 // Type of the left-hand side dense vector
93  , typename VT2 // Type of the right-hand side dense vector
94  , bool TF > // Transpose flag
96  : public VecVecMultExpr< DenseVector< DVecDVecMultExpr<VT1,VT2,TF>, TF > >
97  , private Computation
98 {
99  private:
100  //**Type definitions****************************************************************************
109  //**********************************************************************************************
110 
111  //**Return type evaluation**********************************************************************
113 
118  static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
119 
121  using ExprReturnType = decltype( std::declval<RN1>() * std::declval<RN2>() );
122  //**********************************************************************************************
123 
124  //**Serial evaluation strategy******************************************************************
126 
132  static constexpr bool useAssign =
133  ( RequiresEvaluation_v<VT1> || RequiresEvaluation_v<VT2> || !returnExpr );
134 
136  template< typename VT >
138  static constexpr bool UseAssign_v = useAssign;
140  //**********************************************************************************************
141 
142  //**Parallel evaluation strategy****************************************************************
144 
150  template< typename VT >
151  static constexpr bool UseSMPAssign_v =
152  ( ( !VT1::smpAssignable || !VT2::smpAssignable ) && useAssign );
154  //**********************************************************************************************
155 
156  public:
157  //**Type definitions****************************************************************************
163 
166 
169 
171  using LeftOperand = If_t< IsExpression_v<VT1>, const VT1, const VT1& >;
172 
174  using RightOperand = If_t< IsExpression_v<VT2>, const VT2, const VT2& >;
175  //**********************************************************************************************
176 
177  //**ConstIterator class definition**************************************************************
181  {
182  public:
183  //**Type definitions*************************************************************************
184  using IteratorCategory = std::random_access_iterator_tag;
189 
190  // STL iterator requirements
196 
199 
202  //*******************************************************************************************
203 
204  //**Constructor******************************************************************************
211  : left_ ( left ) // Iterator to the current left-hand side element
212  , right_( right ) // Iterator to the current right-hand side element
213  {}
214  //*******************************************************************************************
215 
216  //**Addition assignment operator*************************************************************
223  left_ += inc;
224  right_ += inc;
225  return *this;
226  }
227  //*******************************************************************************************
228 
229  //**Subtraction assignment operator**********************************************************
236  left_ -= dec;
237  right_ -= dec;
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Prefix increment operator****************************************************************
248  ++left_;
249  ++right_;
250  return *this;
251  }
252  //*******************************************************************************************
253 
254  //**Postfix increment operator***************************************************************
260  return ConstIterator( left_++, right_++ );
261  }
262  //*******************************************************************************************
263 
264  //**Prefix decrement operator****************************************************************
270  --left_;
271  --right_;
272  return *this;
273  }
274  //*******************************************************************************************
275 
276  //**Postfix decrement operator***************************************************************
282  return ConstIterator( left_--, right_-- );
283  }
284  //*******************************************************************************************
285 
286  //**Element access operator******************************************************************
292  return (*left_) * (*right_);
293  }
294  //*******************************************************************************************
295 
296  //**Load function****************************************************************************
301  inline auto load() const noexcept {
302  return left_.load() * right_.load();
303  }
304  //*******************************************************************************************
305 
306  //**Equality operator************************************************************************
312  inline BLAZE_DEVICE_CALLABLE bool operator==( const ConstIterator& rhs ) const {
313  return left_ == rhs.left_;
314  }
315  //*******************************************************************************************
316 
317  //**Inequality operator**********************************************************************
323  inline BLAZE_DEVICE_CALLABLE bool operator!=( const ConstIterator& rhs ) const {
324  return left_ != rhs.left_;
325  }
326  //*******************************************************************************************
327 
328  //**Less-than operator***********************************************************************
334  inline BLAZE_DEVICE_CALLABLE bool operator<( const ConstIterator& rhs ) const {
335  return left_ < rhs.left_;
336  }
337  //*******************************************************************************************
338 
339  //**Greater-than operator********************************************************************
345  inline BLAZE_DEVICE_CALLABLE bool operator>( const ConstIterator& rhs ) const {
346  return left_ > rhs.left_;
347  }
348  //*******************************************************************************************
349 
350  //**Less-or-equal-than operator**************************************************************
356  inline BLAZE_DEVICE_CALLABLE bool operator<=( const ConstIterator& rhs ) const {
357  return left_ <= rhs.left_;
358  }
359  //*******************************************************************************************
360 
361  //**Greater-or-equal-than operator***********************************************************
367  inline BLAZE_DEVICE_CALLABLE bool operator>=( const ConstIterator& rhs ) const {
368  return left_ >= rhs.left_;
369  }
370  //*******************************************************************************************
371 
372  //**Subtraction operator*********************************************************************
379  return left_ - rhs.left_;
380  }
381  //*******************************************************************************************
382 
383  //**Addition operator************************************************************************
390  friend inline BLAZE_DEVICE_CALLABLE const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
391  return ConstIterator( it.left_ + inc, it.right_ + inc );
392  }
393  //*******************************************************************************************
394 
395  //**Addition operator************************************************************************
402  friend inline BLAZE_DEVICE_CALLABLE const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
403  return ConstIterator( it.left_ + inc, it.right_ + inc );
404  }
405  //*******************************************************************************************
406 
407  //**Subtraction operator*********************************************************************
414  friend inline BLAZE_DEVICE_CALLABLE const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
415  return ConstIterator( it.left_ - dec, it.right_ - dec );
416  }
417  //*******************************************************************************************
418 
419  private:
420  //**Member variables*************************************************************************
423  //*******************************************************************************************
424  };
425  //**********************************************************************************************
426 
427  //**Compilation flags***************************************************************************
429  static constexpr bool simdEnabled =
430  ( VT1::simdEnabled && VT2::simdEnabled && HasSIMDMult_v<ET1,ET2> );
431 
433  static constexpr bool smpAssignable = ( VT1::smpAssignable && VT2::smpAssignable );
434  //**********************************************************************************************
435 
436  //**SIMD properties*****************************************************************************
438  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
439  //**********************************************************************************************
440 
441  //**Constructor*********************************************************************************
447  explicit inline DVecDVecMultExpr( const VT1& lhs, const VT2& rhs ) noexcept
448  : lhs_( lhs ) // Left-hand side dense vector of the multiplication expression
449  , rhs_( rhs ) // Right-hand side dense vector of the multiplication expression
450  {
451  BLAZE_INTERNAL_ASSERT( lhs.size() == rhs.size(), "Invalid vector sizes" );
452  }
453  //**********************************************************************************************
454 
455  //**Subscript operator**************************************************************************
461  inline ReturnType operator[]( size_t index ) const {
462  BLAZE_INTERNAL_ASSERT( index < lhs_.size(), "Invalid vector access index" );
463  return lhs_[index] * rhs_[index];
464  }
465  //**********************************************************************************************
466 
467  //**At function*********************************************************************************
474  inline ReturnType at( size_t index ) const {
475  if( index >= lhs_.size() ) {
476  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
477  }
478  return (*this)[index];
479  }
480  //**********************************************************************************************
481 
482  //**Load function*******************************************************************************
488  BLAZE_ALWAYS_INLINE auto load( size_t index ) const noexcept {
489  BLAZE_INTERNAL_ASSERT( index < lhs_.size() , "Invalid vector access index" );
490  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
491  return lhs_.load( index ) * rhs_.load( index );
492  }
493  //**********************************************************************************************
494 
495  //**Begin function******************************************************************************
500  inline ConstIterator begin() const {
501  return ConstIterator( lhs_.begin(), rhs_.begin() );
502  }
503  //**********************************************************************************************
504 
505  //**End function********************************************************************************
510  inline ConstIterator end() const {
511  return ConstIterator( lhs_.end(), rhs_.end() );
512  }
513  //**********************************************************************************************
514 
515  //**Size function*******************************************************************************
520  inline size_t size() const noexcept {
521  return lhs_.size();
522  }
523  //**********************************************************************************************
524 
525  //**Left operand access*************************************************************************
530  inline LeftOperand leftOperand() const noexcept {
531  return lhs_;
532  }
533  //**********************************************************************************************
534 
535  //**Right operand access************************************************************************
540  inline RightOperand rightOperand() const noexcept {
541  return rhs_;
542  }
543  //**********************************************************************************************
544 
545  //**********************************************************************************************
551  template< typename T >
552  inline bool canAlias( const T* alias ) const noexcept {
553  return ( IsExpression_v<VT1> && ( RequiresEvaluation_v<VT1> ? lhs_.isAliased( alias ) : lhs_.canAlias( alias ) ) ) ||
554  ( IsExpression_v<VT2> && ( RequiresEvaluation_v<VT2> ? rhs_.isAliased( alias ) : rhs_.canAlias( alias ) ) );
555  }
556  //**********************************************************************************************
557 
558  //**********************************************************************************************
564  template< typename T >
565  inline bool isAliased( const T* alias ) const noexcept {
566  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
567  }
568  //**********************************************************************************************
569 
570  //**********************************************************************************************
575  inline bool isAligned() const noexcept {
576  return lhs_.isAligned() && rhs_.isAligned();
577  }
578  //**********************************************************************************************
579 
580  //**********************************************************************************************
585  inline bool canSMPAssign() const noexcept {
586  return lhs_.canSMPAssign() || rhs_.canSMPAssign() ||
587  ( size() > SMP_DVECDVECMULT_THRESHOLD );
588  }
589  //**********************************************************************************************
590 
591  private:
592  //**Member variables****************************************************************************
595  //**********************************************************************************************
596 
597  //**Assignment to dense vectors*****************************************************************
612  template< typename VT > // Type of the target dense vector
613  friend inline auto assign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
614  -> EnableIf_t< UseAssign_v<VT> && !IsCommutative_v<VT1,VT2> >
615  {
617 
618  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
619 
620  if( !IsComputation_v<VT1> && isSame( ~lhs, rhs.lhs_ ) ) {
621  multAssign( ~lhs, rhs.rhs_ );
622  }
623  else {
624  CT1 a( serial( rhs.lhs_ ) );
625  CT2 b( serial( rhs.rhs_ ) );
626  assign( ~lhs, a * b );
627  }
628  }
630  //**********************************************************************************************
631 
632  //**Assignment to dense vectors*****************************************************************
646  template< typename VT > // Type of the target dense vector
647  friend inline auto assign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
648  -> EnableIf_t< UseAssign_v<VT> && IsCommutative_v<VT1,VT2> >
649  {
651 
652  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
653 
654  if( !IsComputation_v<VT1> && isSame( ~lhs, rhs.lhs_ ) ) {
655  multAssign( ~lhs, rhs.rhs_ );
656  }
657  else if( !IsComputation_v<VT2> && isSame( ~lhs, rhs.rhs_ ) ) {
658  multAssign( ~lhs, rhs.lhs_ );
659  }
660  else if( !RequiresEvaluation_v<VT2> ) {
661  assign ( ~lhs, rhs.rhs_ );
662  multAssign( ~lhs, rhs.lhs_ );
663  }
664  else {
665  assign ( ~lhs, rhs.lhs_ );
666  multAssign( ~lhs, rhs.rhs_ );
667  }
668  }
670  //**********************************************************************************************
671 
672  //**Assignment to sparse vectors****************************************************************
686  template< typename VT > // Type of the target sparse vector
687  friend inline auto assign( SparseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
688  -> EnableIf_t< UseAssign_v<VT> >
689  {
691 
695 
696  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
697 
698  const ResultType tmp( serial( rhs ) );
699  assign( ~lhs, tmp );
700  }
702  //**********************************************************************************************
703 
704  //**Addition assignment to dense vectors********************************************************
718  template< typename VT > // Type of the target dense vector
719  friend inline auto addAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
720  -> EnableIf_t< UseAssign_v<VT> >
721  {
723 
727 
728  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
729 
730  const ResultType tmp( serial( rhs ) );
731  addAssign( ~lhs, tmp );
732  }
734  //**********************************************************************************************
735 
736  //**Addition assignment to sparse vectors*******************************************************
737  // No special implementation for the addition assignment to sparse vectors.
738  //**********************************************************************************************
739 
740  //**Subtraction assignment to dense vectors*****************************************************
754  template< typename VT > // Type of the target dense vector
755  friend inline auto subAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
756  -> EnableIf_t< UseAssign_v<VT> >
757  {
759 
763 
764  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
765 
766  const ResultType tmp( serial( rhs ) );
767  subAssign( ~lhs, tmp );
768  }
770  //**********************************************************************************************
771 
772  //**Subtraction assignment to sparse vectors****************************************************
773  // No special implementation for the subtraction assignment to sparse vectors.
774  //**********************************************************************************************
775 
776  //**Multiplication assignment to dense vectors**************************************************
791  template< typename VT > // Type of the target dense vector
792  friend inline auto multAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
793  -> EnableIf_t< UseAssign_v<VT> && !IsCommutative_v<VT1,VT2> >
794  {
796 
800 
801  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
802 
803  const ResultType tmp( serial( rhs ) );
804  multAssign( ~lhs, tmp );
805  }
807  //**********************************************************************************************
808 
809  //**Multiplication assignment to dense vectors**************************************************
824  template< typename VT > // Type of the target dense vector
825  friend inline auto multAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
826  -> EnableIf_t< UseAssign_v<VT> && IsCommutative_v<VT1,VT2> >
827  {
829 
830  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
831 
832  if( !RequiresEvaluation_v<VT2> ) {
833  multAssign( ~lhs, rhs.rhs_ );
834  multAssign( ~lhs, rhs.lhs_ );
835  }
836  else {
837  multAssign( ~lhs, rhs.lhs_ );
838  multAssign( ~lhs, rhs.rhs_ );
839  }
840  }
842  //**********************************************************************************************
843 
844  //**Multiplication assignment to sparse vectors*************************************************
845  // No special implementation for the multiplication assignment to sparse vectors.
846  //**********************************************************************************************
847 
848  //**Division assignment to dense vectors********************************************************
862  template< typename VT > // Type of the target dense vector
863  friend inline auto divAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
864  -> EnableIf_t< UseAssign_v<VT> >
865  {
867 
871 
872  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
873 
874  const ResultType tmp( serial( rhs ) );
875  divAssign( ~lhs, tmp );
876  }
878  //**********************************************************************************************
879 
880  //**Division assignment to sparse vectors*******************************************************
881  // No special implementation for the division assignment to sparse vectors.
882  //**********************************************************************************************
883 
884  //**SMP assignment to dense vectors*************************************************************
899  template< typename VT > // Type of the target dense vector
900  friend inline auto smpAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
901  -> EnableIf_t< UseSMPAssign_v<VT> && !IsCommutative_v<VT1,VT2> >
902  {
904 
905  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
906 
907  if( !IsComputation_v<VT1> && isSame( ~lhs, rhs.lhs_ ) ) {
908  multAssign( ~lhs, rhs.rhs_ );
909  }
910  else {
911  CT1 a( rhs.lhs_ );
912  CT2 b( rhs.rhs_ );
913  smpAssign( ~lhs, a * b );
914  }
915  }
917  //**********************************************************************************************
918 
919  //**SMP assignment to dense vectors*************************************************************
934  template< typename VT > // Type of the target dense vector
935  friend inline auto smpAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
936  -> EnableIf_t< UseSMPAssign_v<VT> && IsCommutative_v<VT1,VT2> >
937  {
939 
940  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
941 
942  if( !IsComputation_v<VT1> && isSame( ~lhs, rhs.lhs_ ) ) {
943  smpMultAssign( ~lhs, rhs.rhs_ );
944  }
945  else if( !IsComputation_v<VT2> && isSame( ~lhs, rhs.rhs_ ) ) {
946  smpMultAssign( ~lhs, rhs.lhs_ );
947  }
948  else if( !RequiresEvaluation_v<VT2> ) {
949  smpAssign ( ~lhs, rhs.rhs_ );
950  smpMultAssign( ~lhs, rhs.lhs_ );
951  }
952  else {
953  smpAssign ( ~lhs, rhs.lhs_ );
954  smpMultAssign( ~lhs, rhs.rhs_ );
955  }
956  }
958  //**********************************************************************************************
959 
960  //**SMP assignment to sparse vectors************************************************************
974  template< typename VT > // Type of the target sparse vector
975  friend inline auto smpAssign( SparseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
976  -> EnableIf_t< UseSMPAssign_v<VT> >
977  {
979 
983 
984  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
985 
986  const ResultType tmp( rhs );
987  smpAssign( ~lhs, tmp );
988  }
990  //**********************************************************************************************
991 
992  //**SMP addition assignment to dense vectors****************************************************
1006  template< typename VT > // Type of the target dense vector
1007  friend inline auto smpAddAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
1008  -> EnableIf_t< UseSMPAssign_v<VT> >
1009  {
1011 
1015 
1016  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1017 
1018  const ResultType tmp( rhs );
1019  smpAddAssign( ~lhs, tmp );
1020  }
1022  //**********************************************************************************************
1023 
1024  //**SMP addition assignment to sparse vectors***************************************************
1025  // No special implementation for the SMP addition assignment to sparse vectors.
1026  //**********************************************************************************************
1027 
1028  //**SMP subtraction assignment to dense vectors*************************************************
1043  template< typename VT > // Type of the target dense vector
1044  friend inline auto smpSubAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
1045  -> EnableIf_t< UseSMPAssign_v<VT> >
1046  {
1048 
1052 
1053  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1054 
1055  const ResultType tmp( rhs );
1056  smpSubAssign( ~lhs, tmp );
1057  }
1059  //**********************************************************************************************
1060 
1061  //**SMP subtraction assignment to sparse vectors************************************************
1062  // No special implementation for the SMP subtraction assignment to sparse vectors.
1063  //**********************************************************************************************
1064 
1065  //**SMP multiplication assignment to dense vectors**********************************************
1080  template< typename VT > // Type of the target dense vector
1081  friend inline auto smpMultAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
1082  -> EnableIf_t< UseSMPAssign_v<VT> && !IsCommutative_v<VT1,VT2> >
1083  {
1085 
1089 
1090  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1091 
1092  const ResultType tmp( rhs );
1093  smpMultAssign( ~lhs, tmp );
1094  }
1096  //**********************************************************************************************
1097 
1098  //**SMP multiplication assignment to dense vectors**********************************************
1113  template< typename VT > // Type of the target dense vector
1114  friend inline auto smpMultAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
1115  -> EnableIf_t< UseSMPAssign_v<VT> && IsCommutative_v<VT1,VT2> >
1116  {
1118 
1119  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1120 
1121  if( !RequiresEvaluation_v<VT2> ) {
1122  smpMultAssign( ~lhs, rhs.rhs_ );
1123  smpMultAssign( ~lhs, rhs.lhs_ );
1124  }
1125  else {
1126  smpMultAssign( ~lhs, rhs.lhs_ );
1127  smpMultAssign( ~lhs, rhs.rhs_ );
1128  }
1129  }
1131  //**********************************************************************************************
1132 
1133  //**SMP multiplication assignment to sparse vectors*********************************************
1134  // No special implementation for the SMP multiplication assignment to sparse vectors.
1135  //**********************************************************************************************
1136 
1137  //**SMP division assignment to dense vectors****************************************************
1151  template< typename VT > // Type of the target dense vector
1152  friend inline auto smpDivAssign( DenseVector<VT,TF>& lhs, const DVecDVecMultExpr& rhs )
1153  -> EnableIf_t< UseSMPAssign_v<VT> >
1154  {
1156 
1160 
1161  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1162 
1163  const ResultType tmp( rhs );
1164  smpDivAssign( ~lhs, tmp );
1165  }
1167  //**********************************************************************************************
1168 
1169  //**SMP division assignment to sparse vectors***************************************************
1170  // No special implementation for the SMP division assignment to sparse vectors.
1171  //**********************************************************************************************
1172 
1173  //**Compile time checks*************************************************************************
1181  //**********************************************************************************************
1182 };
1183 //*************************************************************************************************
1184 
1185 
1186 
1187 
1188 //=================================================================================================
1189 //
1190 // GLOBAL BINARY ARITHMETIC OPERATORS
1191 //
1192 //=================================================================================================
1193 
1194 //*************************************************************************************************
1219 template< typename VT1 // Type of the left-hand side dense vector
1220  , typename VT2 // Type of the right-hand side dense vector
1221  , bool TF > // Transpose flag
1222 inline decltype(auto)
1223  operator*( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1224 {
1226 
1227  if( (~lhs).size() != (~rhs).size() ) {
1228  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1229  }
1230 
1231  using ReturnType = const DVecDVecMultExpr<VT1,VT2,TF>;
1232  return ReturnType( ~lhs, ~rhs );
1233 }
1234 //*************************************************************************************************
1235 
1236 
1237 
1238 
1239 //=================================================================================================
1240 //
1241 // ISALIGNED SPECIALIZATIONS
1242 //
1243 //=================================================================================================
1244 
1245 //*************************************************************************************************
1247 template< typename VT1, typename VT2, bool TF >
1248 struct IsAligned< DVecDVecMultExpr<VT1,VT2,TF> >
1249  : public BoolConstant< IsAligned_v<VT1> && IsAligned_v<VT2> >
1250 {};
1252 //*************************************************************************************************
1253 
1254 
1255 
1256 
1257 //=================================================================================================
1258 //
1259 // ISPADDED SPECIALIZATIONS
1260 //
1261 //=================================================================================================
1262 
1263 //*************************************************************************************************
1265 template< typename VT1, typename VT2, bool TF >
1266 struct IsPadded< DVecDVecMultExpr<VT1,VT2,TF> >
1267  : public BoolConstant< IsPadded_v<VT1> && IsPadded_v<VT2> >
1268 {};
1270 //*************************************************************************************************
1271 
1272 } // namespace blaze
1273 
1274 #endif
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecMultExpr.h:422
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Pointer difference type of the Blaze library.
BLAZE_DEVICE_CALLABLE ReturnType operator *() const
Direct access to the element at the current iterator position.
Definition: DVecDVecMultExpr.h:291
Header file for auxiliary alias declarations.
ConstIterator_t< VT1 > LeftIteratorType
ConstIterator type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:198
CompositeType_t< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:105
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecMultExpr.h:530
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:356
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:312
ResultType_t< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:102
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecMultExpr.h:161
Iterator over the elements of the dense vector.
Definition: DVecDVecMultExpr.h:180
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the IsCommutative type trait.
Header file for the serial shim.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecMultExpr.h:552
LeftOperand lhs_
Left-hand side dense vector of the multiplication expression.
Definition: DVecDVecMultExpr.h:593
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecDVecMultExpr.h:429
ElementType * PointerType
Pointer return type.
Definition: DVecDVecMultExpr.h:186
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecMultExpr.h:474
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DVecDVecMultExpr.h:121
Header file for the DenseVector base class.
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecMultExpr.h:421
ReturnType_t< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:103
If_t< IsExpression_v< VT1 >, const VT1, const VT1 & > LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:171
Header file for the Computation base class.
PointerType pointer
Pointer return type.
Definition: DVecDVecMultExpr.h:193
Header file for the RequiresEvaluation type trait.
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecMultExpr.h:402
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
If_t< useAssign, const ResultType, const DVecDVecMultExpr & > CompositeType
Data type for composite expression templates.
Definition: DVecDVecMultExpr.h:168
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:220
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecMultExpr.h:235
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecMultExpr.h:185
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecMultExpr.h:500
CompositeType_t< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:106
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
ReturnType_t< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:104
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecMultExpr.h:222
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecDVecMultExpr.h:575
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecMultExpr.h:585
#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_t< ResultType > ElementType
Resulting element type.
Definition: DVecDVecMultExpr.h:162
Header file for all SIMD functionality.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: DVecDVecMultExpr.h:540
Header file for the IsAligned type trait.
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMultExpr.h:301
Constraint on the data type.
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecMultExpr.h:259
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:367
Header file for the VecVecMultExpr base class.
ResultType_t< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:101
Constraint on the data type.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecDVecMultExpr.h:461
Expression object for dense vector-dense vector multiplications.The DVecDVecMultExpr class represents...
Definition: DVecDVecMultExpr.h:95
ConstIterator_t< VT2 > RightIteratorType
ConstIterator type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:201
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ReferenceType reference
Reference return type.
Definition: DVecDVecMultExpr.h:194
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecDVecMultExpr.h:520
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecMultExpr.h:187
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.The MultTrait_t alias declaration provid...
Definition: MultTrait.h:240
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecDVecMultExpr.h:565
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMultExpr.h:488
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecMultExpr.h:378
ElementType_t< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:108
Header file for the HasSIMDMult type trait.
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecDVecMultExpr.h:438
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DVecDVecMultExpr.h:118
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for all forward declarations for expression class templates.
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecMultExpr.h:414
DVecDVecMultExpr(const VT1 &lhs, const VT2 &rhs) noexcept
Constructor for the DVecDVecMultExpr class.
Definition: DVecDVecMultExpr.h:447
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecMultExpr.h:184
If_t< IsExpression_v< VT2 >, const VT2, const VT2 & > RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:174
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant alias template represents ...
Definition: IntegralConstant.h:110
BLAZE_DEVICE_CALLABLE ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DVecDVecMultExpr.h:210
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecMultExpr.h:269
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecDVecMultExpr.h:510
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecMultExpr.h:390
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecMultExpr.h:191
#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
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DVecDVecMultExpr.h:165
ElementType_t< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecMultExpr.h:107
Macro for CUDA compatibility.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_VECVECMULTEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid vector/vector ...
Definition: VecVecMultExpr.h:104
Header file for the IsComputation type trait class.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecDVecMultExpr.h:188
Header file for the IntegralConstant class template.
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecDVecMultExpr.h:433
RightOperand rhs_
Right-hand side dense vector of the multiplication expression.
Definition: DVecDVecMultExpr.h:594
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:323
MultTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DVecDVecMultExpr.h:160
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition: DVecDVecMultExpr.h:132
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecMultExpr.h:247
System settings for the inline keywords.
ValueType value_type
Type of the underlying elements.
Definition: DVecDVecMultExpr.h:192
#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.
Base class for all vector/vector multiplication expression templates.The VecVecMultExpr class serves ...
Definition: VecVecMultExpr.h:66
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition: DenseVector.h:191
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:334
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecMultExpr.h:281
Header file for the IsExpression type trait class.
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMultExpr.h:345
Header file for the function trace functionality.