35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_ 101 template<
typename MT
104 class SMatScalarDivExpr
105 :
public MatScalarDivExpr< SparseMatrix< SMatScalarDivExpr<MT,ST,SO>, SO > >
106 ,
private Computation
136 static constexpr
bool useAssign = RequiresEvaluation_v<MT>;
139 template<
typename MT2 >
141 static constexpr
bool UseAssign_v =
useAssign;
153 template<
typename MT2 >
154 static constexpr
bool UseSMPAssign_v =
155 ( ( !MT2::smpAssignable || !MT::smpAssignable ) &&
useAssign );
386 inline size_t rows() const noexcept {
487 template<
typename T >
488 inline bool canAlias(
const T* alias )
const noexcept {
489 return matrix_.canAlias( alias );
499 template<
typename T >
500 inline bool isAliased(
const T* alias )
const noexcept {
501 return matrix_.isAliased( alias );
525 template<
typename MT2
535 assign( ~lhs, rhs.matrix_ );
536 (~lhs) /= rhs.scalar_;
555 template<
typename MT2
565 assign( ~lhs, rhs.matrix_ );
566 (~lhs) /= rhs.scalar_;
585 template<
typename MT2
587 friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarDivExpr& rhs )
588 -> EnableIf_t< UseAssign_v<MT2> >
599 addAssign( ~lhs, tmp );
622 template<
typename MT2
624 friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarDivExpr& rhs )
625 -> EnableIf_t< UseAssign_v<MT2> >
636 subAssign( ~lhs, tmp );
659 template<
typename MT2
661 friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarDivExpr& rhs )
662 -> EnableIf_t< UseAssign_v<MT2> >
673 schurAssign( ~lhs, tmp );
712 template<
typename MT2
715 -> EnableIf_t< UseSMPAssign_v<MT2> >
749 template<
typename MT2
752 -> EnableIf_t< UseSMPAssign_v<MT2> >
786 template<
typename MT2
789 -> EnableIf_t< UseSMPAssign_v<MT2> >
845 template<
typename MT
848 struct SMatScalarDivExprHelper
852 using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<MT> > ||
853 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
854 , If_t< IsComplex_v< UnderlyingNumeric_t<MT> > && IsBuiltin_v<ST>
855 , DivTrait_t< UnderlyingBuiltin_t<MT>, ST >
856 , DivTrait_t< UnderlyingNumeric_t<MT>, ST > >
862 using Type = If_t< IsInvertible_v<ScalarType>
863 , SMatScalarMultExpr<MT,ScalarType,SO>
864 , SMatScalarDivExpr<MT,ScalarType,SO> >;
884 template<
typename MT
887 , DisableIf_t< IsZero_v<MT> >* =
nullptr >
888 inline const typename SMatScalarDivExprHelper<MT,ST,SO>::Type
889 smatscalardiv(
const SparseMatrix<MT,SO>& mat, ST scalar )
893 using ReturnType =
typename SMatScalarDivExprHelper<MT,ST,SO>::Type;
894 using ScalarType = RightOperand_t<ReturnType>;
896 if( IsMultExpr_v<ReturnType> ) {
897 return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
900 return ReturnType( ~mat, scalar );
920 template<
typename MT
923 , EnableIf_t< IsZero_v<MT> >* =
nullptr >
924 inline decltype(
auto)
925 smatscalardiv( const SparseMatrix<MT,SO>& mat, ST scalar )
931 using ReturnType =
const DivTrait_t< ResultType_t<MT>, ST >;
936 return ReturnType( (~mat).
rows(), (~mat).
columns() );
964 template<
typename MT
967 , EnableIf_t< IsNumeric_v<ST> >* =
nullptr >
968 inline decltype(
auto) operator/( const
SparseMatrix<MT,SO>& mat, ST scalar )
974 return smatscalardiv( ~mat, scalar );
1000 template<
typename MT
1004 , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1005 inline decltype(
auto) operator*( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1009 return mat.leftOperand() * ( scalar / mat.rightOperand() );
1028 template<
typename ST1
1032 , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* =
nullptr >
1033 inline decltype(
auto) operator*( ST1 scalar, const SMatScalarDivExpr<MT,ST2,SO>& mat )
1037 return mat.leftOperand() * ( scalar / mat.rightOperand() );
1056 template<
typename MT
1060 , EnableIf_t< IsNumeric_v<ST2> >* =
nullptr >
1061 inline decltype(
auto) operator/( const SMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1067 using MultType = MultTrait_t<ST1,ST2>;
1068 using ReturnType =
typename SMatScalarDivExprHelper<MT,MultType,SO>::Type;
1069 using ScalarType = RightOperand_t<ReturnType>;
1071 if( IsMultExpr_v<ReturnType> ) {
1072 return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
1075 return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarDivExpr.h:303
Header file for the UnderlyingNumeric type trait.
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarDivExpr.h:211
Constraint on the data type.
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:110
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:243
ReturnType_t< MT > RN
Return type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:111
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarDivExpr.h:500
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatScalarDivExpr.h:348
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
#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:63
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarDivExpr.h:164
Constraint on the data type.
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatScalarDivExpr.h:169
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatScalarDivExpr.h:396
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarDivExpr.h:178
Header file for the MAYBE_UNUSED function template.
Header file for the Computation base class.
MultTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SMatScalarDivExpr.h:163
Header file for the UnderlyingElement type trait.
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:192
Header file for the RequiresEvaluation type trait.
If_t< IsExpression_v< MT >, const MT, const MT & > LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:175
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:112
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Header file for the SparseMatrix base class.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarDivExpr.h:488
ValueType * PointerType
Pointer return type.
Definition: SMatScalarDivExpr.h:196
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the ValueIndexPair class.
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatScalarDivExpr.h:253
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatScalarDivExpr.h:455
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
Iterator over the elements of the sparse matrix/scalar division expression.
Definition: SMatScalarDivExpr.h:184
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:274
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SMatScalarDivExpr.h:476
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is not a zero vector or matrix type,...
Definition: Zero.h:61
Header file for the UnderlyingBuiltin type trait.
Header file for the IsMultExpr type trait class.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarDivExpr.h:165
#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:71
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
LeftOperand matrix_
Left-hand side sparse matrix of the division expression.
Definition: SMatScalarDivExpr.h:507
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: SMatScalarDivExpr.h:376
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:189
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:304
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
If_t< useAssign, const ResultType, const SMatScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatScalarDivExpr.h:172
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarDivExpr.h:417
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:195
Constraint on the data type.
Header file for the EnableIf class template.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatScalarDivExpr.h:166
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.The MultTrait_t alias declaration provid...
Definition: MultTrait.h:240
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
Header file for the IsNumeric type trait.
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SMatScalarDivExpr.h:122
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarDivExpr.h:429
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:285
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
Header file for the division trait.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarDivExpr.h:406
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarDivExpr.h:222
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarDivExpr.h:198
Expression object for sparse matrix-scalar divisions.The SMatScalarMult class represents the compile ...
Definition: Forward.h:127
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the division expression.
Definition: SMatScalarDivExpr.h:136
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: SMatScalarDivExpr.h:365
SMatScalarDivExpr(const MT &matrix, ST scalar) noexcept
Constructor for the SMatScalarDivExpr class.
Definition: SMatScalarDivExpr.h:320
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:61
Header file for the IsZero type trait.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarDivExpr.h:197
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatScalarDivExpr.h:311
Header file for all forward declarations for expression class templates.
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarDivExpr.h:201
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#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:81
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
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:442
Header file for the RemoveReference type trait.
Header file for the IsInvertible type trait.
#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:81
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarDivExpr.h:125
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatScalarDivExpr.h:386
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarDivExpr.h:466
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
const Element operator *() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:233
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatScalarDivExpr.h:333
Header file for the IsComplex type trait.
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:508
Header file for the MatScalarDivExpr base class.
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarDivExpr.h:263
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarDivExpr.h:296
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.In case the given data type T is a zero vector or matrix type,...
Definition: Zero.h:81
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
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:61
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarDivExpr.h:194
Header file for the IsExpression type trait class.
Header file for the function trace functionality.