35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
105 template<
typename MT
108 class SMatScalarDivExpr :
public SparseMatrix< SMatScalarDivExpr<MT,ST,SO>, SO >
109 ,
private MatScalarDivExpr
110 ,
private Computation
143 template<
typename MT2 >
146 enum { value = useAssign };
159 template<
typename MT2 >
160 struct UseSMPAssign {
161 enum { value = ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign };
317 enum { smpAssignable = 0 };
474 template<
typename T >
476 return matrix_.canAlias( alias );
486 template<
typename T >
488 return matrix_.isAliased( alias );
512 template<
typename MT2
522 assign( ~lhs, rhs.matrix_ );
523 (~lhs) /= rhs.scalar_;
542 template<
typename MT2
552 assign( ~lhs, rhs.matrix_ );
553 (~lhs) /= rhs.scalar_;
572 template<
typename MT2
574 friend inline typename EnableIf< UseAssign<MT2> >::Type
609 template<
typename MT2
611 friend inline typename EnableIf< UseAssign<MT2> >::Type
662 template<
typename MT2
664 friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
699 template<
typename MT2
701 friend inline typename EnableIf< UseSMPAssign<MT2> >::Type
774 template<
typename T1
777 inline const typename EnableIf< IsNumeric<T2>,
typename DivExprTrait<T1,T2>::Type >::Type
785 typedef typename ReturnType::RightOperand ScalarType;
788 return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
818 template<
typename MT
822 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST2,ST1>::Type >
823 ,
typename MultExprTrait< SMatScalarDivExpr<MT,ST1,SO>, ST2 >::Type >::Type
824 operator*(
const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
828 return mat.leftOperand() * ( scalar / mat.rightOperand() );
847 template<
typename ST1
851 inline const typename EnableIf< IsFloatingPoint< typename DivTrait<ST1,ST2>::Type >
852 ,
typename MultExprTrait< ST1, SMatScalarDivExpr<MT,ST2,SO> >::Type >::Type
853 operator*( ST1 scalar,
const SMatScalarDivExpr<MT,ST2,SO>& mat )
857 return mat.leftOperand() * ( scalar / mat.rightOperand() );
876 template<
typename MT
880 inline const typename EnableIf< IsNumeric<ST2>
881 ,
typename DivExprTrait<MT,typename MultTrait<ST1,ST2>::Type>::Type >::Type
882 operator/(
const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
888 typedef typename MultTrait<ST1,ST2>::Type MultType;
889 typedef typename DivExprTrait<MT,MultType>::Type
ReturnType;
890 typedef typename ReturnType::RightOperand ScalarType;
892 if( IsMultExpr<ReturnType>::value ) {
893 return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
896 return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
913 template<
typename MT,
typename ST,
bool SO >
930 template<
typename MT,
typename ST,
bool SO >
947 template<
typename MT,
typename ST,
bool SO >
948 struct IsSymmetric<
SMatScalarDivExpr<MT,ST,SO> > :
public IsTrue< IsSymmetric<MT>::value >
964 template<
typename MT,
typename ST,
bool SO >
965 struct IsLower<
SMatScalarDivExpr<MT,ST,SO> > :
public IsTrue< IsLower<MT>::value >
981 template<
typename MT,
typename ST,
bool SO >
982 struct IsUpper<
SMatScalarDivExpr<MT,ST,SO> > :
public IsTrue< IsUpper<MT>::value >
998 template<
typename MT,
typename ST1,
typename ST2 >
1003 enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1007 typedef typename SMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1008 typedef SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,false>, ST2,
false > T2;
1013 typedef typename SelectType< IsSparseMatrix<MT>::value && IsRowMajorMatrix<MT>::value &&
1014 IsNumeric<ST1>::value && IsNumeric<ST2>::value
1015 ,
typename SelectType<condition,T1,T2>::Type
1016 , INVALID_TYPE >::Type Type;
1033 template<
typename MT,
typename ST1,
typename ST2 >
1038 enum { condition = IsFloatingPoint<typename DivTrait<ST1,ST2>::Type>::value };
1042 typedef typename SMatScalarMultExprTrait<MT,typename DivTrait<ST1,ST2>::Type>::Type T1;
1043 typedef SMatScalarMultExpr< SMatScalarDivExpr<MT,ST1,true>, ST2,
true > T2;
1048 typedef typename SelectType< IsSparseMatrix<MT>::value && IsColumnMajorMatrix<MT>::value &&
1049 IsNumeric<ST1>::value && IsNumeric<ST2>::value
1050 ,
typename SelectType<condition,T1,T2>::Type
1051 , INVALID_TYPE >::Type Type;
1068 template<
typename MT,
typename ST,
bool SO,
bool AF >
1073 typedef typename DivExprTrait< typename SubmatrixExprTrait<const MT,AF>::Type, ST >::Type Type;
1090 template<
typename MT,
typename ST,
bool SO >
1095 typedef typename DivExprTrait< typename RowExprTrait<const MT>::Type, ST >::Type Type;
1112 template<
typename MT,
typename ST,
bool SO >
1117 typedef typename DivExprTrait< typename ColumnExprTrait<const MT>::Type, ST >::Type Type;
Pointer difference type of the Blaze library.
Constraint on the data type.
SelectType< IsExpression< MT >::value, const MT, const MT & >::Type LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:181
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatScalarDivExpr.h:442
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
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.
DivExprTrait< RN, ST >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarDivExpr.h:129
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:4838
const EnableIf< IsNumeric< T2 >, typename DivExprTrait< T1, T2 >::Type >::Type operator/(const DenseMatrix< T1, SO > &mat, T2 scalar)
Division operator for the division of a dense matrix by a scalar value ( ).
Definition: DMatScalarDivExpr.h:936
Compile time check whether the given type is a multiplication expression template.This type trait class tests whether or not the given type Type is a multiplication expression template (i.e. an expression representing an element-wise vector multiplication, a matrix/vector multiplication, a vector/matrix multiplication, or a matrix multiplication). In order to qualify as a valid multiplication expression template, the given type has to derive (publicly or privately) from the MultExpr base class. In case the given type is a valid multiplication expression template, the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsMultExpr.h:90
PointerType pointer
Pointer return type.
Definition: SMatScalarDivExpr.h:209
Header file for the IsSparseMatrix type trait.
#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
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
Header file for the ColumnExprTrait class template.
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatScalarDivExpr.h:352
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatScalarDivExpr.h:339
Header file for the IsColumnMajorMatrix type trait.
ValueType value_type
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:208
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:257
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.
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:239
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarDivExpr.h:171
Header file for the RequiresEvaluation type trait.
MT::ResultType RT
Result type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:114
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarDivExpr.h:217
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatScalarDivExpr.h:259
ValueType * PointerType
Pointer return type.
Definition: SMatScalarDivExpr.h:202
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarDivExpr.h:475
Constraint on the data type.
Header file for the SparseMatrix base class.
SMatScalarDivExpr(const MT &matrix, ST scalar)
Constructor for the SMatScalarDivExpr class.
Definition: SMatScalarDivExpr.h:326
Header file for the DivExprTrait class template.
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:495
Evaluation of the resulting expression type of a division.Via this type trait it is possible to evalu...
Definition: DivExprTrait.h:88
Constraint on the data type.
Header file for the MultExprTrait class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarDivExpr.h:170
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:259
Header file for the ValueIndexPair class.
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarDivExpr.h:184
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 multiplication trait.
Header file for the IsSymmetric type trait.
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarDivExpr.h:200
Header file for the IsFloatingPoint type trait.
Iterator over the elements of the sparse matrix/scalar division expression.
Definition: SMatScalarDivExpr.h:190
RemoveReference< LeftOperand >::Type::ConstIterator IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:198
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarDivExpr.h:487
Header file for the IsMultExpr type trait class.
MultTrait< RT, ST >::Type ResultType
Result type for expression template evaluations.
Definition: SMatScalarDivExpr.h:169
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarDivExpr.h:207
MT::CompositeType CT
Composite type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:116
size_t rows() const
Returns the current number of rows of the matrix.
Definition: SMatScalarDivExpr.h:373
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.
ReferenceType reference
Reference return type.
Definition: SMatScalarDivExpr.h:210
DifferenceType difference_type
Difference between two iterators.
Definition: SMatScalarDivExpr.h:211
LeftOperand leftOperand() const
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarDivExpr.h:453
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.In case the two types A and B are not the same (ignoring all cv-qualifiers of bo...
Definition: SameType.h:89
Header file for the IsLower type trait.
ResultType::ElementType ElementType
Resulting element type.
Definition: SMatScalarDivExpr.h:172
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:280
#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
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarDivExpr.h:416
Constraints on the storage order of matrix types.
SMatScalarDivExpr< MT, ST, SO > This
Type of this SMatScalarDivExpr instance.
Definition: SMatScalarDivExpr.h:168
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.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: SMatScalarDivExpr.h:383
SelectType< useAssign, const ResultType, const SMatScalarDivExpr & >::Type CompositeType
Data type for composite expression templates.
Definition: SMatScalarDivExpr.h:178
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: SMatScalarDivExpr.h:175
Header file for the EnableIf class template.
Header file for the serial shim.
Header file for the BaseElementType type trait.
RightOperand rightOperand() const
Returns the right-hand side scalar operand.
Definition: SMatScalarDivExpr.h:463
Header file for the IsNumeric type trait.
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:291
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 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
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarDivExpr.h:203
Header file for run time assertion macros.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarDivExpr.h:269
Utility type for generic codes.
Base template for the MultTrait class.
Definition: MultTrait.h:142
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
Header file for the division trait.
Expression object for sparse matrix-scalar divisions.The SMatScalarMult class represents the compile ...
Definition: Forward.h:93
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarDivExpr.h:302
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarDivExpr.h:404
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarDivExpr.h:228
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:201
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:310
#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.
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SMatScalarDivExpr.h:429
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarDivExpr.h:309
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is a floating point data type...
Definition: FloatingPoint.h:118
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:249
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.
LeftOperand matrix_
Left-hand side sparse matrix of the division expression.
Definition: SMatScalarDivExpr.h:494
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
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarDivExpr.h:204
#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.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarDivExpr.h:393
Header file for the IsUpper type trait.
Header file for the MatScalarDivExpr base class.
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:195
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatScalarDivExpr.h:363
#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
#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
MT::ReturnType RN
Return type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:115
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