35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATSCHUREXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATTDMATSCHUREXPR_H_
100template<
typename MT1
103 :
public SchurExpr< DenseMatrix< DMatTDMatSchurExpr<MT1,MT2>, false > >
142 template<
typename MT >
143 static constexpr bool UseAssign_v =
useAssign;
155 template<
typename MT >
156 static constexpr bool UseSMPAssign_v =
157 ( ( !MT1::smpAssignable || !MT2::smpAssignable ) &&
useAssign );
192 static constexpr bool smpAssignable = ( MT1::smpAssignable && MT2::smpAssignable );
233 if( i >=
lhs_.rows() ) {
236 if( j >=
lhs_.columns() ) {
248 inline size_t rows() const noexcept {
259 return lhs_.columns();
289 template<
typename T >
290 inline bool canAlias(
const T* alias )
const noexcept {
302 template<
typename T >
303 inline bool isAliased(
const T* alias )
const noexcept {
304 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
314 return lhs_.isAligned() &&
rhs_.isAligned();
324 return lhs_.canSMPAssign() ||
rhs_.canSMPAssign() ||
325 (
rows() *
columns() >= SMP_DMATTDMATSCHUR_THRESHOLD );
349 template<
typename MT
359 constexpr size_t block( BLOCK_SIZE );
361 const size_t m( rhs.rows() );
362 const size_t n( rhs.columns() );
364 for(
size_t ii=0UL; ii<m; ii+=block ) {
365 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
366 for(
size_t jj=0UL; jj<n; jj+=block ) {
367 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
368 for(
size_t i=ii; i<iend; ++i ) {
369 for(
size_t j=jj; j<jend; ++j ) {
370 (*lhs)(i,j) = rhs.lhs_(i,j) * rhs.rhs_(i,j);
394 template<
typename MT
405 schurAssign( *lhs, rhs.rhs_ );
410 assign( *lhs, A % B );
431 template<
typename MT
442 schurAssign( *lhs, rhs.rhs_ );
445 schurAssign( *lhs, rhs.lhs_ );
448 assign ( *lhs, rhs.rhs_ );
449 schurAssign( *lhs, rhs.lhs_ );
452 assign ( *lhs, rhs.lhs_ );
453 schurAssign( *lhs, rhs.rhs_ );
471 template<
typename MT
489 const TmpType tmp(
serial( rhs ) );
510 template<
typename MT
512 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
520 constexpr size_t block( BLOCK_SIZE );
522 const size_t m( rhs.rows() );
523 const size_t n( rhs.columns() );
525 for(
size_t ii=0UL; ii<m; ii+=block ) {
526 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
527 for(
size_t jj=0UL; jj<n; jj+=block ) {
528 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
529 for(
size_t i=ii; i<iend; ++i ) {
530 for(
size_t j=jj; j<jend; ++j ) {
531 (*lhs)(i,j) += rhs.lhs_(i,j) * rhs.rhs_(i,j);
555 template<
typename MT
557 friend inline auto addAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
570 addAssign( *lhs, tmp );
594 template<
typename MT
596 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
604 constexpr size_t block( BLOCK_SIZE );
606 const size_t m( rhs.rows() );
607 const size_t n( rhs.columns() );
609 for(
size_t ii=0UL; ii<m; ii+=block ) {
610 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
611 for(
size_t jj=0UL; jj<n; jj+=block ) {
612 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
613 for(
size_t i=ii; i<iend; ++i ) {
614 for(
size_t j=jj; j<jend; ++j ) {
615 (*lhs)(i,j) -= rhs.lhs_(i,j) * rhs.rhs_(i,j);
639 template<
typename MT
641 friend inline auto subAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
654 subAssign( *lhs, tmp );
678 template<
typename MT
680 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
688 constexpr size_t block( BLOCK_SIZE );
690 const size_t m( rhs.rows() );
691 const size_t n( rhs.columns() );
693 for(
size_t ii=0UL; ii<m; ii+=block ) {
694 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
695 for(
size_t jj=0UL; jj<n; jj+=block ) {
696 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
697 for(
size_t i=ii; i<iend; ++i ) {
698 for(
size_t j=jj; j<jend; ++j ) {
699 (*lhs)(i,j) *= rhs.lhs_(i,j) * rhs.rhs_(i,j);
724 template<
typename MT
726 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
739 schurAssign( *lhs, tmp );
760 template<
typename MT
762 friend inline auto schurAssign( DenseMatrix<MT,SO>& lhs,
const DMatTDMatSchurExpr& rhs )
771 schurAssign( *lhs, rhs.rhs_ );
772 schurAssign( *lhs, rhs.lhs_ );
775 schurAssign( *lhs, rhs.lhs_ );
776 schurAssign( *lhs, rhs.rhs_ );
809 template<
typename MT
846 template<
typename MT
889 template<
typename MT
908 const TmpType tmp( rhs );
929 template<
typename MT
968 template<
typename MT
1008 template<
typename MT
1044 template<
typename MT
1111template<
typename MT1
1148template<
typename MT1
1158inline decltype(
auto)
1166 return trans( *lhs ) % *rhs;
1185template<
typename MT1
1194inline decltype(
auto)
1202 return (*lhs) %
trans( *rhs );
1222template<
typename MT1
1226inline decltype(
auto)
1241 return ReturnType( (*lhs).rows() );
1261template<
typename MT1
1267inline decltype(
auto)
1282 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1317template<
typename MT1
1319inline decltype(
auto)
1324 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1328 return dmattdmatschur( *lhs, *rhs );
1346template<
typename MT1
1356inline const DMatTDMatSchurExpr<MT1,MT2>
1357 tdmatdmatschur(
const DenseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,false>& rhs )
1383template<
typename MT1
1393inline decltype(
auto)
1401 return (*lhs) %
trans( *rhs );
1420template<
typename MT1
1429inline decltype(
auto)
1437 return trans( *lhs ) % (*rhs);
1457template<
typename MT1
1461inline decltype(
auto)
1476 return ReturnType( (*lhs).rows() );
1496template<
typename MT1
1502inline decltype(
auto)
1517 return ReturnType( (*lhs).rows(), (*lhs).columns() );
1552template<
typename MT1
1554inline decltype(
auto)
1559 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() ) {
1563 return tdmatdmatschur( *lhs, *rhs );
1578template<
typename MT1,
typename MT2 >
1579struct IsAligned< DMatTDMatSchurExpr<MT1,MT2> >
1580 :
public BoolConstant< IsAligned_v<MT1> && IsAligned_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.
Constraint on the data type.
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 IsCommutative type trait.
Header file for the IsExpression type trait class.
Header file for the IsLower type trait.
Header file for the IsOperation type trait class.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsTemporary type trait class.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Constraints on the storage order of matrix types.
Header file for the Schur product trait.
Constraint on the data type.
Expression object for dense matrix-transpose dense matrix Schur product.
Definition DMatTDMatSchurExpr.h:105
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition DMatTDMatSchurExpr.h:323
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition DMatTDMatSchurExpr.h:217
DMatTDMatSchurExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatTDMatSchurExpr class.
Definition DMatTDMatSchurExpr.h:201
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition DMatTDMatSchurExpr.h:313
DMatTDMatSchurExpr< MT1, MT2 > This
Type of this DMatTDMatSchurExpr instance.
Definition DMatTDMatSchurExpr.h:164
const ResultType CompositeType
Data type for composite expression templates.
Definition DMatTDMatSchurExpr.h:178
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:110
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:113
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition DMatTDMatSchurExpr.h:258
RightOperand rightOperand() const noexcept
Returns the right-hand side transpose dense matrix operand.
Definition DMatTDMatSchurExpr.h:278
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition DMatTDMatSchurExpr.h:268
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition DMatTDMatSchurExpr.h:123
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition DMatTDMatSchurExpr.h:126
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the Schur product expression.
Definition DMatTDMatSchurExpr.h:137
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition DMatTDMatSchurExpr.h:232
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:112
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:108
SchurTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:169
LeftOperand lhs_
Left-hand side dense matrix of the Schur product expression.
Definition DMatTDMatSchurExpr.h:331
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition DMatTDMatSchurExpr.h:192
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:175
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:109
SchurExpr< DenseMatrix< This, false > > BaseType
Base type of this DMatTDMatSchurExpr instance.
Definition DMatTDMatSchurExpr.h:167
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:184
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition DMatTDMatSchurExpr.h:248
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition DMatTDMatSchurExpr.h:171
RightOperand rhs_
Right-hand side dense matrix of the Schur product expression.
Definition DMatTDMatSchurExpr.h:332
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:181
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition DMatTDMatSchurExpr.h:111
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition DMatTDMatSchurExpr.h:170
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition DMatTDMatSchurExpr.h:290
ElementType_t< ResultType > ElementType
Resulting element type.
Definition DMatTDMatSchurExpr.h:172
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition DMatTDMatSchurExpr.h:303
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition DMatTDMatSchurExpr.h:189
Base class for dense matrices.
Definition DenseMatrix.h:82
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 SchurExpr 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) 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_IDENTITY_MATRIX_TYPE(T)
Constraint on the data type.
Definition Identity.h:60
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_SCHUREXPR(T1, T2)
Constraint on the data type.
Definition SchurExpr.h:103
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition ColumnMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ZERO_TYPE(T)
Constraint on the data type.
Definition Zero.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition StorageOrder.h:63
typename SchurTrait< T1, T2 >::Type SchurTrait_t
Auxiliary alias declaration for the SchurTrait class template.
Definition SchurTrait.h:137
constexpr bool RequiresEvaluation_v
Auxiliary variable template for the RequiresEvaluation type trait.
Definition RequiresEvaluation.h:91
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.
Definition IsStrictlyUpper.h:173
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
constexpr bool IsUniUpper_v
Auxiliary variable template for the IsUniUpper type trait.
Definition IsUniUpper.h:173
constexpr bool IsStrictlyLower_v
Auxiliary variable template for the IsStrictlyLower type trait.
Definition IsStrictlyLower.h:173
constexpr bool IsUpper_v
Auxiliary variable template for the IsUpper type trait.
Definition IsUpper.h:175
constexpr bool IsCommutative_v
Auxiliary variable template for the IsCommutative type trait.
Definition IsCommutative.h:117
constexpr bool IsOperation_v
Auxiliary variable template for the IsOperation type trait.
Definition IsOperation.h:89
constexpr bool IsTemporary_v
Auxiliary variable template for the IsTemporary type trait.
Definition IsTemporary.h:88
constexpr bool IsLower_v
Auxiliary variable template for the IsLower type trait.
Definition IsLower.h:175
constexpr bool IsUniLower_v
Auxiliary variable template for the IsUniLower type trait.
Definition IsUniLower.h:173
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 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 all forward declarations for sparse vectors and matrices.
Header file for the serial shim.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all Schur product expression templates.
Definition SchurExpr.h:68
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.