35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATSCALARMULTEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATSCALARMULTEXPR_H_
126 static constexpr bool useAssign = RequiresEvaluation_v<MT>;
130 template<
typename MT2 >
131 static constexpr bool UseAssign_v =
useAssign;
143 template<
typename MT2 >
144 static constexpr bool UseSMPAssign_v =
145 ( ( !MT2::smpAssignable || !MT::smpAssignable ) &&
useAssign );
380 inline size_t rows() const noexcept {
481 template<
typename T >
482 inline bool canAlias(
const T* alias )
const noexcept {
483 return matrix_.canAlias( alias );
493 template<
typename T >
494 inline bool isAliased(
const T* alias )
const noexcept {
495 return matrix_.isAliased( alias );
519 template<
typename MT2
529 assign( *lhs, rhs.matrix_ );
530 (*lhs) *= rhs.scalar_;
549 template<
typename MT2
559 assign( *lhs, rhs.matrix_ );
560 (*lhs) *= rhs.scalar_;
579 template<
typename MT2
581 friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarMultExpr& rhs )
582 -> EnableIf_t< UseAssign_v<MT2> >
593 addAssign( *lhs, tmp );
616 template<
typename MT2
618 friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarMultExpr& rhs )
619 -> EnableIf_t< UseAssign_v<MT2> >
630 subAssign( *lhs, tmp );
653 template<
typename MT2
655 friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs,
const SMatScalarMultExpr& rhs )
656 -> EnableIf_t< UseAssign_v<MT2> >
667 schurAssign( *lhs, tmp );
706 template<
typename MT2
709 -> EnableIf_t< UseSMPAssign_v<MT2> >
743 template<
typename MT2
746 -> EnableIf_t< UseSMPAssign_v<MT2> >
780 template<
typename MT2
783 -> EnableIf_t< UseSMPAssign_v<MT2> >
857 return ReturnType( *sm, ScalarType(-1) );
886 , DisableIf_t< IsZero_v<MT> >* =
nullptr >
887inline const SMatScalarMultExpr< MT, MultTrait_t< UnderlyingBuiltin_t<MT>, ST >, SO >
888 smatscalarmult(
const SparseMatrix<MT,SO>& mat, ST scalar )
892 using ScalarType = MultTrait_t< UnderlyingBuiltin_t<MT>, ST >;
893 using ReturnType =
const SMatScalarMultExpr<MT,ScalarType,SO>;
894 return ReturnType( *mat, scalar );
916 , EnableIf_t< IsZero_v<MT> >* =
nullptr >
918 smatscalarmult(
const SparseMatrix<MT,SO>& mat, ST scalar )
924 using ReturnType =
const MultTrait_t< ResultType_t<MT>, ST >;
929 return ReturnType( (*mat).rows(), (*mat).columns() );
959 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
964 return smatscalarmult( *mat, scalar );
993 , EnableIf_t< IsScalar_v<ST> >* =
nullptr >
998 return smatscalarmult( *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 EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsExpression type trait class.
Header file for the IsInvertible type trait.
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 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 multiplication expression.
Definition: SMatScalarMultExpr.h:179
ValueIndexPair< ElementType > Element
Element type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:183
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatScalarMultExpr.h:279
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatScalarMultExpr.h:192
Element ValueType
Type of the underlying pointers.
Definition: SMatScalarMultExpr.h:189
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SMatScalarMultExpr.h:298
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two expression iterators.
Definition: SMatScalarMultExpr.h:290
const ConstIterator * operator->() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarMultExpr.h:237
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatScalarMultExpr.h:268
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatScalarMultExpr.h:216
ConstIterator_t< RemoveReference_t< LeftOperand > > IteratorType
Iterator type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:186
DifferenceType difference_type
Difference between two iterators.
Definition: SMatScalarMultExpr.h:199
IteratorCategory iterator_category
The iterator category.
Definition: SMatScalarMultExpr.h:195
size_t index() const
Access to the current index of the sparse element.
Definition: SMatScalarMultExpr.h:257
ValueType * PointerType
Pointer return type.
Definition: SMatScalarMultExpr.h:190
ConstIterator(IteratorType matrix, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: SMatScalarMultExpr.h:205
const Element operator*() const
Direct access to the sparse matrix element at the current iterator position.
Definition: SMatScalarMultExpr.h:227
IteratorType matrix_
Iterator over the elements of the left-hand side sparse matrix expression.
Definition: SMatScalarMultExpr.h:297
ValueType & ReferenceType
Reference return type.
Definition: SMatScalarMultExpr.h:191
ReturnType value() const
Access to the current value of the sparse element.
Definition: SMatScalarMultExpr.h:247
std::forward_iterator_tag IteratorCategory
The iterator category.
Definition: SMatScalarMultExpr.h:188
Expression object for sparse matrix-scalar multiplications.
Definition: SMatScalarMultExpr.h:97
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: SMatScalarMultExpr.h:380
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:102
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatScalarMultExpr.h:482
If_t< IsExpression_v< MT >, const MT, const MT & > LeftOperand
Composite data type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:169
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatScalarMultExpr.h:159
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: SMatScalarMultExpr.h:390
RightOperand scalar_
Right-hand side scalar of the multiplication expression.
Definition: SMatScalarMultExpr.h:502
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the multiplication expression.
Definition: SMatScalarMultExpr.h:126
MultTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: SMatScalarMultExpr.h:157
decltype(std::declval< RN >() *std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: SMatScalarMultExpr.h:115
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: SMatScalarMultExpr.h:163
ConstIterator lowerBound(size_t i, size_t j) const
Returns an iterator to the first index not less then the given index.
Definition: SMatScalarMultExpr.h:436
ReturnType_t< MT > RN
Return type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:101
SMatScalarMultExpr(const MT &matrix, ST scalar) noexcept
Constructor for the SMatScalarMultExpr class.
Definition: SMatScalarMultExpr.h:314
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: SMatScalarMultExpr.h:370
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: SMatScalarMultExpr.h:342
ConstIterator find(size_t i, size_t j) const
Searches for a specific matrix element.
Definition: SMatScalarMultExpr.h:423
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: SMatScalarMultExpr.h:305
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatScalarMultExpr.h:494
LeftOperand leftOperand() const noexcept
Returns the left-hand side sparse matrix operand.
Definition: SMatScalarMultExpr.h:460
If_t< useAssign, const ResultType, const SMatScalarMultExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatScalarMultExpr.h:166
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: SMatScalarMultExpr.h:359
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatScalarMultExpr.h:160
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: SMatScalarMultExpr.h:470
size_t nonZeros(size_t i) const
Returns the number of non-zero elements in the specified row.
Definition: SMatScalarMultExpr.h:411
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: SMatScalarMultExpr.h:400
ConstIterator upperBound(size_t i, size_t j) const
Returns an iterator to the first index greater then the given index.
Definition: SMatScalarMultExpr.h:449
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: SMatScalarMultExpr.h:172
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: SMatScalarMultExpr.h:327
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: SMatScalarMultExpr.h:112
LeftOperand matrix_
Left-hand side sparse matrix of the multiplication expression.
Definition: SMatScalarMultExpr.h:501
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatScalarMultExpr.h:100
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: SMatScalarMultExpr.h:158
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 MatScalarMultExpr base class.
Header file for the SparseMatrix base class.
#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
#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
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition: UnderlyingBuiltin.h:117
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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 multiplication expression templates.
Definition: MatScalarMultExpr.h:77
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.