Blaze  3.6
SMatReduceExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATREDUCEEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATREDUCEEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
67 #include <blaze/math/views/Check.h>
69 #include <blaze/util/Assert.h>
70 #include <blaze/util/EnableIf.h>
72 #include <blaze/util/mpl/If.h>
74 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS DEFINITION
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
93 template< typename MT // Type of the sparse matrix
94  , typename OP // Type of the reduction operation
95  , size_t RF > // Reduction flag
97 {};
98 //*************************************************************************************************
99 
100 
101 
102 
103 //=================================================================================================
104 //
105 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-WISE REDUCTION OPERATIONS OF ROW-MAJOR MATRICES
106 //
107 //=================================================================================================
108 
109 //*************************************************************************************************
116 template< typename MT // Type of the sparse matrix
117  , typename OP > // Type of the reduction operation
119  : public MatReduceExpr< DenseVector< SMatReduceExpr<MT,OP,columnwise>, true >, columnwise >
120  , private Computation
121 {
122  private:
123  //**Type definitions****************************************************************************
128  //**********************************************************************************************
129 
130  //**Parallel evaluation strategy****************************************************************
132 
137  template< typename VT >
138  static constexpr bool UseSMPAssign_v = ( !MT::smpAssignable && RequiresEvaluation_v<MT> );
140  //**********************************************************************************************
141 
142  public:
143  //**Type definitions****************************************************************************
150  using ReturnType = const ElementType;
151  using CompositeType = const ResultType;
152 
154  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
155 
157  using Operation = OP;
158  //**********************************************************************************************
159 
160  //**Compilation flags***************************************************************************
162  static constexpr bool simdEnabled = false;
163 
165  static constexpr bool smpAssignable = MT::smpAssignable;
166  //**********************************************************************************************
167 
168  //**Constructor*********************************************************************************
174  explicit inline SMatReduceExpr( const MT& sm, OP op ) noexcept
175  : sm_( sm ) // Sparse matrix of the reduction expression
176  , op_( op ) // The reduction operation
177  {}
178  //**********************************************************************************************
179 
180  //**Subscript operator**************************************************************************
186  inline ReturnType operator[]( size_t index ) const {
187  BLAZE_INTERNAL_ASSERT( index < sm_.columns(), "Invalid vector access index" );
188  return reduce( column( sm_, index, unchecked ), op_ );
189  }
190  //**********************************************************************************************
191 
192  //**At function*********************************************************************************
199  inline ReturnType at( size_t index ) const {
200  if( index >= sm_.columns() ) {
201  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
202  }
203  return (*this)[index];
204  }
205  //**********************************************************************************************
206 
207  //**Size function*******************************************************************************
212  inline size_t size() const noexcept {
213  return sm_.columns();
214  }
215  //**********************************************************************************************
216 
217  //**Operand access******************************************************************************
222  inline Operand operand() const noexcept {
223  return sm_;
224  }
225  //**********************************************************************************************
226 
227  //**Operation access****************************************************************************
232  inline Operation operation() const {
233  return op_;
234  }
235  //**********************************************************************************************
236 
237  //**********************************************************************************************
243  template< typename T >
244  inline bool canAlias( const T* alias ) const noexcept {
245  return ( sm_.isAliased( alias ) );
246  }
247  //**********************************************************************************************
248 
249  //**********************************************************************************************
255  template< typename T >
256  inline bool isAliased( const T* alias ) const noexcept {
257  return ( sm_.isAliased( alias ) );
258  }
259  //**********************************************************************************************
260 
261  //**********************************************************************************************
266  inline bool isAligned() const noexcept {
267  return false;
268  }
269  //**********************************************************************************************
270 
271  //**********************************************************************************************
276  inline bool canSMPAssign() const noexcept {
277  return sm_.canSMPAssign() || ( size() > SMP_SMATREDUCE_THRESHOLD );
278  }
279  //**********************************************************************************************
280 
281  private:
282  //**Member variables****************************************************************************
285  //**********************************************************************************************
286 
287  //**Assignment to dense vectors*****************************************************************
299  template< typename VT1 > // Type of the target dense vector
300  friend inline void assign( DenseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
301  {
303 
307 
308  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
309 
310  const OT tmp( serial( rhs.sm_ ) );
311  assign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
312  }
314  //**********************************************************************************************
315 
316  //**Assignment to sparse vectors****************************************************************
329  template< typename VT1 > // Type of the target dense vector
330  friend inline void assign( SparseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
331  {
333 
337 
338  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
339 
340  const ResultType tmp( serial( rhs ) );
341  assign( ~lhs, tmp );
342  }
344  //**********************************************************************************************
345 
346  //**Addition assignment to dense vectors********************************************************
359  template< typename VT1 > // Type of the target dense vector
360  friend inline void addAssign( DenseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
361  {
363 
367 
368  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
369 
370  const OT tmp( serial( rhs.sm_ ) );
371  addAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
372  }
374  //**********************************************************************************************
375 
376  //**Addition assignment to sparse vectors*******************************************************
389  template< typename VT1 > // Type of the target dense vector
390  friend inline void addAssign( SparseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
391  {
393 
397 
398  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
399 
400  const ResultType tmp( serial( rhs ) );
401  addAssign( ~lhs, tmp );
402  }
404  //**********************************************************************************************
405 
406  //**Subtraction assignment to dense vectors*****************************************************
419  template< typename VT1 > // Type of the target dense vector
420  friend inline void subAssign( DenseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
421  {
423 
427 
428  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
429 
430  const OT tmp( serial( rhs.sm_ ) );
431  subAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
432  }
434  //**********************************************************************************************
435 
436  //**Subtraction assignment to sparse vectors****************************************************
449  template< typename VT1 > // Type of the target dense vector
450  friend inline void subAssign( SparseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
451  {
453 
457 
458  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
459 
460  const ResultType tmp( serial( rhs ) );
461  subAssign( ~lhs, tmp );
462  }
464  //**********************************************************************************************
465 
466  //**Multiplication assignment to dense vectors**************************************************
479  template< typename VT1 > // Type of the target dense vector
480  friend inline void multAssign( DenseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
481  {
483 
487 
488  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
489 
490  const OT tmp( serial( rhs.sm_ ) );
491  multAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
492  }
494  //**********************************************************************************************
495 
496  //**Multiplication assignment to sparse vectors*************************************************
509  template< typename VT1 > // Type of the target dense vector
510  friend inline void multAssign( SparseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
511  {
513 
517 
518  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
519 
520  const ResultType tmp( serial( rhs ) );
521  multAssign( ~lhs, tmp );
522  }
524  //**********************************************************************************************
525 
526  //**Division assignment to dense vectors********************************************************
539  template< typename VT1 > // Type of the target dense vector
540  friend inline void divAssign( DenseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
541  {
543 
547 
548  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
549 
550  const OT tmp( serial( rhs.sm_ ) );
551  divAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
552  }
554  //**********************************************************************************************
555 
556  //**Division assignment to sparse vectors*******************************************************
569  template< typename VT1 > // Type of the target dense vector
570  friend inline void divAssign( SparseVector<VT1,true>& lhs, const SMatReduceExpr& rhs )
571  {
573 
577 
578  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
579 
580  const ResultType tmp( serial( rhs ) );
581  divAssign( ~lhs, tmp );
582  }
584  //**********************************************************************************************
585 
586  //**SMP assignment to vectors*******************************************************************
600  template< typename VT1 > // Type of the target vector
601  friend inline auto smpAssign( Vector<VT1,true>& lhs, const SMatReduceExpr& rhs )
602  -> EnableIf_t< UseSMPAssign_v<VT1> >
603  {
605 
606  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
607 
608  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
609  smpAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
610  }
612  //**********************************************************************************************
613 
614  //**SMP addition assignment to vectors**********************************************************
629  template< typename VT1 > // Type of the target vector
630  friend inline auto smpAddAssign( Vector<VT1,true>& lhs, const SMatReduceExpr& rhs )
631  -> EnableIf_t< UseSMPAssign_v<VT1> >
632  {
634 
635  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
636 
637  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
638  smpAddAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
639  }
641  //**********************************************************************************************
642 
643  //**SMP subtraction assignment to vectors*******************************************************
658  template< typename VT1 > // Type of the target vector
659  friend inline auto smpSubAssign( Vector<VT1,true>& lhs, const SMatReduceExpr& rhs )
660  -> EnableIf_t< UseSMPAssign_v<VT1> >
661  {
663 
664  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
665 
666  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
667  smpSubAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
668  }
670  //**********************************************************************************************
671 
672  //**SMP multiplication assignment to vectors****************************************************
687  template< typename VT1 > // Type of the target vector
688  friend inline auto smpMultAssign( Vector<VT1,true>& lhs, const SMatReduceExpr& rhs )
689  -> EnableIf_t< UseSMPAssign_v<VT1> >
690  {
692 
693  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
694 
695  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
696  smpMultAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
697  }
699  //**********************************************************************************************
700 
701  //**SMP division assignment to vectors**********************************************************
716  template< typename VT1 > // Type of the target vector
717  friend inline auto smpDivAssign( Vector<VT1,true>& lhs, const SMatReduceExpr& rhs )
718  -> EnableIf_t< UseSMPAssign_v<VT1> >
719  {
721 
722  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
723 
724  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
725  smpDivAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
726  }
728  //**********************************************************************************************
729 
730  //**Compile time checks*************************************************************************
735  //**********************************************************************************************
736 };
737 //*************************************************************************************************
738 
739 
740 
741 
742 //=================================================================================================
743 //
744 // CLASS TEMPLATE SPECIALIZATION FOR ROW-WISE REDUCTION OPERATIONS OF ROW-MAJOR MATRICES
745 //
746 //=================================================================================================
747 
748 //*************************************************************************************************
755 template< typename MT // Type of the sparse matrix
756  , typename OP > // Type of the reduction operation
758  : public MatReduceExpr< DenseVector< SMatReduceExpr<MT,OP,rowwise>, false >, rowwise >
759  , private Computation
760 {
761  private:
762  //**Type definitions****************************************************************************
765  //**********************************************************************************************
766 
767  //**Serial evaluation strategy******************************************************************
769 
775  static constexpr bool useAssign = RequiresEvaluation_v<MT>;
776 
778  template< typename VT >
780  static constexpr bool UseAssign_v = useAssign;
782  //**********************************************************************************************
783 
784  //**Parallel evaluation strategy****************************************************************
786 
791  template< typename VT >
792  static constexpr bool UseSMPAssign_v = ( !MT::smpAssignable && useAssign );
794  //**********************************************************************************************
795 
796  public:
797  //**Type definitions****************************************************************************
804  using ReturnType = const ElementType;
805 
808 
810  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
811 
813  using Operation = OP;
814  //**********************************************************************************************
815 
816  //**ConstIterator class definition**************************************************************
819  class ConstIterator
820  {
821  public:
822  //**Type definitions*************************************************************************
823  using IteratorCategory = std::random_access_iterator_tag;
828 
829  // STL iterator requirements
835  //*******************************************************************************************
836 
837  //**Constructor******************************************************************************
844  explicit inline ConstIterator( Operand sm, size_t index, OP op )
845  : sm_ ( sm ) // Sparse matrix of the reduction expression
846  , index_( index ) // Index to the current matrix row
847  , op_ ( op ) // The reduction operation
848  {}
849  //*******************************************************************************************
850 
851  //**Addition assignment operator*************************************************************
857  inline ConstIterator& operator+=( size_t inc ) {
858  index_ += inc;
859  return *this;
860  }
861  //*******************************************************************************************
862 
863  //**Subtraction assignment operator**********************************************************
869  inline ConstIterator& operator-=( size_t dec ) {
870  index_ -= dec;
871  return *this;
872  }
873  //*******************************************************************************************
874 
875  //**Prefix increment operator****************************************************************
880  inline ConstIterator& operator++() {
881  ++index_;
882  return *this;
883  }
884  //*******************************************************************************************
885 
886  //**Postfix increment operator***************************************************************
891  inline const ConstIterator operator++( int ) {
892  return ConstIterator( index_++ );
893  }
894  //*******************************************************************************************
895 
896  //**Prefix decrement operator****************************************************************
901  inline ConstIterator& operator--() {
902  --index_;
903  return *this;
904  }
905  //*******************************************************************************************
906 
907  //**Postfix decrement operator***************************************************************
912  inline const ConstIterator operator--( int ) {
913  return ConstIterator( index_-- );
914  }
915  //*******************************************************************************************
916 
917  //**Element access operator******************************************************************
922  inline ReturnType operator*() const {
923  return reduce( row( sm_, index_, unchecked ), op_ );
924  }
925  //*******************************************************************************************
926 
927  //**Equality operator************************************************************************
933  inline bool operator==( const ConstIterator& rhs ) const {
934  return index_ == rhs.index_;
935  }
936  //*******************************************************************************************
937 
938  //**Inequality operator**********************************************************************
944  inline bool operator!=( const ConstIterator& rhs ) const {
945  return index_ != rhs.index_;
946  }
947  //*******************************************************************************************
948 
949  //**Less-than operator***********************************************************************
955  inline bool operator<( const ConstIterator& rhs ) const {
956  return index_ < rhs.index_;
957  }
958  //*******************************************************************************************
959 
960  //**Greater-than operator********************************************************************
966  inline bool operator>( const ConstIterator& rhs ) const {
967  return index_ > rhs.index_;
968  }
969  //*******************************************************************************************
970 
971  //**Less-or-equal-than operator**************************************************************
977  inline bool operator<=( const ConstIterator& rhs ) const {
978  return index_ <= rhs.index_;
979  }
980  //*******************************************************************************************
981 
982  //**Greater-or-equal-than operator***********************************************************
988  inline bool operator>=( const ConstIterator& rhs ) const {
989  return index_ >= rhs.index_;
990  }
991  //*******************************************************************************************
992 
993  //**Subtraction operator*********************************************************************
999  inline DifferenceType operator-( const ConstIterator& rhs ) const {
1000  return index_ - rhs.index_;
1001  }
1002  //*******************************************************************************************
1003 
1004  //**Addition operator************************************************************************
1011  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
1012  return ConstIterator( it.index_ + inc );
1013  }
1014  //*******************************************************************************************
1015 
1016  //**Addition operator************************************************************************
1023  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
1024  return ConstIterator( it.index_ + inc );
1025  }
1026  //*******************************************************************************************
1027 
1028  //**Subtraction operator*********************************************************************
1035  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
1036  return ConstIterator( it.index_ - dec );
1037  }
1038  //*******************************************************************************************
1039 
1040  private:
1041  //**Member variables*************************************************************************
1043  size_t index_;
1044  OP op_;
1045  //*******************************************************************************************
1046  };
1047  //**********************************************************************************************
1048 
1049  //**Compilation flags***************************************************************************
1051  static constexpr bool simdEnabled = false;
1052 
1054  static constexpr bool smpAssignable = MT::smpAssignable;
1055  //**********************************************************************************************
1056 
1057  //**Constructor*********************************************************************************
1063  explicit inline SMatReduceExpr( const MT& sm, OP op ) noexcept
1064  : sm_( sm ) // Sparse matrix of the reduction expression
1065  , op_( op ) // The reduction operation
1066  {}
1067  //**********************************************************************************************
1068 
1069  //**Subscript operator**************************************************************************
1075  inline ReturnType operator[]( size_t index ) const {
1076  BLAZE_INTERNAL_ASSERT( index < sm_.rows(), "Invalid vector access index" );
1077  return reduce( row( sm_, index, unchecked ), op_ );
1078  }
1079  //**********************************************************************************************
1080 
1081  //**At function*********************************************************************************
1088  inline ReturnType at( size_t index ) const {
1089  if( index >= sm_.rows() ) {
1090  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
1091  }
1092  return (*this)[index];
1093  }
1094  //**********************************************************************************************
1095 
1096  //**Begin function******************************************************************************
1101  inline ConstIterator begin() const {
1102  return ConstIterator( sm_, 0UL, op_ );
1103  }
1104  //**********************************************************************************************
1105 
1106  //**End function********************************************************************************
1111  inline ConstIterator end() const {
1112  return ConstIterator( sm_, size(), op_ );
1113  }
1114  //**********************************************************************************************
1115 
1116  //**Size function*******************************************************************************
1121  inline size_t size() const noexcept {
1122  return sm_.rows();
1123  }
1124  //**********************************************************************************************
1125 
1126  //**Operand access******************************************************************************
1131  inline Operand operand() const noexcept {
1132  return sm_;
1133  }
1134  //**********************************************************************************************
1135 
1136  //**Operation access****************************************************************************
1141  inline Operation operation() const {
1142  return op_;
1143  }
1144  //**********************************************************************************************
1145 
1146  //**********************************************************************************************
1152  template< typename T >
1153  inline bool canAlias( const T* alias ) const noexcept {
1154  return ( sm_.isAliased( alias ) );
1155  }
1156  //**********************************************************************************************
1157 
1158  //**********************************************************************************************
1164  template< typename T >
1165  inline bool isAliased( const T* alias ) const noexcept {
1166  return ( sm_.isAliased( alias ) );
1167  }
1168  //**********************************************************************************************
1169 
1170  //**********************************************************************************************
1175  inline bool isAligned() const noexcept {
1176  return false;
1177  }
1178  //**********************************************************************************************
1179 
1180  //**********************************************************************************************
1185  inline bool canSMPAssign() const noexcept {
1186  return sm_.canSMPAssign() || ( size() > SMP_SMATREDUCE_THRESHOLD );
1187  }
1188  //**********************************************************************************************
1189 
1190  private:
1191  //**Member variables****************************************************************************
1194  //**********************************************************************************************
1195 
1196  //**Assignment to vectors***********************************************************************
1210  template< typename VT1 > // Type of the target vector
1211  friend inline auto assign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1213  {
1215 
1216  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1217 
1218  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1219  assign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1220  }
1222  //**********************************************************************************************
1223 
1224  //**Addition assignment to vectors**************************************************************
1238  template< typename VT1 > // Type of the target vector
1239  friend inline auto addAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1241  {
1243 
1244  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1245 
1246  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1247  addAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1248  }
1250  //**********************************************************************************************
1251 
1252  //**Subtraction assignment to vectors***********************************************************
1267  template< typename VT1 > // Type of the target vector
1268  friend inline auto subAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1269  -> EnableIf_t< UseAssign_v<VT1> >
1270  {
1272 
1273  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1274 
1275  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1276  subAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1277  }
1279  //**********************************************************************************************
1280 
1281  //**Multiplication assignment to vectors********************************************************
1296  template< typename VT1 > // Type of the target vector
1297  friend inline auto multAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1298  -> EnableIf_t< UseAssign_v<VT1> >
1299  {
1301 
1302  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1303 
1304  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1305  multAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1306  }
1308  //**********************************************************************************************
1309 
1310  //**Division assignment to vectors**************************************************************
1324  template< typename VT1 > // Type of the target vector
1325  friend inline auto divAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1326  -> EnableIf_t< UseAssign_v<VT1> >
1327  {
1329 
1330  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1331 
1332  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1333  divAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1334  }
1336  //**********************************************************************************************
1337 
1338  //**SMP assignment to vectors*******************************************************************
1352  template< typename VT1 > // Type of the target vector
1353  friend inline auto smpAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1354  -> EnableIf_t< UseSMPAssign_v<VT1> >
1355  {
1357 
1358  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1359 
1360  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
1361  smpAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1362  }
1364  //**********************************************************************************************
1365 
1366  //**SMP addition assignment to vectors**********************************************************
1381  template< typename VT1 > // Type of the target vector
1382  friend inline auto smpAddAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1383  -> EnableIf_t< UseSMPAssign_v<VT1> >
1384  {
1386 
1387  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1388 
1389  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
1390  smpAddAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1391  }
1393  //**********************************************************************************************
1394 
1395  //**SMP subtraction assignment to vectors*******************************************************
1410  template< typename VT1 > // Type of the target vector
1411  friend inline auto smpSubAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1412  -> EnableIf_t< UseSMPAssign_v<VT1> >
1413  {
1415 
1416  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1417 
1418  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
1419  smpSubAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1420  }
1422  //**********************************************************************************************
1423 
1424  //**SMP multiplication assignment to vectors****************************************************
1439  template< typename VT1 > // Type of the target vector
1440  friend inline auto smpMultAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1441  -> EnableIf_t< UseSMPAssign_v<VT1> >
1442  {
1444 
1445  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1446 
1447  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
1448  smpMultAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1449  }
1451  //**********************************************************************************************
1452 
1453  //**SMP division assignment to vectors**********************************************************
1468  template< typename VT1 > // Type of the target vector
1469  friend inline auto smpDivAssign( Vector<VT1,false>& lhs, const SMatReduceExpr& rhs )
1470  -> EnableIf_t< UseSMPAssign_v<VT1> >
1471  {
1473 
1474  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1475 
1476  const RT tmp( rhs.sm_ ); // Evaluation of the sparse matrix operand
1477  smpDivAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1478  }
1480  //**********************************************************************************************
1481 
1482  //**Compile time checks*************************************************************************
1487  //**********************************************************************************************
1488 };
1489 //*************************************************************************************************
1490 
1491 
1492 
1493 
1494 //=================================================================================================
1495 //
1496 // GLOBAL FUNCTIONS
1497 //
1498 //=================================================================================================
1499 
1500 //*************************************************************************************************
1527 template< typename MT // Type of the sparse matrix
1528  , bool SO // Storage order
1529  , typename OP > // Type of the reduction operation
1530 inline decltype(auto) reduce( const SparseMatrix<MT,SO>& sm, OP op )
1531 {
1533 
1534  using CT = CompositeType_t<MT>;
1535  using ET = ElementType_t<MT>;
1536 
1537  const size_t M( (~sm).rows() );
1538  const size_t N( (~sm).columns() );
1539 
1540  if( M == 0UL || N == 0UL ) return ET{};
1541 
1542  const size_t iend( SO ? N : M );
1543 
1544  CT tmp( ~sm );
1545 
1546  BLAZE_INTERNAL_ASSERT( tmp.rows() == M, "Invalid number of rows" );
1547  BLAZE_INTERNAL_ASSERT( tmp.columns() == N, "Invalid number of columns" );
1548 
1549  ET redux0{};
1550 
1551  for( size_t i=0UL; i<iend; ++i )
1552  {
1553  const auto end( tmp.end(i) );
1554  auto element( tmp.begin(i) );
1555 
1556  if( element == end ) continue;
1557 
1558  ET redux1( element->value() );
1559  ++element;
1560 
1561  for( ; element!=end; ++element ) {
1562  redux1 = op( redux1, element->value() );
1563  }
1564 
1565  if( i == 0UL ) redux0 = redux1;
1566  else redux0 = op( redux0, redux1 );
1567  }
1568 
1569  return redux0;
1570 }
1571 //*************************************************************************************************
1572 
1573 
1574 //*************************************************************************************************
1583 template< size_t RF // Reduction flag
1584  , typename MT // Type of the sparse matrix
1585  , typename OP > // Type of the reduction operation
1586 inline const SMatReduceExpr<MT,OP,RF> reduce_backend( const SparseMatrix<MT,false>& sm, OP op )
1587 {
1588  using ReturnType = const SMatReduceExpr<MT,OP,RF>;
1589  return ReturnType( ~sm, op );
1590 }
1592 //*************************************************************************************************
1593 
1594 
1595 //*************************************************************************************************
1604 template< size_t RF // Reduction flag
1605  , typename MT // Type of the sparse matrix
1606  , typename OP > // Type of the reduction operation
1607 inline decltype(auto) reduce_backend( const SparseMatrix<MT,true>& sm, OP op )
1608 {
1609  return trans( reduce<1UL-RF>( trans( ~sm ), op ) );
1610 }
1612 //*************************************************************************************************
1613 
1614 
1615 //*************************************************************************************************
1655 template< size_t RF // Reduction flag
1656  , typename MT // Type of the sparse matrix
1657  , bool SO // Storage order
1658  , typename OP > // Type of the reduction operation
1659 inline decltype(auto) reduce( const SparseMatrix<MT,SO>& sm, OP op )
1660 {
1662 
1663  BLAZE_STATIC_ASSERT_MSG( RF < 2UL, "Invalid reduction flag" );
1664 
1665  return reduce_backend<RF>( ~sm, op );
1666 }
1667 //*************************************************************************************************
1668 
1669 
1670 //*************************************************************************************************
1688 template< typename MT // Type of the sparse matrix
1689  , bool SO > // Storage order
1690 inline decltype(auto) sum( const SparseMatrix<MT,SO>& sm )
1691 {
1693 
1694  return reduce( ~sm, Add() );
1695 }
1696 //*************************************************************************************************
1697 
1698 
1699 //*************************************************************************************************
1732 template< size_t RF // Reduction flag
1733  , typename MT // Type of the sparse matrix
1734  , bool SO > // Storage order
1735 inline decltype(auto) sum( const SparseMatrix<MT,SO>& sm )
1736 {
1738 
1739  return reduce<RF>( ~sm, Add() );
1740 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1762 template< typename MT // Type of the sparse matrix
1763  , bool SO > // Storage order
1764 inline decltype(auto) prod( const SparseMatrix<MT,SO>& sm )
1765 {
1767 
1768  return reduce( ~sm, Mult() );
1769 }
1770 //*************************************************************************************************
1771 
1772 
1773 //*************************************************************************************************
1806 template< size_t RF // Reduction flag
1807  , typename MT // Type of the sparse matrix
1808  , bool SO > // Storage order
1809 inline decltype(auto) prod( const SparseMatrix<MT,SO>& sm )
1810 {
1812 
1813  return reduce<RF>( ~sm, Mult() );
1814 }
1815 //*************************************************************************************************
1816 
1817 
1818 //*************************************************************************************************
1840 template< typename MT // Type of the sparse matrix
1841  , bool SO > // Storage order
1842 inline decltype(auto) min( const SparseMatrix<MT,SO>& sm )
1843 {
1845 
1846  return reduce( ~sm, Min() );
1847 }
1848 //*************************************************************************************************
1849 
1850 
1851 //*************************************************************************************************
1884 template< size_t RF // Reduction flag
1885  , typename MT // Type of the sparse matrix
1886  , bool SO > // Storage order
1887 inline decltype(auto) min( const SparseMatrix<MT,SO>& sm )
1888 {
1890 
1891  return reduce<RF>( ~sm, Min() );
1892 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1918 template< typename MT // Type of the sparse matrix
1919  , bool SO > // Storage order
1920 inline decltype(auto) max( const SparseMatrix<MT,SO>& sm )
1921 {
1923 
1924  return reduce( ~sm, Max() );
1925 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1962 template< size_t RF // Reduction flag
1963  , typename MT // Type of the sparse matrix
1964  , bool SO > // Storage order
1965 inline decltype(auto) max( const SparseMatrix<MT,SO>& sm )
1966 {
1968 
1969  return reduce<RF>( ~sm, Max() );
1970 }
1971 //*************************************************************************************************
1972 
1973 } // namespace blaze
1974 
1975 #endif
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: SMatReduceExpr.h:1011
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: SMatReduceExpr.h:149
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatReduceExpr.h:1131
Header file for the blaze::checked and blaze::unchecked instances.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatReduceExpr.h:1185
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: SMatReduceExpr.h:1101
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: SMatReduceExpr.h:1023
If_t< useAssign, const ResultType, const SMatReduceExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatReduceExpr.h:807
Header file for basic type definitions.
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatReduceExpr.h:124
Header file for the Add functor.
Operand sm_
Sparse matrix of the reduction expression.
Definition: SMatReduceExpr.h:1042
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
size_t index_
Index to the current matrix row.
Definition: SMatReduceExpr.h:1043
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: SMatReduceExpr.h:823
Operation operation() const
Returns a copy of the reduction operation.
Definition: SMatReduceExpr.h:232
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: SMatReduceExpr.h:1035
OP Operation
Data type of the custom unary operation.
Definition: SMatReduceExpr.h:157
Header file for the MatReduceExpr base class.
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 serial shim.
Base class for all matrix reduction expression templates.The MatReduceExpr class serves as a tag for ...
Definition: MatReduceExpr.h:67
PointerType pointer
Pointer return type.
Definition: SMatReduceExpr.h:832
const ConstIterator operator++(int)
Post-increment operator.
Definition: SMatReduceExpr.h:891
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
decltype(auto) prod(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of multiplication.
Definition: DMatReduceExpr.h:2220
Header file for the DenseVector base class.
Generic wrapper for the addition operator.
Definition: Add.h:83
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatReduceExpr.h:276
Operand sm_
Sparse matrix of the reduction expression.
Definition: SMatReduceExpr.h:283
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatReduceExpr.h:1075
Header file for the Computation base class.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatReduceExpr.h:802
Constraints on the storage order of matrix types.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatReduceExpr.h:266
Header file for the RequiresEvaluation type trait.
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatReduceExpr.h:1153
Header file for the reduce trait.
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: SMatReduceExpr.h:1111
ReferenceType reference
Reference return type.
Definition: SMatReduceExpr.h:833
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatReduceExpr.h:1175
ElementType * PointerType
Pointer return type.
Definition: SMatReduceExpr.h:825
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
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
OppositeType_t< MT > OT
Opposite type of the sparse matrix expression.
Definition: SMatReduceExpr.h:125
Header file for the SparseMatrix base class.
Constraint on the transpose flag of vector types.
OP Operation
Data type of the custom unary operation.
Definition: SMatReduceExpr.h:813
Constraint on the data type.
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatReduceExpr.h:154
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
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatReduceExpr.h:1165
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatReduceExpr.h:150
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:955
decltype(auto) reduce(const DenseMatrix< MT, SO > &dm, OP op)
Performs a custom reduction operation on the given dense matrix.
Definition: DMatReduceExpr.h:2017
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:933
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: SMatReduceExpr.h:803
ElementType_t< MT > ET
Element type of the sparse matrix expression.
Definition: SMatReduceExpr.h:764
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatReduceExpr.h:804
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Compile time assertion.
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatReduceExpr.h:801
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatReduceExpr.h:186
decltype(auto) operator *(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9091
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:1162
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatReduceExpr.h:127
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
ElementType_t< MT > ET
Element type of the sparse matrix expression.
Definition: SMatReduceExpr.h:126
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2147
Header file for the Mult functor.
ReduceTrait_t< RT, OP, columnwise > ResultType
Result type for expression template evaluations.
Definition: SMatReduceExpr.h:146
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:944
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatReduceExpr.h:212
OP op_
The reduction operation.
Definition: SMatReduceExpr.h:1044
Operation operation() const
Returns a copy of the reduction operation.
Definition: SMatReduceExpr.h:1141
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatReduceExpr.h:256
ValueType value_type
Type of the underlying elements.
Definition: SMatReduceExpr.h:831
Constraint on the data type.
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: SMatReduceExpr.h:869
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:1198
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Constraint on the data type.
Operation op_
The reduction operation.
Definition: SMatReduceExpr.h:284
IteratorCategory iterator_category
The iterator category.
Definition: SMatReduceExpr.h:830
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatReduceExpr.h:810
ElementType & ReferenceType
Reference return type.
Definition: SMatReduceExpr.h:826
Header file for the EnableIf class template.
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatReduceExpr.h:147
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:977
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
const ConstIterator operator--(int)
Post-decrement operator.
Definition: SMatReduceExpr.h:912
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatReduceExpr.h:222
constexpr size_t columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:90
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: SMatReduceExpr.h:999
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.The ReduceTrait_t alias declaration pr...
Definition: ReduceTrait.h:173
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
Generic wrapper for the max() function.
Definition: Max.h:80
SMatReduceExpr(const MT &sm, OP op) noexcept
Constructor for the SMatReduceExpr class.
Definition: SMatReduceExpr.h:174
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatReduceExpr.h:199
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatReduceExpr.h:763
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
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatReduceExpr.h:1121
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: SMatReduceExpr.h:857
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Operation op_
The reduction operation.
Definition: SMatReduceExpr.h:1193
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for all forward declarations for expression class templates.
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
Constraints on the storage order of matrix types.
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatReduceExpr.h:880
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Header file for the HasMember type traits.
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:966
#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
Base template for row-major sparse matrix partial reduction operations.The SMatReduceExpr class repre...
Definition: SMatReduceExpr.h:96
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
SMatReduceExpr(const MT &sm, OP op) noexcept
Constructor for the SMatReduceExpr class.
Definition: SMatReduceExpr.h:1063
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatReduceExpr.h:244
Generic wrapper for the min() function.
Definition: Min.h:80
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatReduceExpr.h:1088
Header file for the Min functor.
ReduceTrait_t< RT, OP, rowwise > ResultType
Result type for expression template evaluations.
Definition: SMatReduceExpr.h:800
#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
Expression object for column-wise row-major sparse matrix reduction operations.This specialization of...
Definition: SMatReduceExpr.h:118
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
constexpr size_t rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:70
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Generic wrapper for the multiplication operator.
Definition: Mult.h:80
ConstIterator(Operand sm, size_t index, OP op)
Constructor for the ConstIterator class.
Definition: SMatReduceExpr.h:844
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
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatReduceExpr.h:151
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatReduceExpr.h:988
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
Operand sm_
Sparse matrix of the reduction expression.
Definition: SMatReduceExpr.h:1192
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
Header file for the Max functor.
ElementType ValueType
Type of the underlying elements.
Definition: SMatReduceExpr.h:824
Expression object for row-wise row-major sparse matrix reduction operations.This specialization of th...
Definition: SMatReduceExpr.h:757
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatReduceExpr.h:148
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type,...
Definition: SparseMatrix.h:61
Header file for the reduction flags.
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ConstIterator & operator--()
Pre-decrement operator.
Definition: SMatReduceExpr.h:901