All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
72 #include <blaze/util/Assert.h>
74 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/InvalidType.h>
77 #include <blaze/util/SelectType.h>
78 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS SMATABSEXPR
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
98 template< typename MT // Type of the sparse matrix
99  , bool SO > // Storage order
100 class SMatAbsExpr : public SparseMatrix< SMatAbsExpr<MT,SO>, SO >
101  , private MatAbsExpr
102  , private Computation
103 {
104  private:
105  //**Type definitions****************************************************************************
106  typedef typename MT::ResultType RT;
107  typedef typename MT::ReturnType RN;
108  typedef typename MT::CompositeType CT;
109  //**********************************************************************************************
110 
111  //**Return type evaluation**********************************************************************
113 
118  enum { returnExpr = !IsTemporary<RN>::value };
119 
122  //**********************************************************************************************
123 
124  //**Serial evaluation strategy******************************************************************
126 
132  enum { useAssign = RequiresEvaluation<MT>::value };
133 
135  template< typename MT2 >
137  struct UseAssign {
138  enum { value = useAssign };
139  };
141  //**********************************************************************************************
142 
143  //**Parallel evaluation strategy****************************************************************
145 
151  template< typename MT2 >
152  struct UseSMPAssign {
153  enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
154  };
156  //**********************************************************************************************
157 
158  public:
159  //**Type definitions****************************************************************************
161  typedef typename MT::ResultType ResultType;
162  typedef typename MT::OppositeType OppositeType;
163  typedef typename MT::TransposeType TransposeType;
164  typedef typename MT::ElementType ElementType;
165 
168 
171 
173  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type Operand;
174  //**********************************************************************************************
175 
176  //**ConstIterator class definition**************************************************************
180  {
181  public:
182  //**Type definitions*************************************************************************
185 
188 
189  typedef std::forward_iterator_tag IteratorCategory;
190  typedef Element ValueType;
194 
195  // STL iterator requirements
201  //*******************************************************************************************
202 
203  //**Constructor******************************************************************************
207  : it_( it ) // Iterator over the elements of the sparse matrix expression
208  {}
209  //*******************************************************************************************
210 
211  //**Prefix increment operator****************************************************************
217  ++it_;
218  return *this;
219  }
220  //*******************************************************************************************
221 
222  //**Element access operator******************************************************************
227  inline const Element operator*() const {
228  using std::abs;
229  return Element( abs( it_->value() ), it_->index() );
230  }
231  //*******************************************************************************************
232 
233  //**Element access operator******************************************************************
238  inline const ConstIterator* operator->() const {
239  return this;
240  }
241  //*******************************************************************************************
242 
243  //**Value function***************************************************************************
248  inline ReturnType value() const {
249  using std::abs;
250  return abs( it_->value() );
251  }
252  //*******************************************************************************************
253 
254  //**Index function***************************************************************************
259  inline size_t index() const {
260  return it_->index();
261  }
262  //*******************************************************************************************
263 
264  //**Equality operator************************************************************************
270  inline bool operator==( const ConstIterator& rhs ) const {
271  return it_ == rhs.it_;
272  }
273  //*******************************************************************************************
274 
275  //**Inequality operator**********************************************************************
281  inline bool operator!=( const ConstIterator& rhs ) const {
282  return it_ != rhs.it_;
283  }
284  //*******************************************************************************************
285 
286  //**Subtraction operator*********************************************************************
292  inline DifferenceType operator-( const ConstIterator& rhs ) const {
293  return it_ - rhs.it_;
294  }
295  //*******************************************************************************************
296 
297  private:
298  //**Member variables*************************************************************************
300  //*******************************************************************************************
301  };
302  //**********************************************************************************************
303 
304  //**Compilation flags***************************************************************************
306  enum { smpAssignable = MT::smpAssignable };
307  //**********************************************************************************************
308 
309  //**Constructor*********************************************************************************
314  explicit inline SMatAbsExpr( const MT& sm )
315  : sm_( sm ) // Sparse matrix of the absolute value expression
316  {}
317  //**********************************************************************************************
318 
319  //**Access operator*****************************************************************************
326  inline ReturnType operator()( size_t i, size_t j ) const {
327  using std::abs;
328  BLAZE_INTERNAL_ASSERT( i < sm_.rows() , "Invalid row access index" );
329  BLAZE_INTERNAL_ASSERT( j < sm_.columns(), "Invalid column access index" );
330  return abs( sm_(i,j) );
331  }
332  //**********************************************************************************************
333 
334  //**Begin function******************************************************************************
340  inline ConstIterator begin( size_t i ) const {
341  return ConstIterator( sm_.begin(i) );
342  }
343  //**********************************************************************************************
344 
345  //**End function********************************************************************************
351  inline ConstIterator end( size_t i ) const {
352  return ConstIterator( sm_.end(i) );
353  }
354  //**********************************************************************************************
355 
356  //**Rows function*******************************************************************************
361  inline size_t rows() const {
362  return sm_.rows();
363  }
364  //**********************************************************************************************
365 
366  //**Columns function****************************************************************************
371  inline size_t columns() const {
372  return sm_.columns();
373  }
374  //**********************************************************************************************
375 
376  //**NonZeros function***************************************************************************
381  inline size_t nonZeros() const {
382  return sm_.nonZeros();
383  }
384  //**********************************************************************************************
385 
386  //**NonZeros function***************************************************************************
392  inline size_t nonZeros( size_t i ) const {
393  return sm_.nonZeros(i);
394  }
395  //**********************************************************************************************
396 
397  //**Find function*******************************************************************************
404  inline ConstIterator find( size_t i, size_t j ) const {
406  return ConstIterator( sm_.find( i, j ) );
407  }
408  //**********************************************************************************************
409 
410  //**LowerBound function*************************************************************************
417  inline ConstIterator lowerBound( size_t i, size_t j ) const {
419  return ConstIterator( sm_.lowerBound( i, j ) );
420  }
421  //**********************************************************************************************
422 
423  //**UpperBound function*************************************************************************
430  inline ConstIterator upperBound( size_t i, size_t j ) const {
432  return ConstIterator( sm_.upperBound( i, j ) );
433  }
434  //**********************************************************************************************
435 
436  //**Operand access******************************************************************************
441  inline Operand operand() const {
442  return sm_;
443  }
444  //**********************************************************************************************
445 
446  //**********************************************************************************************
452  template< typename T >
453  inline bool canAlias( const T* alias ) const {
454  return sm_.canAlias( alias );
455  }
456  //**********************************************************************************************
457 
458  //**********************************************************************************************
464  template< typename T >
465  inline bool isAliased( const T* alias ) const {
466  return sm_.isAliased( alias );
467  }
468  //**********************************************************************************************
469 
470  //**********************************************************************************************
475  inline bool canSMPAssign() const {
476  return sm_.canSMPAssign();
477  }
478  //**********************************************************************************************
479 
480  private:
481  //**Member variables****************************************************************************
483  //**********************************************************************************************
484 
485  //**Assignment to dense matrices****************************************************************
499  template< typename MT2 // Type of the target dense matrix
500  , bool SO2 > // Storage order of the target dense matrix
501  friend inline typename EnableIf< UseAssign<MT2> >::Type
502  assign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
503  {
505 
506  using std::abs;
507 
508  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
509  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
510 
511  assign( ~lhs, rhs.sm_ );
512  assign( ~lhs, abs( ~lhs ) );
513  }
515  //**********************************************************************************************
516 
517  //**Assignment to row-major sparse matrices*****************************************************
531  template< typename MT2 > // Type of the target sparse matrix
532  friend inline typename EnableIf< UseAssign<MT2> >::Type
533  assign( SparseMatrix<MT2,false>& lhs, const SMatAbsExpr& rhs )
534  {
536 
537  using std::abs;
538 
539  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
540  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
541 
542  typedef typename MT2::Iterator Iterator;
543 
544  assign( ~lhs, rhs.sm_ );
545 
546  const size_t m( rhs.rows() );
547 
548  for( size_t i=0UL; i<m; ++i ) {
549  const Iterator end( (~lhs).end(i) );
550  for( Iterator element=(~lhs).begin(i); element!=end; ++element ) {
551  element->value() = abs( element->value() );
552  }
553  }
554  }
556  //**********************************************************************************************
557 
558  //**Assignment to column-major sparse matrices**************************************************
572  template< typename MT2 > // Type of the target sparse matrix
573  friend inline typename EnableIf< UseAssign<MT2> >::Type
574  assign( SparseMatrix<MT2,true>& lhs, const SMatAbsExpr& rhs )
575  {
577 
578  using std::abs;
579 
580  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
581  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
582 
583  typedef typename MT2::Iterator Iterator;
584 
585  assign( ~lhs, rhs.sm_ );
586 
587  const size_t n( rhs.columns() );
588 
589  for( size_t j=0UL; j<n; ++j ) {
590  const Iterator end( (~lhs).end(j) );
591  for( Iterator element=(~lhs).begin(j); element!=end; ++element ) {
592  element->value() = abs( element->value() );
593  }
594  }
595  }
597  //**********************************************************************************************
598 
599  //**Addition assignment to dense matrices*******************************************************
613  template< typename MT2 // Type of the target dense matrix
614  , bool SO2 > // Storage order of the target dense matrix
615  friend inline typename EnableIf< UseAssign<MT2> >::Type
616  addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
617  {
619 
622 
623  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
624  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
625 
626  const ResultType tmp( serial( rhs ) );
627  addAssign( ~lhs, tmp );
628  }
630  //**********************************************************************************************
631 
632  //**Addition assignment to sparse matrices******************************************************
633  // No special implementation for the addition assignment to sparse matrices.
634  //**********************************************************************************************
635 
636  //**Subtraction assignment to dense matrices****************************************************
650  template< typename MT2 // Type of the target dense matrix
651  , bool SO2 > // Storage order of the target sparse matrix
652  friend inline typename EnableIf< UseAssign<MT2> >::Type
653  subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
654  {
656 
659 
660  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
661  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
662 
663  const ResultType tmp( serial( rhs ) );
664  subAssign( ~lhs, tmp );
665  }
667  //**********************************************************************************************
668 
669  //**Subtraction assignment to sparse matrices***************************************************
670  // No special implementation for the subtraction assignment to sparse matrices.
671  //**********************************************************************************************
672 
673  //**Multiplication assignment to dense matrices*************************************************
674  // No special implementation for the multiplication assignment to dense matrices.
675  //**********************************************************************************************
676 
677  //**Multiplication assignment to sparse matrices************************************************
678  // No special implementation for the multiplication assignment to sparse matrices.
679  //**********************************************************************************************
680 
681  //**SMP assignment to dense matrices************************************************************
695  template< typename MT2 // Type of the target dense matrix
696  , bool SO2 > // Storage order of the target dense matrix
697  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
698  smpAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
699  {
701 
702  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
703  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
704 
705  smpAssign( ~lhs, rhs.sm_ );
706  smpAssign( ~lhs, abs( ~lhs ) );
707  }
709  //**********************************************************************************************
710 
711  //**SMP assignment to sparse matrices***********************************************************
712  // No special implementation for the SMP assignment to sparse matrices.
713  //**********************************************************************************************
714 
715  //**SMP addition assignment to dense matrices***************************************************
729  template< typename MT2 // Type of the target dense matrix
730  , bool SO2 > // Storage order of the target dense matrix
731  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
732  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
733  {
735 
738 
739  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
740  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
741 
742  const ResultType tmp( rhs );
743  smpAddAssign( ~lhs, tmp );
744  }
746  //**********************************************************************************************
747 
748  //**SMP addition assignment to sparse matrices**************************************************
749  // No special implementation for the SMP addition assignment to sparse matrices.
750  //**********************************************************************************************
751 
752  //**SMP subtraction assignment to dense matrices************************************************
766  template< typename MT2 // Type of the target dense matrix
767  , bool SO2 > // Storage order of the target sparse matrix
768  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
769  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
770  {
772 
775 
776  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
777  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
778 
779  const ResultType tmp( rhs );
780  smpSubAssign( ~lhs, tmp );
781  }
783  //**********************************************************************************************
784 
785  //**SMP subtraction assignment to sparse matrices***********************************************
786  // No special implementation for the SMP subtraction assignment to sparse matrices.
787  //**********************************************************************************************
788 
789  //**SMP multiplication assignment to dense matrices*********************************************
790  // No special implementation for the SMP multiplication assignment to dense matrices.
791  //**********************************************************************************************
792 
793  //**SMP multiplication assignment to sparse matrices********************************************
794  // No special implementation for the SMP multiplication assignment to sparse matrices.
795  //**********************************************************************************************
796 
797  //**Compile time checks*************************************************************************
802  //**********************************************************************************************
803 };
804 //*************************************************************************************************
805 
806 
807 
808 
809 //=================================================================================================
810 //
811 // GLOBAL FUNCTIONS
812 //
813 //=================================================================================================
814 
815 //*************************************************************************************************
832 template< typename MT // Type of the sparse matrix
833  , bool SO > // Storage order
834 inline const SMatAbsExpr<MT,SO> abs( const SparseMatrix<MT,SO>& sm )
835 {
837 
838  return SMatAbsExpr<MT,SO>( ~sm );
839 }
840 //*************************************************************************************************
841 
842 
843 
844 
845 //=================================================================================================
846 //
847 // GLOBAL RESTRUCTURING FUNCTIONS
848 //
849 //=================================================================================================
850 
851 //*************************************************************************************************
862 template< typename MT // Type of the sparse matrix
863  , bool TF > // Transpose flag
864 inline const SMatAbsExpr<MT,TF>& abs( const SMatAbsExpr<MT,TF>& sm )
865 {
867 
868  return sm;
869 }
871 //*************************************************************************************************
872 
873 
874 
875 
876 //=================================================================================================
877 //
878 // ROWS SPECIALIZATIONS
879 //
880 //=================================================================================================
881 
882 //*************************************************************************************************
884 template< typename MT, bool SO >
885 struct Rows< SMatAbsExpr<MT,SO> > : public Rows<MT>
886 {};
888 //*************************************************************************************************
889 
890 
891 
892 
893 //=================================================================================================
894 //
895 // COLUMNS SPECIALIZATIONS
896 //
897 //=================================================================================================
898 
899 //*************************************************************************************************
901 template< typename MT, bool SO >
902 struct Columns< SMatAbsExpr<MT,SO> > : public Columns<MT>
903 {};
905 //*************************************************************************************************
906 
907 
908 
909 
910 //=================================================================================================
911 //
912 // ISSYMMETRIC SPECIALIZATIONS
913 //
914 //=================================================================================================
915 
916 //*************************************************************************************************
918 template< typename MT, bool SO >
919 struct IsSymmetric< SMatAbsExpr<MT,SO> > : public IsTrue< IsSymmetric<MT>::value >
920 {};
922 //*************************************************************************************************
923 
924 
925 
926 
927 //=================================================================================================
928 //
929 // ISLOWER SPECIALIZATIONS
930 //
931 //=================================================================================================
932 
933 //*************************************************************************************************
935 template< typename MT, bool SO >
936 struct IsLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsLower<MT>::value >
937 {};
939 //*************************************************************************************************
940 
941 
942 
943 
944 //=================================================================================================
945 //
946 // ISUPPER SPECIALIZATIONS
947 //
948 //=================================================================================================
949 
950 //*************************************************************************************************
952 template< typename MT, bool SO >
953 struct IsUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsUpper<MT>::value >
954 {};
956 //*************************************************************************************************
957 
958 
959 
960 
961 //=================================================================================================
962 //
963 // EXPRESSION TRAIT SPECIALIZATIONS
964 //
965 //=================================================================================================
966 
967 //*************************************************************************************************
969 template< typename MT >
970 struct SMatAbsExprTrait< SMatAbsExpr<MT,false> >
971 {
972  public:
973  //**********************************************************************************************
974  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value
975  , SMatAbsExpr<MT,false>
976  , INVALID_TYPE >::Type Type;
977  //**********************************************************************************************
978 };
980 //*************************************************************************************************
981 
982 
983 //*************************************************************************************************
985 template< typename MT >
986 struct TSMatAbsExprTrait< SMatAbsExpr<MT,true> >
987 {
988  public:
989  //**********************************************************************************************
990  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value
991  , SMatAbsExpr<MT,true>
992  , INVALID_TYPE >::Type Type;
993  //**********************************************************************************************
994 };
996 //*************************************************************************************************
997 
998 
999 //*************************************************************************************************
1001 template< typename MT, bool SO, bool AF >
1002 struct SubmatrixExprTrait< SMatAbsExpr<MT,SO>, AF >
1003 {
1004  public:
1005  //**********************************************************************************************
1006  typedef typename AbsExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type >::Type Type;
1007  //**********************************************************************************************
1008 };
1010 //*************************************************************************************************
1011 
1012 
1013 //*************************************************************************************************
1015 template< typename MT, bool SO >
1016 struct RowExprTrait< SMatAbsExpr<MT,SO> >
1017 {
1018  public:
1019  //**********************************************************************************************
1020  typedef typename AbsExprTrait< typename RowExprTrait<const MT>::Type >::Type Type;
1021  //**********************************************************************************************
1022 };
1024 //*************************************************************************************************
1025 
1026 
1027 //*************************************************************************************************
1029 template< typename MT, bool SO >
1030 struct ColumnExprTrait< SMatAbsExpr<MT,SO> >
1031 {
1032  public:
1033  //**********************************************************************************************
1034  typedef typename AbsExprTrait< typename ColumnExprTrait<const MT>::Type >::Type Type;
1035  //**********************************************************************************************
1036 };
1038 //*************************************************************************************************
1039 
1040 } // namespace blaze
1041 
1042 #endif
IteratorCategory iterator_category
The iterator category.
Definition: SMatAbsExpr.h:196
Pointer difference type of the Blaze library.
MT::ResultType ResultType
Result type for expression template evaluations.
Definition: SMatAbsExpr.h:161
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.
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatAbsExpr.h:167
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatAbsExpr.h:193
ReferenceType reference
Reference return type.
Definition: SMatAbsExpr.h:199
RemoveReference< Operand >::Type::ConstIterator IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatAbsExpr.h:187
PointerType pointer
Pointer return type.
Definition: SMatAbsExpr.h:198
MT::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatAbsExpr.h:162
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatAbsExpr.h:404
#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
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatAbsExpr.h:248
Header file for the ColumnExprTrait class template.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Header file for the IsRowVector type trait.
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:909
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatAbsExpr.h:475
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatAbsExpr.h:340
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
Header file for the Computation base class.
Header file for the RequiresEvaluation type trait.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatAbsExpr.h:465
ValueType & ReferenceType
Reference return type.
Definition: SMatAbsExpr.h:192
MT::ElementType ElementType
Resulting element type.
Definition: SMatAbsExpr.h:164
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2474
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatAbsExpr.h:430
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
Operand operand() const
Returns the sparse matrix operand.
Definition: SMatAbsExpr.h:441
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:834
Header file for the SparseMatrix base class.
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatAbsExpr.h:392
ConstIterator(IteratorType it)
Constructor for the ConstIterator class.
Definition: SMatAbsExpr.h:206
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:259
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 IsSymmetric type trait.
Element ValueType
Type of the underlying pointers.
Definition: SMatAbsExpr.h:190
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:281
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatAbsExpr.h:326
ValueType * PointerType
Pointer return type.
Definition: SMatAbsExpr.h:191
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
size_t index() const
Access to the current index of the sparse element.
Definition: SMatAbsExpr.h:259
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.
SMatAbsExpr(const MT &sm)
Constructor for the SMatAbsExpr class.
Definition: SMatAbsExpr.h:314
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:179
#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:2475
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
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.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:270
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:238
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:227
Header file for the EnableIf class template.
Header file for the serial shim.
MT::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatAbsExpr.h:163
Header file for the TSMatAbsExprTrait class template.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatAbsExpr.h:381
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
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatAbsExpr.h:453
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:2477
Removal of reference modifiers.The RemoveCV type trait removes any reference modifiers from the given...
Definition: RemoveReference.h:69
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatAbsExpr.h:361
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.
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
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:2481
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:417
#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
Header file for the RemoveReference type trait.
IteratorType it_
Iterator over the elements of the sparse matrix expression.
Definition: SMatAbsExpr.h:299
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatAbsExpr.h:216
Header file for the SMatAbsExprTrait class template.
SelectType< useAssign, const ResultType, const SMatAbsExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatAbsExpr.h:170
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatAbsExpr.h:106
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatAbsExpr.h:351
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatAbsExpr.h:189
ValueType value_type
Type of the underlying pointers.
Definition: SMatAbsExpr.h:197
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatAbsExpr.h:184
AbsExprTrait< RN >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatAbsExpr.h:121
Header file for the IsComputation type trait class.
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
DifferenceType difference_type
Difference between two iterators.
Definition: SMatAbsExpr.h:200
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatAbsExpr.h:108
#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:2473
Header file for the IsTrue value trait.
Header file for basic type definitions.
Expression object for the sparse matrix abs() function.The SMatAbsExpr class represents the compile t...
Definition: Forward.h:88
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatAbsExpr.h:107
Header file for the IsUpper type trait.
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:482
Evaluation of the return type of an absolute value expression.Via this type trait it is possible to e...
Definition: AbsExprTrait.h:87
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatAbsExpr.h:371
#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
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatAbsExpr.h:292
#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
SMatAbsExpr< MT, SO > This
Type of this SMatAbsExpr instance.
Definition: SMatAbsExpr.h:160
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type Operand
Composite data type of the sparse matrix expression.
Definition: SMatAbsExpr.h:173
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