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>
67 #include <blaze/system/Inline.h>
68 #include <blaze/util/Assert.h>
69 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/mpl/And.h>
72 #include <blaze/util/mpl/If.h>
73 #include <blaze/util/mpl/Maximum.h>
74 #include <blaze/util/Template.h>
75 #include <blaze/util/Types.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS DVECDVECMAPEXPR
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
95 template< typename VT1 // Type of the left-hand side dense vector
96  , typename VT2 // Type of the right-hand side dense vector
97  , typename OP // Type of the custom operation
98  , bool TF > // Transpose flag
100  : public VecVecMapExpr< DenseVector< DVecDVecMapExpr<VT1,VT2,OP,TF>, TF > >
101  , private Computation
102 {
103  private:
104  //**Type definitions****************************************************************************
113 
115  BLAZE_CREATE_HAS_DATA_OR_FUNCTION_MEMBER_TYPE_TRAIT( HasSIMDEnabled, simdEnabled );
116 
119  //**********************************************************************************************
120 
121  //**Serial evaluation strategy******************************************************************
123 
129  enum : bool { useAssign = ( RequiresEvaluation<VT1>::value || RequiresEvaluation<VT2>::value ) };
130 
132  template< typename VT >
134  struct UseAssign {
135  enum : bool { value = useAssign };
136  };
138  //**********************************************************************************************
139 
140  //**Parallel evaluation strategy****************************************************************
142 
148  template< typename VT >
149  struct UseSMPAssign {
150  enum : bool { value = ( !VT1::smpAssignable || !VT2::smpAssignable ) && useAssign };
151  };
153  //**********************************************************************************************
154 
155  //**SIMD support detection**********************************************************************
157  struct UseSIMDEnabledFlag {
159  enum : bool { value = OP::BLAZE_TEMPLATE simdEnabled<ET1,ET2>() };
160  };
162  //**********************************************************************************************
163 
164  public:
165  //**Type definitions****************************************************************************
170 
172  using ReturnType = decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
173 
176 
178  using LeftOperand = If_< IsExpression<VT1>, const VT1, const VT1& >;
179 
181  using RightOperand = If_< IsExpression<VT2>, const VT2, const VT2& >;
182 
184  using Operation = OP;
185 
188 
191  //**********************************************************************************************
192 
193  //**ConstIterator class definition**************************************************************
197  {
198  public:
199  //**Type definitions*************************************************************************
200  using IteratorCategory = std::random_access_iterator_tag;
205 
206  // STL iterator requirements
212 
215 
218  //*******************************************************************************************
219 
220  //**Constructor******************************************************************************
227  explicit inline ConstIterator( LeftIteratorType left, RightIteratorType right, OP op )
228  : left_ ( left ) // Iterator to the current left-hand side element
229  , right_( right ) // Iterator to the current right-hand side element
230  , op_ ( op ) // The custom unary operation
231  {}
232  //*******************************************************************************************
233 
234  //**Addition assignment operator*************************************************************
240  inline ConstIterator& operator+=( size_t inc ) {
241  left_ += inc;
242  right_ += inc;
243  return *this;
244  }
245  //*******************************************************************************************
246 
247  //**Subtraction assignment operator**********************************************************
253  inline ConstIterator& operator-=( size_t dec ) {
254  left_ -= dec;
255  right_ -= dec;
256  return *this;
257  }
258  //*******************************************************************************************
259 
260  //**Prefix increment operator****************************************************************
266  ++left_;
267  ++right_;
268  return *this;
269  }
270  //*******************************************************************************************
271 
272  //**Postfix increment operator***************************************************************
277  inline const ConstIterator operator++( int ) {
278  return ConstIterator( left_++, right_++, op_ );
279  }
280  //*******************************************************************************************
281 
282  //**Prefix decrement operator****************************************************************
288  --left_;
289  --right_;
290  return *this;
291  }
292  //*******************************************************************************************
293 
294  //**Postfix decrement operator***************************************************************
299  inline const ConstIterator operator--( int ) {
300  return ConstIterator( left_--, right_--, op_ );
301  }
302  //*******************************************************************************************
303 
304  //**Element access operator******************************************************************
309  inline ReturnType operator*() const {
310  return op_( *left_, *right_ );
311  }
312  //*******************************************************************************************
313 
314  //**Load function****************************************************************************
319  inline auto load() const noexcept {
320  return op_.load( left_.load(), right_.load() );
321  }
322  //*******************************************************************************************
323 
324  //**Equality operator************************************************************************
330  inline bool operator==( const ConstIterator& rhs ) const {
331  return left_ == rhs.left_;
332  }
333  //*******************************************************************************************
334 
335  //**Inequality operator**********************************************************************
341  inline bool operator!=( const ConstIterator& rhs ) const {
342  return left_ != rhs.left_;
343  }
344  //*******************************************************************************************
345 
346  //**Less-than operator***********************************************************************
352  inline bool operator<( const ConstIterator& rhs ) const {
353  return left_ < rhs.left_;
354  }
355  //*******************************************************************************************
356 
357  //**Greater-than operator********************************************************************
363  inline bool operator>( const ConstIterator& rhs ) const {
364  return left_ > rhs.left_;
365  }
366  //*******************************************************************************************
367 
368  //**Less-or-equal-than operator**************************************************************
374  inline bool operator<=( const ConstIterator& rhs ) const {
375  return left_ <= rhs.left_;
376  }
377  //*******************************************************************************************
378 
379  //**Greater-or-equal-than operator***********************************************************
385  inline bool operator>=( const ConstIterator& rhs ) const {
386  return left_ >= rhs.left_;
387  }
388  //*******************************************************************************************
389 
390  //**Subtraction operator*********************************************************************
396  inline DifferenceType operator-( const ConstIterator& rhs ) const {
397  return left_ - rhs.left_;
398  }
399  //*******************************************************************************************
400 
401  //**Addition operator************************************************************************
408  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
409  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
410  }
411  //*******************************************************************************************
412 
413  //**Addition operator************************************************************************
420  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
421  return ConstIterator( it.left_ + inc, it.right_ + inc, it.op_ );
422  }
423  //*******************************************************************************************
424 
425  //**Subtraction operator*********************************************************************
432  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
433  return ConstIterator( it.left_ - dec, it.right_ - dec, it.op_ );
434  }
435  //*******************************************************************************************
436 
437  private:
438  //**Member variables*************************************************************************
441  OP op_;
442  //*******************************************************************************************
443  };
444  //**********************************************************************************************
445 
446  //**Compilation flags***************************************************************************
448  enum : bool { simdEnabled = VT1::simdEnabled && VT2::simdEnabled &&
449  If_< HasSIMDEnabled<OP>, UseSIMDEnabledFlag, HasLoad<OP> >::value };
450 
452  enum : bool { smpAssignable = VT1::smpAssignable && VT2::smpAssignable };
453  //**********************************************************************************************
454 
455  //**SIMD properties*****************************************************************************
457  enum : size_t { SIMDSIZE = SIMDTrait<ElementType>::size };
458  //**********************************************************************************************
459 
460  //**Constructor*********************************************************************************
467  explicit inline DVecDVecMapExpr( const VT1& lhs, const VT2& rhs, OP op ) noexcept
468  : lhs_( lhs ) // Left-hand side dense vector of the map expression
469  , rhs_( rhs ) // Right-hand side dense vector of the map expression
470  , op_ ( op ) // The custom unary operation
471  {}
472  //**********************************************************************************************
473 
474  //**Subscript operator**************************************************************************
480  inline ReturnType operator[]( size_t index ) const {
481  BLAZE_INTERNAL_ASSERT( index < lhs_.size(), "Invalid vector access index" );
482  return op_( lhs_[index], rhs_[index] );
483  }
484  //**********************************************************************************************
485 
486  //**At function*********************************************************************************
493  inline ReturnType at( size_t index ) const {
494  if( index >= lhs_.size() ) {
495  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
496  }
497  return (*this)[index];
498  }
499  //**********************************************************************************************
500 
501  //**Load function*******************************************************************************
507  BLAZE_ALWAYS_INLINE auto load( size_t index ) const noexcept {
508  BLAZE_INTERNAL_ASSERT( index < lhs_.size() , "Invalid vector access index" );
509  BLAZE_INTERNAL_ASSERT( index % SIMDSIZE == 0UL, "Invalid vector access index" );
510  return op_.load( lhs_.load( index ), rhs_.load( index ) );
511  }
512  //**********************************************************************************************
513 
514  //**Begin function******************************************************************************
519  inline ConstIterator begin() const {
520  return ConstIterator( lhs_.begin(), rhs_.begin(), op_ );
521  }
522  //**********************************************************************************************
523 
524  //**End function********************************************************************************
529  inline ConstIterator end() const {
530  return ConstIterator( lhs_.end(), rhs_.end(), op_ );
531  }
532  //**********************************************************************************************
533 
534  //**Size function*******************************************************************************
539  inline size_t size() const noexcept {
540  return lhs_.size();
541  }
542  //**********************************************************************************************
543 
544  //**Left operand access*************************************************************************
549  inline LeftOperand leftOperand() const noexcept {
550  return lhs_;
551  }
552  //**********************************************************************************************
553 
554  //**Right operand access************************************************************************
559  inline RightOperand rightOperand() const noexcept {
560  return rhs_;
561  }
562  //**********************************************************************************************
563 
564  //**Operation access****************************************************************************
569  inline Operation operation() const {
570  return op_;
571  }
572  //**********************************************************************************************
573 
574  //**********************************************************************************************
580  template< typename T >
581  inline bool canAlias( const T* alias ) const noexcept {
582  return ( IsExpression<VT1>::value && lhs_.canAlias( alias ) ) ||
583  ( IsExpression<VT2>::value && rhs_.canAlias( alias ) );
584  }
585  //**********************************************************************************************
586 
587  //**********************************************************************************************
593  template< typename T >
594  inline bool isAliased( const T* alias ) const noexcept {
595  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
596  }
597  //**********************************************************************************************
598 
599  //**********************************************************************************************
604  inline bool isAligned() const noexcept {
605  return lhs_.isAligned() && rhs_.isAligned();
606  }
607  //**********************************************************************************************
608 
609  //**********************************************************************************************
614  inline bool canSMPAssign() const noexcept {
615  return lhs_.canSMPAssign() && rhs_.canSMPAssign();
616  }
617  //**********************************************************************************************
618 
619  private:
620  //**Member variables****************************************************************************
624  //**********************************************************************************************
625 
626  //**Assignment to dense vectors*****************************************************************
640  template< typename VT > // Type of the target dense vector
641  friend inline EnableIf_< UseAssign<VT> >
642  assign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
643  {
645 
646  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
647 
648  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
649  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
650 
651  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
652  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
653 
654  assign( ~lhs, map( x, y, rhs.op_ ) );
655  }
657  //**********************************************************************************************
658 
659  //**Assignment to sparse vectors****************************************************************
673  template< typename VT > // Type of the target sparse vector
674  friend inline EnableIf_< UseAssign<VT> >
675  assign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
676  {
678 
682 
683  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
684 
685  const ResultType tmp( serial( rhs ) );
686  assign( ~lhs, tmp );
687  }
689  //**********************************************************************************************
690 
691  //**Addition assignment to dense vectors********************************************************
705  template< typename VT > // Type of the target dense vector
706  friend inline EnableIf_< UseAssign<VT> >
707  addAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
708  {
710 
711  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
712 
713  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
714  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
715 
716  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
717  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
718 
719  addAssign( ~lhs, map( x, y, rhs.op_ ) );
720  }
722  //**********************************************************************************************
723 
724  //**Addition assignment to sparse vectors*******************************************************
725  // No special implementation for the addition assignment to sparse vectors.
726  //**********************************************************************************************
727 
728  //**Subtraction assignment to dense vectors*****************************************************
742  template< typename VT > // Type of the target dense vector
743  friend inline EnableIf_< UseAssign<VT> >
744  subAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
745  {
747 
748  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
749 
750  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
751  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
752 
753  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
754  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
755 
756  subAssign( ~lhs, map( x, y, rhs.op_ ) );
757  }
759  //**********************************************************************************************
760 
761  //**Subtraction assignment to sparse vectors****************************************************
762  // No special implementation for the subtraction assignment to sparse vectors.
763  //**********************************************************************************************
764 
765  //**Multiplication assignment to dense vectors**************************************************
779  template< typename VT > // Type of the target dense vector
780  friend inline EnableIf_< UseAssign<VT> >
781  multAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
782  {
784 
785  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
786 
787  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
788  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
789 
790  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
791  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
792 
793  multAssign( ~lhs, map( x, y, rhs.op_ ) );
794  }
796  //**********************************************************************************************
797 
798  //**Multiplication assignment to sparse vectors*************************************************
799  // No special implementation for the multiplication assignment to sparse vectors.
800  //**********************************************************************************************
801 
802  //**Division assignment to dense vectors********************************************************
816  template< typename VT > // Type of the target dense vector
817  friend inline EnableIf_< UseAssign<VT> >
818  divAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
819  {
821 
822  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
823 
824  LT x( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense vector operand
825  RT y( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense vector operand
826 
827  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
828  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
829 
830  divAssign( ~lhs, map( x, y, rhs.op_ ) );
831  }
833  //**********************************************************************************************
834 
835  //**Division assignment to sparse vectors*******************************************************
836  // No special implementation for the division assignment to sparse vectors.
837  //**********************************************************************************************
838 
839  //**SMP assignment to dense vectors*************************************************************
853  template< typename VT > // Type of the target dense vector
854  friend inline EnableIf_< UseSMPAssign<VT> >
855  smpAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
856  {
858 
859  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
860 
861  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
862  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
863 
864  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
865  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
866 
867  smpAssign( ~lhs, map( x, y, rhs.op_ ) );
868  }
870  //**********************************************************************************************
871 
872  //**SMP assignment to sparse vectors************************************************************
886  template< typename VT > // Type of the target sparse vector
887  friend inline EnableIf_< UseSMPAssign<VT> >
888  smpAssign( SparseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
889  {
891 
895 
896  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
897 
898  const ResultType tmp( rhs );
899  smpAssign( ~lhs, tmp );
900  }
902  //**********************************************************************************************
903 
904  //**SMP addition assignment to dense vectors****************************************************
919  template< typename VT > // Type of the target dense vector
920  friend inline EnableIf_< UseSMPAssign<VT> >
922  {
924 
925  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
926 
927  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
928  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
929 
930  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
931  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
932 
933  smpAddAssign( ~lhs, map( x, y, rhs.op_ ) );
934  }
936  //**********************************************************************************************
937 
938  //**SMP addition assignment to sparse vectors***************************************************
939  // No special implementation for the SMP addition assignment to sparse vectors.
940  //**********************************************************************************************
941 
942  //**SMP subtraction assignment to dense vectors*************************************************
957  template< typename VT > // Type of the target dense vector
958  friend inline EnableIf_< UseSMPAssign<VT> >
960  {
962 
963  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
964 
965  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
966  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
967 
968  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
969  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
970 
971  smpSubAssign( ~lhs, map( x, y, rhs.op_ ) );
972  }
974  //**********************************************************************************************
975 
976  //**SMP subtraction assignment to sparse vectors************************************************
977  // No special implementation for the SMP subtraction assignment to sparse vectors.
978  //**********************************************************************************************
979 
980  //**SMP multiplication assignment to dense vectors**********************************************
995  template< typename VT > // Type of the target dense vector
996  friend inline EnableIf_< UseSMPAssign<VT> >
998  {
1000 
1001  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1002 
1003  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
1004  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
1005 
1006  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
1007  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
1008 
1009  smpMultAssign( ~lhs, map( x, y, rhs.op_ ) );
1010  }
1012  //**********************************************************************************************
1013 
1014  //**SMP multiplication assignment to sparse vectors*********************************************
1015  // No special implementation for the SMP multiplication assignment to sparse vectors.
1016  //**********************************************************************************************
1017 
1018  //**SMP division assignment to dense vectors****************************************************
1033  template< typename VT > // Type of the target dense vector
1034  friend inline EnableIf_< UseSMPAssign<VT> >
1035  smpDivAssign( DenseVector<VT,TF>& lhs, const DVecDVecMapExpr& rhs )
1036  {
1038 
1039  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1040 
1041  LT x( rhs.lhs_ ); // Evaluation of the left-hand side dense vector operand
1042  RT y( rhs.rhs_ ); // Evaluation of the right-hand side dense vector operand
1043 
1044  BLAZE_INTERNAL_ASSERT( x.size() == rhs.lhs_.size() , "Invalid vector size" );
1045  BLAZE_INTERNAL_ASSERT( y.size() == rhs.rhs_.size() , "Invalid vector size" );
1046 
1047  smpDivAssign( ~lhs, map( x, y, rhs.op_ ) );
1048  }
1050  //**********************************************************************************************
1051 
1052  //**SMP division assignment to sparse vectors***************************************************
1053  // No special implementation for the SMP division assignment to sparse vectors.
1054  //**********************************************************************************************
1055 
1056  //**Compile time checks*************************************************************************
1063  //**********************************************************************************************
1064 };
1065 //*************************************************************************************************
1066 
1067 
1068 
1069 
1070 //=================================================================================================
1071 //
1072 // GLOBAL FUNCTIONS
1073 //
1074 //=================================================================================================
1075 
1076 //*************************************************************************************************
1097 template< typename VT1 // Type of the left-hand side dense vector
1098  , typename VT2 // Type of the right-hand side dense vector
1099  , bool TF // Transpose flag
1100  , typename OP > // Type of the custom operation
1101 inline decltype(auto)
1102  map( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs, OP op )
1103 {
1105 
1106  if( (~lhs).size() != (~rhs).size() ) {
1107  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1108  }
1109 
1111  return ReturnType( ~lhs, ~rhs, op );
1112 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1134 template< typename VT1 // Type of the left-hand side dense vector
1135  , typename VT2 // Type of the right-hand side dense vector
1136  , bool TF > // Transpose flag
1137 inline decltype(auto)
1138  min( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1139 {
1141 
1142  return map( ~lhs, ~rhs, Min() );
1143 }
1144 //*************************************************************************************************
1145 
1146 
1147 //*************************************************************************************************
1165 template< typename VT1 // Type of the left-hand side dense vector
1166  , typename VT2 // Type of the right-hand side dense vector
1167  , bool TF > // Transpose flag
1168 inline decltype(auto)
1169  max( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1170 {
1172 
1173  return map( ~lhs, ~rhs, Max() );
1174 }
1175 //*************************************************************************************************
1176 
1177 
1178 //*************************************************************************************************
1196 template< typename VT1 // Type of the left-hand side dense vector
1197  , typename VT2 // Type of the right-hand side dense vector
1198  , bool TF > // Transpose flag
1199 inline decltype(auto)
1200  hypot( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1201 {
1203 
1204  return map( ~lhs, ~rhs, Hypot() );
1205 }
1206 //*************************************************************************************************
1207 
1208 
1209 //*************************************************************************************************
1227 template< typename VT1 // Type of the left-hand side dense vector
1228  , typename VT2 // Type of the right-hand side dense vector
1229  , bool TF > // Transpose flag
1230 inline decltype(auto)
1231  pow( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1232 {
1234 
1235  return map( ~lhs, ~rhs, Pow() );
1236 }
1237 //*************************************************************************************************
1238 
1239 
1240 //*************************************************************************************************
1258 template< typename VT1 // Type of the left-hand side dense vector
1259  , typename VT2 // Type of the right-hand side dense vector
1260  , bool TF > // Transpose flag
1261 inline decltype(auto)
1262  atan2( const DenseVector<VT1,TF>& lhs, const DenseVector<VT2,TF>& rhs )
1263 {
1265 
1266  return map( ~lhs, ~rhs, Atan2() );
1267 }
1268 //*************************************************************************************************
1269 
1270 
1271 
1272 
1273 //=================================================================================================
1274 //
1275 // SIZE SPECIALIZATIONS
1276 //
1277 //=================================================================================================
1278 
1279 //*************************************************************************************************
1281 template< typename VT1, typename VT2, typename OP, bool TF >
1282 struct Size< DVecDVecMapExpr<VT1,VT2,OP,TF>, 0UL >
1283  : public Maximum< Size<VT1,0UL>, Size<VT2,0UL> >
1284 {};
1286 //*************************************************************************************************
1287 
1288 
1289 
1290 
1291 //=================================================================================================
1292 //
1293 // ISALIGNED SPECIALIZATIONS
1294 //
1295 //=================================================================================================
1296 
1297 //*************************************************************************************************
1299 template< typename VT1, typename VT2, typename OP, bool TF >
1300 struct IsAligned< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1301  : public And< IsAligned<VT1>, IsAligned<VT2> >
1302 {};
1304 //*************************************************************************************************
1305 
1306 
1307 
1308 
1309 //=================================================================================================
1310 //
1311 // ISPADDED SPECIALIZATIONS
1312 //
1313 //=================================================================================================
1314 
1315 //*************************************************************************************************
1317 template< typename VT1, typename VT2, typename OP, bool TF >
1318 struct IsPadded< DVecDVecMapExpr<VT1,VT2,OP,TF> >
1319  : public And< IsPadded<VT1>, IsPadded<VT2> >
1320 {};
1322 //*************************************************************************************************
1323 
1324 } // namespace blaze
1325 
1326 #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
Pointer difference type of the Blaze library.
IteratorCategory iterator_category
The iterator category.
Definition: DVecDVecMapExpr.h:207
ReferenceType reference
Reference return type.
Definition: DVecDVecMapExpr.h:210
ConstIterator & operator++()
Pre-increment operator.
Definition: DVecDVecMapExpr.h:265
Header file for auxiliary alias declarations.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DVecDVecMapExpr.h:253
If_< RequiresEvaluation< VT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:187
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition: DVecDVecMapExpr.h:172
ConstIterator & operator--()
Pre-decrement operator.
Definition: DVecDVecMapExpr.h:287
Header file for basic type definitions.
ElementType_< VT1 > ET1
Element type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:107
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:1235
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DVecDVecMapExpr.h:309
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 Hypot functor.
Header file for the serial shim.
Generic wrapper for the atan2() function.
Definition: Atan2.h:62
RightOperand rhs_
Right-hand side dense vector of the map expression.
Definition: DVecDVecMapExpr.h:622
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DVecDVecMapExpr.h:299
Header file for the IsSame and IsStrictlySame type traits.
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:1267
typename BinaryMapTrait< T1, T2, OP >::Type BinaryMapTrait_
Auxiliary alias declaration for the BinaryMapTrait class template.The BinaryMapTrait_ alias declarati...
Definition: BinaryMapTrait.h:139
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DVecDVecMapExpr.h:581
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:341
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:1903
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:621
ElementType * PointerType
Pointer return type.
Definition: DVecDVecMapExpr.h:202
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:112
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:432
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:1950
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:169
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:604
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:71
const ConstIterator operator++(int)
Post-increment operator.
Definition: DVecDVecMapExpr.h:277
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:108
ElementType & ReferenceType
Reference return type.
Definition: DVecDVecMapExpr.h:203
Operation operation() const
Returns a copy of the custom operation.
Definition: DVecDVecMapExpr.h:569
ElementType ValueType
Type of the underlying elements.
Definition: DVecDVecMapExpr.h:201
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for 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:480
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:363
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:3085
Iterator over the elements of the dense vector map expression.
Definition: DVecDVecMapExpr.h:196
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DVecDVecMapExpr.h:529
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.
Constraint on the data type.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:330
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DVecDVecMapExpr.h:440
OP op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:441
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DVecDVecMapExpr.h:439
Constraint on the data type.
DVecDVecMapExpr(const VT1 &lhs, const VT2 &rhs, OP op) noexcept
Constructor for the DVecMapExpr class.
Definition: DVecDVecMapExpr.h:467
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DVecDVecMapExpr.h:396
ReturnType_< VT1 > RN1
Return type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:109
Header file for the exception macros of the math module.
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:1299
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:352
Constraint on the data type.
ResultType_< VT1 > RT1
Result type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:105
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:190
ResultType_< VT2 > RT2
Result type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:106
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DVecDVecMapExpr.h:614
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:227
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:374
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DVecDVecMapExpr.h:385
Header file for the binary map trait.
ReturnType_< VT2 > RN2
Return type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:110
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense vector operand.
Definition: DVecDVecMapExpr.h:549
Header file for run time assertion macros.
PointerType pointer
Pointer return type.
Definition: DVecDVecMapExpr.h:209
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DVecDVecMapExpr.h:493
Generic wrapper for the pow() function.
Definition: Pow.h:62
Generic wrapper for the max() function.
Definition: Max.h:62
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DVecDVecMapExpr.h:200
OP Operation
Data type of the custom unary operation.
Definition: DVecDVecMapExpr.h:184
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
Header file for the Atan2 functor.
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:111
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:816
BLAZE_ALWAYS_INLINE auto load(size_t index) const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:507
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:594
#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:214
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DVecDVecMapExpr.h:519
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:217
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
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:208
If_< IsExpression< VT2 >, const VT2, const VT2 &> RightOperand
Composite type of the right-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:181
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DVecDVecMapExpr.h:168
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DVecDVecMapExpr.h:408
auto load() const noexcept
Access to the SIMD elements of the vector.
Definition: DVecDVecMapExpr.h:319
Operation op_
The custom unary operation.
Definition: DVecDVecMapExpr.h:623
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 vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Generic wrapper for the hypot() function.
Definition: Hypot.h:62
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DVecDVecMapExpr.h:420
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:167
Base class for all binary vector map expression templates.The VecVecMapExpr class serves as a tag for...
Definition: VecVecMapExpr.h:66
Compile time logical &#39;and&#39; evaluation.The And alias declaration performs at compile time a logical &#39;a...
Definition: And.h:76
Header file for the Max functor.
Expression object for the dense vector-dense vector map() function.The DVecDVecMapExpr class represen...
Definition: DVecDVecMapExpr.h:99
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:175
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DVecDVecMapExpr.h:240
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:559
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:539
If_< IsExpression< VT1 >, const VT1, const VT1 &> LeftOperand
Composite type of the left-hand side dense vector expression.
Definition: DVecDVecMapExpr.h:178
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:1134