35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSMATSUBEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DMATSMATSUBEXPR_H_ 87 template<
typename MT1
91 :
public MatMatSubExpr< DenseMatrix< DMatSMatSubExpr<MT1,MT2,SO>, SO > >
109 static constexpr
bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
122 template<
typename MT >
123 static constexpr
bool UseSMPAssign_v = ( !MT1::smpAssignable || !MT2::smpAssignable );
195 if( i >=
lhs_.rows() ) {
198 if( j >=
lhs_.columns() ) {
210 inline size_t rows() const noexcept {
221 return lhs_.columns();
251 template<
typename T >
252 inline bool canAlias(
const T* alias )
const noexcept {
253 return ( IsExpression_v<MT1> &&
lhs_.canAlias( alias ) ) ||
254 (
rhs_.canAlias( alias ) );
264 template<
typename T >
265 inline bool isAliased(
const T* alias )
const noexcept {
266 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
288 template<
typename MT
297 if( !IsOperation_v<MT1> &&
isSame( ~lhs, rhs.
lhs_ ) ) {
298 subAssign( ~lhs, rhs.
rhs_ );
301 assign ( ~lhs, rhs.
lhs_ );
302 subAssign( ~lhs, rhs.
rhs_ );
320 template<
typename MT
338 const TmpType tmp(
serial( rhs ) );
356 template<
typename MT
358 friend inline void addAssign( DenseMatrix<MT,SO2>& lhs,
const DMatSMatSubExpr& rhs )
365 addAssign( ~lhs, rhs.lhs_ );
366 subAssign( ~lhs, rhs.rhs_ );
387 template<
typename MT
389 friend inline void subAssign( DenseMatrix<MT,SO2>& lhs,
const DMatSMatSubExpr& rhs )
396 subAssign( ~lhs, rhs.lhs_ );
397 addAssign( ~lhs, rhs.rhs_ );
418 template<
typename MT
420 friend inline void schurAssign( DenseMatrix<MT,SO2>& lhs,
const DMatSMatSubExpr& rhs )
432 schurAssign( ~lhs, tmp );
463 template<
typename MT
466 -> EnableIf_t< UseSMPAssign_v<MT> >
473 if( !IsOperation_v<MT1> &&
isSame( ~lhs, rhs.lhs_ ) ) {
498 template<
typename MT
501 -> EnableIf_t< UseSMPAssign_v<MT> >
505 using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
517 const TmpType tmp( rhs );
537 template<
typename MT
540 -> EnableIf_t< UseSMPAssign_v<MT> >
571 template<
typename MT
574 -> EnableIf_t< UseSMPAssign_v<MT> >
606 template<
typename MT
609 -> EnableIf_t< UseSMPAssign_v<MT> >
671 template<
typename MT1
674 , DisableIf_t< IsZero_v<MT2> &&
675 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* =
nullptr >
676 inline const DMatSMatSubExpr<MT1,MT2,SO>
677 dmatsmatsub(
const DenseMatrix<MT1,SO>& lhs,
const SparseMatrix<MT2,SO>& rhs )
684 return DMatSMatSubExpr<MT1,MT2,SO>( ~lhs, ~rhs );
703 template<
typename MT1
706 , EnableIf_t< IsZero_v<MT2> &&
707 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* =
nullptr >
709 dmatsmatsub(
const DenseMatrix<MT1,SO>& lhs,
const SparseMatrix<MT2,SO>& rhs )
753 template<
typename MT1
756 inline decltype(
auto)
765 return dmatsmatsub( ~lhs, ~rhs );
791 template<
typename MT1
796 inline decltype(
auto)
797 operator+( const DMatSMatSubExpr<MT1,MT2,SO1>& lhs, const DenseMatrix<MT3,SO2>& rhs )
801 return ( lhs.leftOperand() + (~rhs) ) - lhs.rightOperand();
820 template<
typename MT1
825 inline decltype(
auto)
826 operator-( const DMatSMatSubExpr<MT1,MT2,SO1>& lhs, const DenseMatrix<MT3,SO2>& rhs )
830 return ( lhs.leftOperand() - (~rhs) ) - lhs.rightOperand();
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
RightOperand rhs_
Right-hand side sparse matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:273
Header file for auxiliary alias declarations.
typename SubTrait< T1, T2 >::Type SubTrait_t
Auxiliary alias declaration for the SubTrait class template.The SubTrait_t alias declaration provides...
Definition: SubTrait.h:238
Header file for the subtraction trait.
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:992
Header file for basic type definitions.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatSMatSubExpr.h:252
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:146
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatSMatSubExpr.h:179
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
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type,...
Definition: DenseMatrix.h:61
Header file for the IsSame and IsStrictlySame type traits.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatSMatSubExpr.h:220
Header file for the MAYBE_UNUSED function template.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatSMatSubExpr.h:265
Header file for the Computation base class.
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatSMatSubExpr.h:109
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
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
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:96
Constraint on the data type.
Constraint on the data type.
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:143
decltype(std::declval< RN1 >() - std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatSMatSubExpr.h:112
Header file for the DisableIf class template.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatSMatSubExpr.h:134
Header file for the IsTemporary type trait class.
LeftOperand lhs_
Left-hand side dense matrix of the subtraction expression.
Definition: DMatSMatSubExpr.h:272
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition: DMatSMatSubExpr.h:240
Base class for all matrix/matrix subtraction expression templates.The MatMatSubExpr class serves as a...
Definition: MatMatSubExpr.h:67
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatSMatSubExpr.h:140
#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
Header file for the DenseMatrix base class.
Header file for the MatMatSubExpr base class.
Header file for the IsOperation type trait class.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatSMatSubExpr.h:154
Constraints on the storage order of matrix types.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatSMatSubExpr.h:132
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for the EnableIf class template.
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
ReturnType_t< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:99
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatSMatSubExpr.h:133
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatSMatSubExpr.h:230
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.
Expression object for dense matrix-sparse matrix subtractions.The DMatSMatSubExpr class represents th...
Definition: DMatSMatSubExpr.h:90
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatSMatSubExpr.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
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatSMatSubExpr.h:151
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
Header file for all forward declarations for expression class templates.
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatSMatSubExpr.h:210
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
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:84
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatSMatSubExpr.h:98
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatSMatSubExpr.h:137
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: DMatSMatSubExpr.h:97
DMatSMatSubExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatSMatSubExpr class.
Definition: DMatSMatSubExpr.h:163
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
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
Header file for the IntegralConstant class template.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATSUBEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatSubExpr.h:103
SubTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatSMatSubExpr.h:131
#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
Header file for the IsExpression type trait class.
Header file for the function trace functionality.