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>
60 #include <blaze/math/SIMD.h>
69 #include <blaze/system/Inline.h>
70 #include <blaze/util/Assert.h>
71 #include <blaze/util/EnableIf.h>
74 #include <blaze/util/mpl/If.h>
75 #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  //**********************************************************************************************
112 
113  //**Serial evaluation strategy******************************************************************
115 
121  static constexpr bool useAssign = ( RequiresEvaluation_v<VT1> || RequiresEvaluation_v<VT2> );
122 
124  template< typename VT >
126  static constexpr bool UseAssign_v = useAssign;
128  //**********************************************************************************************
129 
130  //**Parallel evaluation strategy****************************************************************
132 
138  template< typename VT >
139  static constexpr bool UseSMPAssign_v =
142  //**********************************************************************************************
143 
144  public:
145  //**Type definitions****************************************************************************
151 
153  using ReturnType = decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
154 
157 
159  using LeftOperand = If_t< IsExpression_v<VT1>, const VT1, const VT1& >;
160 
162  using RightOperand = If_t< IsExpression_v<VT2>, const VT2, const VT2& >;
163 
165  using Operation = OP;
166 
169 
172  //**********************************************************************************************
173 
174  //**ConstIterator class definition**************************************************************
178  {
179  public:
180  //**Type definitions*************************************************************************
181  using IteratorCategory = std::random_access_iterator_tag;
186 
187  // STL iterator requirements
193 
196 
199  //*******************************************************************************************
200 
201  //**Constructor******************************************************************************
208  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right, OP op )
209  : left_ ( left ) // Iterator to the current left-hand side element
210  , right_( right ) // Iterator to the current right-hand side element
211  , op_ ( op ) // The custom unary operation
212  {}
213  //*******************************************************************************************
214 
215  //**Addition assignment operator*************************************************************
221  inline ConstIterator& operator+=( size_t inc ) {
222  left_ += inc;
223  right_ += inc;
224  return *this;
225  }
226  //*******************************************************************************************
227 
228  //**Subtraction assignment operator**********************************************************
234  inline ConstIterator& operator-=( size_t dec ) {
235  left_ -= dec;
236  right_ -= dec;
237  return *this;
238  }
239  //*******************************************************************************************
240 
241  //**Prefix increment operator****************************************************************
247  ++left_;
248  ++right_;
249  return *this;
250  }
251  //*******************************************************************************************
252 
253  //**Postfix increment operator***************************************************************
258  inline const ConstIterator operator++( int ) {
259  return ConstIterator( left_++, right_++, op_ );
260  }
261  //*******************************************************************************************
262 
263  //**Prefix decrement operator****************************************************************
269  --left_;
270  --right_;
271  return *this;
272  }
273  //*******************************************************************************************
274 
275  //**Postfix decrement operator***************************************************************
280  inline const ConstIterator operator--( int ) {
281  return ConstIterator( left_--, right_--, op_ );
282  }
283  //*******************************************************************************************
284 
285  //**Element access operator******************************************************************
290  inline ReturnType operator*() const {
291  return op_( *left_, *right_ );
292  }
293  //*******************************************************************************************
294 
295  //**Load function****************************************************************************
300  inline auto load() const noexcept {
301  return op_.load( left_.load(), right_.load() );
302  }
303  //*******************************************************************************************
304 
305  //**Equality operator************************************************************************
311  inline bool operator==( const ConstIterator& rhs ) const {
312  return left_ == rhs.left_;
313  }
314  //*******************************************************************************************
315 
316  //**Inequality operator**********************************************************************
322  inline bool operator!=( const ConstIterator& rhs ) const {
323  return left_ != rhs.left_;
324  }
325  //*******************************************************************************************
326 
327  //**Less-than operator***********************************************************************
333  inline bool operator<( const ConstIterator& rhs ) const {
334  return left_ < rhs.left_;
335  }
336  //*******************************************************************************************
337 
338  //**Greater-than operator********************************************************************
344  inline bool operator>( const ConstIterator& rhs ) const {
345  return left_ > rhs.left_;
346  }
347  //*******************************************************************************************
348 
349  //**Less-or-equal-than operator**************************************************************
355  inline bool operator<=( const ConstIterator& rhs ) const {
356  return left_ <= rhs.left_;
357  }
358  //*******************************************************************************************
359 
360  //**Greater-or-equal-than operator***********************************************************
366  inline bool operator>=( const ConstIterator& rhs ) const {
367  return left_ >= rhs.left_;
368  }
369  //*******************************************************************************************
370 
371  //**Subtraction operator*********************************************************************
377  inline DifferenceType operator-( const ConstIterator& rhs ) const {
378  return left_ - rhs.left_;
379  }
380  //*******************************************************************************************
381 
382  //**Addition operator************************************************************************
389  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
390  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
391  }
392  //*******************************************************************************************
393 
394  //**Addition operator************************************************************************
401  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
402  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
403  }
404  //*******************************************************************************************
405 
406  //**Subtraction operator*********************************************************************
413  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
414  return ConstIterator( it.left_ - dec, it.right_ - dec, it.op_ );
415  }
416  //*******************************************************************************************
417 
418  private:
419  //**Member variables*************************************************************************
422  OP op_;
423  //*******************************************************************************************
424  };
425  //**********************************************************************************************
426 
427  //**Compilation flags***************************************************************************
429  static constexpr bool simdEnabled =
430  ( VT1::simdEnabled && VT2::simdEnabled &&
431  If_t< HasSIMDEnabled_v<OP>, GetSIMDEnabled<OP,ET1,ET2>, HasLoad<OP> >::value );
432 
434  static constexpr bool smpAssignable = ( VT1::smpAssignable && VT2::smpAssignable );
435  //**********************************************************************************************
436 
437  //**SIMD properties*****************************************************************************
439  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
440  //**********************************************************************************************
441 
442  //**Constructor*********************************************************************************
449  explicit inline DVecDVecMapExpr( const VT1& lhs, const VT2& rhs, OP op ) noexcept
450  : lhs_( lhs ) // Left-hand side dense vector of the map expression
451  , rhs_( rhs ) // Right-hand side dense vector of the map expression
452  , op_ ( op ) // The custom unary operation
453  {}
454  //**********************************************************************************************
455 
456  //**Subscript operator**************************************************************************
462  inline ReturnType operator[]( size_t index ) const {
463  BLAZE_INTERNAL_ASSERT( index < lhs_.size(), "Invalid vector access index" );
464  return op_( lhs_[index], rhs_[index] );
465  }
466  //**********************************************************************************************
467 
468  //**At function*********************************************************************************
475  inline ReturnType at( size_t index ) const {
476  if( index >= lhs_.size() ) {
477  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
478  }
479  return (*this)[index];
480  }
481  //**********************************************************************************************
482 
483  //**Load function*******************************************************************************
489  BLAZE_ALWAYS_INLINE auto load( size_t index ) const noexcept {
490  BLAZE_INTERNAL_ASSERT( index < lhs_.size() , "Invalid vector access index" );
491  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
492  return op_.load( lhs_.load( index ), rhs_.load( index ) );
493  }
494  //**********************************************************************************************
495 
496  //**Begin function******************************************************************************
501  inline ConstIterator begin() const {
502  return ConstIterator( lhs_.begin(), rhs_.begin(), op_ );
503  }
504  //**********************************************************************************************
505 
506  //**End function********************************************************************************
511  inline ConstIterator end() const {
512  return ConstIterator( lhs_.end(), rhs_.end(), op_ );
513  }
514  //**********************************************************************************************
515 
516  //**Size function*******************************************************************************
521  inline size_t size() const noexcept {
522  return lhs_.size();
523  }
524  //**********************************************************************************************
525 
526  //**Left operand access*************************************************************************
531  inline LeftOperand leftOperand() const noexcept {
532  return lhs_;
533  }
534  //**********************************************************************************************
535 
536  //**Right operand access************************************************************************
541  inline RightOperand rightOperand() const noexcept {
542  return rhs_;
543  }
544  //**********************************************************************************************
545 
546  //**Operation access****************************************************************************
551  inline Operation operation() const {
552  return op_;
553  }
554  //**********************************************************************************************
555 
556  //**********************************************************************************************
562  template< typename T >
563  inline bool canAlias( const T* alias ) const noexcept {
564  return ( IsExpression_v<VT1> && lhs_.canAlias( alias ) ) ||
565  ( IsExpression_v<VT2> && rhs_.canAlias( alias ) );
566  }
567  //**********************************************************************************************
568 
569  //**********************************************************************************************
575  template< typename T >
576  inline bool isAliased( const T* alias ) const noexcept {
577  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
578  }
579  //**********************************************************************************************
580 
581  //**********************************************************************************************
586  inline bool isAligned() const noexcept {
587  return lhs_.isAligned() && rhs_.isAligned();
588  }
589  //**********************************************************************************************
590 
591  //**********************************************************************************************
596  inline bool canSMPAssign() const noexcept {
597  return lhs_.canSMPAssign() && rhs_.canSMPAssign();
598  }
599  //**********************************************************************************************
600 
601  private:
602  //**Member variables****************************************************************************
606  //**********************************************************************************************
607 
608  //**Assignment to dense vectors*****************************************************************
622  template< typename VT > // Type of the target dense vector
623  friend inline auto assign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
625  {
627 
628  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
629 
630  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
631  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
632 
633  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
634  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
635 
636  assign( ~lhs, map( x, y, rhs.op_ ) );
637  }
639  //**********************************************************************************************
640 
641  //**Assignment to sparse vectors****************************************************************
655  template< typename VT > // Type of the target sparse vector
656  friend inline auto assign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
658  {
660 
664 
665  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
666 
667  const ResultType tmp( serial( rhs ) );
668  assign( ~lhs, tmp );
669  }
671  //**********************************************************************************************
672 
673  //**Addition assignment to dense vectors********************************************************
687  template< typename VT > // Type of the target dense vector
688  friend inline auto addAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
689  -> EnableIf_t< UseAssign_v<VT> >
690  {
692 
693  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
694 
695  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
696  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
697 
698  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
699  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
700 
701  addAssign( ~lhs, map( x, y, rhs.op_ ) );
702  }
704  //**********************************************************************************************
705 
706  //**Addition assignment to sparse vectors*******************************************************
707  // No special implementation for the addition assignment to sparse vectors.
708  //**********************************************************************************************
709 
710  //**Subtraction assignment to dense vectors*****************************************************
724  template< typename VT > // Type of the target dense vector
725  friend inline auto subAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
726  -> EnableIf_t< UseAssign_v<VT> >
727  {
729 
730  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
731 
732  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
733  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
734 
735  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
736  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
737 
738  subAssign( ~lhs, map( x, y, rhs.op_ ) );
739  }
741  //**********************************************************************************************
742 
743  //**Subtraction assignment to sparse vectors****************************************************
744  // No special implementation for the subtraction assignment to sparse vectors.
745  //**********************************************************************************************
746 
747  //**Multiplication assignment to dense vectors**************************************************
761  template< typename VT > // Type of the target dense vector
762  friend inline auto multAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
763  -> EnableIf_t< UseAssign_v<VT> >
764  {
766 
767  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
768 
769  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
770  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
771 
772  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
773  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
774 
775  multAssign( ~lhs, map( x, y, rhs.op_ ) );
776  }
778  //**********************************************************************************************
779 
780  //**Multiplication assignment to sparse vectors*************************************************
781  // No special implementation for the multiplication assignment to sparse vectors.
782  //**********************************************************************************************
783 
784  //**Division assignment to dense vectors********************************************************
798  template< typename VT > // Type of the target dense vector
799  friend inline auto divAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
800  -> EnableIf_t< UseAssign_v<VT> >
801  {
803 
804  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
805 
806  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
807  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
808 
809  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
810  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
811 
812  divAssign( ~lhs, map( x, y, rhs.op_ ) );
813  }
815  //**********************************************************************************************
816 
817  //**Division assignment to sparse vectors*******************************************************
818  // No special implementation for the division assignment to sparse vectors.
819  //**********************************************************************************************
820 
821  //**SMP assignment to dense vectors*************************************************************
835  template< typename VT > // Type of the target dense vector
836  friend inline auto smpAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
837  -> EnableIf_t< UseSMPAssign_v<VT> >
838  {
840 
841  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
842 
843  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
844  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
845 
846  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
847  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
848 
849  smpAssign( ~lhs, map( x, y, rhs.op_ ) );
850  }
852  //**********************************************************************************************
853 
854  //**SMP assignment to sparse vectors************************************************************
868  template< typename VT > // Type of the target sparse vector
869  friend inline auto smpAssign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
870  -> EnableIf_t< UseSMPAssign_v<VT> >
871  {
873 
877 
878  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
879 
880  const ResultType tmp( rhs );
881  smpAssign( ~lhs, tmp );
882  }
884  //**********************************************************************************************
885 
886  //**SMP addition assignment to dense vectors****************************************************
901  template< typename VT > // Type of the target dense vector
902  friend inline auto smpAddAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
903  -> EnableIf_t< UseSMPAssign_v<VT> >
904  {
906 
907  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
908 
909  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
910  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
911 
912  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
913  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
914 
915  smpAddAssign( ~lhs, map( x, y, rhs.op_ ) );
916  }
918  //**********************************************************************************************
919 
920  //**SMP addition assignment to sparse vectors***************************************************
921  // No special implementation for the SMP addition assignment to sparse vectors.
922  //**********************************************************************************************
923 
924  //**SMP subtraction assignment to dense vectors*************************************************
939  template< typename VT > // Type of the target dense vector
940  friend inline auto smpSubAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
941  -> EnableIf_t< UseSMPAssign_v<VT> >
942  {
944 
945  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
946 
947  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
948  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
949 
950  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
951  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
952 
953  smpSubAssign( ~lhs, map( x, y, rhs.op_ ) );
954  }
956  //**********************************************************************************************
957 
958  //**SMP subtraction assignment to sparse vectors************************************************
959  // No special implementation for the SMP subtraction assignment to sparse vectors.
960  //**********************************************************************************************
961 
962  //**SMP multiplication assignment to dense vectors**********************************************
977  template< typename VT > // Type of the target dense vector
978  friend inline auto smpMultAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
979  -> EnableIf_t< UseSMPAssign_v<VT> >
980  {
982 
983  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
984 
985  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
986  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
987 
988  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
989  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
990 
991  smpMultAssign( ~lhs, map( x, y, rhs.op_ ) );
992  }
994  //**********************************************************************************************
995 
996  //**SMP multiplication assignment to sparse vectors*********************************************
997  // No special implementation for the SMP multiplication assignment to sparse vectors.
998  //**********************************************************************************************
999 
1000  //**SMP division assignment to dense vectors****************************************************
1015  template< typename VT > // Type of the target dense vector
1016  friend inline auto smpDivAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
1017  -> EnableIf_t< UseSMPAssign_v<VT> >
1018  {
1020 
1021  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1022 
1023  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
1024  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
1025 
1026  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
1027  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
1028 
1029  smpDivAssign( ~lhs, map( x, y, rhs.op_ ) );
1030  }
1032  //**********************************************************************************************
1033 
1034  //**SMP division assignment to sparse vectors***************************************************
1035  // No special implementation for the SMP division assignment to sparse vectors.
1036  //**********************************************************************************************
1037 
1038  //**Compile time checks*************************************************************************
1045  //**********************************************************************************************
1046 };
1047 //*************************************************************************************************
1048 
1049 
1050 
1051 
1052 //=================================================================================================
1053 //
1054 // GLOBAL FUNCTIONS
1055 //
1056 //=================================================================================================
1057 
1058 //*************************************************************************************************
1079 template< typename VT1 // Type of the left-hand side dense vector
1080  , typename VT2 // Type of the right-hand side dense vector
1081  , bool TF // Transpose flag
1082  , typename OP > // Type of the custom operation
1083 inline decltype(auto)
1084  map( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs, OP op )
1085 {
1087 
1088  if( (~lhs).size() != (~rhs).size() ) {
1089  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1090  }
1091 
1093  return ReturnType( ~lhs, ~rhs, op );
1094 }
1095 //*************************************************************************************************
1096 
1097 
1098 //*************************************************************************************************
1116 template< typename VT1 // Type of the left-hand side dense vector
1117  , typename VT2 // Type of the right-hand side dense vector
1118  , bool TF > // Transpose flag
1119 inline decltype(auto)
1120  min( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1121 {
1123 
1124  return map( ~lhs, ~rhs, Min() );
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1147 template< typename VT1 // Type of the left-hand side dense vector
1148  , typename VT2 // Type of the right-hand side dense vector
1149  , bool TF > // Transpose flag
1150 inline decltype(auto)
1151  max( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1152 {
1154 
1155  return map( ~lhs, ~rhs, Max() );
1156 }
1157 //*************************************************************************************************
1158 
1159 
1160 //*************************************************************************************************
1178 template< typename VT1 // Type of the left-hand side dense vector
1179  , typename VT2 // Type of the right-hand side dense vector
1180  , bool TF > // Transpose flag
1181 inline decltype(auto)
1182  hypot( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1183 {
1185 
1186  return map( ~lhs, ~rhs, Hypot() );
1187 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1209 template< typename VT1 // Type of the left-hand side dense vector
1210  , typename VT2 // Type of the right-hand side dense vector
1211  , bool TF > // Transpose flag
1212 inline decltype(auto)
1213  pow( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1214 {
1216 
1217  return map( ~lhs, ~rhs, Pow() );
1218 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1240 template< typename VT1 // Type of the left-hand side dense vector
1241  , typename VT2 // Type of the right-hand side dense vector
1242  , bool TF > // Transpose flag
1243 inline decltype(auto)
1244  atan2( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1245 {
1247 
1248  return map( ~lhs, ~rhs, Atan2() );
1249 }
1250 //*************************************************************************************************
1251 
1252 
1253 
1254 
1255 //=================================================================================================
1256 //
1257 // ISALIGNED SPECIALIZATIONS
1258 //
1259 //=================================================================================================
1260 
1261 //*************************************************************************************************
1263 template< typename VT1, typename VT2, typename OP, bool TF >
1264 struct IsAligned< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1265  : public BoolConstant< IsAligned_v<VT1> && IsAligned_v<VT2> >
1266 {};
1268 //*************************************************************************************************
1269 
1270 
1271 
1272 
1273 //=================================================================================================
1274 //
1275 // ISPADDED SPECIALIZATIONS
1276 //
1277 //=================================================================================================
1278 
1279 //*************************************************************************************************
1281 template< typename VT1, typename VT2, typename OP, bool TF >
1282 struct IsPadded< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1283  : public BoolConstant< IsPadded_v<VT1> && IsPadded_v<VT2> && IsPaddingEnabled_v<OP> >
1284 {};
1286 //*************************************************************************************************
1287 
1288 } // namespace blaze
1289 
1290 #endif
Header file for the Pow functor.
#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
Header file for the IsPaddingEnabled type trait.
Pointer difference type of the Blaze library.
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecMapExpr.h:188
ReferenceType reference
Reference return type.
Definition: DVecDVecMapExpr.h:191
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecMapExpr.h:246
Header file for auxiliary alias declarations.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecMapExpr.h:234
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition: DVecDVecMapExpr.h:153
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecMapExpr.h:268
Header file for the HasLoad type trait.
Header file for basic type definitions.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the map expression.
Definition: DVecDVecMapExpr.h:121
decltype(auto) hypot(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise hypotenous for the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1211
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecMapExpr.h:149
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecDVecMapExpr.h:290
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DVecDVecMapExpr.h:429
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 Hypot functor.
Header file for the serial shim.
Generic wrapper for the atan2() function.
Definition: Atan2.h:75
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:224
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.The MapTrait_t alias declaration provides...
Definition: MapTrait.h:160
RightOperand rhs_
Right-hand side dense vector of the map expression.
Definition: DVecDVecMapExpr.h:604
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecMapExpr.h:280
decltype(auto) pow(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise exponential value for the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1243
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecMapExpr.h:563
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DVecDVecMapExpr.h:185
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:322
Header file for the DenseVector base class.
LeftOperand lhs_
Left-hand side dense vector of the map expression.
Definition: DVecDVecMapExpr.h:603
ElementType * PointerType
Pointer return type.
Definition: DVecDVecMapExpr.h:183
CompositeType_t< VT2 > CT2
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:110
ElementType_t< VT2 > ET2
Element type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:106
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:413
ReturnType_t< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:107
Header file for the VecVecMapExpr base class.
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
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DVecDVecMapExpr.h:586
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
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecMapExpr.h:258
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecMapExpr.h:184
If_t< IsExpression_v< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:162
Operation operation() const
Returns a copy of the custom operation.
Definition: DVecDVecMapExpr.h:551
If_t< RequiresEvaluation_v< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:168
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecMapExpr.h:182
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
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DVecDVecMapExpr.h:150
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:462
ConstIterator_t< VT1 > LeftIteratorType
ConstIterator type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:195
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:344
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
#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
If_t< RequiresEvaluation_v< VT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:171
MapTrait_t< RT1, RT2, OP > ResultType
Result type for expression template evaluations.
Definition: DVecDVecMapExpr.h:148
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Iterator over the elements of the dense vector map expression.
Definition: DVecDVecMapExpr.h:177
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:511
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Header file for the IsAligned type trait.
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DVecDVecMapExpr.h:439
Constraint on the data type.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:311
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecMapExpr.h:421
OP op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:422
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecMapExpr.h:420
Constraint on the data type.
DVecDVecMapExpr(const VT1 &lhs, const VT2 &rhs, OP op) noexcept
Constructor for the DVecMapExpr class.
Definition: DVecDVecMapExpr.h:449
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecMapExpr.h:377
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
decltype(auto) atan2(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the multi-valued inverse tangent of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1275
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:333
Constraint on the data type.
Header file for all forward declarations for expression class templates.
ConstIterator_t< VT2 > RightIteratorType
ConstIterator type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:198
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecMapExpr.h:596
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ReturnType_t< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:108
ConstIterator(LeftIteratorType left, RightIteratorType right, OP op)
Constructor for the ConstIterator class.
Definition: DVecDVecMapExpr.h:208
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:355
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:366
Header file for the IsSIMDEnabled type trait.
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:531
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
PointerType pointer
Pointer return type.
Definition: DVecDVecMapExpr.h:190
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecMapExpr.h:475
Generic wrapper for the pow() function.
Definition: Pow.h:62
Generic wrapper for the max() function.
Definition: Max.h:79
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecMapExpr.h:181
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
OP Operation
Data type of the custom unary operation.
Definition: DVecDVecMapExpr.h:165
Header file for the Atan2 functor.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
If_t< IsExpression_v< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:159
#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
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
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:489
CompositeType_t< VT1 > CT1
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:109
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DVecDVecMapExpr.h:576
#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 class template represents ...
Definition: IntegralConstant.h:101
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecMapExpr.h:501
ElementType_t< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:105
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DVecDVecMapExpr.h:434
Generic wrapper for the min() function.
Definition: Min.h:79
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
Header file for the Min functor.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#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:189
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:389
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:300
Operation op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:605
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
If_t< useAssign, const ResultType, const DVecDVecMapExpr &> CompositeType
Data type for composite expression templates.
Definition: DVecDVecMapExpr.h:156
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
Generic wrapper for the hypot() function.
Definition: Hypot.h:75
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecMapExpr.h:401
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
Header file for the IntegralConstant class template.
ResultType_t< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:104
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 map trait.
Header file for the Max functor.
Expression object for the dense vector-dense vector map() function.The DVecDVecMapExpr class represen...
Definition: DVecDVecMapExpr.h:97
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecMapExpr.h:221
RightOperand rightOperand() const noexcept
Returns the right-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:541
System settings for the inline keywords.
#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
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
ResultType_t< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:103
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:521
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:1110