35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DMATTDMATMAPEXPR_H_ 102 template<
typename MT1
106 :
public MatMatMapExpr< DenseMatrix< DMatTDMatMapExpr<MT1,MT2,OP>, false > >
132 template<
typename MT >
135 enum :
bool { value = useAssign };
148 template<
typename MT >
149 struct UseSMPAssign {
150 enum :
bool { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
164 using ReturnType = decltype( std::declval<OP>()( std::declval<RN1>(), std::declval<RN2>() ) );
187 enum :
bool { simdEnabled =
false };
190 enum :
bool { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
230 if( i >=
lhs_.rows() ) {
233 if( j >=
lhs_.columns() ) {
245 inline size_t rows() const noexcept {
256 return lhs_.columns();
296 template<
typename T >
297 inline bool canAlias(
const T* alias )
const noexcept {
309 template<
typename T >
310 inline bool isAliased(
const T* alias )
const noexcept {
311 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
321 return lhs_.isAligned() &&
rhs_.isAligned();
331 return lhs_.canSMPAssign() &&
rhs_.canSMPAssign();
356 template<
typename MT
366 constexpr
size_t block( BLOCK_SIZE );
368 const size_t m( rhs.
rows() );
369 const size_t n( rhs.
columns() );
371 for(
size_t ii=0UL; ii<m; ii+=block ) {
372 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
373 for(
size_t jj=0UL; jj<n; jj+=block ) {
374 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
375 for(
size_t i=ii; i<iend; ++i ) {
376 for(
size_t j=jj; j<jend; ++j ) {
377 (~lhs)(i,j) = rhs.
op_( rhs.
lhs_(i,j), rhs.
rhs_(i,j) );
400 template<
typename MT
420 assign( ~lhs,
map( A, B, rhs.
op_ ) );
439 template<
typename MT
458 const TmpType tmp(
serial( rhs ) );
478 template<
typename MT
488 constexpr
size_t block( BLOCK_SIZE );
490 const size_t m( rhs.
rows() );
491 const size_t n( rhs.
columns() );
493 for(
size_t ii=0UL; ii<m; ii+=block ) {
494 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
495 for(
size_t jj=0UL; jj<n; jj+=block ) {
496 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
497 for(
size_t i=ii; i<iend; ++i ) {
498 for(
size_t j=jj; j<jend; ++j ) {
499 (~lhs)(i,j) += rhs.
op_( rhs.
lhs_(i,j), rhs.
rhs_(i,j) );
522 template<
typename MT
542 addAssign( ~lhs,
map( A, B, rhs.
op_ ) );
565 template<
typename MT
575 constexpr
size_t block( BLOCK_SIZE );
577 const size_t m( rhs.
rows() );
578 const size_t n( rhs.
columns() );
580 for(
size_t ii=0UL; ii<m; ii+=block ) {
581 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
582 for(
size_t jj=0UL; jj<n; jj+=block ) {
583 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
584 for(
size_t i=ii; i<iend; ++i ) {
585 for(
size_t j=jj; j<jend; ++j ) {
586 (~lhs)(i,j) -= rhs.
op_( rhs.
lhs_(i,j), rhs.
rhs_(i,j) );
609 template<
typename MT
629 subAssign( ~lhs,
map( A, B, rhs.
op_ ) );
652 template<
typename MT
662 constexpr
size_t block( BLOCK_SIZE );
664 const size_t m( rhs.
rows() );
665 const size_t n( rhs.
columns() );
667 for(
size_t ii=0UL; ii<m; ii+=block ) {
668 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
669 for(
size_t jj=0UL; jj<n; jj+=block ) {
670 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
671 for(
size_t i=ii; i<iend; ++i ) {
672 for(
size_t j=jj; j<jend; ++j ) {
673 (~lhs)(i,j) *= rhs.
op_( rhs.
lhs_(i,j), rhs.
rhs_(i,j) );
696 template<
typename MT
716 schurAssign( ~lhs,
map( A, B, rhs.
op_ ) );
747 template<
typename MT
786 template<
typename MT
805 const TmpType tmp( rhs );
826 template<
typename MT
870 template<
typename MT
914 template<
typename MT
984 template<
typename MT1
1016 template<
typename MT1
1019 inline decltype(
auto)
1028 return map(
trans( ~lhs ), ~rhs, op );
1049 template<
typename MT1
1052 inline decltype(
auto)
1061 return map( ~lhs,
trans( ~rhs ), op );
1092 template<
typename MT1
1095 inline decltype(
auto)
1104 return map_backend( ~lhs, ~rhs, op );
1123 template<
typename MT1
1155 template<
typename MT1
1158 inline decltype(
auto)
1167 return map( ~lhs,
trans( ~rhs ), op );
1188 template<
typename MT1
1191 inline decltype(
auto)
1200 return map(
trans( ~lhs ), ~rhs, op );
1231 template<
typename MT1
1234 inline decltype(
auto)
1243 return map_backend( ~lhs, ~rhs, op );
1258 template<
typename MT1,
typename MT2,
typename OP >
1259 struct Size< DMatTDMatMapExpr<MT1,MT2,OP>, 0UL >
1260 :
public Maximum< Size<MT1,0UL>, Size<MT2,0UL> >
1263 template<
typename MT1,
typename MT2,
typename OP >
1264 struct Size< DMatTDMatMapExpr<MT1,MT2,OP>, 1UL >
1265 :
public Maximum< Size<MT1,1UL>, Size<MT2,1UL> >
1281 template<
typename MT1,
typename MT2,
typename OP >
1282 struct IsAligned< DMatTDMatMapExpr<MT1,MT2,OP> >
1283 :
public And< IsAligned<MT1>, IsAligned<MT2> >
1299 template<
typename MT1,
typename MT2,
typename OP >
1300 struct IsPadded< DMatTDMatMapExpr<MT1,MT2,OP> >
1301 :
public And< IsPadded<MT1>, IsPadded<MT2> >
1317 template<
typename MT1,
typename MT2 >
1318 struct IsSymmetric< DMatTDMatMapExpr<MT1,MT2,Min> >
1319 :
public And< IsSymmetric<MT1>, IsSymmetric<MT2> >
1322 template<
typename MT1,
typename MT2 >
1323 struct IsSymmetric< DMatTDMatMapExpr<MT1,MT2,Max> >
1324 :
public And< IsSymmetric<MT1>, IsSymmetric<MT2> >
1340 template<
typename MT1,
typename MT2 >
1341 struct IsHermitian< DMatTDMatMapExpr<MT1,MT2,Min> >
1342 :
public And< IsHermitian<MT1>, IsHermitian<MT2> >
1345 template<
typename MT1,
typename MT2 >
1346 struct IsHermitian< DMatTDMatMapExpr<MT1,MT2,Max> >
1347 :
public And< IsHermitian<MT1>, IsHermitian<MT2> >
1363 template<
typename MT1,
typename MT2 >
1364 struct IsLower< DMatTDMatMapExpr<MT1,MT2,Min> >
1365 :
public And< IsLower<MT1>, IsLower<MT2> >
1368 template<
typename MT1,
typename MT2 >
1369 struct IsLower< DMatTDMatMapExpr<MT1,MT2,Max> >
1370 :
public And< IsLower<MT1>, IsLower<MT2> >
1386 template<
typename MT1,
typename MT2 >
1387 struct IsUniLower< DMatTDMatMapExpr<MT1,MT2,Min> >
1388 :
public And< IsUniLower<MT1>, IsUniLower<MT2> >
1391 template<
typename MT1,
typename MT2 >
1392 struct IsUniLower< DMatTDMatMapExpr<MT1,MT2,Max> >
1393 :
public And< IsUniLower<MT1>, IsUniLower<MT2> >
1409 template<
typename MT1,
typename MT2 >
1411 :
public And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >
1414 template<
typename MT1,
typename MT2 >
1416 :
public And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >
1432 template<
typename MT1,
typename MT2 >
1433 struct IsUpper< DMatTDMatMapExpr<MT1,MT2,Min> >
1434 :
public And< IsUpper<MT1>, IsUpper<MT2> >
1437 template<
typename MT1,
typename MT2 >
1438 struct IsUpper< DMatTDMatMapExpr<MT1,MT2,Max> >
1439 :
public And< IsUpper<MT1>, IsUpper<MT2> >
1455 template<
typename MT1,
typename MT2 >
1456 struct IsUniUpper< DMatTDMatMapExpr<MT1,MT2,Min> >
1457 :
public And< IsUniUpper<MT1>, IsUniUpper<MT2> >
1460 template<
typename MT1,
typename MT2 >
1461 struct IsUniUpper< DMatTDMatMapExpr<MT1,MT2,Max> >
1462 :
public And< IsUniUpper<MT1>, IsUniUpper<MT2> >
1478 template<
typename MT1,
typename MT2 >
1480 :
public And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >
1483 template<
typename MT1,
typename MT2 >
1485 :
public And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >
#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
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 the IsUniUpper type trait.
EnableIf_< IsDenseMatrix< MT1 > > smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:196
Header file for basic type definitions.
Operation operation() const
Returns a copy of the custom operation.
Definition: DMatTDMatMapExpr.h:285
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
Header file for the serial shim.
#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:338
typename BinaryMapTrait< T1, T2, OP >::Type BinaryMapTrait_
Auxiliary alias declaration for the BinaryMapTrait class template.The BinaryMapTrait_ alias declarati...
Definition: BinaryMapTrait.h:139
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatTDMatMapExpr.h:245
Operation op_
The custom unary operation.
Definition: DMatTDMatMapExpr.h:339
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the And class template.
Compile time value evaluation.The Maximum alias declaration selects the larger of the two given templ...
Definition: Maximum.h:73
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:87
Header file for the Computation base class.
ResultType_< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:112
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:87
CompositeType_< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:117
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
Header file for the IsUniLower type trait.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:343
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
typename IfTrue< Condition, T1, T2 >::Type IfTrue_
Auxiliary alias declaration for the IfTrue class template.The IfTrue_ alias declaration provides a co...
Definition: If.h:109
typename T::ReturnType ReturnType_
Alias declaration for nested ReturnType type definitions.The ReturnType_ alias declaration provides a...
Definition: Aliases.h:363
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
Constraint on the data type.
Header file for the Maximum class template.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:71
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatMapExpr.h:320
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:86
DMatTDMatMapExpr(const MT1 &lhs, const MT2 &rhs, OP op) noexcept
Constructor for the DMatTDMatMapExpr class.
Definition: DMatTDMatMapExpr.h:200
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
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:330
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatMapExpr.h:297
CompositeType_< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:118
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
#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:255
TransposeType_< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:160
Header file for the Not class template.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Header file for all SIMD functionality.
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
Constraints on the storage order of matrix types.
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
Header file for the exception macros of the math module.
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the IsPadded type trait.
#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:105
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:86
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatMapExpr.h:229
If_< IsExpression< MT1 >, const MT1, const MT1 &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:170
#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
Header file for the binary map trait.
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatMapExpr.h:214
Header file for run time assertion macros.
OppositeType_< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatMapExpr.h:159
ResultType_< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:111
BinaryMapTrait_< RT1, RT2, OP > ResultType
Result type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:158
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
ElementType_< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:113
ReturnType_< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:115
#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
Compile time type negation.The Not alias declaration negates the given compile time condition...
Definition: Not.h:70
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:265
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:275
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:816
LeftOperand lhs_
Left-hand side dense matrix of the map expression.
Definition: DMatTDMatMapExpr.h:337
#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
ElementType_< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:114
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
typename T::OppositeType OppositeType_
Alias declaration for nested OppositeType type definitions.The OppositeType_ alias declaration provid...
Definition: Aliases.h:263
#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:176
decltype(std::declval< OP >()(std::declval< RN1 >(), std::declval< RN2 >())) ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatMapExpr.h:164
Header file for the Min functor.
If_< RequiresEvaluation< MT2 >, const RT2, CT2 > RT
Type for the assignment of the right-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:182
IfTrue_< useAssign, const ResultType, const DMatTDMatMapExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatTDMatMapExpr.h:167
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
Header file for the MatMatMapExpr base class.
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ElementType_< ResultType > ElementType
Resulting element type.
Definition: DMatTDMatMapExpr.h:161
Compile time evaluation of the size of vectors and matrices.The Size type trait evaluates the size of...
Definition: Size.h:80
Compile time logical 'and' evaluation.The And alias declaration performs at compile time a logical 'a...
Definition: And.h:76
Header file for the Max functor.
If_< IsExpression< MT2 >, const MT2, const MT2 &> RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:173
typename T::TransposeType TransposeType_
Alias declaration for nested TransposeType type definitions.The TransposeType_ alias declaration prov...
Definition: Aliases.h:423
Header file for the IsUpper type trait.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatMapExpr.h:310
Header file for the IsHermitian type trait.
If_< RequiresEvaluation< MT1 >, const RT1, CT1 > LT
Type for the assignment of the left-hand side dense matrix operand.
Definition: DMatTDMatMapExpr.h:179
System settings for the inline keywords.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
ReturnType_< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatMapExpr.h:116
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:95
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:1134