35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATSCALARDIVEXPR_H_
101 :
public MatScalarDivExpr< SparseMatrix< SMatScalarDivExpr<MT,ST,SO>, SO > >
132 static constexpr bool useAssign = RequiresEvaluation_v<MT>;
136 template<
typename MT2 >
137 static constexpr bool UseAssign_v =
useAssign;
149 template<
typename MT2 >
150 static constexpr bool UseSMPAssign_v =
151 ( ( !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> >
847using SMatScalarDivExprHelper_t =
848 If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<MT> > ||
849 IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
850 , If_t< IsBuiltin_v<ST>
851 , DivTrait_t< UnderlyingBuiltin_t<MT>, ST >
852 ,
decltype(
inv( std::declval<ST>() ) ) >
873 , EnableIf_t< !IsZero_v<MT> &&
874 !IsInvertible_v< SMatScalarDivExprHelper_t<MT,ST> > >* =
nullptr >
875inline decltype(
auto) smatscalardiv(
const SparseMatrix<MT,SO>& mat, ST scalar )
879 using ScalarType = SMatScalarDivExprHelper_t<MT,ST>;
880 using ReturnType =
const SMatScalarDivExpr<MT,ScalarType,SO>;
882 return ReturnType( *mat, scalar );
903 , EnableIf_t< !IsZero_v<MT> &&
904 IsInvertible_v< SMatScalarDivExprHelper_t<MT,ST> > >* =
nullptr >
905inline decltype(
auto) smatscalardiv(
const SparseMatrix<MT,SO>& mat, ST scalar )
909 using ScalarType = SMatScalarDivExprHelper_t<MT,ST>;
910 using ReturnType =
const SMatScalarMultExpr<MT,ScalarType,SO>;
912 return ReturnType( *mat,
inv(scalar) );
934 , EnableIf_t< IsZero_v<MT> >* =
nullptr >
936 smatscalardiv(
const SparseMatrix<MT,SO>& mat, ST scalar )
942 using ReturnType =
const DivTrait_t< ResultType_t<MT>, ST >;
947 return ReturnType( (*mat).rows(), (*mat).columns() );
978 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
985 return smatscalardiv( *mat, scalar );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition: Aliases.h:130
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the division trait.
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsBuiltin type trait.
Header file for the IsExpression type trait class.
Header file for the IsFloatingPoint type trait.
Header file for the IsInvertible type trait.
Header file for the IsMultExpr type trait class.
Header file for the IsScalar type trait.
Header file for the IsTemporary type trait class.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Header file for the RemoveReference type trait.
Constraint on the data type.
Header file for the UnderlyingBuiltin type trait.
Header file for the UnderlyingElement type trait.
Header file for the ValueIndexPair class.
Constraint on the data type.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Iterator over the elements of the sparse matrix/scalar division expression.
Definition: SMatScalarDivExpr.h:185
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:189
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarDivExpr.h:194
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:274
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarDivExpr.h:222
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarDivExpr.h:197
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarDivExpr.h:195
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarDivExpr.h:201
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarDivExpr.h:285
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarDivExpr.h:303
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatScalarDivExpr.h:253
DifferenceType difference_type
Difference between two iterators.
Definition: SMatScalarDivExpr.h:205
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarDivExpr.h:296
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarDivExpr.h:211
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:192
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarDivExpr.h:198
ValueType * PointerType
Pointer return type.
Definition: SMatScalarDivExpr.h:196
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarDivExpr.h:263
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:243
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarDivExpr.h:233
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:304
Expression object for sparse matrix-scalar divisions.
Definition: SMatScalarDivExpr.h:103
SMatScalarDivExpr(const MT &matrix, ST scalar) noexcept
Constructor for the SMatScalarDivExpr class.
Definition: SMatScalarDivExpr.h:320
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarDivExpr.h:164
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatScalarDivExpr.h:386
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatScalarDivExpr.h:333
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarDivExpr.h:466
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatScalarDivExpr.h:311
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarDivExpr.h:165
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatScalarDivExpr.h:376
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatScalarDivExpr.h:348
MultTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SMatScalarDivExpr.h:163
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarDivExpr.h:500
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SMatScalarDivExpr.h:118
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:106
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarDivExpr.h:488
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the division expression.
Definition: SMatScalarDivExpr.h:132
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatScalarDivExpr.h:166
ReturnType_t< MT > RN
Return type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:107
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatScalarDivExpr.h:396
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
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarDivExpr.h:121
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatScalarDivExpr.h:365
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarDivExpr.h:406
LeftOperand matrix_
Left-hand side sparse matrix of the division expression.
Definition: SMatScalarDivExpr.h:507
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarDivExpr.h:429
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: SMatScalarDivExpr.h:508
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarDivExpr.h:178
If_t< IsExpression_v< MT >, const MT, const MT & > LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:175
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatScalarDivExpr.h:169
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatScalarDivExpr.h:108
If_t< useAssign, const ResultType, const SMatScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatScalarDivExpr.h:172
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SMatScalarDivExpr.h:476
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarDivExpr.h:417
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
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Index-value-pair for sparse vectors and matrices.
Definition: ValueIndexPair.h:75
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the MatScalarDivExpr base class.
Header file for the SparseMatrix base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.
Definition: FloatingPoint.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.
Definition: SameType.h:71
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:405
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition: Zero.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition: MultTrait.h:165
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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
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
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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all matrix/scalar division expression templates.
Definition: MatScalarDivExpr.h:75
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.