35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATABSEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATABSEXPR_H_
94 class SMatAbsExpr :
public SparseMatrix< SMatAbsExpr<MT,SO>, SO >
129 template<
typename MT2 >
132 enum { value = useAssign };
229 return abs(
it_->value() );
285 enum { smpAssignable = MT::smpAssignable };
351 return sm_.columns();
361 return sm_.nonZeros();
372 return sm_.nonZeros(i);
392 template<
typename T >
394 return sm_.canAlias( alias );
404 template<
typename T >
406 return sm_.isAliased( alias );
416 return sm_.canSMPAssign();
439 template<
typename MT2
471 template<
typename MT2 >
486 const size_t m( rhs.rows() );
488 for(
size_t i=0UL; i<m; ++i ) {
489 const Iterator
end( (~lhs).
end(i) );
490 for( Iterator element=(~lhs).
begin(i); element!=
end; ++element ) {
491 element->value() =
abs( element->value() );
512 template<
typename MT2 >
513 friend inline typename EnableIf< UseAssign<MT2> >::Type
527 const size_t n( rhs.columns() );
529 for(
size_t j=0UL; j<n; ++j ) {
530 const Iterator
end( (~lhs).
end(j) );
531 for( Iterator element=(~lhs).
begin(j); element!=
end; ++element ) {
532 element->value() =
abs( element->value() );
553 template<
typename MT2
555 friend inline typename EnableIf< UseAssign<MT2> >::Type
590 template<
typename MT2
592 friend inline typename EnableIf< UseAssign<MT2> >::Type
656 template<
typename MT
686 template<
typename MT
688 inline const SMatAbsExpr<MT,TF>&
abs(
const SMatAbsExpr<MT,TF>& sm )
708 template<
typename MT >
709 struct SMatAbsExprTrait< SMatAbsExpr<MT,false> >
713 typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value
714 , SMatAbsExpr<MT,false>
715 , INVALID_TYPE >::Type Type;
724 template<
typename MT >
725 struct TSMatAbsExprTrait< SMatAbsExpr<MT,true> >
729 typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value
730 , SMatAbsExpr<MT,true>
731 , INVALID_TYPE >::Type Type;
740 template<
typename MT,
bool SO,
bool AF >
741 struct SubmatrixExprTrait< SMatAbsExpr<MT,SO>, AF >
745 typedef typename AbsExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type >::Type Type;
754 template<
typename MT,
bool SO >
755 struct RowExprTrait< SMatAbsExpr<MT,SO> >
759 typedef typename AbsExprTrait< typename RowExprTrait<const MT>::Type >::Type Type;
768 template<
typename MT,
bool SO >
769 struct ColumnExprTrait< SMatAbsExpr<MT,SO> >
773 typedef typename AbsExprTrait< typename ColumnExprTrait<const MT>::Type >::Type Type;
IteratorCategory iterator_category
The iterator category.
Definition: SMatAbsExpr.h:175
Pointer difference type of the Blaze library.
MT::ResultType ResultType
Result type for expression template evaluations.
Definition: SMatAbsExpr.h:140
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatAbsExpr.h:146
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatAbsExpr.h:172
ReferenceType reference
Reference return type.
Definition: SMatAbsExpr.h:178
RemoveReference< Operand >::Type::ConstIterator IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatAbsExpr.h:166
PointerType pointer
Pointer return type.
Definition: SMatAbsExpr.h:177
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:151
MT::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatAbsExpr.h:141
#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:227
Header file for the ColumnExprTrait class template.
Header file for the sparse matrix SMP implementation.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2384
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:764
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: SMatAbsExpr.h:415
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatAbsExpr.h:319
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:405
ValueType & ReferenceType
Reference return type.
Definition: SMatAbsExpr.h:171
MT::ElementType ElementType
Resulting element type.
Definition: SMatAbsExpr.h:143
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2380
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:104
Constraint on the data type.
Operand operand() const
Returns the sparse matrix operand.
Definition: SMatAbsExpr.h:381
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:371
ConstIterator(IteratorType it)
Constructor for the ConstIterator class.
Definition: SMatAbsExpr.h:185
Constraint on the data type.
void smpAddAssign(DenseMatrix< 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:121
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:251
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.
Element ValueType
Type of the underlying pointers.
Definition: SMatAbsExpr.h:169
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatAbsExpr.h:260
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatAbsExpr.h:305
ValueType * PointerType
Pointer return type.
Definition: SMatAbsExpr.h:170
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
Header file for the dense matrix SMP implementation.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatAbsExpr.h:238
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:179
SMatAbsExpr(const MT &sm)
Constructor for the SMatAbsExpr class.
Definition: SMatAbsExpr.h:293
Header file for the MatAbsExpr base class.
Iterator over the elements of the sparse matrix absolute value expression.
Definition: SMatAbsExpr.h:158
#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:2381
Constraints on the storage order of matrix types.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
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:249
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:217
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatAbsExpr.h:206
Header file for the EnableIf class template.
MT::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatAbsExpr.h:142
Header file for the TSMatAbsExprTrait class template.
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:91
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatAbsExpr.h:360
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatAbsExpr.h:393
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:2383
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:340
Header file for run time assertion macros.
Utility type for generic codes.
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:209
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
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:239
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2387
Header file for the RemoveReference type trait.
IteratorType it_
Iterator over the elements of the sparse matrix expression.
Definition: SMatAbsExpr.h:278
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatAbsExpr.h:195
Header file for the SMatAbsExprTrait class template.
SelectType< useAssign, const ResultType, const SMatAbsExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatAbsExpr.h:149
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatAbsExpr.h:100
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatAbsExpr.h:330
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatAbsExpr.h:168
ValueType value_type
Type of the underlying pointers.
Definition: SMatAbsExpr.h:176
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatAbsExpr.h:163
AbsExprTrait< RN >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatAbsExpr.h:115
Header file for the IsComputation type trait class.
DifferenceType difference_type
Difference between two iterators.
Definition: SMatAbsExpr.h:179
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatAbsExpr.h:102
#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:2379
Header file for basic type definitions.
Expression object for the sparse matrix abs() function.The SMatAbsExpr class represents the compile t...
Definition: Forward.h:86
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatAbsExpr.h:101
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:422
Evaluation of the return type of an absolute value expression.Via this type trait it is possible to e...
Definition: AbsExprTrait.h:86
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatAbsExpr.h:350
#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:271
#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:139
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type Operand
Composite data type of the sparse matrix expression.
Definition: SMatAbsExpr.h:152
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.