35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_
93 :
public MatMatMapExpr< DenseMatrix< DMatTDMatMapExpr<MT1,MT2,OP>, false > >
120 template<
typename MT >
121 static constexpr bool UseAssign_v =
useAssign;
133 template<
typename MT >
134 static constexpr bool UseSMPAssign_v =
135 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) &&
useAssign );
153 using ReturnType =
decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
179 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
192 ,
op_ ( std::move(op) )
219 if( i >=
lhs_.rows() ) {
222 if( j >=
lhs_.columns() ) {
234 inline size_t rows() const noexcept {
245 return lhs_.columns();
285 template<
typename T >
286 inline bool canAlias(
const T* alias )
const noexcept {
298 template<
typename T >
299 inline bool isAliased(
const T* alias )
const noexcept {
300 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
310 return lhs_.isAligned() &&
rhs_.isAligned();
320 return lhs_.canSMPAssign() &&
rhs_.canSMPAssign();
345 template<
typename MT
355 constexpr size_t block( BLOCK_SIZE );
357 const size_t m( rhs.rows() );
358 const size_t n( rhs.columns() );
360 for(
size_t ii=0UL; ii<m; ii+=block ) {
361 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
362 for(
size_t jj=0UL; jj<n; jj+=block ) {
363 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
364 for(
size_t i=ii; i<iend; ++i ) {
365 for(
size_t j=jj; j<jend; ++j ) {
366 (*lhs)(i,j) = rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
389 template<
typename MT
409 assign( *lhs,
map( A, B, rhs.op_ ) );
428 template<
typename MT
430 friend inline auto assign( SparseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
435 using TmpType = If_t< SO, OppositeType, ResultType >;
447 const TmpType tmp(
serial( rhs ) );
467 template<
typename MT
469 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
477 constexpr size_t block( BLOCK_SIZE );
479 const size_t m( rhs.rows() );
480 const size_t n( rhs.columns() );
482 for(
size_t ii=0UL; ii<m; ii+=block ) {
483 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
484 for(
size_t jj=0UL; jj<n; jj+=block ) {
485 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
486 for(
size_t i=ii; i<iend; ++i ) {
487 for(
size_t j=jj; j<jend; ++j ) {
488 (*lhs)(i,j) += rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
511 template<
typename MT
513 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
531 addAssign( *lhs,
map( A, B, rhs.op_ ) );
554 template<
typename MT
556 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
564 constexpr size_t block( BLOCK_SIZE );
566 const size_t m( rhs.rows() );
567 const size_t n( rhs.columns() );
569 for(
size_t ii=0UL; ii<m; ii+=block ) {
570 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
571 for(
size_t jj=0UL; jj<n; jj+=block ) {
572 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
573 for(
size_t i=ii; i<iend; ++i ) {
574 for(
size_t j=jj; j<jend; ++j ) {
575 (*lhs)(i,j) -= rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
598 template<
typename MT
600 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
618 subAssign( *lhs,
map( A, B, rhs.op_ ) );
641 template<
typename MT
643 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
651 constexpr size_t block( BLOCK_SIZE );
653 const size_t m( rhs.rows() );
654 const size_t n( rhs.columns() );
656 for(
size_t ii=0UL; ii<m; ii+=block ) {
657 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
658 for(
size_t jj=0UL; jj<n; jj+=block ) {
659 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
660 for(
size_t i=ii; i<iend; ++i ) {
661 for(
size_t j=jj; j<jend; ++j ) {
662 (*lhs)(i,j) *= rhs.op_( rhs.lhs_(i,j), rhs.rhs_(i,j) );
685 template<
typename MT
687 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatMapExpr& rhs )
705 schurAssign( *lhs,
map( A, B, rhs.op_ ) );
736 template<
typename MT
775 template<
typename MT
794 const TmpType tmp( rhs );
815 template<
typename MT
859 template<
typename MT
903 template<
typename MT
973template<
typename MT1
1005template<
typename MT1
1009inline decltype(
auto)
1017 return map(
trans( *lhs ), *rhs, std::move(op) );
1038template<
typename MT1
1042inline decltype(
auto)
1050 return map( *lhs,
trans( *rhs ), std::move(op) );
1081template<
typename MT1
1084inline decltype(
auto)
1089 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1093 return map_backend( *lhs, *rhs, std::move(op) );
1112template<
typename MT1
1116inline const DMatTDMatMapExpr<MT1,MT2,OP>
1117 map_backend(
const DenseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,false>& rhs, OP op )
1144template<
typename MT1
1148inline decltype(
auto)
1156 return map( *lhs,
trans( *rhs ), std::move(op) );
1177template<
typename MT1
1181inline decltype(
auto)
1189 return map(
trans( *lhs ), *rhs, std::move(op) );
1220template<
typename MT1
1223inline decltype(
auto)
1228 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1232 return map_backend( *lhs, *rhs, std::move(op) );
1247template<
typename MT1,
typename MT2,
typename OP >
1248struct IsAligned< DMatTDMatMapExpr<MT1,MT2,OP> >
1249 :
public BoolConstant< IsAligned_v<MT1> && IsAligned_v<MT2> >
1265template<
typename MT1,
typename MT2,
typename OP >
1267 :
public BoolConstant< IsPadded_v<MT1> && IsPadded_v<MT2> >
Header file for auxiliary alias declarations.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition Aliases.h:470
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition Aliases.h:310
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition Aliases.h:110
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for run time assertion macros.
Header file for kernel specific block sizes.
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 IsAligned type trait.
Header file for the IsExpression type trait class.
Header file for the IsPadded type trait.
Header file for the IsSymmetric type trait.
Header file for the map trait.
Constraints on the storage order of matrix types.
Header file for all SIMD functionality.
Expression object for the dense matrix/tranpose dense matrix map() function.
Definition DMatTDMatMapExpr.h:95
RightOperand rhs_
Right-hand side dense matrix of the map expression.
Definition DMatTDMatMapExpr.h:327
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition DMatTDMatMapExpr.h:309
DMatTDMatMapExpr(const MT1 &lhs, const MT2 &rhs, OP op) noexcept
Constructor for the DMatTDMatMapExpr class.
Definition DMatTDMatMapExpr.h:189
ElementType_t< ResultType > ElementType
Resulting element type.
Definition DMatTDMatMapExpr.h:150
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:103
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:104
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:162
Operation operation() const
Returns a copy of the custom operation.
Definition DMatTDMatMapExpr.h:274
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition DMatTDMatMapExpr.h:264
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition DMatTDMatMapExpr.h:254
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition DMatTDMatMapExpr.h:299
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:159
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:102
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition DMatTDMatMapExpr.h:244
If_t< useAssign, const ResultType, const DMatTDMatMapExpr & > CompositeType
Data type for composite expression templates.
Definition DMatTDMatMapExpr.h:156
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition DMatTDMatMapExpr.h:148
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition DMatTDMatMapExpr.h:179
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition DMatTDMatMapExpr.h:218
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:100
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:99
If_t< RequiresEvaluation_v< MT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition DMatTDMatMapExpr.h:171
Operation op_
The custom unary operation.
Definition DMatTDMatMapExpr.h:328
OP Operation
Data type of the custom unary operation.
Definition DMatTDMatMapExpr.h:165
MatMatMapExpr< DenseMatrix< This, false > > BaseType
Base type of this DMatTDMatMapExpr instance.
Definition DMatTDMatMapExpr.h:145
MapTrait_t< RT1, RT2, OP > ResultType
Result type for expression template evaluations.
Definition DMatTDMatMapExpr.h:147
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition DMatTDMatMapExpr.h:286
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition DMatTDMatMapExpr.h:153
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition DMatTDMatMapExpr.h:319
LeftOperand lhs_
Left-hand side dense matrix of the map expression.
Definition DMatTDMatMapExpr.h:326
If_t< RequiresEvaluation_v< MT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition DMatTDMatMapExpr.h:168
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition DMatTDMatMapExpr.h:234
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the map expression.
Definition DMatTDMatMapExpr.h:116
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:105
DMatTDMatMapExpr< MT1, MT2, OP > This
Type of this DMatTDMatMapExpr instance.
Definition DMatTDMatMapExpr.h:142
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition DMatTDMatMapExpr.h:176
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition DMatTDMatMapExpr.h:149
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition DMatTDMatMapExpr.h:203
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:101
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition DMatTDMatMapExpr.h:98
Base class for dense matrices.
Definition DenseMatrix.h:82
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 MatMatMapExpr base class.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition DMatDMatMapExpr.h:1144
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_MATRICES_MUST_HAVE_DIFFERENT_STORAGE_ORDER(T1, T2)
Constraint on the data type.
Definition StorageOrder.h:106
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition ColumnMajorMatrix.h:61
typename MapTrait< Args... >::Type MapTrait_t
Auxiliary alias declaration for the MapTrait class template.
Definition MapTrait.h:131
constexpr bool RequiresEvaluation_v
Auxiliary variable template for the RequiresEvaluation type trait.
Definition RequiresEvaluation.h:91
constexpr bool IsSymmetric_v
Auxiliary variable template for the IsSymmetric type trait.
Definition IsSymmetric.h:172
constexpr bool IsExpression_v
Auxiliary variable template for the IsExpression type trait.
Definition IsExpression.h:114
#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
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
#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
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition IntegralConstant.h:110
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
Compile time check for data types with padding.
Definition IsPadded.h:77
Base class for all binary matrix map expression templates.
Definition MatMatMapExpr.h:68
System settings for the inline keywords.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.