35#ifndef _BLAZE_MATH_EXPRESSIONS_TDMATSMATADDEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_TDMATSMATADDEXPR_H_
91 :
public MatMatAddExpr< DenseMatrix< TDMatSMatAddExpr<MT1,MT2>, true > >
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 );
199 if( i >=
lhs_.rows() ) {
202 if( j >=
lhs_.columns() ) {
214 inline size_t rows() const noexcept {
225 return lhs_.columns();
255 template<
typename T >
256 inline bool canAlias(
const T* alias )
const noexcept {
257 return ( IsExpression_v<MT1> &&
lhs_.canAlias( alias ) ) ||
258 (
rhs_.canAlias( alias ) );
268 template<
typename T >
269 inline bool isAliased(
const T* alias )
const noexcept {
270 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
292 template<
typename MT
301 if( !IsOperation_v<MT1> &&
isSame( *lhs, rhs.
lhs_ ) ) {
302 addAssign( *lhs, rhs.
rhs_ );
305 assign ( *lhs, rhs.
lhs_ );
306 addAssign( *lhs, rhs.
rhs_ );
324 template<
typename MT
342 const TmpType tmp(
serial( rhs ) );
361 template<
typename MT
363 friend inline void addAssign( DenseMatrix<MT,SO2>& lhs,
const TDMatSMatAddExpr& rhs )
370 addAssign( *lhs, rhs.lhs_ );
371 addAssign( *lhs, rhs.rhs_ );
393 template<
typename MT
395 friend inline void subAssign( DenseMatrix<MT,SO2>& lhs,
const TDMatSMatAddExpr& rhs )
402 subAssign( *lhs, rhs.lhs_ );
403 subAssign( *lhs, rhs.rhs_ );
425 template<
typename MT
427 friend inline void schurAssign( DenseMatrix<MT,SO2>& lhs,
const TDMatSMatAddExpr& rhs )
439 schurAssign( *lhs, tmp );
470 template<
typename MT
473 -> EnableIf_t< UseSMPAssign_v<MT> >
480 if( !IsOperation_v<MT1> &&
isSame( *lhs, rhs.lhs_ ) ) {
505 template<
typename MT
508 -> EnableIf_t< UseSMPAssign_v<MT> >
512 using TmpType = If_t< SO2, ResultType, OppositeType >;
524 const TmpType tmp( rhs );
545 template<
typename MT
548 -> EnableIf_t< UseSMPAssign_v<MT> >
580 template<
typename MT
583 -> EnableIf_t< UseSMPAssign_v<MT> >
615 template<
typename MT
618 -> EnableIf_t< UseSMPAssign_v<MT> >
681template<
typename MT1
683 , DisableIf_t< IsZero_v<MT2> &&
684 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* =
nullptr >
685inline const TDMatSMatAddExpr<MT1,MT2>
686 tdmatsmatadd(
const DenseMatrix<MT1,true>& lhs,
const SparseMatrix<MT2,false>& rhs )
693 return TDMatSMatAddExpr<MT1,MT2>( *lhs, *rhs );
713template<
typename MT1
715 , EnableIf_t< IsZero_v<MT2> &&
716 IsSame_v< ElementType_t<MT1>, ElementType_t<MT2> > >* =
nullptr >
718 tdmatsmatadd(
const DenseMatrix<MT1,true>& lhs,
const SparseMatrix<MT2,false>& rhs )
764template<
typename MT1
771 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
775 return tdmatsmatadd( *lhs, *rhs );
811template<
typename MT1
818 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
822 return tdmatsmatadd( *rhs, *lhs );
848template<
typename MT1
853 operator+(
const TDMatSMatAddExpr<MT1,MT2>& lhs,
const DenseMatrix<MT3,SO>& rhs )
857 return ( lhs.leftOperand() + (*rhs) ) + lhs.rightOperand();
876template<
typename MT1
881 operator-(
const TDMatSMatAddExpr<MT1,MT2>& lhs,
const DenseMatrix<MT3,SO>& rhs )
885 return ( lhs.leftOperand() - (*rhs) ) + lhs.rightOperand();
Header file for the addition trait.
Header file for auxiliary alias declarations.
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::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Constraints on the storage order of matrix types.
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 IntegralConstant class template.
Header file for the IsExpression type trait class.
Header file for the IsOperation type trait class.
Header file for the IsSame and IsStrictlySame type traits.
Header file for the IsTemporary type trait class.
Header file for the MAYBE_UNUSED function template.
Constraints on the storage order of matrix types.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Expression object for dense matrix-sparse matrix additions.
Definition: TDMatSMatAddExpr.h:93
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: TDMatSMatAddExpr.h:276
RightOperand rightOperand() const noexcept
Returns the right-hand side sparse matrix operand.
Definition: TDMatSMatAddExpr.h:244
TDMatSMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the TDMatSMatAddExpr class.
Definition: TDMatSMatAddExpr.h:167
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:137
ReturnType_t< MT2 > RN2
Return type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:99
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:150
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:141
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: TDMatSMatAddExpr.h:214
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: TDMatSMatAddExpr.h:158
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: TDMatSMatAddExpr.h:183
const ResultType CompositeType
Data type for composite expression templates.
Definition: TDMatSMatAddExpr.h:144
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: TDMatSMatAddExpr.h:135
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: TDMatSMatAddExpr.h:155
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: TDMatSMatAddExpr.h:256
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: TDMatSMatAddExpr.h:224
RightOperand rhs_
Right-hand side sparse matrix of the addition expression.
Definition: TDMatSMatAddExpr.h:277
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: TDMatSMatAddExpr.h:269
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:147
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: TDMatSMatAddExpr.h:136
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: TDMatSMatAddExpr.h:138
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: TDMatSMatAddExpr.h:109
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: TDMatSMatAddExpr.h:198
LeftOperand leftOperand() const noexcept
Returns the left-hand side transpose dense matrix operand.
Definition: TDMatSMatAddExpr.h:234
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:96
ResultType_t< MT2 > RT2
Result type of the right-hand side sparse matrix expression.
Definition: TDMatSMatAddExpr.h:97
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: TDMatSMatAddExpr.h:112
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: TDMatSMatAddExpr.h:98
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseMatrix base class.
Header file for the MatMatAddExpr base class.
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_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition: StorageOrder.h:84
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.
Definition: MatMatAddExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
typename AddTrait< T1, T2 >::Type AddTrait_t
Auxiliary alias declaration for the AddTrait class template.
Definition: AddTrait.h:163
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:1424
#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 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
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
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_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#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/matrix addition expression templates.
Definition: MatMatAddExpr.h:68
Header file for the IsZero type trait.
Header file for basic type definitions.