35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATADDEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATDMATADDEXPR_H_
95 :
public MatMatAddExpr< DenseMatrix< DMatDMatAddExpr<MT1,MT2,SO>, SO > >
117 static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
132 ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> || !
returnExpr );
136 template<
typename MT >
137 static constexpr bool UseAssign_v =
useAssign;
149 template<
typename MT >
150 static constexpr bool UseSMPAssign_v =
151 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) &&
useAssign );
296 return (*
left_) + (*right_);
305 inline auto load() const noexcept {
434 ( MT1::simdEnabled && MT2::simdEnabled && HasSIMDAdd_v<ET1,ET2> );
437 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
483 if( i >=
lhs_.rows() ) {
486 if( j >=
lhs_.columns() ) {
505 return lhs_.load(i,j) +
rhs_.load(i,j);
536 inline size_t rows() const noexcept {
547 return lhs_.columns();
577 template<
typename T >
578 inline bool canAlias(
const T* alias )
const noexcept {
579 return ( IsExpression_v<MT1> && ( RequiresEvaluation_v<MT1> ?
lhs_.isAliased( alias ) :
lhs_.canAlias( alias ) ) ) ||
580 ( IsExpression_v<MT2> && ( RequiresEvaluation_v<MT2> ?
rhs_.isAliased( alias ) :
rhs_.canAlias( alias ) ) );
590 template<
typename T >
591 inline bool isAliased(
const T* alias )
const noexcept {
592 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
602 return lhs_.isAligned() &&
rhs_.isAligned();
612 return lhs_.canSMPAssign() ||
rhs_.canSMPAssign() ||
613 (
rows() *
columns() >= SMP_DMATDMATADD_THRESHOLD );
637 template<
typename MT
647 if( !IsOperation_v<MT1> &&
isSame( *lhs, rhs.lhs_ ) ) {
648 addAssign( *lhs, rhs.rhs_ );
650 else if( !IsOperation_v<MT2> &&
isSame( *lhs, rhs.rhs_ ) ) {
651 addAssign( *lhs, rhs.lhs_ );
653 else if( !RequiresEvaluation_v<MT2> ) {
654 assign ( *lhs, rhs.rhs_ );
655 addAssign( *lhs, rhs.lhs_ );
658 assign ( *lhs, rhs.lhs_ );
659 addAssign( *lhs, rhs.rhs_ );
679 template<
typename MT
698 const TmpType tmp(
serial( rhs ) );
718 template<
typename MT
720 friend inline auto addAssign( DenseMatrix<MT,SO2>& lhs,
const DMatDMatAddExpr& rhs )
721 -> EnableIf_t< UseAssign_v<MT> >
728 if( !RequiresEvaluation_v<MT2> ) {
729 addAssign( *lhs, rhs.rhs_ );
730 addAssign( *lhs, rhs.lhs_ );
733 addAssign( *lhs, rhs.lhs_ );
734 addAssign( *lhs, rhs.rhs_ );
758 template<
typename MT
760 friend inline auto subAssign( DenseMatrix<MT,SO2>& lhs,
const DMatDMatAddExpr& rhs )
761 -> EnableIf_t< UseAssign_v<MT> >
768 if( !RequiresEvaluation_v<MT2> ) {
769 subAssign( *lhs, rhs.rhs_ );
770 subAssign( *lhs, rhs.lhs_ );
773 subAssign( *lhs, rhs.lhs_ );
774 subAssign( *lhs, rhs.rhs_ );
798 template<
typename MT
800 friend inline auto schurAssign( DenseMatrix<MT,SO2>& lhs,
const DMatDMatAddExpr& rhs )
801 -> EnableIf_t< UseAssign_v<MT> >
813 schurAssign( *lhs, tmp );
844 template<
typename MT
847 -> EnableIf_t< UseSMPAssign_v<MT> >
854 if( !IsOperation_v<MT1> &&
isSame( *lhs, rhs.lhs_ ) ) {
857 else if( !IsOperation_v<MT2> &&
isSame( *lhs, rhs.rhs_ ) ) {
860 else if( !RequiresEvaluation_v<MT2> ) {
886 template<
typename MT
889 -> EnableIf_t< UseSMPAssign_v<MT> >
893 using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
905 const TmpType tmp( rhs );
925 template<
typename MT
928 -> EnableIf_t< UseSMPAssign_v<MT> >
935 if( !RequiresEvaluation_v<MT2> ) {
965 template<
typename MT
968 -> EnableIf_t< UseSMPAssign_v<MT> >
975 if( !RequiresEvaluation_v<MT2> ) {
1005 template<
typename MT
1008 -> EnableIf_t< UseSMPAssign_v<MT> >
1084template<
typename MT1
1087inline decltype(
auto)
1092 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1097 return ReturnType( *lhs, *rhs );
1112template<
typename MT1,
typename MT2,
bool SO >
1113struct IsAligned< DMatDMatAddExpr<MT1,MT2,SO> >
1114 :
public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1130template<
typename MT1,
typename MT2,
bool SO >
1131struct IsPadded< DMatDMatAddExpr<MT1,MT2,SO> >
1132 :
public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
Header file for the addition trait.
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 HasSIMDAdd type trait.
Macro for CUDA compatibility.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsExpression type trait class.
Header file for the IsOperation type trait class.
Header file for the IsPadded type trait.
Header file for the IsTemporary type trait class.
Header file for all SIMD functionality.
Iterator over the elements of the dense matrix.
Definition: DMatDMatAddExpr.h:185
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatDMatAddExpr.h:239
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:349
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatDMatAddExpr.h:382
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:394
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatDMatAddExpr.h:226
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatDMatAddExpr.h:285
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatDMatAddExpr.h:273
LeftIteratorType left_
Iterator to the current left-hand side element.
Definition: DMatDMatAddExpr.h:425
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatDMatAddExpr.h:192
ElementType * PointerType
Pointer return type.
Definition: DMatDMatAddExpr.h:190
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:360
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:327
ConstIterator_t< MT2 > RightIteratorType
ConstIterator type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:205
BLAZE_DEVICE_CALLABLE ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatDMatAddExpr.h:295
ReferenceType reference
Reference return type.
Definition: DMatDMatAddExpr.h:198
RightIteratorType right_
Iterator to the current right-hand side element.
Definition: DMatDMatAddExpr.h:426
ConstIterator_t< MT1 > LeftIteratorType
ConstIterator type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:202
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:338
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatDMatAddExpr.h:188
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatDMatAddExpr.h:406
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:371
BLAZE_DEVICE_CALLABLE ConstIterator(LeftIteratorType left, RightIteratorType right)
Constructor for the ConstIterator class.
Definition: DMatDMatAddExpr.h:214
ElementType & ReferenceType
Reference return type.
Definition: DMatDMatAddExpr.h:191
DifferenceType difference_type
Difference between two iterators.
Definition: DMatDMatAddExpr.h:199
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatDMatAddExpr.h:263
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatDMatAddExpr.h:251
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:305
ValueType value_type
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:196
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatDMatAddExpr.h:316
ElementType ValueType
Type of the underlying elements.
Definition: DMatDMatAddExpr.h:189
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatDMatAddExpr.h:418
PointerType pointer
Pointer return type.
Definition: DMatDMatAddExpr.h:197
IteratorCategory iterator_category
The iterator category.
Definition: DMatDMatAddExpr.h:195
Expression object for dense matrix-dense matrix additions.
Definition: DMatDMatAddExpr.h:97
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatDMatAddExpr.h:433
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatAddExpr.h:591
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DMatDMatAddExpr.h:526
decltype(std::declval< RN1 >()+std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatAddExpr.h:120
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:556
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:107
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatDMatAddExpr.h:442
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:103
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:178
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatAddExpr.h:566
AddTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatAddExpr.h:163
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DMatDMatAddExpr.h:515
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatAddExpr.h:611
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:100
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:175
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatAddExpr.h:164
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:102
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatAddExpr.h:578
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatDMatAddExpr.h:117
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatDMatAddExpr.h:166
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:106
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:104
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatAddExpr.h:165
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the addition expression.
Definition: DMatDMatAddExpr.h:131
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatAddExpr.h:536
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDMatAddExpr.h:601
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:101
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:620
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatAddExpr.h:546
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatAddExpr.h:467
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatDMatAddExpr.h:500
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatAddExpr.h:169
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatAddExpr.h:482
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatDMatAddExpr.h:619
If_t< useAssign, const ResultType, const DMatDMatAddExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatDMatAddExpr.h:172
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatAddExpr.h:105
DMatDMatAddExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatAddExpr class.
Definition: DMatDMatAddExpr.h:451
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatDMatAddExpr.h:437
Base class for dense matrices.
Definition: DenseMatrix.h:82
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
Base class for sparse matrices.
Definition: SparseMatrix.h:77
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_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_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.
Definition: MatMatAddExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
#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
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.