35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTDMATADDEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATTDMATADDEXPR_H_
104 template<
typename MT1
144 template<
typename MT >
147 enum { value = useAssign };
160 template<
typename MT >
161 struct UseSMPAssign {
162 enum { value = ( !MT1::smpAssignable || !MT2::smpAssignable ) && useAssign };
190 enum { vectorizable = 0 };
193 enum { smpAssignable = MT1::smpAssignable && MT2::smpAssignable };
233 inline ReturnType
at(
size_t i,
size_t j )
const {
234 if( i >=
lhs_.rows() ) {
237 if( j >=
lhs_.columns() ) {
260 return lhs_.columns();
290 template<
typename T >
303 template<
typename T >
305 return (
lhs_.isAliased( alias ) ||
rhs_.isAliased( alias ) );
315 return lhs_.isAligned() &&
rhs_.isAligned();
325 return lhs_.canSMPAssign() ||
rhs_.canSMPAssign() ||
326 (
rows() > SMP_DMATTDMATADD_THRESHOLD );
350 template<
typename MT
360 const size_t m( rhs.
rows() );
361 const size_t n( rhs.
columns() );
362 const size_t block( BLOCK_SIZE );
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);
393 template<
typename MT
404 addAssign( ~lhs, rhs.
rhs_ );
406 else if( !IsExpression<MT2>::value &&
isSame( ~lhs, rhs.
rhs_ ) ) {
407 addAssign( ~lhs, rhs.
lhs_ );
410 assign ( ~lhs, rhs.
lhs_ );
411 addAssign( ~lhs, rhs.
rhs_ );
429 template<
typename MT
431 friend inline void assign( SparseMatrix<MT,SO2>& lhs,
const DMatTDMatAddExpr& rhs )
435 typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
447 const TmpType tmp(
serial( rhs ) );
467 template<
typename MT
469 friend inline typename DisableIf< UseAssign<MT> >::Type
477 const size_t m( rhs.rows() );
478 const size_t n( rhs.columns() );
479 const size_t block( BLOCK_SIZE );
481 for(
size_t ii=0UL; ii<m; ii+=block ) {
482 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
483 for(
size_t jj=0UL; jj<n; jj+=block ) {
484 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
485 for(
size_t i=ii; i<iend; ++i ) {
486 for(
size_t j=jj; j<jend; ++j ) {
487 (~lhs)(i,j) += rhs.lhs_(i,j) + rhs.rhs_(i,j);
510 template<
typename MT
512 friend inline typename EnableIf< UseAssign<MT> >::Type
520 addAssign( ~lhs, rhs.lhs_ );
521 addAssign( ~lhs, rhs.rhs_ );
544 template<
typename MT
546 friend inline typename DisableIf< UseAssign<MT> >::Type
554 const size_t m( rhs.rows() );
555 const size_t n( rhs.columns() );
556 const size_t block( BLOCK_SIZE );
558 for(
size_t ii=0UL; ii<m; ii+=block ) {
559 const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
560 for(
size_t jj=0UL; jj<n; jj+=block ) {
561 const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
562 for(
size_t i=ii; i<iend; ++i ) {
563 for(
size_t j=jj; j<jend; ++j ) {
564 (~lhs)(i,j) -= rhs.lhs_(i,j) + rhs.rhs_(i,j);
587 template<
typename MT
589 friend inline typename EnableIf< UseAssign<MT> >::Type
597 subAssign( ~lhs, rhs.lhs_ );
598 subAssign( ~lhs, rhs.rhs_ );
629 template<
typename MT
631 friend inline typename EnableIf< UseSMPAssign<MT> >::Type
639 if( !IsExpression<MT1>::value &&
isSame( ~lhs, rhs.lhs_ ) ) {
642 else if( !IsExpression<MT2>::value &&
isSame( ~lhs, rhs.rhs_ ) ) {
667 template<
typename MT
669 friend inline typename EnableIf< UseSMPAssign<MT> >::Type
674 typedef typename SelectType< SO2, OppositeType, ResultType >::Type TmpType;
686 const TmpType tmp( rhs );
707 template<
typename MT
709 friend inline typename EnableIf< UseSMPAssign<MT> >::Type
742 template<
typename MT
744 friend inline typename EnableIf< UseSMPAssign<MT> >::Type
820 template<
typename T1
822 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
823 ,
const DMatTDMatAddExpr<T1,T2> >::Type
866 template<
typename T1
868 inline typename EnableIf< And< Not< IsSymmetric<T1> >, Not< IsSymmetric<T2> > >
869 ,
const DMatTDMatAddExpr<T2,T1> >::Type
905 template<
typename T1
907 inline typename EnableIf< And< IsSymmetric<T1>, Not< IsSymmetric<T2> > >
908 ,
const typename AddExprTrait<T1,T2>::Type >::Type
909 operator+(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,true>& rhs )
917 return trans( ~lhs ) + ~rhs;
937 template<
typename T1
939 inline typename EnableIf< IsSymmetric<T2>
940 ,
const typename AddExprTrait<T1,T2>::Type >::Type
941 operator+(
const DenseMatrix<T1,false>& lhs,
const DenseMatrix<T2,true>& rhs )
949 return (~lhs) +
trans( ~rhs );
969 template<
typename T1
971 inline typename EnableIf< And< Not< IsSymmetric<T1> >, IsSymmetric<T2> >
972 ,
const typename AddExprTrait<T2,T1>::Type >::Type
973 operator+(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,false>& rhs )
981 return trans( ~rhs ) + (~lhs);
1001 template<
typename T1
1003 inline typename EnableIf< IsSymmetric<T1>
1004 ,
const typename AddExprTrait<T2,T1>::Type >::Type
1005 operator+(
const DenseMatrix<T1,true>& lhs,
const DenseMatrix<T2,false>& rhs )
1013 return (~rhs) +
trans( ~lhs );
1029 template<
typename MT1,
typename MT2 >
1031 :
public Max< Rows<MT1>, Rows<MT2> >
1047 template<
typename MT1,
typename MT2 >
1049 :
public Max< Columns<MT1>, Columns<MT2> >
1065 template<
typename MT1,
typename MT2 >
1067 :
public IsTrue< And< IsAligned<MT1>, IsAligned<MT2> >::value >
1083 template<
typename MT1,
typename MT2 >
1085 :
public IsTrue< IsSymmetric<MT1>::value && IsSymmetric<MT2>::value >
1101 template<
typename MT1,
typename MT2 >
1103 :
public IsTrue< IsHermitian<MT1>::value && IsHermitian<MT2>::value >
1119 template<
typename MT1,
typename MT2 >
1121 :
public IsTrue< And< IsLower<MT1>, IsLower<MT2> >::value >
1137 template<
typename MT1,
typename MT2 >
1139 :
public IsTrue< Or< And< IsUniLower<MT1>, IsStrictlyLower<MT2> >
1140 , And< IsUniLower<MT2>, IsStrictlyLower<MT1> > >::value >
1156 template<
typename MT1,
typename MT2 >
1158 :
public IsTrue< And< IsStrictlyLower<MT1>, IsStrictlyLower<MT2> >::value >
1174 template<
typename MT1,
typename MT2 >
1176 :
public IsTrue< And< IsUpper<MT1>, IsUpper<MT2> >::value >
1192 template<
typename MT1,
typename MT2 >
1194 :
public IsTrue< Or< And< IsUniUpper<MT1>, IsStrictlyUpper<MT2> >
1195 , And< IsUniUpper<MT2>, IsStrictlyUpper<MT1> > >::value >
1211 template<
typename MT1,
typename MT2 >
1213 :
public IsTrue< And< IsStrictlyUpper<MT1>, IsStrictlyUpper<MT2> >::value >
1229 template<
typename MT1,
typename MT2,
bool AF >
1234 typedef typename AddExprTrait< typename SubmatrixExprTrait<const MT1,AF>::Type
1235 ,
typename SubmatrixExprTrait<const MT2,AF>::Type >::Type Type;
1244 template<
typename MT1,
typename MT2 >
1249 typedef typename AddExprTrait< typename RowExprTrait<const MT1>::Type
1250 ,
typename RowExprTrait<const MT2>::Type >::Type Type;
1259 template<
typename MT1,
typename MT2 >
1264 typedef typename AddExprTrait< typename ColumnExprTrait<const MT1>::Type
1265 ,
typename ColumnExprTrait<const MT2>::Type >::Type Type;
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Header file for the Max class template.
Header file for kernel specific block sizes.
Evaluation of the return type of an addition expression.Via this type trait it is possible to evaluat...
Definition: AddExprTrait.h:104
Compile time check whether the given type is a temporary vector or matrix type.This type trait class ...
Definition: IsTemporary.h:87
Header file for the Rows type trait.
Header file for the IsUniUpper type trait.
Header file for basic type definitions.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
#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:79
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:647
Header file for the ColumnExprTrait class template.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatTDMatAddExpr.h:171
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:172
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
Header file for the And class template.
AddTrait< RT1, RT2 >::Type ResultType
Result type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:170
Header file for the AddExprTrait class template.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
Header file for the Computation base class.
Constraints on the storage order of matrix types.
bool canAlias(const T *alias) const
Returns whether the expression can alias with the given address alias.
Definition: DMatTDMatAddExpr.h:291
Header file for the RequiresEvaluation type trait.
Header file for the IsUniLower type trait.
MT1::CompositeType CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:116
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Constraint on the data type.
DMatTDMatAddExpr(const MT1 &lhs, const MT2 &rhs)
Constructor for the DMatTDMatAddExpr class.
Definition: DMatTDMatAddExpr.h:202
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
MT1::ReturnType RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:114
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DMatTDMatAddExpr.h:249
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the IsTemporary type trait class.
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatTDMatAddExpr.h:233
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatTDMatAddExpr.h:179
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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:79
const SelectType< returnExpr, ExprReturnType, ElementType >::Type ReturnType
Return type for expression template evaluations.
Definition: DMatTDMatAddExpr.h:176
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Header file for the Not class template.
Base class for all matrix/matrix addition expression templates.The MatMatAddExpr class serves as a ta...
Definition: MatMatAddExpr.h:65
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
AddExprTrait< RN1, RN2 >::Type ExprReturnType
Expression return type for the subscript operator.
Definition: DMatTDMatAddExpr.h:130
#define BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:78
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DMatTDMatAddExpr.h:259
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATADDEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatAddExpr.h:165
Header file for the SelectType class template.
Header file for the RowExprTrait class template.
Header file for all forward declarations for expression class templates.
bool isAliased(const T *alias) const
Returns whether the expression is aliased with the given address alias.
Definition: DMatTDMatAddExpr.h:304
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
DMatTDMatAddExpr< MT1, MT2 > This
Type of this DMatTDMatAdd instance.
Definition: DMatTDMatAddExpr.h:169
Header file for the serial shim.
MT2::ResultType RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:113
EnableIf< IsDenseMatrix< MT1 > >::Type 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:160
Header file for the SubmatrixExprTrait class template.
SelectType< IsExpression< MT2 >::value, const MT2, const MT2 & >::Type RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:185
#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:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
LeftOperand lhs_
Left-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:332
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:138
EnableIf< IsDenseMatrix< MT1 > >::Type 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:98
Header file for the addition trait.
ResultType::ElementType ElementType
Resulting element type.
Definition: DMatTDMatAddExpr.h:173
RightOperand rhs_
Right-hand side dense matrix of the addition expression.
Definition: DMatTDMatAddExpr.h:333
RightOperand rightOperand() const
Returns the right-hand side transpose dense matrix operand.
Definition: DMatTDMatAddExpr.h:279
LeftOperand leftOperand() const
Returns the left-hand side dense matrix operand.
Definition: DMatTDMatAddExpr.h:269
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Constraints on the storage order of matrix types.
MT2::ReturnType RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:115
Header file for the MatMatAddExpr base class.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
#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:122
SelectType< IsExpression< MT1 >::value, const MT1, const MT1 & >::Type LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:182
MT1::ResultType RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:112
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatTDMatAddExpr.h:218
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:59
EnableIf< IsDenseMatrix< MT1 > >::Type 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:129
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool isAligned() const
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatTDMatAddExpr.h:314
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
Header file for the IsUpper type trait.
Header file for exception macros.
MT2::CompositeType CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatTDMatAddExpr.h:117
Header file for the IsHermitian type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
bool canSMPAssign() const
Returns whether the expression can be used in SMP assignments.
Definition: DMatTDMatAddExpr.h:324
Compile time check whether the given type is an expression template.This type trait class tests wheth...
Definition: IsExpression.h:87
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
Expression object for dense matrix-transpose dense matrix additions.The DMatTDMatAddExpr class repres...
Definition: DMatTDMatAddExpr.h:106