SMatMapExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATMAPEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATMAPEXPR_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>
54 #include <blaze/math/Functors.h>
64 #include <blaze/util/Assert.h>
65 #include <blaze/util/EnableIf.h>
67 #include <blaze/util/mpl/If.h>
68 #include <blaze/util/Types.h>
73 
74 
75 namespace blaze {
76 
77 //=================================================================================================
78 //
79 // CLASS SMATMAPEXPR
80 //
81 //=================================================================================================
82 
83 //*************************************************************************************************
90 template< typename MT // Type of the sparse matrix
91  , typename OP // Type of the custom operation
92  , bool SO > // Storage order
93 class SMatMapExpr
94  : public MatMapExpr< SparseMatrix< SMatMapExpr<MT,OP,SO>, SO > >
95  , private Computation
96 {
97  private:
98  //**Type definitions****************************************************************************
99  using RT = ResultType_t<MT>;
102  //**********************************************************************************************
103 
104  //**Serial evaluation strategy******************************************************************
106 
112  static constexpr bool useAssign = RequiresEvaluation_v<MT>;
113 
115  template< typename MT2 >
117  static constexpr bool UseAssign_v = useAssign;
119  //**********************************************************************************************
120 
121  //**Parallel evaluation strategy****************************************************************
123 
129  template< typename MT2 >
130  static constexpr bool UseSMPAssign_v =
133  //**********************************************************************************************
134 
135  public:
136  //**Type definitions****************************************************************************
143 
145  using ReturnType = decltype( std::declval<OP>()( std::declval<RN>() ) );
146 
149 
151  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
152 
154  using Operation = OP;
155  //**********************************************************************************************
156 
157  //**ConstIterator class definition**************************************************************
161  {
162  public:
163  //**Type definitions*************************************************************************
166 
169 
170  using IteratorCategory = std::forward_iterator_tag;
171  using ValueType = Element;
175 
176  // STL iterator requirements
182  //*******************************************************************************************
183 
184  //**Constructor******************************************************************************
190  inline ConstIterator( IteratorType it, OP op )
191  : it_( it ) // Iterator over the elements of the sparse matrix expression
192  , op_( op ) // The custom unary operation
193  {}
194  //*******************************************************************************************
195 
196  //**Prefix increment operator****************************************************************
202  ++it_;
203  return *this;
204  }
205  //*******************************************************************************************
206 
207  //**Element access operator******************************************************************
212  inline const Element operator*() const {
213  return Element( op_( it_->value() ), it_->index() );
214  }
215  //*******************************************************************************************
216 
217  //**Element access operator******************************************************************
222  inline const ConstIterator* operator->() const {
223  return this;
224  }
225  //*******************************************************************************************
226 
227  //**Value function***************************************************************************
232  inline ReturnType value() const {
233  return op_( it_->value() );
234  }
235  //*******************************************************************************************
236 
237  //**Index function***************************************************************************
242  inline size_t index() const {
243  return it_->index();
244  }
245  //*******************************************************************************************
246 
247  //**Equality operator************************************************************************
253  inline bool operator==( const ConstIterator& rhs ) const {
254  return it_ == rhs.it_;
255  }
256  //*******************************************************************************************
257 
258  //**Inequality operator**********************************************************************
264  inline bool operator!=( const ConstIterator& rhs ) const {
265  return it_ != rhs.it_;
266  }
267  //*******************************************************************************************
268 
269  //**Subtraction operator*********************************************************************
275  inline DifferenceType operator-( const ConstIterator& rhs ) const {
276  return it_ - rhs.it_;
277  }
278  //*******************************************************************************************
279 
280  private:
281  //**Member variables*************************************************************************
283  OP op_;
284  //*******************************************************************************************
285  };
286  //**********************************************************************************************
287 
288  //**Compilation flags***************************************************************************
290  static constexpr bool smpAssignable = MT::smpAssignable;
291  //**********************************************************************************************
292 
293  //**Constructor*********************************************************************************
299  explicit inline SMatMapExpr( const MT& sm, OP op ) noexcept
300  : sm_( sm ) // Sparse matrix of the map expression
301  , op_( op ) // The custom unary operation
302  {}
303  //**********************************************************************************************
304 
305  //**Access operator*****************************************************************************
312  inline ReturnType operator()( size_t i, size_t j ) const {
313  BLAZE_INTERNAL_ASSERT( i < sm_.rows() , "Invalid row access index" );
314  BLAZE_INTERNAL_ASSERT( j < sm_.columns(), "Invalid column access index" );
315  return op_( sm_(i,j) );
316  }
317  //**********************************************************************************************
318 
319  //**At function*********************************************************************************
327  inline ReturnType at( size_t i, size_t j ) const {
328  if( i >= sm_.rows() ) {
329  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
330  }
331  if( j >= sm_.columns() ) {
332  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
333  }
334  return (*this)(i,j);
335  }
336  //**********************************************************************************************
337 
338  //**Begin function******************************************************************************
344  inline ConstIterator begin( size_t i ) const {
345  return ConstIterator( sm_.begin(i), op_ );
346  }
347  //**********************************************************************************************
348 
349  //**End function********************************************************************************
355  inline ConstIterator end( size_t i ) const {
356  return ConstIterator( sm_.end(i), op_ );
357  }
358  //**********************************************************************************************
359 
360  //**Rows function*******************************************************************************
365  inline size_t rows() const noexcept {
366  return sm_.rows();
367  }
368  //**********************************************************************************************
369 
370  //**Columns function****************************************************************************
375  inline size_t columns() const noexcept {
376  return sm_.columns();
377  }
378  //**********************************************************************************************
379 
380  //**NonZeros function***************************************************************************
385  inline size_t nonZeros() const {
386  return sm_.nonZeros();
387  }
388  //**********************************************************************************************
389 
390  //**NonZeros function***************************************************************************
396  inline size_t nonZeros( size_t i ) const {
397  return sm_.nonZeros(i);
398  }
399  //**********************************************************************************************
400 
401  //**Find function*******************************************************************************
408  inline ConstIterator find( size_t i, size_t j ) const {
410  return ConstIterator( sm_.find( i, j ), op_ );
411  }
412  //**********************************************************************************************
413 
414  //**LowerBound function*************************************************************************
421  inline ConstIterator lowerBound( size_t i, size_t j ) const {
423  return ConstIterator( sm_.lowerBound( i, j ), op_ );
424  }
425  //**********************************************************************************************
426 
427  //**UpperBound function*************************************************************************
434  inline ConstIterator upperBound( size_t i, size_t j ) const {
436  return ConstIterator( sm_.upperBound( i, j ), op_ );
437  }
438  //**********************************************************************************************
439 
440  //**Operand access******************************************************************************
445  inline Operand operand() const noexcept {
446  return sm_;
447  }
448  //**********************************************************************************************
449 
450  //**Operation access****************************************************************************
455  inline Operation operation() const {
456  return op_;
457  }
458  //**********************************************************************************************
459 
460  //**********************************************************************************************
466  template< typename T >
467  inline bool canAlias( const T* alias ) const noexcept {
468  return sm_.canAlias( alias );
469  }
470  //**********************************************************************************************
471 
472  //**********************************************************************************************
478  template< typename T >
479  inline bool isAliased( const T* alias ) const noexcept {
480  return sm_.isAliased( alias );
481  }
482  //**********************************************************************************************
483 
484  //**********************************************************************************************
489  inline bool canSMPAssign() const noexcept {
490  return sm_.canSMPAssign();
491  }
492  //**********************************************************************************************
493 
494  private:
495  //**Member variables****************************************************************************
498  //**********************************************************************************************
499 
500  //**Assignment to dense matrices****************************************************************
514  template< typename MT2 // Type of the target dense matrix
515  , bool SO2 > // Storage order of the target dense matrix
516  friend inline auto assign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
518  {
520 
524 
525  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
526  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
527 
528  const RT tmp( serial( rhs.sm_ ) );
529  assign( ~lhs, map( tmp, rhs.op_ ) );
530  }
532  //**********************************************************************************************
533 
534  //**Assignment to row-major sparse matrices*****************************************************
549  template< typename MT2 > // Type of the target sparse matrix
550  friend inline auto assign( SparseMatrix<MT2,false>& lhs, const SMatMapExpr& rhs )
552  IsSame_v< UnderlyingNumeric_t<MT>, UnderlyingNumeric_t<MT2> > >
553  {
555 
556  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
557  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
558 
559  assign( ~lhs, rhs.sm_ );
560 
561  const size_t m( rhs.rows() );
562 
563  for( size_t i=0UL; i<m; ++i ) {
564  const auto end( (~lhs).end(i) );
565  for( auto element=(~lhs).begin(i); element!=end; ++element ) {
566  element->value() = rhs.op_( element->value() );
567  }
568  }
569  }
571  //**********************************************************************************************
572 
573  //**Assignment to column-major sparse matrices**************************************************
588  template< typename MT2 > // Type of the target sparse matrix
589  friend inline auto assign( SparseMatrix<MT2,true>& lhs, const SMatMapExpr& rhs )
590  -> EnableIf_t< UseAssign_v<MT2> &&
591  IsSame_v< UnderlyingNumeric_t<MT>, UnderlyingNumeric_t<MT2> > >
592  {
594 
595  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
596  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
597 
598  assign( ~lhs, rhs.sm_ );
599 
600  const size_t n( rhs.columns() );
601 
602  for( size_t j=0UL; j<n; ++j ) {
603  const auto end( (~lhs).end(j) );
604  for( auto element=(~lhs).begin(j); element!=end; ++element ) {
605  element->value() = rhs.op_( element->value() );
606  }
607  }
608  }
610  //**********************************************************************************************
611 
612  //**Assignment to sparse matrices***************************************************************
627  template< typename MT2 // Type of the target sparse matrix
628  , bool SO2 > // Storage order of the target sparse matrix
629  friend inline auto assign( SparseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
630  -> EnableIf_t< UseAssign_v<MT2> &&
631  !IsSame_v< UnderlyingNumeric_t<MT>, UnderlyingNumeric_t<MT2> > >
632  {
634 
638 
639  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
640  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
641 
642  const RT tmp( serial( rhs.sm_ ) );
643  (~lhs).reserve( tmp.nonZeros() );
644  assign( ~lhs, map( tmp, rhs.op_ ) );
645  }
647  //**********************************************************************************************
648 
649  //**Addition assignment to dense matrices*******************************************************
663  template< typename MT2 // Type of the target dense matrix
664  , bool SO2 > // Storage order of the target dense matrix
665  friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
666  -> EnableIf_t< UseAssign_v<MT2> >
667  {
669 
673 
674  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
675  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
676 
677  const RT tmp( serial( rhs.sm_ ) );
678  addAssign( ~lhs, map( tmp, rhs.op_ ) );
679  }
681  //**********************************************************************************************
682 
683  //**Addition assignment to sparse matrices******************************************************
684  // No special implementation for the addition assignment to sparse matrices.
685  //**********************************************************************************************
686 
687  //**Subtraction assignment to dense matrices****************************************************
701  template< typename MT2 // Type of the target dense matrix
702  , bool SO2 > // Storage order of the target sparse matrix
703  friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
704  -> EnableIf_t< UseAssign_v<MT2> >
705  {
707 
711 
712  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
713  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
714 
715  const RT tmp( serial( rhs.sm_ ) );
716  subAssign( ~lhs, map( tmp, rhs.op_ ) );
717  }
719  //**********************************************************************************************
720 
721  //**Subtraction assignment to sparse matrices***************************************************
722  // No special implementation for the subtraction assignment to sparse matrices.
723  //**********************************************************************************************
724 
725  //**Schur product assignment to dense matrices**************************************************
739  template< typename MT2 // Type of the target dense matrix
740  , bool SO2 > // Storage order of the target dense matrix
741  friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
742  -> EnableIf_t< UseAssign_v<MT2> >
743  {
745 
749 
750  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
751  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
752 
753  const RT tmp( serial( rhs.sm_ ) );
754  schurAssign( ~lhs, map( tmp, rhs.op_ ) );
755  }
757  //**********************************************************************************************
758 
759  //**Schur product assignment to sparse matrices*************************************************
760  // No special implementation for the Schur product assignment to sparse matrices.
761  //**********************************************************************************************
762 
763  //**Multiplication assignment to dense matrices*************************************************
764  // No special implementation for the multiplication assignment to dense matrices.
765  //**********************************************************************************************
766 
767  //**Multiplication assignment to sparse matrices************************************************
768  // No special implementation for the multiplication assignment to sparse matrices.
769  //**********************************************************************************************
770 
771  //**SMP assignment to dense matrices************************************************************
785  template< typename MT2 // Type of the target dense matrix
786  , bool SO2 > // Storage order of the target dense matrix
787  friend inline auto smpAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
788  -> EnableIf_t< UseSMPAssign_v<MT2> >
789  {
791 
795 
796  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
797  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
798 
799  const RT tmp( rhs.sm_ );
800  smpAssign( ~lhs, map( tmp, rhs.op_ ) );
801  }
803  //**********************************************************************************************
804 
805  //**SMP assignment to sparse matrices***********************************************************
806  // No special implementation for the SMP assignment to sparse matrices.
807  //**********************************************************************************************
808 
809  //**SMP addition assignment to dense matrices***************************************************
823  template< typename MT2 // Type of the target dense matrix
824  , bool SO2 > // Storage order of the target dense matrix
825  friend inline auto smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
826  -> EnableIf_t< UseSMPAssign_v<MT2> >
827  {
829 
833 
834  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
835  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
836 
837  const RT tmp( rhs.sm_ );
838  smpAddAssign( ~lhs, map( tmp, rhs.op_ ) );
839  }
841  //**********************************************************************************************
842 
843  //**SMP addition assignment to sparse matrices**************************************************
844  // No special implementation for the SMP addition assignment to sparse matrices.
845  //**********************************************************************************************
846 
847  //**SMP subtraction assignment to dense matrices************************************************
861  template< typename MT2 // Type of the target dense matrix
862  , bool SO2 > // Storage order of the target sparse matrix
863  friend inline auto smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
864  -> EnableIf_t< UseSMPAssign_v<MT2> >
865  {
867 
871 
872  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
873  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
874 
875  const RT tmp( rhs.sm_ );
876  smpSubAssign( ~lhs, map( tmp, rhs.op_ ) );
877  }
879  //**********************************************************************************************
880 
881  //**SMP subtraction assignment to sparse matrices***********************************************
882  // No special implementation for the SMP subtraction assignment to sparse matrices.
883  //**********************************************************************************************
884 
885  //**SMP Schur product assignment to dense matrices**********************************************
899  template< typename MT2 // Type of the target dense matrix
900  , bool SO2 > // Storage order of the target dense matrix
901  friend inline auto smpSchurAssign( DenseMatrix<MT2,SO2>& lhs, const SMatMapExpr& rhs )
902  -> EnableIf_t< UseSMPAssign_v<MT2> >
903  {
905 
909 
910  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
911  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
912 
913  const RT tmp( rhs.sm_ );
914  smpSchurAssign( ~lhs, map( tmp, rhs.op_ ) );
915  }
917  //**********************************************************************************************
918 
919  //**SMP Schur product assignment to sparse matrices*********************************************
920  // No special implementation for the SMP Schur product assignment to sparse matrices.
921  //**********************************************************************************************
922 
923  //**SMP multiplication assignment to dense matrices*********************************************
924  // No special implementation for the SMP multiplication assignment to dense matrices.
925  //**********************************************************************************************
926 
927  //**SMP multiplication assignment to sparse matrices********************************************
928  // No special implementation for the SMP multiplication assignment to sparse matrices.
929  //**********************************************************************************************
930 
931  //**Compile time checks*************************************************************************
936  //**********************************************************************************************
937 };
938 //*************************************************************************************************
939 
940 
941 
942 
943 //=================================================================================================
944 //
945 // GLOBAL FUNCTIONS
946 //
947 //=================================================================================================
948 
949 //*************************************************************************************************
967 template< typename MT // Type of the sparse matrix
968  , bool SO // Storage order
969  , typename OP > // Type of the custom operation
970 inline decltype(auto) map( const SparseMatrix<MT,SO>& sm, OP op )
971 {
973 
974  using ReturnType = const SMatMapExpr<MT,OP,SO>;
975  return ReturnType( ~sm, op );
976 }
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
998 template< typename MT // Type of the sparse matrix
999  , bool SO // Storage order
1000  , typename OP > // Type of the custom operation
1001 inline decltype(auto) forEach( const SparseMatrix<MT,SO>& sm, OP op )
1002 {
1004 
1005  using ReturnType = const SMatMapExpr<MT,OP,SO>;
1006  return ReturnType( ~sm, op );
1007 }
1008 //*************************************************************************************************
1009 
1010 
1011 //*************************************************************************************************
1028 template< typename MT // Type of the sparse matrix
1029  , bool SO > // Storage order
1030 inline decltype(auto) abs( const SparseMatrix<MT,SO>& sm )
1031 {
1033 
1034  using ReturnType = const SMatMapExpr<MT,Abs,SO>;
1035  return ReturnType( ~sm, Abs() );
1036 }
1037 //*************************************************************************************************
1038 
1039 
1040 //*************************************************************************************************
1057 template< typename MT // Type of the sparse matrix
1058  , bool SO > // Storage order
1059 inline decltype(auto) sign( const SparseMatrix<MT,SO>& sm )
1060 {
1062 
1063  using ReturnType = const SMatMapExpr<MT,Sign,SO>;
1064  return ReturnType( ~sm, Sign() );
1065 }
1066 //*************************************************************************************************
1067 
1068 
1069 //*************************************************************************************************
1086 template< typename MT // Type of the sparse matrix
1087  , bool SO > // Storage order
1088 inline decltype(auto) floor( const SparseMatrix<MT,SO>& sm )
1089 {
1091 
1092  using ReturnType = const SMatMapExpr<MT,Floor,SO>;
1093  return ReturnType( ~sm, Floor() );
1094 }
1095 //*************************************************************************************************
1096 
1097 
1098 //*************************************************************************************************
1115 template< typename MT // Type of the sparse matrix
1116  , bool SO > // Storage order
1117 inline decltype(auto) ceil( const SparseMatrix<MT,SO>& sm )
1118 {
1120 
1121  using ReturnType = const SMatMapExpr<MT,Ceil,SO>;
1122  return ReturnType( ~sm, Ceil() );
1123 }
1124 //*************************************************************************************************
1125 
1126 
1127 //*************************************************************************************************
1144 template< typename MT // Type of the sparse matrix
1145  , bool SO > // Storage order
1146 inline decltype(auto) trunc( const SparseMatrix<MT,SO>& sm )
1147 {
1149 
1150  using ReturnType = const SMatMapExpr<MT,Trunc,SO>;
1151  return ReturnType( ~sm, Trunc() );
1152 }
1153 //*************************************************************************************************
1154 
1155 
1156 //*************************************************************************************************
1173 template< typename MT // Type of the sparse matrix
1174  , bool SO > // Storage order
1175 inline decltype(auto) round( const SparseMatrix<MT,SO>& sm )
1176 {
1178 
1179  using ReturnType = const SMatMapExpr<MT,Round,SO>;
1180  return ReturnType( ~sm, Round() );
1181 }
1182 //*************************************************************************************************
1183 
1184 
1185 //*************************************************************************************************
1202 template< typename MT // Type of the sparse matrix
1203  , bool SO > // Storage order
1204 inline decltype(auto) conj( const SparseMatrix<MT,SO>& sm )
1205 {
1207 
1208  using ReturnType = const SMatMapExpr<MT,Conj,SO>;
1209  return ReturnType( ~sm, Conj() );
1210 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
1240 template< typename MT // Type of the sparse matrix
1241  , bool SO > // Storage order
1242 inline decltype(auto) ctrans( const SparseMatrix<MT,SO>& sm )
1243 {
1245 
1246  return trans( conj( ~sm ) );
1247 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1268 template< typename MT // Type of the sparse matrix
1269  , bool SO > // Storage order
1270 inline decltype(auto) real( const SparseMatrix<MT,SO>& sm )
1271 {
1273 
1274  using ReturnType = const SMatMapExpr<MT,Real,SO>;
1275  return ReturnType( ~sm, Real() );
1276 }
1277 //*************************************************************************************************
1278 
1279 
1280 //*************************************************************************************************
1297 template< typename MT // Type of the sparse matrix
1298  , bool SO > // Storage order
1299 inline decltype(auto) imag( const SparseMatrix<MT,SO>& sm )
1300 {
1302 
1303  using ReturnType = const SMatMapExpr<MT,Imag,SO>;
1304  return ReturnType( ~sm, Imag() );
1305 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1329 template< typename MT // Type of the sparse matrix
1330  , bool SO > // Storage order
1331 inline decltype(auto) sqrt( const SparseMatrix<MT,SO>& sm )
1332 {
1334 
1335  using ReturnType = const SMatMapExpr<MT,Sqrt,SO>;
1336  return ReturnType( ~sm, Sqrt() );
1337 }
1338 //*************************************************************************************************
1339 
1340 
1341 //*************************************************************************************************
1361 template< typename MT // Type of the sparse matrix
1362  , bool SO > // Storage order
1363 inline decltype(auto) invsqrt( const SparseMatrix<MT,SO>& sm )
1364 {
1366 
1367  using ReturnType = const SMatMapExpr<MT,InvSqrt,SO>;
1368  return ReturnType( ~sm, InvSqrt() );
1369 }
1370 //*************************************************************************************************
1371 
1372 
1373 //*************************************************************************************************
1393 template< typename MT // Type of the sparse matrix
1394  , bool SO > // Storage order
1395 inline decltype(auto) cbrt( const SparseMatrix<MT,SO>& sm )
1396 {
1398 
1399  using ReturnType = const SMatMapExpr<MT,Cbrt,SO>;
1400  return ReturnType( ~sm, Cbrt() );
1401 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1425 template< typename MT // Type of the sparse matrix
1426  , bool SO > // Storage order
1427 inline decltype(auto) invcbrt( const SparseMatrix<MT,SO>& sm )
1428 {
1430 
1431  using ReturnType = const SMatMapExpr<MT,InvCbrt,SO>;
1432  return ReturnType( ~sm, InvCbrt() );
1433 }
1434 //*************************************************************************************************
1435 
1436 
1437 //*************************************************************************************************
1456 template< typename MT // Type of the sparse matrix
1457  , bool SO // Storage order
1458  , typename DT > // Type of the delimiters
1459 inline decltype(auto) clamp( const SparseMatrix<MT,SO>& sm, const DT& min, const DT& max )
1460 {
1462 
1463  using ReturnType = const SMatMapExpr<MT,Clamp<DT>,SO>;
1464  return ReturnType( ~sm, Clamp<DT>( min, max ) );
1465 }
1466 //*************************************************************************************************
1467 
1468 
1469 //*************************************************************************************************
1487 template< typename MT // Type of the sparse matrix
1488  , bool SO // Storage order
1489  , typename ST // Type of the scalar exponent
1490  , EnableIf_t< IsNumeric_v<ST> >* = nullptr >
1491 inline decltype(auto) pow( const SparseMatrix<MT,SO>& sm, ST exp )
1492 {
1494 
1495  using ScalarType = MultTrait_t< UnderlyingBuiltin_t<MT>, ST >;
1497  return ReturnType( ~sm, UnaryPow<ScalarType>( exp ) );
1498 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1519 template< typename MT // Type of the sparse matrix
1520  , bool SO > // Storage order
1521 inline decltype(auto) exp( const SparseMatrix<MT,SO>& sm )
1522 {
1524 
1525  using ReturnType = const SMatMapExpr<MT,Exp,SO>;
1526  return ReturnType( ~sm, Exp() );
1527 }
1528 //*************************************************************************************************
1529 
1530 
1531 //*************************************************************************************************
1548 template< typename MT // Type of the sparse matrix
1549  , bool SO > // Storage order
1550 inline decltype(auto) exp2( const SparseMatrix<MT,SO>& sm )
1551 {
1553 
1554  using ReturnType = const SMatMapExpr<MT,Exp2,SO>;
1555  return ReturnType( ~sm, Exp2() );
1556 }
1557 //*************************************************************************************************
1558 
1559 
1560 //*************************************************************************************************
1577 template< typename MT // Type of the sparse matrix
1578  , bool SO > // Storage order
1579 inline decltype(auto) exp10( const SparseMatrix<MT,SO>& sm )
1580 {
1582 
1583  using ReturnType = const SMatMapExpr<MT,Exp10,SO>;
1584  return ReturnType( ~sm, Exp10() );
1585 }
1586 //*************************************************************************************************
1587 
1588 
1589 //*************************************************************************************************
1609 template< typename MT // Type of the sparse matrix
1610  , bool SO > // Storage order
1611 inline decltype(auto) log( const SparseMatrix<MT,SO>& sm )
1612 {
1614 
1615  using ReturnType = const SMatMapExpr<MT,Log,SO>;
1616  return ReturnType( ~sm, Log() );
1617 }
1618 //*************************************************************************************************
1619 
1620 
1621 //*************************************************************************************************
1641 template< typename MT // Type of the sparse matrix
1642  , bool SO > // Storage order
1643 inline decltype(auto) log2( const SparseMatrix<MT,SO>& sm )
1644 {
1646 
1647  using ReturnType = const SMatMapExpr<MT,Log2,SO>;
1648  return ReturnType( ~sm, Log2() );
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 //*************************************************************************************************
1673 template< typename MT // Type of the sparse matrix
1674  , bool SO > // Storage order
1675 inline decltype(auto) log10( const SparseMatrix<MT,SO>& sm )
1676 {
1678 
1679  using ReturnType = const SMatMapExpr<MT,Log10,SO>;
1680  return ReturnType( ~sm, Log10() );
1681 }
1682 //*************************************************************************************************
1683 
1684 
1685 //*************************************************************************************************
1702 template< typename MT // Type of the sparse matrix
1703  , bool SO > // Storage order
1704 inline decltype(auto) sin( const SparseMatrix<MT,SO>& sm )
1705 {
1707 
1708  using ReturnType = const SMatMapExpr<MT,Sin,SO>;
1709  return ReturnType( ~sm, Sin() );
1710 }
1711 //*************************************************************************************************
1712 
1713 
1714 //*************************************************************************************************
1734 template< typename MT // Type of the sparse matrix
1735  , bool SO > // Storage order
1736 inline decltype(auto) asin( const SparseMatrix<MT,SO>& sm )
1737 {
1739 
1740  using ReturnType = const SMatMapExpr<MT,Asin,SO>;
1741  return ReturnType( ~sm, Asin() );
1742 }
1743 //*************************************************************************************************
1744 
1745 
1746 //*************************************************************************************************
1763 template< typename MT // Type of the sparse matrix
1764  , bool SO > // Storage order
1765 inline decltype(auto) sinh( const SparseMatrix<MT,SO>& sm )
1766 {
1768 
1769  using ReturnType = const SMatMapExpr<MT,Sinh,SO>;
1770  return ReturnType( ~sm, Sinh() );
1771 }
1772 //*************************************************************************************************
1773 
1774 
1775 //*************************************************************************************************
1792 template< typename MT // Type of the sparse matrix
1793  , bool SO > // Storage order
1794 inline decltype(auto) asinh( const SparseMatrix<MT,SO>& sm )
1795 {
1797 
1798  using ReturnType = const SMatMapExpr<MT,Asinh,SO>;
1799  return ReturnType( ~sm, Asinh() );
1800 }
1801 //*************************************************************************************************
1802 
1803 
1804 //*************************************************************************************************
1821 template< typename MT // Type of the sparse matrix
1822  , bool SO > // Storage order
1823 inline decltype(auto) cos( const SparseMatrix<MT,SO>& sm )
1824 {
1826 
1827  using ReturnType = const SMatMapExpr<MT,Cos,SO>;
1828  return ReturnType( ~sm, Cos() );
1829 }
1830 //*************************************************************************************************
1831 
1832 
1833 //*************************************************************************************************
1853 template< typename MT // Type of the sparse matrix
1854  , bool SO > // Storage order
1855 inline decltype(auto) acos( const SparseMatrix<MT,SO>& sm )
1856 {
1858 
1859  using ReturnType = const SMatMapExpr<MT,Acos,SO>;
1860  return ReturnType( ~sm, Acos() );
1861 }
1862 //*************************************************************************************************
1863 
1864 
1865 //*************************************************************************************************
1882 template< typename MT // Type of the sparse matrix
1883  , bool SO > // Storage order
1884 inline decltype(auto) cosh( const SparseMatrix<MT,SO>& sm )
1885 {
1887 
1888  using ReturnType = const SMatMapExpr<MT,Cosh,SO>;
1889  return ReturnType( ~sm, Cosh() );
1890 }
1891 //*************************************************************************************************
1892 
1893 
1894 //*************************************************************************************************
1914 template< typename MT // Type of the sparse matrix
1915  , bool SO > // Storage order
1916 inline decltype(auto) acosh( const SparseMatrix<MT,SO>& sm )
1917 {
1919 
1920  using ReturnType = const SMatMapExpr<MT,Acosh,SO>;
1921  return ReturnType( ~sm, Acosh() );
1922 }
1923 //*************************************************************************************************
1924 
1925 
1926 //*************************************************************************************************
1943 template< typename MT // Type of the sparse matrix
1944  , bool SO > // Storage order
1945 inline decltype(auto) tan( const SparseMatrix<MT,SO>& sm )
1946 {
1948 
1949  using ReturnType = const SMatMapExpr<MT,Tan,SO>;
1950  return ReturnType( ~sm, Tan() );
1951 }
1952 //*************************************************************************************************
1953 
1954 
1955 //*************************************************************************************************
1972 template< typename MT // Type of the sparse matrix
1973  , bool SO > // Storage order
1974 inline decltype(auto) atan( const SparseMatrix<MT,SO>& sm )
1975 {
1977 
1978  using ReturnType = const SMatMapExpr<MT,Atan,SO>;
1979  return ReturnType( ~sm, Atan() );
1980 }
1981 //*************************************************************************************************
1982 
1983 
1984 //*************************************************************************************************
2004 template< typename MT // Type of the sparse matrix
2005  , bool SO > // Storage order
2006 inline decltype(auto) tanh( const SparseMatrix<MT,SO>& sm )
2007 {
2009 
2010  using ReturnType = const SMatMapExpr<MT,Tanh,SO>;
2011  return ReturnType( ~sm, Tanh() );
2012 }
2013 //*************************************************************************************************
2014 
2015 
2016 //*************************************************************************************************
2036 template< typename MT // Type of the sparse matrix
2037  , bool SO > // Storage order
2038 inline decltype(auto) atanh( const SparseMatrix<MT,SO>& sm )
2039 {
2041 
2042  using ReturnType = const SMatMapExpr<MT,Atanh,SO>;
2043  return ReturnType( ~sm, Atanh() );
2044 }
2045 //*************************************************************************************************
2046 
2047 
2048 //*************************************************************************************************
2065 template< typename MT // Type of the sparse matrix
2066  , bool SO > // Storage order
2067 inline decltype(auto) erf( const SparseMatrix<MT,SO>& sm )
2068 {
2070 
2071  using ReturnType = const SMatMapExpr<MT,Erf,SO>;
2072  return ReturnType( ~sm, Erf() );
2073 }
2074 //*************************************************************************************************
2075 
2076 
2077 //*************************************************************************************************
2095 template< typename MT // Type of the sparse matrix
2096  , bool SO > // Storage order
2097 inline decltype(auto) erfc( const SparseMatrix<MT,SO>& sm )
2098 {
2100 
2101  using ReturnType = const SMatMapExpr<MT,Erfc,SO>;
2102  return ReturnType( ~sm, Erfc() );
2103 }
2104 //*************************************************************************************************
2105 
2106 
2107 
2108 
2109 //=================================================================================================
2110 //
2111 // GLOBAL RESTRUCTURING FUNCTIONS
2112 //
2113 //=================================================================================================
2114 
2115 //*************************************************************************************************
2126 template< typename MT // Type of the sparse matrix
2127  , bool SO > // Storage order
2128 inline decltype(auto) abs( const SMatMapExpr<MT,Abs,SO>& sm )
2129 {
2131 
2132  return sm;
2133 }
2135 //*************************************************************************************************
2136 
2137 
2138 //*************************************************************************************************
2149 template< typename MT // Type of the sparse matrix
2150  , bool SO > // Storage order
2151 inline decltype(auto) sign( const SMatMapExpr<MT,Sign,SO>& sm )
2152 {
2154 
2155  return sm;
2156 }
2158 //*************************************************************************************************
2159 
2160 
2161 //*************************************************************************************************
2172 template< typename MT // Type of the sparse matrix
2173  , bool SO > // Storage order
2174 inline decltype(auto) floor( const SMatMapExpr<MT,Floor,SO>& sm )
2175 {
2177 
2178  return sm;
2179 }
2181 //*************************************************************************************************
2182 
2183 
2184 //*************************************************************************************************
2195 template< typename MT // Type of the sparse matrix
2196  , bool SO > // Storage order
2197 inline decltype(auto) ceil( const SMatMapExpr<MT,Ceil,SO>& sm )
2198 {
2200 
2201  return sm;
2202 }
2204 //*************************************************************************************************
2205 
2206 
2207 //*************************************************************************************************
2218 template< typename MT // Type of the sparse matrix
2219  , bool SO > // Storage order
2220 inline decltype(auto) trunc( const SMatMapExpr<MT,Trunc,SO>& sm )
2221 {
2223 
2224  return sm;
2225 }
2227 //*************************************************************************************************
2228 
2229 
2230 //*************************************************************************************************
2241 template< typename MT // Type of the sparse matrix
2242  , bool SO > // Storage order
2243 inline decltype(auto) round( const SMatMapExpr<MT,Round,SO>& sm )
2244 {
2246 
2247  return sm;
2248 }
2250 //*************************************************************************************************
2251 
2252 
2253 //*************************************************************************************************
2271 template< typename MT // Type of the sparse matrix
2272  , bool TF > // Transpose flag
2273 inline decltype(auto) conj( const SMatMapExpr<MT,Conj,TF>& sm )
2274 {
2276 
2277  return sm.operand();
2278 }
2280 //*************************************************************************************************
2281 
2282 
2283 //*************************************************************************************************
2301 template< typename MT // Type of the sparse matrix
2302  , bool SO > // Storage order
2303 inline decltype(auto) conj( const SMatTransExpr<SMatMapExpr<MT,Conj,SO>,!SO>& sm )
2304 {
2306 
2307  using ReturnType = const SMatTransExpr<MT,!SO>;
2308  return ReturnType( sm.operand().operand() );
2309 }
2311 //*************************************************************************************************
2312 
2313 
2314 //*************************************************************************************************
2325 template< typename MT // Type of the sparse matrix
2326  , bool SO > // Storage order
2327 inline decltype(auto) real( const SMatMapExpr<MT,Real,SO>& sm )
2328 {
2330 
2331  return sm;
2332 }
2334 //*************************************************************************************************
2335 
2336 
2337 //*************************************************************************************************
2348 template< typename MT // Type of the sparse matrix
2349  , bool SO > // Storage order
2350 inline decltype(auto) imag( const SMatMapExpr<MT,Imag,SO>& sm )
2351 {
2353 
2354  return sm;
2355 }
2357 //*************************************************************************************************
2358 
2359 } // namespace blaze
2360 
2361 #endif
Header file for the UnderlyingNumeric type trait.
Generic wrapper for the trunc() function.
Definition: Trunc.h:80
Pointer difference type of the Blaze library.
decltype(auto) acosh(const DenseMatrix< MT, SO > &dm)
Computes the inverse hyperbolic cosine for each single element of the dense matrix dm...
Definition: DMatMapExpr.h:2038
ValueType * PointerType
Pointer return type.
Definition: SMatMapExpr.h:172
Header file for auxiliary alias declarations.
Generic wrapper for the ceil() function.
Definition: Ceil.h:80
decltype(auto) exp10(const DenseMatrix< MT, SO > &dm)
Computes for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1701
MapTrait_t< RT, OP > ResultType
Result type for expression template evaluations.
Definition: SMatMapExpr.h:139
Generic wrapper for the cbrt() function.
Definition: Cbrt.h:80
Header file for basic type definitions.
Operation operation() const
Returns a copy of the custom operation.
Definition: SMatMapExpr.h:455
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatMapExpr.h:408
Generic wrapper for the sin() function.
Definition: Sin.h:78
ReturnType_t< MT > RN
Return type of the sparse matrix expression.
Definition: SMatMapExpr.h:101
typename UnderlyingNumeric< T >::Type UnderlyingNumeric_t
Auxiliary alias declaration for the UnderlyingNumeric type trait.The UnderlyingNumeric_t alias declar...
Definition: UnderlyingNumeric.h:123
Generic wrapper for the conj() function.
Definition: Conj.h:82
Generic wrapper for the invsqrt() function.
Definition: InvSqrt.h:68
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.
decltype(auto) real(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the real part of each single element of dm.
Definition: DMatMapExpr.h:1392
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.The MapTrait_t alias declaration provides...
Definition: MapTrait.h:160
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatMapExpr.h:232
IteratorType it_
Iterator over the elements of the sparse matrix expression.
Definition: SMatMapExpr.h:282
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SMatMapExpr.h:421
Header file for the IsSame and IsStrictlySame type traits.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatMapExpr.h:479
decltype(auto) ceil(const DenseMatrix< MT, SO > &dm)
Applies the ceil() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1239
Generic wrapper for the clamp() function.
Definition: Clamp.h:60
decltype(auto) pow(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise exponential value for the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1243
Iterator over the elements of the sparse matrix map expression.
Definition: SMatMapExpr.h:160
Generic wrapper for the acosh() function.
Definition: Acosh.h:68
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
decltype(auto) clamp(const DenseMatrix< MT, SO > &dm, const DT &min, const DT &max)
Restricts each single element of the dense matrix dm to the range .
Definition: DMatMapExpr.h:1581
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the map expression.
Definition: SMatMapExpr.h:112
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatMapExpr.h:264
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatMapExpr.h:99
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatMapExpr.h:344
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatMapExpr.h:275
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatMapExpr.h:355
Generic wrapper for the pow() function with fixed exponent.
Definition: Forward.h:129
decltype(auto) sign(const DenseMatrix< MT, SO > &dm)
Applies the sign() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1181
Header file for the Computation base class.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatMapExpr.h:242
decltype(std::declval< OP >()(std::declval< RN >())) ReturnType
Return type for expression template evaluations.
Definition: SMatMapExpr.h:145
Header file for the RequiresEvaluation type trait.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatMapExpr.h:365
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatMapExpr.h:445
decltype(auto) acos(const DenseMatrix< MT, SO > &dm)
Computes the inverse cosine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1977
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatMapExpr.h:142
Expression object for the sparse matrix map() function.The SMatMapExpr class represents the compile t...
Definition: Forward.h:120
Operand sm_
Sparse matrix of the map expression.
Definition: SMatMapExpr.h:496
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
decltype(auto) erf(const DenseMatrix< MT, SO > &dm)
Computes the error function for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:2189
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatMapExpr.h:165
Header file for the SparseMatrix base class.
Constraint on the data type.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatMapExpr.h:174
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
Generic wrapper for the abs() function.
Definition: Abs.h:82
OP op_
The custom unary operation.
Definition: SMatMapExpr.h:283
Header file for the MatMapExpr base class.
Generic wrapper for the sqrt() function.
Definition: Sqrt.h:82
Header file for the ValueIndexPair class.
Header file for the multiplication trait.
decltype(auto) cos(const DenseMatrix< MT, SO > &dm)
Computes the cosine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1945
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1364
If_t< IsExpression_v< MT >, const MT, const MT &> Operand
Composite data type of the sparse matrix expression.
Definition: SMatMapExpr.h:151
Header file for the If class template.
Generic wrapper for the imag() function.
Definition: Imag.h:73
Generic wrapper for the exp10() function.
Definition: Exp10.h:66
decltype(auto) exp2(const DenseMatrix< MT, SO > &dm)
Computes for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1672
decltype(auto) sinh(const DenseMatrix< MT, SO > &dm)
Computes the hyperbolic sine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1887
Header file for the UnderlyingBuiltin type trait.
decltype(auto) asin(const DenseMatrix< MT, SO > &dm)
Computes the inverse sine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1858
decltype(auto) cosh(const DenseMatrix< MT, SO > &dm)
Computes the hyperbolic cosine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:2006
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatMapExpr.h:253
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
decltype(auto) cbrt(const DenseMatrix< MT, SO > &dm)
Computes the cubic root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1517
#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
Generic wrapper for the log10() function.
Definition: Log10.h:68
decltype(auto) trunc(const DenseMatrix< MT, SO > &dm)
Applies the trunc() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1268
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Header file for all functors.
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatMapExpr.h:290
Generic wrapper for the exp2() function.
Definition: Exp2.h:66
Generic wrapper for the asin() function.
Definition: Asin.h:78
decltype(auto) atan(const DenseMatrix< MT, SO > &dm)
Computes the inverse tangent for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:2096
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatMapExpr.h:170
decltype(auto) asinh(const DenseMatrix< MT, SO > &dm)
Computes the inverse hyperbolic sine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1916
Generic wrapper for the erf() function.
Definition: Erf.h:76
ConstIterator(IteratorType it, OP op)
Constructor for the ConstIterator class.
Definition: SMatMapExpr.h:190
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatMapExpr.h:312
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatMapExpr.h:140
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Generic wrapper for the floor() function.
Definition: Floor.h:80
decltype(auto) exp(const DenseMatrix< MT, SO > &dm)
Computes for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1643
Header file for the EnableIf class template.
decltype(auto) abs(const DenseMatrix< MT, SO > &dm)
Applies the abs() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1152
decltype(auto) log(const DenseMatrix< MT, SO > &dm)
Computes the natural logarithm for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1733
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.The MultTrait_t alias declaration provid...
Definition: MultTrait.h:240
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
Header file for the IsNumeric type trait.
decltype(auto) floor(const DenseMatrix< MT, SO > &dm)
Applies the floor() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1210
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatMapExpr.h:141
decltype(auto) round(const DenseMatrix< MT, SO > &dm)
Applies the round() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1297
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatMapExpr.h:434
decltype(auto) tanh(const DenseMatrix< MT, SO > &dm)
Computes the hyperbolic tangent for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:2128
decltype(auto) forEach(const DenseMatrix< MT, SO > &dm, OP op)
Evaluates the given custom operation on each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1123
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.
Generic wrapper for the atanh() function.
Definition: Atanh.h:78
Generic wrapper for the invcbrt() function.
Definition: InvCbrt.h:66
Generic wrapper for the real() function.
Definition: Real.h:79
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
Generic wrapper for the asinh() function.
Definition: Asinh.h:78
decltype(auto) invcbrt(const DenseMatrix< MT, SO > &dm)
Computes the inverse cubic root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1549
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatMapExpr.h:375
Generic wrapper for the tan() function.
Definition: Tan.h:78
Generic wrapper for the log() function.
Definition: Log.h:68
decltype(auto) atanh(const DenseMatrix< MT, SO > &dm)
Computes the inverse hyperbolic tangent for each single element of the dense matrix dm...
Definition: DMatMapExpr.h:2160
#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
ConstIterator_t< RemoveReference_t< Operand > > IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatMapExpr.h:168
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
Generic wrapper for the erfc() function.
Definition: Erfc.h:66
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
Generic wrapper for the cos() function.
Definition: Cos.h:68
#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
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatMapExpr.h:396
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatMapExpr.h:467
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
Header file for the RemoveReference type trait.
Generic wrapper for the sign() function.
Definition: Sign.h:80
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: SMatMapExpr.h:489
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatMapExpr.h:327
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatMapExpr.h:212
decltype(auto) sin(const DenseMatrix< MT, SO > &dm)
Computes the sine for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1826
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatMapExpr.h:385
decltype(auto) erfc(const DenseMatrix< MT, SO > &dm)
Computes the complementary error function for each single element of the dense matrix dm...
Definition: DMatMapExpr.h:2218
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
decltype(auto) sqrt(const DenseMatrix< MT, SO > &dm)
Computes the square root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1453
SMatMapExpr(const MT &sm, OP op) noexcept
Constructor for the SMatMapExpr class.
Definition: SMatMapExpr.h:299
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
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
Generic wrapper for the acos() function.
Definition: Acos.h:68
decltype(auto) tan(const DenseMatrix< MT, SO > &dm)
Computes the tangent for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:2067
OppositeType_t< MT > OT
Opposite type of the sparse matrix expression.
Definition: SMatMapExpr.h:100
If_t< useAssign, const ResultType, const SMatMapExpr &> CompositeType
Data type for composite expression templates.
Definition: SMatMapExpr.h:148
ValueType & ReferenceType
Reference return type.
Definition: SMatMapExpr.h:173
Generic wrapper for the atan() function.
Definition: Atan.h:78
Generic wrapper for the round() function.
Definition: Round.h:80
Generic wrapper for the sinh() function.
Definition: Sinh.h:78
OP Operation
Data type of the custom unary operation.
Definition: SMatMapExpr.h:154
Header file for the map trait.
IteratorCategory iterator_category
The iterator category.
Definition: SMatMapExpr.h:177
decltype(auto) log10(const DenseMatrix< MT, SO > &dm)
Computes the common logarithm for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1797
Generic wrapper for the log2() function.
Definition: Log2.h:66
decltype(auto) imag(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the imaginary part of each single element of dm.
Definition: DMatMapExpr.h:1421
Generic wrapper for the cosh() function.
Definition: Cosh.h:68
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1326
decltype(auto) log2(const DenseMatrix< MT, SO > &dm)
Computes the binary logarithm for each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1765
decltype(auto) invsqrt(const DenseMatrix< MT, SO > &dm)
Computes the inverse square root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1485
Generic wrapper for the tanh() function.
Definition: Tanh.h:78
Generic wrapper for the exp() function.
Definition: Exp.h:68
#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
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatMapExpr.h:201
Element ValueType
Type of the underlying pointers.
Definition: SMatMapExpr.h:171
#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 IsExpression type trait class.
Header file for the function trace functionality.
Operation op_
The custom unary operation.
Definition: SMatMapExpr.h:497
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs...
Definition: DMatDMatMapExpr.h:1110
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatMapExpr.h:222