35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_ 90 template<
typename MT1
94 :
public MatMatMapExpr< DenseMatrix< DMatTDMatMapExpr<MT1,MT2,OP>, false > >
117 static constexpr
bool useAssign = ( RequiresEvaluation_v<MT1> || RequiresEvaluation_v<MT2> );
120 template<
typename MT >
122 static constexpr
bool UseAssign_v =
useAssign;
134 template<
typename MT >
135 static constexpr
bool UseSMPAssign_v =
136 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) &&
useAssign );
150 using ReturnType = decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
176 static constexpr
bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
216 if( i >=
lhs_.rows() ) {
219 if( j >=
lhs_.columns() ) {
231 inline size_t rows() const noexcept {
242 return lhs_.columns();
282 template<
typename T >
283 inline bool canAlias(
const T* alias )
const noexcept {
284 return ( IsExpression_v<MT1> &&
lhs_.canAlias( alias ) ) ||
285 ( IsExpression_v<MT2> &&
rhs_.canAlias( alias ) );
295 template<
typename T >
296 inline bool isAliased(
const T* alias )
const noexcept {
297 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
307 return lhs_.isAligned() &&
rhs_.isAligned();
317 return lhs_.canSMPAssign() &&
rhs_.canSMPAssign();
342 template<
typename MT
352 constexpr
size_t block( BLOCK_SIZE );
354 const size_t m( rhs.rows() );
355 const size_t n( rhs.columns() );
357 for(
size_t ii=0UL; ii<m; ii+=block ) {
358 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
359 for(
size_t jj=0UL; jj<n; jj+=block ) {
360 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
361 for(
size_t i=ii; i<iend; ++i ) {
362 for(
size_t j=jj; j<jend; ++j ) {
363 (~lhs)(i,j) = rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
386 template<
typename MT
406 assign( ~lhs,
map( A, B, rhs.op_ ) );
425 template<
typename MT
427 friend inline auto assign( SparseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
428 -> EnableIf_t< UseAssign_v<MT> >
432 using TmpType = If_t< SO, OppositeType, ResultType >;
444 const TmpType tmp(
serial( rhs ) );
464 template<
typename MT
466 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
467 -> DisableIf_t< UseAssign_v<MT> >
474 constexpr
size_t block( BLOCK_SIZE );
476 const size_t m( rhs.rows() );
477 const size_t n( rhs.columns() );
479 for(
size_t ii=0UL; ii<m; ii+=block ) {
480 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
481 for(
size_t jj=0UL; jj<n; jj+=block ) {
482 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
483 for(
size_t i=ii; i<iend; ++i ) {
484 for(
size_t j=jj; j<jend; ++j ) {
485 (~lhs)(i,j) += rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
508 template<
typename MT
510 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
511 -> EnableIf_t< UseAssign_v<MT> >
528 addAssign( ~lhs,
map( A, B, rhs.op_ ) );
551 template<
typename MT
553 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
554 -> DisableIf_t< UseAssign_v<MT> >
561 constexpr
size_t block( BLOCK_SIZE );
563 const size_t m( rhs.rows() );
564 const size_t n( rhs.columns() );
566 for(
size_t ii=0UL; ii<m; ii+=block ) {
567 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
568 for(
size_t jj=0UL; jj<n; jj+=block ) {
569 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
570 for(
size_t i=ii; i<iend; ++i ) {
571 for(
size_t j=jj; j<jend; ++j ) {
572 (~lhs)(i,j) -= rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
595 template<
typename MT
597 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
598 -> EnableIf_t< UseAssign_v<MT> >
615 subAssign( ~lhs,
map( A, B, rhs.op_ ) );
638 template<
typename MT
640 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
641 -> DisableIf_t< UseAssign_v<MT> >
648 constexpr
size_t block( BLOCK_SIZE );
650 const size_t m( rhs.rows() );
651 const size_t n( rhs.columns() );
653 for(
size_t ii=0UL; ii<m; ii+=block ) {
654 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
655 for(
size_t jj=0UL; jj<n; jj+=block ) {
656 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
657 for(
size_t i=ii; i<iend; ++i ) {
658 for(
size_t j=jj; j<jend; ++j ) {
659 (~lhs)(i,j) *= rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
682 template<
typename MT
684 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
685 -> EnableIf_t< UseAssign_v<MT> >
702 schurAssign( ~lhs,
map( A, B, rhs.op_ ) );
733 template<
typename MT
736 -> EnableIf_t< UseSMPAssign_v<MT> >
772 template<
typename MT
775 -> EnableIf_t< UseSMPAssign_v<MT> >
779 using TmpType = If_t< SO, OppositeType, ResultType >;
791 const TmpType tmp( rhs );
812 template<
typename MT
815 -> EnableIf_t< UseSMPAssign_v<MT> >
856 template<
typename MT
859 -> EnableIf_t< UseSMPAssign_v<MT> >
900 template<
typename MT
903 -> EnableIf_t< UseSMPAssign_v<MT> >
970 template<
typename MT1
973 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* =
nullptr >
974 inline const DMatTDMatMapExpr<MT1,MT2,OP>
975 map_backend(
const DenseMatrix<MT1,false>& lhs,
const DenseMatrix<MT2,true>& rhs, OP op )
982 return DMatTDMatMapExpr<MT1,MT2,OP>( ~lhs, ~rhs, op );
1002 template<
typename MT1
1005 , EnableIf_t< IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* =
nullptr >
1006 inline decltype(
auto)
1007 map_backend( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs, OP op )
1014 return map(
trans( ~lhs ), ~rhs, op );
1035 template<
typename MT1
1038 , EnableIf_t< IsSymmetric_v<MT2> >* =
nullptr >
1039 inline decltype(
auto)
1040 map_backend( const DenseMatrix<MT1,false>& lhs, const DenseMatrix<MT2,true>& rhs, OP op )
1047 return map( ~lhs,
trans( ~rhs ), op );
1078 template<
typename MT1
1081 inline decltype(
auto)
1090 return map_backend( ~lhs, ~rhs, op );
1109 template<
typename MT1
1112 , EnableIf_t< !IsSymmetric_v<MT1> && !IsSymmetric_v<MT2> >* =
nullptr >
1113 inline const DMatTDMatMapExpr<MT1,MT2,OP>
1114 map_backend(
const DenseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,false>& rhs, OP op )
1121 return DMatTDMatMapExpr<MT1,MT2,OP>( ~lhs, ~rhs, op );
1141 template<
typename MT1
1144 , EnableIf_t< !IsSymmetric_v<MT1> && IsSymmetric_v<MT2> >* =
nullptr >
1145 inline decltype(
auto)
1146 map_backend( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs, OP op )
1153 return map( ~lhs,
trans( ~rhs ), op );
1174 template<
typename MT1
1177 , EnableIf_t< IsSymmetric_v<MT1> >* =
nullptr >
1178 inline decltype(
auto)
1179 map_backend( const DenseMatrix<MT1,true>& lhs, const DenseMatrix<MT2,false>& rhs, OP op )
1186 return map(
trans( ~lhs ), ~rhs, op );
1217 template<
typename MT1
1220 inline decltype(
auto)
1229 return map_backend( ~lhs, ~rhs, op );
1244 template<
typename MT1,
typename MT2,
typename OP >
1245 struct IsAligned< DMatTDMatMapExpr<MT1,MT2,OP> >
1246 :
public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1262 template<
typename MT1,
typename MT2,
typename OP >
1263 struct IsPadded< DMatTDMatMapExpr<MT1,MT2,OP> >
1264 :
public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:100
MapTrait_t< RT1, RT2, OP > ResultType
Result type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:144
#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
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:105
Header file for auxiliary alias declarations.
Header file for kernel specific block sizes.
Base class for all binary matrix map expression templates.The MatMatMapExpr class serves as a tag for...
Definition: MatMatMapExpr.h:66
Header file for basic type definitions.
Operation operation() const
Returns a copy of the custom operation.
Definition: DMatTDMatMapExpr.h:271
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
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:104
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.
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.The MapTrait_t alias declaration provides...
Definition: MapTrait.h:160
#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
RightOperand rhs_
Right-hand side dense matrix of the map expression.
Definition: DMatTDMatMapExpr.h:324
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTDMatMapExpr.h:231
Operation op_
The custom unary operation.
Definition: DMatTDMatMapExpr.h:325
Header file for the Computation base class.
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatMapExpr.h:145
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
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:101
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
If_t< useAssign, const ResultType, const DMatTDMatMapExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatTDMatMapExpr.h:153
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatMapExpr.h:306
DMatTDMatMapExpr(const MT1 &lhs, const MT2 &rhs, OP op) noexcept
Constructor for the DMatTDMatMapExpr class.
Definition: DMatTDMatMapExpr.h:186
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:146
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatTDMatMapExpr.h:316
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatMapExpr.h:283
#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.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatTDMatMapExpr.h:241
Header file for all SIMD functionality.
Header file for the IsAligned type trait.
If_t< RequiresEvaluation_v< MT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:165
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatTDMatMapExpr.h:147
Constraints on the storage order of matrix types.
If_t< RequiresEvaluation_v< MT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:168
Header file for the exception macros of the math module.
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the map expression.
Definition: DMatTDMatMapExpr.h:117
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:103
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_DIFFERENT_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:106
Expression object for the dense matrix/tranpose dense matrix map() function.The DMatTDMatMapExpr clas...
Definition: DMatTDMatMapExpr.h:93
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatMapExpr.h:215
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:99
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatMapExpr.h:200
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.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
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
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:106
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:159
#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.
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:251
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:261
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatTDMatMapExpr.h:173
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
Constraints on the storage order of matrix types.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
LeftOperand lhs_
Left-hand side dense matrix of the map expression.
Definition: DMatTDMatMapExpr.h:323
#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
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant alias template represents ...
Definition: IntegralConstant.h:110
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
OP Operation
Data type of the custom unary operation.
Definition: DMatTDMatMapExpr.h:162
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatTDMatMapExpr.h:176
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:150
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
Header file for the MatMatMapExpr base class.
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.
Header file for the map trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatMapExpr.h:296
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:102
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:156
System settings for the inline keywords.
#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
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Evaluates the given binary operation on each single element of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1121