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>
77 #include <blaze/util/Assert.h>
79 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/Exception.h>
81 #include <blaze/util/InvalidType.h>
83 #include <blaze/util/SelectType.h>
84 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS SMATABSEXPR
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
104 template< typename MT // Type of the sparse matrix
105  , bool SO > // Storage order
106 class SMatAbsExpr : public SparseMatrix< SMatAbsExpr<MT,SO>, SO >
107  , private MatAbsExpr
108  , private Computation
109 {
110  private:
111  //**Type definitions****************************************************************************
112  typedef typename MT::ResultType RT;
113  typedef typename MT::ReturnType RN;
114  typedef typename MT::CompositeType CT;
115  //**********************************************************************************************
116 
117  //**Return type evaluation**********************************************************************
119 
124  enum { returnExpr = !IsTemporary<RN>::value };
125 
128  //**********************************************************************************************
129 
130  //**Serial evaluation strategy******************************************************************
132 
138  enum { useAssign = RequiresEvaluation<MT>::value };
139 
141  template< typename MT2 >
143  struct UseAssign {
144  enum { value = useAssign };
145  };
147  //**********************************************************************************************
148 
149  //**Parallel evaluation strategy****************************************************************
151 
157  template< typename MT2 >
158  struct UseSMPAssign {
159  enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
160  };
162  //**********************************************************************************************
163 
164  public:
165  //**Type definitions****************************************************************************
167  typedef typename MT::ResultType ResultType;
168  typedef typename MT::OppositeType OppositeType;
169  typedef typename MT::TransposeType TransposeType;
170  typedef typename MT::ElementType ElementType;
171 
174 
177 
179  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type Operand;
180  //**********************************************************************************************
181 
182  //**ConstIterator class definition**************************************************************
186  {
187  public:
188  //**Type definitions*************************************************************************
191 
194 
195  typedef std::forward_iterator_tag IteratorCategory;
196  typedef Element ValueType;
197  typedef ValueType* PointerType;
198  typedef ValueType& ReferenceType;
200 
201  // STL iterator requirements
202  typedef IteratorCategory iterator_category;
203  typedef ValueType value_type;
204  typedef PointerType pointer;
205  typedef ReferenceType reference;
206  typedef DifferenceType difference_type;
207  //*******************************************************************************************
208 
209  //**Constructor******************************************************************************
212  inline ConstIterator( IteratorType it )
213  : it_( it ) // Iterator over the elements of the sparse matrix expression
214  {}
215  //*******************************************************************************************
216 
217  //**Prefix increment operator****************************************************************
223  ++it_;
224  return *this;
225  }
226  //*******************************************************************************************
227 
228  //**Element access operator******************************************************************
233  inline const Element operator*() const {
234  using std::abs;
235  return Element( abs( it_->value() ), it_->index() );
236  }
237  //*******************************************************************************************
238 
239  //**Element access operator******************************************************************
244  inline const ConstIterator* operator->() const {
245  return this;
246  }
247  //*******************************************************************************************
248 
249  //**Value function***************************************************************************
254  inline ReturnType value() const {
255  using std::abs;
256  return abs( it_->value() );
257  }
258  //*******************************************************************************************
259 
260  //**Index function***************************************************************************
265  inline size_t index() const {
266  return it_->index();
267  }
268  //*******************************************************************************************
269 
270  //**Equality operator************************************************************************
276  inline bool operator==( const ConstIterator& rhs ) const {
277  return it_ == rhs.it_;
278  }
279  //*******************************************************************************************
280 
281  //**Inequality operator**********************************************************************
287  inline bool operator!=( const ConstIterator& rhs ) const {
288  return it_ != rhs.it_;
289  }
290  //*******************************************************************************************
291 
292  //**Subtraction operator*********************************************************************
298  inline DifferenceType operator-( const ConstIterator& rhs ) const {
299  return it_ - rhs.it_;
300  }
301  //*******************************************************************************************
302 
303  private:
304  //**Member variables*************************************************************************
305  IteratorType it_;
306  //*******************************************************************************************
307  };
308  //**********************************************************************************************
309 
310  //**Compilation flags***************************************************************************
312  enum { smpAssignable = MT::smpAssignable };
313  //**********************************************************************************************
314 
315  //**Constructor*********************************************************************************
320  explicit inline SMatAbsExpr( const MT& sm )
321  : sm_( sm ) // Sparse matrix of the absolute value expression
322  {}
323  //**********************************************************************************************
324 
325  //**Access operator*****************************************************************************
332  inline ReturnType operator()( size_t i, size_t j ) const {
333  using std::abs;
334  BLAZE_INTERNAL_ASSERT( i < sm_.rows() , "Invalid row access index" );
335  BLAZE_INTERNAL_ASSERT( j < sm_.columns(), "Invalid column access index" );
336  return abs( sm_(i,j) );
337  }
338  //**********************************************************************************************
339 
340  //**At function*********************************************************************************
348  inline ReturnType at( size_t i, size_t j ) const {
349  if( i >= sm_.rows() ) {
350  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
351  }
352  if( j >= sm_.columns() ) {
353  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
354  }
355  return (*this)(i,j);
356  }
357  //**********************************************************************************************
358 
359  //**Begin function******************************************************************************
365  inline ConstIterator begin( size_t i ) const {
366  return ConstIterator( sm_.begin(i) );
367  }
368  //**********************************************************************************************
369 
370  //**End function********************************************************************************
376  inline ConstIterator end( size_t i ) const {
377  return ConstIterator( sm_.end(i) );
378  }
379  //**********************************************************************************************
380 
381  //**Rows function*******************************************************************************
386  inline size_t rows() const {
387  return sm_.rows();
388  }
389  //**********************************************************************************************
390 
391  //**Columns function****************************************************************************
396  inline size_t columns() const {
397  return sm_.columns();
398  }
399  //**********************************************************************************************
400 
401  //**NonZeros function***************************************************************************
406  inline size_t nonZeros() const {
407  return sm_.nonZeros();
408  }
409  //**********************************************************************************************
410 
411  //**NonZeros function***************************************************************************
417  inline size_t nonZeros( size_t i ) const {
418  return sm_.nonZeros(i);
419  }
420  //**********************************************************************************************
421 
422  //**Find function*******************************************************************************
429  inline ConstIterator find( size_t i, size_t j ) const {
431  return ConstIterator( sm_.find( i, j ) );
432  }
433  //**********************************************************************************************
434 
435  //**LowerBound function*************************************************************************
442  inline ConstIterator lowerBound( size_t i, size_t j ) const {
444  return ConstIterator( sm_.lowerBound( i, j ) );
445  }
446  //**********************************************************************************************
447 
448  //**UpperBound function*************************************************************************
455  inline ConstIterator upperBound( size_t i, size_t j ) const {
457  return ConstIterator( sm_.upperBound( i, j ) );
458  }
459  //**********************************************************************************************
460 
461  //**Operand access******************************************************************************
466  inline Operand operand() const {
467  return sm_;
468  }
469  //**********************************************************************************************
470 
471  //**********************************************************************************************
477  template< typename T >
478  inline bool canAlias( const T* alias ) const {
479  return sm_.canAlias( alias );
480  }
481  //**********************************************************************************************
482 
483  //**********************************************************************************************
489  template< typename T >
490  inline bool isAliased( const T* alias ) const {
491  return sm_.isAliased( alias );
492  }
493  //**********************************************************************************************
494 
495  //**********************************************************************************************
500  inline bool canSMPAssign() const {
501  return sm_.canSMPAssign();
502  }
503  //**********************************************************************************************
504 
505  private:
506  //**Member variables****************************************************************************
507  Operand sm_;
508  //**********************************************************************************************
509 
510  //**Assignment to dense matrices****************************************************************
524  template< typename MT2 // Type of the target dense matrix
525  , bool SO2 > // Storage order of the target dense matrix
526  friend inline typename EnableIf< UseAssign<MT2> >::Type
527  assign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
528  {
530 
531  using std::abs;
532 
533  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
534  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
535 
536  assign( ~lhs, rhs.sm_ );
537  assign( ~lhs, abs( ~lhs ) );
538  }
540  //**********************************************************************************************
541 
542  //**Assignment to row-major sparse matrices*****************************************************
556  template< typename MT2 > // Type of the target sparse matrix
557  friend inline typename EnableIf< UseAssign<MT2> >::Type
558  assign( SparseMatrix<MT2,false>& lhs, const SMatAbsExpr& rhs )
559  {
561 
562  using std::abs;
563 
564  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
565  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
566 
567  typedef typename MT2::Iterator Iterator;
568 
569  assign( ~lhs, rhs.sm_ );
570 
571  const size_t m( rhs.rows() );
572 
573  for( size_t i=0UL; i<m; ++i ) {
574  const Iterator end( (~lhs).end(i) );
575  for( Iterator element=(~lhs).begin(i); element!=end; ++element ) {
576  element->value() = abs( element->value() );
577  }
578  }
579  }
581  //**********************************************************************************************
582 
583  //**Assignment to column-major sparse matrices**************************************************
597  template< typename MT2 > // Type of the target sparse matrix
598  friend inline typename EnableIf< UseAssign<MT2> >::Type
599  assign( SparseMatrix<MT2,true>& lhs, const SMatAbsExpr& rhs )
600  {
602 
603  using std::abs;
604 
605  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
606  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
607 
608  typedef typename MT2::Iterator Iterator;
609 
610  assign( ~lhs, rhs.sm_ );
611 
612  const size_t n( rhs.columns() );
613 
614  for( size_t j=0UL; j<n; ++j ) {
615  const Iterator end( (~lhs).end(j) );
616  for( Iterator element=(~lhs).begin(j); element!=end; ++element ) {
617  element->value() = abs( element->value() );
618  }
619  }
620  }
622  //**********************************************************************************************
623 
624  //**Addition assignment to dense matrices*******************************************************
638  template< typename MT2 // Type of the target dense matrix
639  , bool SO2 > // Storage order of the target dense matrix
640  friend inline typename EnableIf< UseAssign<MT2> >::Type
641  addAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
642  {
644 
647 
648  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
649  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
650 
651  const ResultType tmp( serial( rhs ) );
652  addAssign( ~lhs, tmp );
653  }
655  //**********************************************************************************************
656 
657  //**Addition assignment to sparse matrices******************************************************
658  // No special implementation for the addition assignment to sparse matrices.
659  //**********************************************************************************************
660 
661  //**Subtraction assignment to dense matrices****************************************************
675  template< typename MT2 // Type of the target dense matrix
676  , bool SO2 > // Storage order of the target sparse matrix
677  friend inline typename EnableIf< UseAssign<MT2> >::Type
678  subAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
679  {
681 
684 
685  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
686  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
687 
688  const ResultType tmp( serial( rhs ) );
689  subAssign( ~lhs, tmp );
690  }
692  //**********************************************************************************************
693 
694  //**Subtraction assignment to sparse matrices***************************************************
695  // No special implementation for the subtraction assignment to sparse matrices.
696  //**********************************************************************************************
697 
698  //**Multiplication assignment to dense matrices*************************************************
699  // No special implementation for the multiplication assignment to dense matrices.
700  //**********************************************************************************************
701 
702  //**Multiplication assignment to sparse matrices************************************************
703  // No special implementation for the multiplication assignment to sparse matrices.
704  //**********************************************************************************************
705 
706  //**SMP assignment to dense matrices************************************************************
720  template< typename MT2 // Type of the target dense matrix
721  , bool SO2 > // Storage order of the target dense matrix
722  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
723  smpAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
724  {
726 
727  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
728  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
729 
730  smpAssign( ~lhs, rhs.sm_ );
731  smpAssign( ~lhs, abs( ~lhs ) );
732  }
734  //**********************************************************************************************
735 
736  //**SMP assignment to sparse matrices***********************************************************
737  // No special implementation for the SMP assignment to sparse matrices.
738  //**********************************************************************************************
739 
740  //**SMP addition assignment to dense matrices***************************************************
754  template< typename MT2 // Type of the target dense matrix
755  , bool SO2 > // Storage order of the target dense matrix
756  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
757  smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
758  {
760 
763 
764  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
765  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
766 
767  const ResultType tmp( rhs );
768  smpAddAssign( ~lhs, tmp );
769  }
771  //**********************************************************************************************
772 
773  //**SMP addition assignment to sparse matrices**************************************************
774  // No special implementation for the SMP addition assignment to sparse matrices.
775  //**********************************************************************************************
776 
777  //**SMP subtraction assignment to dense matrices************************************************
791  template< typename MT2 // Type of the target dense matrix
792  , bool SO2 > // Storage order of the target sparse matrix
793  friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
794  smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const SMatAbsExpr& rhs )
795  {
797 
800 
801  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
802  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
803 
804  const ResultType tmp( rhs );
805  smpSubAssign( ~lhs, tmp );
806  }
808  //**********************************************************************************************
809 
810  //**SMP subtraction assignment to sparse matrices***********************************************
811  // No special implementation for the SMP subtraction assignment to sparse matrices.
812  //**********************************************************************************************
813 
814  //**SMP multiplication assignment to dense matrices*********************************************
815  // No special implementation for the SMP multiplication assignment to dense matrices.
816  //**********************************************************************************************
817 
818  //**SMP multiplication assignment to sparse matrices********************************************
819  // No special implementation for the SMP multiplication assignment to sparse matrices.
820  //**********************************************************************************************
821 
822  //**Compile time checks*************************************************************************
827  //**********************************************************************************************
828 };
829 //*************************************************************************************************
830 
831 
832 
833 
834 //=================================================================================================
835 //
836 // GLOBAL FUNCTIONS
837 //
838 //=================================================================================================
839 
840 //*************************************************************************************************
857 template< typename MT // Type of the sparse matrix
858  , bool SO > // Storage order
859 inline const SMatAbsExpr<MT,SO> abs( const SparseMatrix<MT,SO>& sm )
860 {
862 
863  return SMatAbsExpr<MT,SO>( ~sm );
864 }
865 //*************************************************************************************************
866 
867 
868 
869 
870 //=================================================================================================
871 //
872 // GLOBAL RESTRUCTURING FUNCTIONS
873 //
874 //=================================================================================================
875 
876 //*************************************************************************************************
887 template< typename MT // Type of the sparse matrix
888  , bool TF > // Transpose flag
889 inline const SMatAbsExpr<MT,TF>& abs( const SMatAbsExpr<MT,TF>& sm )
890 {
892 
893  return sm;
894 }
896 //*************************************************************************************************
897 
898 
899 
900 
901 //=================================================================================================
902 //
903 // ROWS SPECIALIZATIONS
904 //
905 //=================================================================================================
906 
907 //*************************************************************************************************
909 template< typename MT, bool SO >
910 struct Rows< SMatAbsExpr<MT,SO> > : public Rows<MT>
911 {};
913 //*************************************************************************************************
914 
915 
916 
917 
918 //=================================================================================================
919 //
920 // COLUMNS SPECIALIZATIONS
921 //
922 //=================================================================================================
923 
924 //*************************************************************************************************
926 template< typename MT, bool SO >
927 struct Columns< SMatAbsExpr<MT,SO> > : public Columns<MT>
928 {};
930 //*************************************************************************************************
931 
932 
933 
934 
935 //=================================================================================================
936 //
937 // ISSYMMETRIC SPECIALIZATIONS
938 //
939 //=================================================================================================
940 
941 //*************************************************************************************************
943 template< typename MT, bool SO >
944 struct IsSymmetric< SMatAbsExpr<MT,SO> > : public IsTrue< IsSymmetric<MT>::value >
945 {};
947 //*************************************************************************************************
948 
949 
950 
951 
952 //=================================================================================================
953 //
954 // ISHERMITIAN SPECIALIZATIONS
955 //
956 //=================================================================================================
957 
958 //*************************************************************************************************
960 template< typename MT, bool SO >
961 struct IsHermitian< SMatAbsExpr<MT,SO> > : public IsTrue< IsHermitian<MT>::value >
962 {};
964 //*************************************************************************************************
965 
966 
967 
968 
969 //=================================================================================================
970 //
971 // ISLOWER SPECIALIZATIONS
972 //
973 //=================================================================================================
974 
975 //*************************************************************************************************
977 template< typename MT, bool SO >
978 struct IsLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsLower<MT>::value >
979 {};
981 //*************************************************************************************************
982 
983 
984 
985 
986 //=================================================================================================
987 //
988 // ISUNILOWER SPECIALIZATIONS
989 //
990 //=================================================================================================
991 
992 //*************************************************************************************************
994 template< typename MT, bool SO >
995 struct IsUniLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsUniLower<MT>::value >
996 {};
998 //*************************************************************************************************
999 
1000 
1001 
1002 
1003 //=================================================================================================
1004 //
1005 // ISSTRICTLYLOWER SPECIALIZATIONS
1006 //
1007 //=================================================================================================
1008 
1009 //*************************************************************************************************
1011 template< typename MT, bool SO >
1012 struct IsStrictlyLower< SMatAbsExpr<MT,SO> > : public IsTrue< IsStrictlyLower<MT>::value >
1013 {};
1015 //*************************************************************************************************
1016 
1017 
1018 
1019 
1020 //=================================================================================================
1021 //
1022 // ISUPPER SPECIALIZATIONS
1023 //
1024 //=================================================================================================
1025 
1026 //*************************************************************************************************
1028 template< typename MT, bool SO >
1029 struct IsUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsUpper<MT>::value >
1030 {};
1032 //*************************************************************************************************
1033 
1034 
1035 
1036 
1037 //=================================================================================================
1038 //
1039 // ISUNIUPPER SPECIALIZATIONS
1040 //
1041 //=================================================================================================
1042 
1043 //*************************************************************************************************
1045 template< typename MT, bool SO >
1046 struct IsUniUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsUniUpper<MT>::value >
1047 {};
1049 //*************************************************************************************************
1050 
1051 
1052 
1053 
1054 //=================================================================================================
1055 //
1056 // ISSTRICTLYUPPER SPECIALIZATIONS
1057 //
1058 //=================================================================================================
1059 
1060 //*************************************************************************************************
1062 template< typename MT, bool SO >
1063 struct IsStrictlyUpper< SMatAbsExpr<MT,SO> > : public IsTrue< IsStrictlyUpper<MT>::value >
1064 {};
1066 //*************************************************************************************************
1067 
1068 
1069 
1070 
1071 //=================================================================================================
1072 //
1073 // EXPRESSION TRAIT SPECIALIZATIONS
1074 //
1075 //=================================================================================================
1076 
1077 //*************************************************************************************************
1079 template< typename MT >
1080 struct SMatAbsExprTrait< SMatAbsExpr<MT,false> >
1081 {
1082  public:
1083  //**********************************************************************************************
1084  typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value
1085  , SMatAbsExpr<MT,false>
1086  , INVALID_TYPE >::Type Type;
1087  //**********************************************************************************************
1088 };
1090 //*************************************************************************************************
1091 
1092 
1093 //*************************************************************************************************
1095 template< typename MT >
1096 struct TSMatAbsExprTrait< SMatAbsExpr<MT,true> >
1097 {
1098  public:
1099  //**********************************************************************************************
1100  typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value
1101  , SMatAbsExpr<MT,true>
1102  , INVALID_TYPE >::Type Type;
1103  //**********************************************************************************************
1104 };
1106 //*************************************************************************************************
1107 
1108 
1109 //*************************************************************************************************
1111 template< typename MT, bool SO, bool AF >
1112 struct SubmatrixExprTrait< SMatAbsExpr<MT,SO>, AF >
1113 {
1114  public:
1115  //**********************************************************************************************
1116  typedef typename AbsExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type >::Type Type;
1117  //**********************************************************************************************
1118 };
1120 //*************************************************************************************************
1121 
1122 
1123 //*************************************************************************************************
1125 template< typename MT, bool SO >
1126 struct RowExprTrait< SMatAbsExpr<MT,SO> >
1127 {
1128  public:
1129  //**********************************************************************************************
1130  typedef typename AbsExprTrait< typename RowExprTrait<const MT>::Type >::Type Type;
1131  //**********************************************************************************************
1132 };
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1139 template< typename MT, bool SO >
1140 struct ColumnExprTrait< SMatAbsExpr<MT,SO> >
1141 {
1142  public:
1143  //**********************************************************************************************
1144  typedef typename AbsExprTrait< typename ColumnExprTrait<const MT>::Type >::Type Type;
1145  //**********************************************************************************************
1146 };
1148 //*************************************************************************************************
1149 
1150 } // namespace blaze
1151 
1152 #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:455
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatAbsExpr.h:113
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:233
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatAbsExpr.h:173
SMatAbsExpr< MT, SO > This
Type of this SMatAbsExpr instance.
Definition: SMatAbsExpr.h:166
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:406
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatAbsExpr.h:478
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:287
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type Operand
Composite data type of the sparse matrix expression.
Definition: SMatAbsExpr.h:179
#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:81
Header file for the ColumnExprTrait class template.
ReferenceType reference
Reference return type.
Definition: SMatAbsExpr.h:205
Header file for the IsColumnMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
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:442
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:938
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatAbsExpr.h:429
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Header file for the Computation base class.
Element ValueType
Type of the underlying pointers.
Definition: SMatAbsExpr.h:196
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatAbsExpr.h:114
Header file for the RequiresEvaluation type trait.
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:276
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatAbsExpr.h:396
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatAbsExpr.h:376
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:244
Header file for the IsUniLower type trait.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
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:117
ValueType * PointerType
Pointer return type.
Definition: SMatAbsExpr.h:197
ValueType & ReferenceType
Reference return type.
Definition: SMatAbsExpr.h:198
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:859
Header file for the SparseMatrix base class.
DifferenceType difference_type
Difference between two iterators.
Definition: SMatAbsExpr.h:206
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatAbsExpr.h:348
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:261
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:190
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:490
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
SelectType< useAssign, const ResultType, const SMatAbsExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatAbsExpr.h:176
size_t index() const
Access to the current index of the sparse element.
Definition: SMatAbsExpr.h:265
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:185
#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:2585
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
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:199
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatAbsExpr.h:417
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:2587
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:222
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatAbsExpr.h:112
MT::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatAbsExpr.h:169
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:2591
AbsExprTrait< RN >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatAbsExpr.h:127
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatAbsExpr.h:500
ValueType value_type
Type of the underlying pointers.
Definition: SMatAbsExpr.h:203
#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:365
IteratorType it_
Iterator over the elements of the sparse matrix expression.
Definition: SMatAbsExpr.h:305
Header file for the RemoveReference type trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatAbsExpr.h:386
Header file for the SMatAbsExprTrait class template.
MT::ElementType ElementType
Resulting element type.
Definition: SMatAbsExpr.h:170
PointerType pointer
Pointer return type.
Definition: SMatAbsExpr.h:204
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComputation type trait class.
IteratorCategory iterator_category
The iterator category.
Definition: SMatAbsExpr.h:202
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:193
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatAbsExpr.h:332
#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:2583
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:298
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatAbsExpr.h:195
Expression object for the sparse matrix abs() function.The SMatAbsExpr class represents the compile t...
Definition: Forward.h:95
Operand operand() const
Returns the sparse matrix operand.
Definition: SMatAbsExpr.h:466
Header file for the IsUpper type trait.
Header file for exception macros.
MT::ResultType ResultType
Result type for expression template evaluations.
Definition: SMatAbsExpr.h:167
Header file for the AbsExprTrait class template.
Operand sm_
Sparse matrix of the absolute value expression.
Definition: SMatAbsExpr.h:507
Evaluation of the return type of an absolute value expression.Via this type trait it is possible to e...
Definition: AbsExprTrait.h:88
SMatAbsExpr(const MT &sm)
Constructor for the SMatAbsExpr class.
Definition: SMatAbsExpr.h:320
Header file for the IsHermitian type trait.
ConstIterator(IteratorType it)
Constructor for the ConstIterator class.
Definition: SMatAbsExpr.h:212
#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:168
#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.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatAbsExpr.h:254