DVecDVecMapExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECDVECMAPEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECDVECMAPEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
57 #include <blaze/math/SIMD.h>
64 #include <blaze/system/Inline.h>
65 #include <blaze/util/Assert.h>
66 #include <blaze/util/EnableIf.h>
69 #include <blaze/util/mpl/And.h>
70 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/mpl/Maximum.h>
72 #include <blaze/util/Template.h>
73 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS DVECDVECMAPEXPR
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
93 template< typename VT1 // Type of the left-hand side dense vector
94  , typename VT2 // Type of the right-hand side dense vector
95  , typename OP // Type of the custom operation
96  , bool TF > // Transpose flag
98  : public VecVecMapExpr< DenseVector< DVecDVecMapExpr<VT1,VT2,OP,TF>, TF > >
99  , private Computation
100 {
101  private:
102  //**Type definitions****************************************************************************
111 
113  BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( HasSIMDEnabled, simdEnabled );
114 
117  //**********************************************************************************************
118 
119  //**Serial evaluation strategy******************************************************************
121 
127  enum : bool { useAssign = ( RequiresEvaluation<VT1>::value || RequiresEvaluation<VT2>::value ) };
128 
130  template< typename VT >
132  struct UseAssign {
133  enum : bool { value = useAssign };
134  };
136  //**********************************************************************************************
137 
138  //**Parallel evaluation strategy****************************************************************
140 
146  template< typename VT >
147  struct UseSMPAssign {
148  enum : bool { value = ( !VT1::smpAssignable || !VT2::smpAssignable ) && useAssign };
149  };
151  //**********************************************************************************************
152 
153  //**SIMD support detection**********************************************************************
155  struct UseSIMDEnabledFlag {
157  enum : bool { value = OP::BLAZE_TEMPLATE simdEnabled<ET1,ET2>() };
158  };
160  //**********************************************************************************************
161 
162  public:
163  //**Type definitions****************************************************************************
168 
170  using ReturnType = decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
171 
174 
176  using LeftOperand = If_< IsExpression<VT1>, const VT1, const VT1& >;
177 
179  using RightOperand = If_< IsExpression<VT2>, const VT2, const VT2& >;
180 
182  using Operation = OP;
183 
186 
189  //**********************************************************************************************
190 
191  //**ConstIterator class definition**************************************************************
195  {
196  public:
197  //**Type definitions*************************************************************************
198  using IteratorCategory = std::random_access_iterator_tag;
203 
204  // STL iterator requirements
210 
213 
216  //*******************************************************************************************
217 
218  //**Constructor******************************************************************************
225  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right, OP op )
226  : left_ ( left ) // Iterator to the current left-hand side element
227  , right_( right ) // Iterator to the current right-hand side element
228  , op_ ( op ) // The custom unary operation
229  {}
230  //*******************************************************************************************
231 
232  //**Addition assignment operator*************************************************************
238  inline ConstIterator& operator+=( size_t inc ) {
239  left_ += inc;
240  right_ += inc;
241  return *this;
242  }
243  //*******************************************************************************************
244 
245  //**Subtraction assignment operator**********************************************************
251  inline ConstIterator& operator-=( size_t dec ) {
252  left_ -= dec;
253  right_ -= dec;
254  return *this;
255  }
256  //*******************************************************************************************
257 
258  //**Prefix increment operator****************************************************************
264  ++left_;
265  ++right_;
266  return *this;
267  }
268  //*******************************************************************************************
269 
270  //**Postfix increment operator***************************************************************
275  inline const ConstIterator operator++( int ) {
276  return ConstIterator( left_++, right_++, op_ );
277  }
278  //*******************************************************************************************
279 
280  //**Prefix decrement operator****************************************************************
286  --left_;
287  --right_;
288  return *this;
289  }
290  //*******************************************************************************************
291 
292  //**Postfix decrement operator***************************************************************
297  inline const ConstIterator operator--( int ) {
298  return ConstIterator( left_--, right_--, op_ );
299  }
300  //*******************************************************************************************
301 
302  //**Element access operator******************************************************************
307  inline ReturnType operator*() const {
308  return op_( *left_, *right_ );
309  }
310  //*******************************************************************************************
311 
312  //**Load function****************************************************************************
317  inline auto load() const noexcept {
318  return op_.load( left_.load(), right_.load() );
319  }
320  //*******************************************************************************************
321 
322  //**Equality operator************************************************************************
328  inline bool operator==( const ConstIterator& rhs ) const {
329  return left_ == rhs.left_;
330  }
331  //*******************************************************************************************
332 
333  //**Inequality operator**********************************************************************
339  inline bool operator!=( const ConstIterator& rhs ) const {
340  return left_ != rhs.left_;
341  }
342  //*******************************************************************************************
343 
344  //**Less-than operator***********************************************************************
350  inline bool operator<( const ConstIterator& rhs ) const {
351  return left_ < rhs.left_;
352  }
353  //*******************************************************************************************
354 
355  //**Greater-than operator********************************************************************
361  inline bool operator>( const ConstIterator& rhs ) const {
362  return left_ > rhs.left_;
363  }
364  //*******************************************************************************************
365 
366  //**Less-or-equal-than operator**************************************************************
372  inline bool operator<=( const ConstIterator& rhs ) const {
373  return left_ <= rhs.left_;
374  }
375  //*******************************************************************************************
376 
377  //**Greater-or-equal-than operator***********************************************************
383  inline bool operator>=( const ConstIterator& rhs ) const {
384  return left_ >= rhs.left_;
385  }
386  //*******************************************************************************************
387 
388  //**Subtraction operator*********************************************************************
394  inline DifferenceType operator-( const ConstIterator& rhs ) const {
395  return left_ - rhs.left_;
396  }
397  //*******************************************************************************************
398 
399  //**Addition operator************************************************************************
406  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
407  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
408  }
409  //*******************************************************************************************
410 
411  //**Addition operator************************************************************************
418  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
419  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
420  }
421  //*******************************************************************************************
422 
423  //**Subtraction operator*********************************************************************
430  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
431  return ConstIterator( it.left_ - dec, it.right_ - dec, it.op_ );
432  }
433  //*******************************************************************************************
434 
435  private:
436  //**Member variables*************************************************************************
439  OP op_;
440  //*******************************************************************************************
441  };
442  //**********************************************************************************************
443 
444  //**Compilation flags***************************************************************************
446  enum : bool { simdEnabled = VT1::simdEnabled && VT2::simdEnabled &&
447  If_< HasSIMDEnabled<OP>, UseSIMDEnabledFlag, HasLoad<OP> >::value };
448 
450  enum : bool { smpAssignable = VT1::smpAssignable && VT2::smpAssignable };
451  //**********************************************************************************************
452 
453  //**SIMD properties*****************************************************************************
455  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
456  //**********************************************************************************************
457 
458  //**Constructor*********************************************************************************
465  explicit inline DVecDVecMapExpr( const VT1& lhs, const VT2& rhs, OP op ) noexcept
466  : lhs_( lhs ) // Left-hand side dense vector of the map expression
467  , rhs_( rhs ) // Right-hand side dense vector of the map expression
468  , op_ ( op ) // The custom unary operation
469  {}
470  //**********************************************************************************************
471 
472  //**Subscript operator**************************************************************************
478  inline ReturnType operator[]( size_t index ) const {
479  BLAZE_INTERNAL_ASSERT( index < lhs_.size(), "Invalid vector access index" );
480  return op_( lhs_[index], rhs_[index] );
481  }
482  //**********************************************************************************************
483 
484  //**At function*********************************************************************************
491  inline ReturnType at( size_t index ) const {
492  if( index >= lhs_.size() ) {
493  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
494  }
495  return (*this)[index];
496  }
497  //**********************************************************************************************
498 
499  //**Load function*******************************************************************************
505  BLAZE_ALWAYS_INLINE auto load( size_t index ) const noexcept {
506  BLAZE_INTERNAL_ASSERT( index < lhs_.size() , "Invalid vector access index" );
507  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
508  return op_.load( lhs_.load( index ), rhs_.load( index ) );
509  }
510  //**********************************************************************************************
511 
512  //**Begin function******************************************************************************
517  inline ConstIterator begin() const {
518  return ConstIterator( lhs_.begin(), rhs_.begin(), op_ );
519  }
520  //**********************************************************************************************
521 
522  //**End function********************************************************************************
527  inline ConstIterator end() const {
528  return ConstIterator( lhs_.end(), rhs_.end(), op_ );
529  }
530  //**********************************************************************************************
531 
532  //**Size function*******************************************************************************
537  inline size_t size() const noexcept {
538  return lhs_.size();
539  }
540  //**********************************************************************************************
541 
542  //**Left operand access*************************************************************************
547  inline LeftOperand leftOperand() const noexcept {
548  return lhs_;
549  }
550  //**********************************************************************************************
551 
552  //**Right operand access************************************************************************
557  inline RightOperand rightOperand() const noexcept {
558  return rhs_;
559  }
560  //**********************************************************************************************
561 
562  //**Operation access****************************************************************************
567  inline Operation operation() const {
568  return op_;
569  }
570  //**********************************************************************************************
571 
572  //**********************************************************************************************
578  template< typename T >
579  inline bool canAlias( const T* alias ) const noexcept {
580  return ( IsExpression<VT1>::value && lhs_.canAlias( alias ) ) ||
581  ( IsExpression<VT2>::value && rhs_.canAlias( alias ) );
582  }
583  //**********************************************************************************************
584 
585  //**********************************************************************************************
591  template< typename T >
592  inline bool isAliased( const T* alias ) const noexcept {
593  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
594  }
595  //**********************************************************************************************
596 
597  //**********************************************************************************************
602  inline bool isAligned() const noexcept {
603  return lhs_.isAligned() && rhs_.isAligned();
604  }
605  //**********************************************************************************************
606 
607  //**********************************************************************************************
612  inline bool canSMPAssign() const noexcept {
613  return lhs_.canSMPAssign() && rhs_.canSMPAssign();
614  }
615  //**********************************************************************************************
616 
617  private:
618  //**Member variables****************************************************************************
622  //**********************************************************************************************
623 
624  //**Assignment to dense vectors*****************************************************************
638  template< typename VT > // Type of the target dense vector
639  friend inline EnableIf_< UseAssign<VT> >
640  assign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
641  {
643 
644  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
645 
646  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
647  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
648 
649  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
650  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
651 
652  assign( ~lhs, map( x, y, rhs.op_ ) );
653  }
655  //**********************************************************************************************
656 
657  //**Assignment to sparse vectors****************************************************************
671  template< typename VT > // Type of the target sparse vector
672  friend inline EnableIf_< UseAssign<VT> >
673  assign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
674  {
676 
680 
681  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
682 
683  const ResultType tmp( serial( rhs ) );
684  assign( ~lhs, tmp );
685  }
687  //**********************************************************************************************
688 
689  //**Addition assignment to dense vectors********************************************************
703  template< typename VT > // Type of the target dense vector
704  friend inline EnableIf_< UseAssign<VT> >
705  addAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
706  {
708 
709  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
710 
711  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
712  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
713 
714  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
715  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
716 
717  addAssign( ~lhs, map( x, y, rhs.op_ ) );
718  }
720  //**********************************************************************************************
721 
722  //**Addition assignment to sparse vectors*******************************************************
723  // No special implementation for the addition assignment to sparse vectors.
724  //**********************************************************************************************
725 
726  //**Subtraction assignment to dense vectors*****************************************************
740  template< typename VT > // Type of the target dense vector
741  friend inline EnableIf_< UseAssign<VT> >
742  subAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
743  {
745 
746  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
747 
748  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
749  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
750 
751  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
752  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
753 
754  subAssign( ~lhs, map( x, y, rhs.op_ ) );
755  }
757  //**********************************************************************************************
758 
759  //**Subtraction assignment to sparse vectors****************************************************
760  // No special implementation for the subtraction assignment to sparse vectors.
761  //**********************************************************************************************
762 
763  //**Multiplication assignment to dense vectors**************************************************
777  template< typename VT > // Type of the target dense vector
778  friend inline EnableIf_< UseAssign<VT> >
779  multAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
780  {
782 
783  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
784 
785  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
786  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
787 
788  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
789  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
790 
791  multAssign( ~lhs, map( x, y, rhs.op_ ) );
792  }
794  //**********************************************************************************************
795 
796  //**Multiplication assignment to sparse vectors*************************************************
797  // No special implementation for the multiplication assignment to sparse vectors.
798  //**********************************************************************************************
799 
800  //**Division assignment to dense vectors********************************************************
814  template< typename VT > // Type of the target dense vector
815  friend inline EnableIf_< UseAssign<VT> >
816  divAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
817  {
819 
820  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
821 
822  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
823  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
824 
825  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
826  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
827 
828  divAssign( ~lhs, map( x, y, rhs.op_ ) );
829  }
831  //**********************************************************************************************
832 
833  //**Division assignment to sparse vectors*******************************************************
834  // No special implementation for the division assignment to sparse vectors.
835  //**********************************************************************************************
836 
837  //**SMP assignment to dense vectors*************************************************************
851  template< typename VT > // Type of the target dense vector
852  friend inline EnableIf_< UseSMPAssign<VT> >
853  smpAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
854  {
856 
857  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
858 
859  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
860  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
861 
862  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
863  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
864 
865  smpAssign( ~lhs, map( x, y, rhs.op_ ) );
866  }
868  //**********************************************************************************************
869 
870  //**SMP assignment to sparse vectors************************************************************
884  template< typename VT > // Type of the target sparse vector
885  friend inline EnableIf_< UseSMPAssign<VT> >
886  smpAssign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
887  {
889 
893 
894  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
895 
896  const ResultType tmp( rhs );
897  smpAssign( ~lhs, tmp );
898  }
900  //**********************************************************************************************
901 
902  //**SMP addition assignment to dense vectors****************************************************
917  template< typename VT > // Type of the target dense vector
918  friend inline EnableIf_< UseSMPAssign<VT> >
920  {
922 
923  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
924 
925  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
926  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
927 
928  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
929  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
930 
931  smpAddAssign( ~lhs, map( x, y, rhs.op_ ) );
932  }
934  //**********************************************************************************************
935 
936  //**SMP addition assignment to sparse vectors***************************************************
937  // No special implementation for the SMP addition assignment to sparse vectors.
938  //**********************************************************************************************
939 
940  //**SMP subtraction assignment to dense vectors*************************************************
955  template< typename VT > // Type of the target dense vector
956  friend inline EnableIf_< UseSMPAssign<VT> >
958  {
960 
961  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
962 
963  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
964  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
965 
966  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
967  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
968 
969  smpSubAssign( ~lhs, map( x, y, rhs.op_ ) );
970  }
972  //**********************************************************************************************
973 
974  //**SMP subtraction assignment to sparse vectors************************************************
975  // No special implementation for the SMP subtraction assignment to sparse vectors.
976  //**********************************************************************************************
977 
978  //**SMP multiplication assignment to dense vectors**********************************************
993  template< typename VT > // Type of the target dense vector
994  friend inline EnableIf_< UseSMPAssign<VT> >
996  {
998 
999  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1000 
1001  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
1002  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
1003 
1004  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
1005  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
1006 
1007  smpMultAssign( ~lhs, map( x, y, rhs.op_ ) );
1008  }
1010  //**********************************************************************************************
1011 
1012  //**SMP multiplication assignment to sparse vectors*********************************************
1013  // No special implementation for the SMP multiplication assignment to sparse vectors.
1014  //**********************************************************************************************
1015 
1016  //**SMP division assignment to dense vectors****************************************************
1031  template< typename VT > // Type of the target dense vector
1032  friend inline EnableIf_< UseSMPAssign<VT> >
1033  smpDivAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
1034  {
1036 
1037  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1038 
1039  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
1040  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
1041 
1042  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
1043  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
1044 
1045  smpDivAssign( ~lhs, map( x, y, rhs.op_ ) );
1046  }
1048  //**********************************************************************************************
1049 
1050  //**SMP division assignment to sparse vectors***************************************************
1051  // No special implementation for the SMP division assignment to sparse vectors.
1052  //**********************************************************************************************
1053 
1054  //**Compile time checks*************************************************************************
1061  //**********************************************************************************************
1062 };
1063 //*************************************************************************************************
1064 
1065 
1066 
1067 
1068 //=================================================================================================
1069 //
1070 // GLOBAL FUNCTIONS
1071 //
1072 //=================================================================================================
1073 
1074 //*************************************************************************************************
1095 template< typename VT1 // Type of the left-hand side dense vector
1096  , typename VT2 // Type of the right-hand side dense vector
1097  , bool TF // Transpose flag
1098  , typename OP > // Type of the custom operation
1099 inline decltype(auto)
1100  map( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs, OP op )
1101 {
1103 
1104  if( (~lhs).size() != (~rhs).size() ) {
1105  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1106  }
1107 
1109  return ReturnType( ~lhs, ~rhs, op );
1110 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1132 template< typename VT1 // Type of the left-hand side dense vector
1133  , typename VT2 // Type of the right-hand side dense vector
1134  , bool TF > // Transpose flag
1135 inline decltype(auto)
1136  min( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1137 {
1139 
1141  return ReturnType( ~lhs, ~rhs, Min() );
1142 }
1143 //*************************************************************************************************
1144 
1145 
1146 //*************************************************************************************************
1164 template< typename VT1 // Type of the left-hand side dense vector
1165  , typename VT2 // Type of the right-hand side dense vector
1166  , bool TF > // Transpose flag
1167 inline decltype(auto)
1168  max( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1169 {
1171 
1173  return ReturnType( ~lhs, ~rhs, Max() );
1174 }
1175 //*************************************************************************************************
1176 
1177 
1178 
1179 
1180 //=================================================================================================
1181 //
1182 // SIZE SPECIALIZATIONS
1183 //
1184 //=================================================================================================
1185 
1186 //*************************************************************************************************
1188 template< typename VT1, typename VT2, typename OP, bool TF >
1189 struct Size< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1190  : public Maximum< Size<VT1>, Size<VT2> >
1191 {};
1193 //*************************************************************************************************
1194 
1195 
1196 
1197 
1198 //=================================================================================================
1199 //
1200 // ISALIGNED SPECIALIZATIONS
1201 //
1202 //=================================================================================================
1203 
1204 //*************************************************************************************************
1206 template< typename VT1, typename VT2, typename OP, bool TF >
1207 struct IsAligned< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1208  : public BoolConstant< And< IsAligned<VT1>, IsAligned<VT2> >::value >
1209 {};
1211 //*************************************************************************************************
1212 
1213 
1214 
1215 
1216 //=================================================================================================
1217 //
1218 // ISPADDED SPECIALIZATIONS
1219 //
1220 //=================================================================================================
1221 
1222 //*************************************************************************************************
1224 template< typename VT1, typename VT2, typename OP, bool TF >
1225 struct IsPadded< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1226  : public BoolConstant< And< IsPadded<VT1>, IsPadded<VT2> >::value >
1227 {};
1229 //*************************************************************************************************
1230 
1231 } // namespace blaze
1232 
1233 #endif
#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.
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecMapExpr.h:205
ReferenceType reference
Reference return type.
Definition: DVecDVecMapExpr.h:208
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecMapExpr.h:263
Header file for auxiliary alias declarations.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecMapExpr.h:251
If_< RequiresEvaluation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:185
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition: DVecDVecMapExpr.h:170
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecMapExpr.h:285
Header file for basic type definitions.
ElementType_< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:105
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecDVecMapExpr.h:307
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:164
Header file for the serial shim.
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
RightOperand rhs_
Right-hand side dense vector of the map expression.
Definition: DVecDVecMapExpr.h:620
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecMapExpr.h:297
Header file for the IsSame and IsStrictlySame type traits.
typename BinaryMapTrait< T1, T2, OP >::Type BinaryMapTrait_
Auxiliary alias declaration for the BinaryMapTrait class template.The BinaryMapTrait_ alias declarati...
Definition: BinaryMapTrait.h:161
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecMapExpr.h:579
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
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:339
Header file for the And class template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
Compile time value evaluation.The Maximum alias declaration selects the larger of the two given templ...
Definition: Maximum.h:73
Header file for the DenseVector base class.
LeftOperand lhs_
Left-hand side dense vector of the map expression.
Definition: DVecDVecMapExpr.h:619
ElementType * PointerType
Pointer return type.
Definition: DVecDVecMapExpr.h:200
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
CompositeType_< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:110
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:430
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
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:133
Header file for the VecVecMapExpr base class.
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:363
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DVecDVecMapExpr.h:167
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecDVecMapExpr.h:602
Header file for the Maximum class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:72
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecMapExpr.h:275
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
ElementType_< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:106
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecMapExpr.h:201
Operation operation() const
Returns a copy of the custom operation.
Definition: DVecDVecMapExpr.h:567
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecMapExpr.h:199
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 nested template disabiguation.
Header file for the If class template.
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DVecDVecMapExpr.h:478
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:361
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
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:102
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
Iterator over the elements of the dense vector map expression.
Definition: DVecDVecMapExpr.h:194
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.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecDVecMapExpr.h:527
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Header file for the IsAligned type trait.
Constraint on the data type.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:328
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecMapExpr.h:438
OP op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:439
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecMapExpr.h:437
Constraint on the data type.
DVecDVecMapExpr(const VT1 &lhs, const VT2 &rhs, OP op) noexcept
Constructor for the DVecMapExpr class.
Definition: DVecDVecMapExpr.h:465
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecMapExpr.h:394
ReturnType_< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:107
Header file for the exception macros of the math module.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:350
Constraint on the data type.
ResultType_< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:103
Header file for all forward declarations for expression class templates.
If_< RequiresEvaluation< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:188
ResultType_< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:104
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecMapExpr.h:612
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ConstIterator(LeftIteratorType left, RightIteratorType right, OP op)
Constructor for the ConstIterator class.
Definition: DVecDVecMapExpr.h:225
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:372
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:383
Header file for the binary map trait.
ReturnType_< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:108
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:547
Header file for run time assertion macros.
PointerType pointer
Pointer return type.
Definition: DVecDVecMapExpr.h:207
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecMapExpr.h:491
Generic wrapper for the max() function.
Definition: Max.h:62
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecMapExpr.h:198
OP Operation
Data type of the custom unary operation.
Definition: DVecDVecMapExpr.h:182
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:154
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
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:296
#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
CompositeType_< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:109
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:505
Header file for the HasMember type traits.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecDVecMapExpr.h:592
#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
ConstIterator_< VT1 > LeftIteratorType
ConstIterator type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:212
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecMapExpr.h:517
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
Generic wrapper for the min() function.
Definition: Min.h:62
Header file for the Min functor.
ConstIterator_< VT2 > RightIteratorType
ConstIterator type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:215
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
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
ValueType value_type
Type of the underlying elements.
Definition: DVecDVecMapExpr.h:206
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:179
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecMapExpr.h:166
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:406
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:317
Operation op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:621
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
Compile time evaluation of the size of a vector.The Size type trait evaluates the size of the given v...
Definition: Size.h:74
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecMapExpr.h:418
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:130
BinaryMapTrait_< RT1, RT2, OP > ResultType
Result type for expression template evaluations.
Definition: DVecDVecMapExpr.h:165
Header file for the IntegralConstant class template.
Base class for all binary vector map expression templates.The VecVecMapExpr class serves as a tag for...
Definition: VecVecMapExpr.h:66
Header file for the Max functor.
Expression object for the dense vector-dense vector map() function.The DVecDVecMapExpr class represen...
Definition: DVecDVecMapExpr.h:97
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
IfTrue_< useAssign, const ResultType, const DVecDVecMapExpr &> CompositeType
Data type for composite expression templates.
Definition: DVecDVecMapExpr.h:173
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecMapExpr.h:238
BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT(HasSIMDEnabled, simdEnabled)
Definition of the HasSIMDEnabled type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:557
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
#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
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:95
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DVecDVecMapExpr.h:537
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:176
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs...
Definition: DMatDMatMapExpr.h:1133