SMatAbsExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATABSEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATABSEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <cmath>
44 #include <iterator>
76 #include <blaze/util/Assert.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/InvalidType.h>
81 #include <blaze/util/SelectType.h>
82 #include <blaze/util/Types.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS SMATABSEXPR
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
102 template< typename MT // Type of the sparse matrix
103  , bool SO > // Storage order
104 class SMatAbsExpr : public SparseMatrix< SMatAbsExpr<MT,SO>, SO >
105  , private MatAbsExpr
106  , private Computation
107 {
108  private:
109  //**Type definitions****************************************************************************
110  typedef typename MT::ResultType RT;
111  typedef typename MT::ReturnType RN;
112  typedef typename MT::CompositeType CT;
113  //**********************************************************************************************
114 
115  //**Return type evaluation**********************************************************************
117 
122  enum { returnExpr = !IsTemporary<RN>::value };
123 
126  //**********************************************************************************************
127 
128  //**Serial evaluation strategy******************************************************************
130 
136  enum { useAssign = RequiresEvaluation<MT>::value };
137 
139  template< typename MT2 >
141  struct UseAssign {
142  enum { value = useAssign };
143  };
145  //**********************************************************************************************
146 
147  //**Parallel evaluation strategy****************************************************************
149 
155  template< typename MT2 >
156  struct UseSMPAssign {
157  enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
158  };
160  //**********************************************************************************************
161 
162  public:
163  //**Type definitions****************************************************************************
165  typedef typename MT::ResultType ResultType;
166  typedef typename MT::OppositeType OppositeType;
167  typedef typename MT::TransposeType TransposeType;
168  typedef typename MT::ElementType ElementType;
169 
172 
175 
177  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type Operand;
178  //**********************************************************************************************
179 
180  //**ConstIterator class definition**************************************************************
184  {
185  public:
186  //**Type definitions*************************************************************************
189 
192 
193  typedef std::forward_iterator_tag IteratorCategory;
194  typedef Element ValueType;
195  typedef ValueType* PointerType;
196  typedef ValueType& ReferenceType;
198 
199  // STL iterator requirements
200  typedef IteratorCategory iterator_category;
201  typedef ValueType value_type;
202  typedef PointerType pointer;
203  typedef ReferenceType reference;
204  typedef DifferenceType difference_type;
205  //*******************************************************************************************
206 
207  //**Constructor******************************************************************************
210  inline ConstIterator( IteratorType it )
211  : it_( it ) // Iterator over the elements of the sparse matrix expression
212  {}
213  //*******************************************************************************************
214 
215  //**Prefix increment operator****************************************************************
221  ++it_;
222  return *this;
223  }
224  //*******************************************************************************************
225 
226  //**Element access operator******************************************************************
231  inline const Element operator*() const {
232  using std::abs;
233  return Element( abs( it_->value() ), it_->index() );
234  }
235  //*******************************************************************************************
236 
237  //**Element access operator******************************************************************
242  inline const ConstIterator* operator->() const {
243  return this;
244  }
245  //*******************************************************************************************
246 
247  //**Value function***************************************************************************
252  inline ReturnType value() const {
253  using std::abs;
254  return abs( it_->value() );
255  }
256  //*******************************************************************************************
257 
258  //**Index function***************************************************************************
263  inline size_t index() const {
264  return it_->index();
265  }
266  //*******************************************************************************************
267 
268  //**Equality operator************************************************************************
274  inline bool operator==( const ConstIterator& rhs ) const {
275  return it_ == rhs.it_;
276  }
277  //*******************************************************************************************
278 
279  //**Inequality operator**********************************************************************
285  inline bool operator!=( const ConstIterator& rhs ) const {
286  return it_ != rhs.it_;
287  }
288  //*******************************************************************************************
289 
290  //**Subtraction operator*********************************************************************
296  inline DifferenceType operator-( const ConstIterator& rhs ) const {
297  return it_ - rhs.it_;
298  }
299  //*******************************************************************************************
300 
301  private:
302  //**Member variables*************************************************************************
303  IteratorType it_;
304  //*******************************************************************************************
305  };
306  //**********************************************************************************************
307 
308  //**Compilation flags***************************************************************************
310  enum { smpAssignable = MT::smpAssignable };
311  //**********************************************************************************************
312 
313  //**Constructor*********************************************************************************
318  explicit inline SMatAbsExpr( const MT& sm )
319  : sm_( sm ) // Sparse matrix of the absolute value expression
320  {}
321  //**********************************************************************************************
322 
323  //**Access operator*****************************************************************************
330  inline ReturnType operator()( size_t i, size_t j ) const {
331  using std::abs;
332  BLAZE_INTERNAL_ASSERT( i < sm_.rows() , "Invalid row access index" );
333  BLAZE_INTERNAL_ASSERT( j < sm_.columns(), "Invalid column access index" );
334  return abs( sm_(i,j) );
335  }
336  //**********************************************************************************************
337 
338  //**Begin function******************************************************************************
344  inline ConstIterator begin( size_t i ) const {
345  return ConstIterator( sm_.begin(i) );
346  }
347  //**********************************************************************************************
348 
349  //**End function********************************************************************************
355  inline ConstIterator end( size_t i ) const {
356  return ConstIterator( sm_.end(i) );
357  }
358  //**********************************************************************************************
359 
360  //**Rows function*******************************************************************************
365  inline size_t rows() const {
366  return sm_.rows();
367  }
368  //**********************************************************************************************
369 
370  //**Columns function****************************************************************************
375  inline size_t columns() const {
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 ) );
411  }
412  //**********************************************************************************************
413 
414  //**LowerBound function*************************************************************************
421  inline ConstIterator lowerBound( size_t i, size_t j ) const {
423  return ConstIterator( sm_.lowerBound( i, j ) );
424  }
425  //**********************************************************************************************
426 
427  //**UpperBound function*************************************************************************
434  inline ConstIterator upperBound( size_t i, size_t j ) const {
436  return ConstIterator( sm_.upperBound( i, j ) );
437  }
438  //**********************************************************************************************
439 
440  //**Operand access******************************************************************************
445  inline Operand operand() const {
446  return sm_;
447  }
448  //**********************************************************************************************
449 
450  //**********************************************************************************************
456  template< typename T >
457  inline bool canAlias( const T* alias ) const {
458  return sm_.canAlias( alias );
459  }
460  //**********************************************************************************************
461 
462  //**********************************************************************************************
468  template< typename T >
469  inline bool isAliased( const T* alias ) const {
470  return sm_.isAliased( alias );
471  }
472  //**********************************************************************************************
473 
474  //**********************************************************************************************
479  inline bool canSMPAssign() const {
480  return sm_.canSMPAssign();
481  }
482  //**********************************************************************************************
483 
484  private:
485  //**Member variables****************************************************************************
486  Operand sm_;
487  //**********************************************************************************************
488 
489  //**Assignment to dense matrices****************************************************************
503  template< typename MT2 // Type of the target dense matrix
504  , bool SO2 > // Storage order of the target dense matrix
505  friend inline typename EnableIf< UseAssign<MT2> >::Type
506  assign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
507  {
509 
510  using std::abs;
511 
512  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
513  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
514 
515  assign( ~lhs, rhs.sm_ );
516  assign( ~lhs, abs( ~lhs ) );
517  }
519  //**********************************************************************************************
520 
521  //**Assignment to row-major sparse matrices*****************************************************
535  template< typename MT2 > // Type of the target sparse matrix
536  friend inline typename EnableIf< UseAssign<MT2> >::Type
537  assign( SparseMatrix<MT2,false>& lhs, const SMatAbsExpr& rhs )
538  {
540 
541  using std::abs;
542 
543  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
544  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
545 
546  typedef typename MT2::Iterator Iterator;
547 
548  assign( ~lhs, rhs.sm_ );
549 
550  const size_t m( rhs.rows() );
551 
552  for( size_t i=0UL; i<m; ++i ) {
553  const Iterator end( (~lhs).end(i) );
554  for( Iterator element=(~lhs).begin(i); element!=end; ++element ) {
555  element->value() = abs( element->value() );
556  }
557  }
558  }
560  //**********************************************************************************************
561 
562  //**Assignment to column-major sparse matrices**************************************************
576  template< typename MT2 > // Type of the target sparse matrix
577  friend inline typename EnableIf< UseAssign<MT2> >::Type
578  assign( SparseMatrix<MT2,true>& lhs, const SMatAbsExpr& rhs )
579  {
581 
582  using std::abs;
583 
584  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
585  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
586 
587  typedef typename MT2::Iterator Iterator;
588 
589  assign( ~lhs, rhs.sm_ );
590 
591  const size_t n( rhs.columns() );
592 
593  for( size_t j=0UL; j<n; ++j ) {
594  const Iterator end( (~lhs).end(j) );
595  for( Iterator element=(~lhs).begin(j); element!=end; ++element ) {
596  element->value() = abs( element->value() );
597  }
598  }
599  }
601  //**********************************************************************************************
602 
603  //**Addition assignment to dense matrices*******************************************************
617  template< typename MT2 // Type of the target dense matrix
618  , bool SO2 > // Storage order of the target dense matrix
619  friend inline typename EnableIf< UseAssign<MT2> >::Type
620  addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
621  {
623 
626 
627  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
628  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
629 
630  const ResultType tmp( serial( rhs ) );
631  addAssign( ~lhs, tmp );
632  }
634  //**********************************************************************************************
635 
636  //**Addition assignment to sparse matrices******************************************************
637  // No special implementation for the addition assignment to sparse matrices.
638  //**********************************************************************************************
639 
640  //**Subtraction assignment to dense matrices****************************************************
654  template< typename MT2 // Type of the target dense matrix
655  , bool SO2 > // Storage order of the target sparse matrix
656  friend inline typename EnableIf< UseAssign<MT2> >::Type
657  subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
658  {
660 
663 
664  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
665  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
666 
667  const ResultType tmp( serial( rhs ) );
668  subAssign( ~lhs, tmp );
669  }
671  //**********************************************************************************************
672 
673  //**Subtraction assignment to sparse matrices***************************************************
674  // No special implementation for the subtraction assignment to sparse matrices.
675  //**********************************************************************************************
676 
677  //**Multiplication assignment to dense matrices*************************************************
678  // No special implementation for the multiplication assignment to dense matrices.
679  //**********************************************************************************************
680 
681  //**Multiplication assignment to sparse matrices************************************************
682  // No special implementation for the multiplication assignment to sparse matrices.
683  //**********************************************************************************************
684 
685  //**SMP assignment to dense matrices************************************************************
699  template< typename MT2 // Type of the target dense matrix
700  , bool SO2 > // Storage order of the target dense matrix
701  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
702  smpAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
703  {
705 
706  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
707  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
708 
709  smpAssign( ~lhs, rhs.sm_ );
710  smpAssign( ~lhs, abs( ~lhs ) );
711  }
713  //**********************************************************************************************
714 
715  //**SMP assignment to sparse matrices***********************************************************
716  // No special implementation for the SMP assignment to sparse matrices.
717  //**********************************************************************************************
718 
719  //**SMP addition assignment to dense matrices***************************************************
733  template< typename MT2 // Type of the target dense matrix
734  , bool SO2 > // Storage order of the target dense matrix
735  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
736  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
737  {
739 
742 
743  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
744  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
745 
746  const ResultType tmp( rhs );
747  smpAddAssign( ~lhs, tmp );
748  }
750  //**********************************************************************************************
751 
752  //**SMP addition assignment to sparse matrices**************************************************
753  // No special implementation for the SMP addition assignment to sparse matrices.
754  //**********************************************************************************************
755 
756  //**SMP subtraction assignment to dense matrices************************************************
770  template< typename MT2 // Type of the target dense matrix
771  , bool SO2 > // Storage order of the target sparse matrix
772  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
773  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
774  {
776 
779 
780  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
781  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
782 
783  const ResultType tmp( rhs );
784  smpSubAssign( ~lhs, tmp );
785  }
787  //**********************************************************************************************
788 
789  //**SMP subtraction assignment to sparse matrices***********************************************
790  // No special implementation for the SMP subtraction assignment to sparse matrices.
791  //**********************************************************************************************
792 
793  //**SMP multiplication assignment to dense matrices*********************************************
794  // No special implementation for the SMP multiplication assignment to dense matrices.
795  //**********************************************************************************************
796 
797  //**SMP multiplication assignment to sparse matrices********************************************
798  // No special implementation for the SMP multiplication assignment to sparse matrices.
799  //**********************************************************************************************
800 
801  //**Compile time checks*************************************************************************
806  //**********************************************************************************************
807 };
808 //*************************************************************************************************
809 
810 
811 
812 
813 //=================================================================================================
814 //
815 // GLOBAL FUNCTIONS
816 //
817 //=================================================================================================
818 
819 //*************************************************************************************************
836 template< typename MT // Type of the sparse matrix
837  , bool SO > // Storage order
838 inline const SMatAbsExpr<MT,SO> abs( const SparseMatrix<MT,SO>& sm )
839 {
841 
842  return SMatAbsExpr<MT,SO>( ~sm );
843 }
844 //*************************************************************************************************
845 
846 
847 
848 
849 //=================================================================================================
850 //
851 // GLOBAL RESTRUCTURING FUNCTIONS
852 //
853 //=================================================================================================
854 
855 //*************************************************************************************************
866 template< typename MT // Type of the sparse matrix
867  , bool TF > // Transpose flag
868 inline const SMatAbsExpr<MT,TF>& abs( const SMatAbsExpr<MT,TF>& sm )
869 {
871 
872  return sm;
873 }
875 //*************************************************************************************************
876 
877 
878 
879 
880 //=================================================================================================
881 //
882 // ROWS SPECIALIZATIONS
883 //
884 //=================================================================================================
885 
886 //*************************************************************************************************
888 template< typename MT, bool SO >
889 struct Rows< SMatAbsExpr<MT,SO> > : public Rows<MT>
890 {};
892 //*************************************************************************************************
893 
894 
895 
896 
897 //=================================================================================================
898 //
899 // COLUMNS SPECIALIZATIONS
900 //
901 //=================================================================================================
902 
903 //*************************************************************************************************
905 template< typename MT, bool SO >
906 struct Columns< SMatAbsExpr<MT,SO> > : public Columns<MT>
907 {};
909 //*************************************************************************************************
910 
911 
912 
913 
914 //=================================================================================================
915 //
916 // ISSYMMETRIC SPECIALIZATIONS
917 //
918 //=================================================================================================
919 
920 //*************************************************************************************************
922 template< typename MT, bool SO >
923 struct IsSymmetric< SMatAbsExpr<MT,SO> > : public IsTrue< IsSymmetric<MT>::value >
924 {};
926 //*************************************************************************************************
927 
928 
929 
930 
931 //=================================================================================================
932 //
933 // ISLOWER SPECIALIZATIONS
934 //
935 //=================================================================================================
936 
937 //*************************************************************************************************
939 template< typename MT, bool SO >
940 struct IsLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsLower<MT>::value >
941 {};
943 //*************************************************************************************************
944 
945 
946 
947 
948 //=================================================================================================
949 //
950 // ISUNILOWER SPECIALIZATIONS
951 //
952 //=================================================================================================
953 
954 //*************************************************************************************************
956 template< typename MT, bool SO >
957 struct IsUniLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsUniLower<MT>::value >
958 {};
960 //*************************************************************************************************
961 
962 
963 
964 
965 //=================================================================================================
966 //
967 // ISSTRICTLYLOWER SPECIALIZATIONS
968 //
969 //=================================================================================================
970 
971 //*************************************************************************************************
973 template< typename MT, bool SO >
974 struct IsStrictlyLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsStrictlyLower<MT>::value >
975 {};
977 //*************************************************************************************************
978 
979 
980 
981 
982 //=================================================================================================
983 //
984 // ISUPPER SPECIALIZATIONS
985 //
986 //=================================================================================================
987 
988 //*************************************************************************************************
990 template< typename MT, bool SO >
991 struct IsUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsUpper<MT>::value >
992 {};
994 //*************************************************************************************************
995 
996 
997 
998 
999 //=================================================================================================
1000 //
1001 // ISUNIUPPER SPECIALIZATIONS
1002 //
1003 //=================================================================================================
1004 
1005 //*************************************************************************************************
1007 template< typename MT, bool SO >
1008 struct IsUniUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsUniUpper<MT>::value >
1009 {};
1011 //*************************************************************************************************
1012 
1013 
1014 
1015 
1016 //=================================================================================================
1017 //
1018 // ISSTRICTLYUPPER SPECIALIZATIONS
1019 //
1020 //=================================================================================================
1021 
1022 //*************************************************************************************************
1024 template< typename MT, bool SO >
1025 struct IsStrictlyUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsStrictlyUpper<MT>::value >
1026 {};
1028 //*************************************************************************************************
1029 
1030 
1031 
1032 
1033 //=================================================================================================
1034 //
1035 // EXPRESSION TRAIT SPECIALIZATIONS
1036 //
1037 //=================================================================================================
1038 
1039 //*************************************************************************************************
1041 template< typename MT >
1042 struct SMatAbsExprTrait< SMatAbsExpr<MT,false> >
1043 {
1044  public:
1045  //**********************************************************************************************
1046  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value
1047  , SMatAbsExpr<MT,false>
1048  , INVALID_TYPE >::Type Type;
1049  //**********************************************************************************************
1050 };
1052 //*************************************************************************************************
1053 
1054 
1055 //*************************************************************************************************
1057 template< typename MT >
1058 struct TSMatAbsExprTrait< SMatAbsExpr<MT,true> >
1059 {
1060  public:
1061  //**********************************************************************************************
1062  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value
1063  , SMatAbsExpr<MT,true>
1064  , INVALID_TYPE >::Type Type;
1065  //**********************************************************************************************
1066 };
1068 //*************************************************************************************************
1069 
1070 
1071 //*************************************************************************************************
1073 template< typename MT, bool SO, bool AF >
1074 struct SubmatrixExprTrait< SMatAbsExpr<MT,SO>, AF >
1075 {
1076  public:
1077  //**********************************************************************************************
1078  typedef typename AbsExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type >::Type Type;
1079  //**********************************************************************************************
1080 };
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1087 template< typename MT, bool SO >
1088 struct RowExprTrait< SMatAbsExpr<MT,SO> >
1089 {
1090  public:
1091  //**********************************************************************************************
1092  typedef typename AbsExprTrait< typename RowExprTrait<const MT>::Type >::Type Type;
1093  //**********************************************************************************************
1094 };
1096 //*************************************************************************************************
1097 
1098 
1099 //*************************************************************************************************
1101 template< typename MT, bool SO >
1102 struct ColumnExprTrait< SMatAbsExpr<MT,SO> >
1103 {
1104  public:
1105  //**********************************************************************************************
1106  typedef typename AbsExprTrait< typename ColumnExprTrait<const MT>::Type >::Type Type;
1107  //**********************************************************************************************
1108 };
1110 //*************************************************************************************************
1111 
1112 } // namespace blaze
1113 
1114 #endif
Pointer difference type of the Blaze library.
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatAbsExpr.h:434
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatAbsExpr.h:111
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:231
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatAbsExpr.h:171
SMatAbsExpr< MT, SO > This
Type of this SMatAbsExpr instance.
Definition: SMatAbsExpr.h:164
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
Header file for basic type definitions.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatAbsExpr.h:385
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatAbsExpr.h:457
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:285
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type Operand
Composite data type of the sparse matrix expression.
Definition: SMatAbsExpr.h:177
#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:242
Header file for the ColumnExprTrait class template.
ReferenceType reference
Reference return type.
Definition: SMatAbsExpr.h:203
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
Header file for the IsRowVector type trait.
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SMatAbsExpr.h:421
const DMatAbsExpr< MT, SO > abs(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the absolute values of each single element of dm.
Definition: DMatAbsExpr.h:914
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatAbsExpr.h:408
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:699
Header file for the Computation base class.
Element ValueType
Type of the underlying pointers.
Definition: SMatAbsExpr.h:194
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatAbsExpr.h:112
Header file for the RequiresEvaluation type trait.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:274
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatAbsExpr.h:375
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatAbsExpr.h:355
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:242
Header file for the IsUniLower type trait.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2503
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
ValueType * PointerType
Pointer return type.
Definition: SMatAbsExpr.h:195
ValueType & ReferenceType
Reference return type.
Definition: SMatAbsExpr.h:196
Constraint on the data type.
const SMatAbsExpr< MT, SO > abs(const SparseMatrix< MT, SO > &sm)
Returns a matrix containing the absolute values of each single element of sm.
Definition: SMatAbsExpr.h:838
Header file for the SparseMatrix base class.
DifferenceType difference_type
Difference between two iterators.
Definition: SMatAbsExpr.h:204
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:263
Header file for the ValueIndexPair class.
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatAbsExpr.h:188
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatAbsExpr.h:469
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Header file for the Columns type trait.
SelectType< useAssign, const ResultType, const SMatAbsExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatAbsExpr.h:174
size_t index() const
Access to the current index of the sparse element.
Definition: SMatAbsExpr.h:263
Header file for the MatAbsExpr base class.
Header file for the IsLower type trait.
Iterator over the elements of the sparse matrix absolute value expression.
Definition: SMatAbsExpr.h:183
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:78
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2504
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
Constraint on the data type.
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
Header file for the TSMatAbsExprTrait class template.
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatAbsExpr.h:197
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatAbsExpr.h:396
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
Utility type for generic codes.
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatAbsExpr.h:220
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatAbsExpr.h:110
MT::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatAbsExpr.h:167
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
AbsExprTrait< RN >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatAbsExpr.h:125
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatAbsExpr.h:479
ValueType value_type
Type of the underlying pointers.
Definition: SMatAbsExpr.h:201
#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:118
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatAbsExpr.h:344
IteratorType it_
Iterator over the elements of the sparse matrix expression.
Definition: SMatAbsExpr.h:303
Header file for the RemoveReference type trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatAbsExpr.h:365
Header file for the SMatAbsExprTrait class template.
MT::ElementType ElementType
Resulting element type.
Definition: SMatAbsExpr.h:168
PointerType pointer
Pointer return type.
Definition: SMatAbsExpr.h:202
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
Header file for the IsComputation type trait class.
IteratorCategory iterator_category
The iterator category.
Definition: SMatAbsExpr.h:200
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
RemoveReference< Operand >::Type::ConstIterator IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatAbsExpr.h:191
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatAbsExpr.h:330
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
Header file for the IsTrue value trait.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatAbsExpr.h:296
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatAbsExpr.h:193
Expression object for the sparse matrix abs() function.The SMatAbsExpr class represents the compile t...
Definition: Forward.h:88
Operand operand() const
Returns the sparse matrix operand.
Definition: SMatAbsExpr.h:445
Header file for the IsUpper type trait.
MT::ResultType ResultType
Result type for expression template evaluations.
Definition: SMatAbsExpr.h:165
Header file for the AbsExprTrait class template.
Header file for the IsColumnVector type trait.
Operand sm_
Sparse matrix of the absolute value expression.
Definition: SMatAbsExpr.h:486
Evaluation of the return type of an absolute value expression.Via this type trait it is possible to e...
Definition: AbsExprTrait.h:87
SMatAbsExpr(const MT &sm)
Constructor for the SMatAbsExpr class.
Definition: SMatAbsExpr.h:318
ConstIterator(IteratorType it)
Constructor for the ConstIterator class.
Definition: SMatAbsExpr.h:210
#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
MT::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatAbsExpr.h:166
#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:79
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatAbsExpr.h:252