35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATREDUCEEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DMATREDUCEEXPR_H_ 102 template<
typename MT
125 template<
typename MT
128 :
public MatReduceExpr< DenseVector< DMatReduceExpr<MT,OP,columnwise>, true >, columnwise >
145 template<
typename VT >
146 static constexpr
bool UseSMPAssign_v = ( !MT::smpAssignable && RequiresEvaluation_v<MT> );
170 static constexpr
bool simdEnabled =
false;
173 static constexpr
bool smpAssignable = MT::smpAssignable;
208 if( index >= dm_.columns() ) {
211 return (*
this)[index];
220 inline size_t size() const noexcept {
221 return dm_.columns();
251 template<
typename T >
252 inline bool canAlias(
const T* alias )
const noexcept {
253 return ( dm_.isAliased( alias ) );
263 template<
typename T >
264 inline bool isAliased(
const T* alias )
const noexcept {
265 return ( dm_.isAliased( alias ) );
285 return dm_.canSMPAssign() || (
size() > SMP_DMATREDUCE_THRESHOLD );
307 template<
typename VT1 >
314 const size_t M( rhs.dm_.rows() );
324 for(
size_t i=1UL; i<M; ++i ) {
343 template<
typename VT1 >
354 const ResultType tmp(
serial( rhs ) );
373 template<
typename VT1 >
374 friend inline void addAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
380 if( rhs.dm_.rows() == 0UL ) {
383 else if( IsSame_v<OP,Add> ) {
384 CT tmp(
serial( rhs.dm_ ) );
385 const size_t M( tmp.rows() );
386 for(
size_t i=0UL; i<M; ++i ) {
391 const ResultType tmp(
serial( rhs ) );
392 addAssign( ~lhs, tmp );
411 template<
typename VT1 >
412 friend inline void addAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
422 const ResultType tmp(
serial( rhs ) );
423 addAssign( ~lhs, tmp );
441 template<
typename VT1 >
442 friend inline void subAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
448 if( rhs.dm_.rows() == 0UL ) {
451 else if( IsSame_v<OP,Add> ) {
452 CT tmp(
serial( rhs.dm_ ) );
453 const size_t M( tmp.rows() );
454 for(
size_t i=0UL; i<M; ++i ) {
459 const ResultType tmp(
serial( rhs ) );
460 subAssign( ~lhs, tmp );
479 template<
typename VT1 >
480 friend inline void subAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
490 const ResultType tmp(
serial( rhs ) );
491 subAssign( ~lhs, tmp );
509 template<
typename VT1 >
510 friend inline void multAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
516 if( rhs.dm_.rows() == 0UL ) {
519 else if( IsSame_v<OP,Mult> ) {
520 CT tmp(
serial( rhs.dm_ ) );
521 const size_t M( tmp.rows() );
522 for(
size_t i=0UL; i<M; ++i ) {
527 const ResultType tmp(
serial( rhs ) );
528 multAssign( ~lhs, tmp );
547 template<
typename VT1 >
548 friend inline void multAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
558 const ResultType tmp(
serial( rhs ) );
559 multAssign( ~lhs, tmp );
577 template<
typename VT1 >
578 friend inline void divAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
588 const ResultType tmp(
serial( rhs ) );
589 divAssign( ~lhs, tmp );
608 template<
typename VT1 >
609 friend inline auto smpAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
610 -> EnableIf_t< UseSMPAssign_v<VT1> >
616 const RT tmp( rhs.dm_ );
617 smpAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
637 template<
typename VT1 >
638 friend inline auto smpAddAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
639 -> EnableIf_t< UseSMPAssign_v<VT1> >
645 const RT tmp( rhs.dm_ );
646 smpAddAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
666 template<
typename VT1 >
667 friend inline auto smpSubAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
668 -> EnableIf_t< UseSMPAssign_v<VT1> >
674 const RT tmp( rhs.dm_ );
675 smpSubAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
695 template<
typename VT1 >
696 friend inline auto smpMultAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
697 -> EnableIf_t< UseSMPAssign_v<VT1> >
703 const RT tmp( rhs.dm_ );
724 template<
typename VT1 >
725 friend inline auto smpDivAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
726 -> EnableIf_t< UseSMPAssign_v<VT1> >
732 const RT tmp( rhs.dm_ );
733 smpDivAssign( ~lhs, reduce<columnwise>( tmp, rhs.op_ ) );
763 template<
typename MT
766 :
public MatReduceExpr< DenseVector< DMatReduceExpr<MT,OP,rowwise>, false >, rowwise >
783 static constexpr
bool useAssign = RequiresEvaluation_v<MT>;
786 template<
typename VT >
788 static constexpr
bool UseAssign_v = useAssign;
799 template<
typename VT >
800 static constexpr
bool UseSMPAssign_v = ( !MT::smpAssignable && useAssign );
900 return ConstIterator( index_++ );
921 return ConstIterator( index_-- );
942 return index_ == rhs.index_;
953 return index_ != rhs.index_;
963 inline bool operator<(
const ConstIterator& rhs )
const {
964 return index_ < rhs.index_;
974 inline bool operator>(
const ConstIterator& rhs )
const {
975 return index_ > rhs.index_;
986 return index_ <= rhs.index_;
997 return index_ >= rhs.index_;
1008 return index_ - rhs.index_;
1019 friend inline const ConstIterator
operator+(
const ConstIterator& it,
size_t inc ) {
1020 return ConstIterator( it.index_ + inc );
1031 friend inline const ConstIterator
operator+(
size_t inc,
const ConstIterator& it ) {
1032 return ConstIterator( it.index_ + inc );
1043 friend inline const ConstIterator
operator-(
const ConstIterator& it,
size_t dec ) {
1044 return ConstIterator( it.index_ - dec );
1059 static constexpr
bool simdEnabled =
false;
1062 static constexpr
bool smpAssignable = MT::smpAssignable;
1097 if( index >= dm_.rows() ) {
1100 return (*
this)[index];
1110 return ConstIterator( dm_, 0UL, op_ );
1119 inline ConstIterator
end()
const {
1120 return ConstIterator( dm_,
size(), op_ );
1129 inline size_t size() const noexcept {
1160 template<
typename T >
1161 inline bool canAlias(
const T* alias )
const noexcept {
1162 return ( dm_.isAliased( alias ) );
1172 template<
typename T >
1174 return ( dm_.isAliased( alias ) );
1194 return dm_.canSMPAssign() || (
size() > SMP_DMATREDUCE_THRESHOLD );
1218 template<
typename VT1 >
1227 assign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1246 template<
typename VT1 >
1254 const RT tmp(
serial( rhs.dm_ ) );
1255 addAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1275 template<
typename VT1 >
1276 friend inline auto subAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1277 -> EnableIf_t< UseAssign_v<VT1> >
1283 const RT tmp(
serial( rhs.dm_ ) );
1284 subAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1304 template<
typename VT1 >
1305 friend inline auto multAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1306 -> EnableIf_t< UseAssign_v<VT1> >
1312 const RT tmp(
serial( rhs.dm_ ) );
1313 multAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1332 template<
typename VT1 >
1333 friend inline auto divAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1334 -> EnableIf_t< UseAssign_v<VT1> >
1340 const RT tmp(
serial( rhs.dm_ ) );
1341 divAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1360 template<
typename VT1 >
1361 friend inline auto smpAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1362 -> EnableIf_t< UseSMPAssign_v<VT1> >
1368 const RT tmp( rhs.dm_ );
1369 smpAssign( ~lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1389 template<
typename VT1 >
1390 friend inline auto smpAddAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1391 -> EnableIf_t< UseSMPAssign_v<VT1> >
1397 const RT tmp( rhs.dm_ );
1418 template<
typename VT1 >
1419 friend inline auto smpSubAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1420 -> EnableIf_t< UseSMPAssign_v<VT1> >
1426 const RT tmp( rhs.dm_ );
1447 template<
typename VT1 >
1448 friend inline auto smpMultAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1449 -> EnableIf_t< UseSMPAssign_v<VT1> >
1455 const RT tmp( rhs.dm_ );
1476 template<
typename VT1 >
1477 friend inline auto smpDivAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1478 -> EnableIf_t< UseSMPAssign_v<VT1> >
1484 const RT tmp( rhs.dm_ );
1513 template<
typename MT
1515 struct DMatReduceExprHelper
1519 using CT = RemoveReference_t< CompositeType_t<MT> >;
1522 using ET = ElementType_t<CT>;
1526 static constexpr
bool value =
1527 ( CT::simdEnabled &&
1528 If_t< HasSIMDEnabled_v<OP>, GetSIMDEnabled<OP,ET,ET>, HasLoad<OP> >::value );
1556 template<
typename MT
1558 inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, OP op )
1559 -> DisableIf_t< DMatReduceExprHelper<MT,OP>::value, ElementType_t<MT> >
1561 using CT = CompositeType_t<MT>;
1562 using ET = ElementType_t<MT>;
1564 const size_t M( (~dm).
rows() );
1565 const size_t N( (~dm).
columns() );
1567 if( M == 0UL || N == 0UL )
return ET{};
1568 if( M == 1UL && N == 1UL )
return (~dm)(0UL,0UL);
1578 redux0 = tmp(0UL,0UL);
1580 for(
size_t j=1UL; j<N; ++j ) {
1581 redux0 = op( redux0, tmp(0UL,j) );
1587 for( ; (i+2UL) <= M; i+=2UL )
1589 ET redux1( tmp(i ,0UL) );
1590 ET redux2( tmp(i+1UL,0UL) );
1592 for(
size_t j=1UL; j<N; ++j ) {
1593 redux1 = op( redux1, tmp(i ,j) );
1594 redux2 = op( redux2, tmp(i+1UL,j) );
1597 redux1 = op( redux1, redux2 );
1598 redux0 = op( redux0, redux1 );
1603 ET redux1( tmp(i,0UL) );
1605 for(
size_t j=1UL; j<N; ++j ) {
1606 redux1 = op( redux1, tmp(i,j) );
1609 redux0 = op( redux0, redux1 );
1631 template<
typename MT
1633 inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, OP op )
1634 -> EnableIf_t< DMatReduceExprHelper<MT,OP>::value, ElementType_t<MT> >
1636 using CT = CompositeType_t<MT>;
1637 using ET = ElementType_t<MT>;
1639 const size_t M( (~dm).
rows() );
1640 const size_t N( (~dm).
columns() );
1642 if( M == 0UL || N == 0UL )
return ET{};
1651 alignas( AlignmentOf_v<ET> ) ET array1[SIMDSIZE];
1652 alignas( AlignmentOf_v<ET> ) ET array2[SIMDSIZE];
1653 alignas( AlignmentOf_v<ET> ) ET array3[SIMDSIZE];
1654 alignas( AlignmentOf_v<ET> ) ET array4[SIMDSIZE];
1660 const size_t jpos( N &
size_t(-SIMDSIZE) );
1663 SIMDTrait_t<ET> xmm1;
1666 xmm1 = tmp.load(0UL,0UL);
1667 size_t j( SIMDSIZE );
1669 for( ; j<jpos; j+=SIMDSIZE ) {
1670 xmm1 = op( xmm1, tmp.load(0UL,j) );
1678 array1[0UL] = op( array1[0UL], tmp(0UL,j) );
1681 xmm1 =
loada( array1 );
1687 for( ; (i+4UL) <= M; i+=4UL )
1689 xmm1 = op( xmm1, tmp.load(i,0UL) );
1690 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1691 SIMDTrait_t<ET> xmm3( tmp.load(i+2UL,0UL) );
1692 SIMDTrait_t<ET> xmm4( tmp.load(i+3UL,0UL) );
1693 size_t j( SIMDSIZE );
1695 for( ; j<jpos; j+=SIMDSIZE ) {
1696 xmm1 = op( xmm1, tmp.load(i ,j) );
1697 xmm2 = op( xmm2, tmp.load(i+1UL,j) );
1698 xmm3 = op( xmm3, tmp.load(i+2UL,j) );
1699 xmm4 = op( xmm4, tmp.load(i+3UL,j) );
1710 array1[0UL] = op( array1[0UL], tmp(i ,j) );
1711 array2[0UL] = op( array2[0UL], tmp(i+1UL,j) );
1712 array3[0UL] = op( array3[0UL], tmp(i+2UL,j) );
1713 array4[0UL] = op( array4[0UL], tmp(i+3UL,j) );
1716 xmm1 =
loada( array1 );
1717 xmm2 =
loada( array2 );
1718 xmm3 =
loada( array3 );
1719 xmm4 =
loada( array4 );
1722 xmm1 = op( xmm1, xmm2 );
1723 xmm3 = op( xmm3, xmm4 );
1724 xmm1 = op( xmm1, xmm3 );
1729 xmm1 = op( xmm1, tmp.load(i,0UL) );
1730 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1731 size_t j( SIMDSIZE );
1733 for( ; j<jpos; j+=SIMDSIZE ) {
1734 xmm1 = op( xmm1, tmp.load(i ,j) );
1735 xmm2 = op( xmm2, tmp.load(i+1UL,j) );
1744 array1[0UL] = op( array1[0UL], tmp(i ,j) );
1745 array2[0UL] = op( array2[0UL], tmp(i+1UL,j) );
1748 xmm1 =
loada( array1 );
1749 xmm2 =
loada( array2 );
1752 xmm1 = op( xmm1, xmm2 );
1759 xmm1 = op( xmm1, tmp.load(i,0UL) );
1760 size_t j( SIMDSIZE );
1762 for( ; j<jpos; j+=SIMDSIZE ) {
1763 xmm1 = op( xmm1, tmp.load(i,j) );
1771 array1[0] = op( array1[0], tmp(i,j) );
1774 xmm1 =
loada( array1 );
1778 redux =
reduce( xmm1, op );
1783 redux = tmp(0UL,0UL);
1784 for(
size_t j=1UL; j<N; ++j ) {
1785 redux = op( redux, tmp(0UL,j) );
1788 for(
size_t i=1UL; i<M; ++i ) {
1789 for(
size_t j=0UL; j<N; ++j ) {
1790 redux = op( redux, tmp(i,j) );
1813 template<
typename MT >
1814 inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Add )
1815 -> EnableIf_t< DMatReduceExprHelper<MT,Add>::value, ElementType_t<MT> >
1817 using CT = CompositeType_t<MT>;
1818 using ET = ElementType_t<MT>;
1820 const size_t M( (~dm).
rows() );
1821 const size_t N( (~dm).
columns() );
1823 if( M == 0UL || N == 0UL )
return ET{};
1830 constexpr
bool remainder( !usePadding || !
IsPadded_v< RemoveReference_t<CT> > );
1835 if( !remainder || N >= SIMDSIZE )
1837 const size_t jpos( ( remainder )?( N &
size_t(-SIMDSIZE) ):( N ) );
1840 SIMDTrait_t<ET> xmm1;
1843 for( ; (i+4UL) <= M; i+=4UL )
1845 xmm1 += tmp.load(i,0UL);
1846 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1847 SIMDTrait_t<ET> xmm3( tmp.load(i+2UL,0UL) );
1848 SIMDTrait_t<ET> xmm4( tmp.load(i+3UL,0UL) );
1849 size_t j( SIMDSIZE );
1851 for( ; j<jpos; j+=SIMDSIZE ) {
1852 xmm1 += tmp.load(i ,j);
1853 xmm2 += tmp.load(i+1UL,j);
1854 xmm3 += tmp.load(i+2UL,j);
1855 xmm4 += tmp.load(i+3UL,j);
1857 for( ; remainder && j<N; ++j ) {
1859 redux += tmp(i+1UL,j);
1860 redux += tmp(i+2UL,j);
1861 redux += tmp(i+3UL,j);
1871 xmm1 += tmp.load(i,0UL);
1872 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1873 size_t j( SIMDSIZE );
1875 for( ; j<jpos; j+=SIMDSIZE ) {
1876 xmm1 += tmp.load(i ,j);
1877 xmm2 += tmp.load(i+1UL,j);
1879 for( ; remainder && j<N; ++j ) {
1881 redux += tmp(i+1UL,j);
1891 xmm1 += tmp.load(i,0UL);
1892 size_t j( SIMDSIZE );
1894 for( ; j<jpos; j+=SIMDSIZE ) {
1895 xmm1 += tmp.load(i,j);
1897 for( ; remainder && j<N; ++j ) {
1902 redux +=
sum( xmm1 );
1906 for(
size_t i=0UL; i<M; ++i ) {
1907 for(
size_t j=0UL; j<N; ++j ) {
1931 template<
typename MT >
1932 inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Min )
1933 -> EnableIf_t< IsUniform_v<MT>, ElementType_t<MT> >
1935 return (~dm)(0UL,0UL);
1952 template<
typename MT >
1953 inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Max )
1954 -> EnableIf_t< IsUniform_v<MT>, ElementType_t<MT> >
1956 return (~dm)(0UL,0UL);
1975 template<
typename MT
1977 inline ElementType_t<MT> dmatreduce(
const DenseMatrix<MT,true>& dm, OP op )
1979 return dmatreduce(
trans( ~dm ), op );
2014 template<
typename MT
2021 return dmatreduce( ~dm, op );
2038 inline const DMatReduceExpr<MT,OP,RF> reduce_backend(
const DenseMatrix<MT,false>& dm, OP op )
2040 using ReturnType =
const DMatReduceExpr<MT,OP,RF>;
2041 return ReturnType( ~dm, op );
2059 inline decltype(
auto) reduce_backend( const DenseMatrix<MT,true>& dm, OP op )
2061 return trans( reduce<1UL-RF>(
trans( ~dm ), op ) );
2123 return reduce_backend<RF>( ~dm, op );
2145 template<
typename MT
2196 return reduce<RF>( ~dm,
Add() );
2218 template<
typename MT
2269 return reduce<RF>( ~dm,
Mult() );
2292 template<
typename MT
2340 return reduce<RF>( ~dm,
Min() );
2363 template<
typename MT
2411 return reduce<RF>( ~dm,
Max() );
ElementType_t< MT > ET
Element type of the dense matrix expression.
Definition: DMatReduceExpr.h:134
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the blaze::checked and blaze::unchecked instances.
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:974
ConstIterator(Operand dm, size_t index, OP op)
Constructor for the ConstIterator class.
Definition: DMatReduceExpr.h:852
Header file for the HasLoad type trait.
DMatReduceExpr(const MT &dm, OP op) noexcept
Constructor for the DMatReduceExpr class.
Definition: DMatReduceExpr.h:182
Header file for basic type definitions.
ElementType * PointerType
Pointer return type.
Definition: DMatReduceExpr.h:833
Header file for the Add functor.
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
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatReduceExpr.h:1183
Header file for the MatReduceExpr base class.
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: DMatReduceExpr.h:811
Header file for the serial shim.
Base class for all matrix reduction expression templates.The MatReduceExpr class serves as a tag for ...
Definition: MatReduceExpr.h:67
ResultType_t< MT > RT
Result type of the dense matrix expression.
Definition: DMatReduceExpr.h:133
#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
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatReduceExpr.h:264
Header file for the IsSame and IsStrictlySame type traits.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatReduceExpr.h:899
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatReduceExpr.h:159
Expression object for row-wise row-major dense matrix reduction operations.This specialization of the...
Definition: DMatReduceExpr.h:765
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatReduceExpr.h:877
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
decltype(auto) prod(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of multiplication.
Definition: DMatReduceExpr.h:2220
Header file for the DenseVector base class.
Generic wrapper for the addition operator.
Definition: Add.h:83
PointerType pointer
Pointer return type.
Definition: DMatReduceExpr.h:840
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DMatReduceExpr.h:1096
Header file for the Computation base class.
ResultType_t< MT > RT
Result type of the dense matrix expression.
Definition: DMatReduceExpr.h:771
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatReduceExpr.h:284
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
OP Operation
Data type of the custom unary operation.
Definition: DMatReduceExpr.h:165
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatReduceExpr.h:920
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatReduceExpr.h:810
Header file for the reduce trait.
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatReduceExpr.h:1043
DMatReduceExpr(const MT &dm, OP op) noexcept
Constructor for the DMatReduceExpr class.
Definition: DMatReduceExpr.h:1071
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Expression object for column-wise row-major dense matrix reduction operations.This specialization of ...
Definition: DMatReduceExpr.h:127
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
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:220
size_t index_
Index to the current matrix row.
Definition: DMatReduceExpr.h:1051
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatReduceExpr.h:812
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatReduceExpr.h:1007
Constraint on the transpose flag of vector types.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:963
Base template for row-major dense matrix partial reduction operations.The DMatReduceExpr class repres...
Definition: DMatReduceExpr.h:105
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatReduceExpr.h:1173
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
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DMatReduceExpr.h:194
decltype(auto) reduce(const DenseMatrix< MT, SO > &dm, OP op)
Performs a custom reduction operation on the given dense matrix.
Definition: DMatReduceExpr.h:2017
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DMatReduceExpr.h:1109
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DMatReduceExpr.h:1083
decltype(auto) operator *(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9091
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatReduceExpr.h:909
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:941
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatReduceExpr.h:155
#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
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2147
Header file for the Mult functor.
Header file for the DenseMatrix base class.
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatReduceExpr.h:1129
Header file for all SIMD functionality.
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
Operation op_
The reduction operation.
Definition: DMatReduceExpr.h:1201
Operation operation() const
Returns a copy of the reduction operation.
Definition: DMatReduceExpr.h:1149
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:996
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
ReduceTrait_t< RT, OP, rowwise > ResultType
Result type for expression template evaluations.
Definition: DMatReduceExpr.h:808
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:985
Constraint on the data type.
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
Constraint on the data type.
ReferenceType reference
Reference return type.
Definition: DMatReduceExpr.h:841
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatReduceExpr.h:274
ReduceTrait_t< RT, OP, columnwise > ResultType
Result type for expression template evaluations.
Definition: DMatReduceExpr.h:154
If_t< useAssign, const ResultType, const DMatReduceExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatReduceExpr.h:815
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side dense matrix expression.
Definition: DMatReduceExpr.h:162
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DMatReduceExpr.h:207
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:952
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatReduceExpr.h:220
Header file for the IsSIMDEnabled type trait.
constexpr size_t columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:90
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatReduceExpr.h:888
#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
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.The ReduceTrait_t alias declaration pr...
Definition: ReduceTrait.h:173
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:1050
constexpr bool IsPadded_v
Auxiliary variable template for the IsPadded type trait.The IsPadded_v variable template provides a c...
Definition: IsPadded.h:134
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
Generic wrapper for the max() function.
Definition: Max.h:80
ElementType_t< MT > ET
Element type of the dense matrix expression.
Definition: DMatReduceExpr.h:772
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
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:291
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatReduceExpr.h:1031
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:1200
#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
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatReduceExpr.h:831
Header file for all forward declarations for expression class templates.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatReduceExpr.h:1161
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatReduceExpr.h:156
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Operation op_
The reduction operation.
Definition: DMatReduceExpr.h:292
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
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatReduceExpr.h:1139
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
Header file for the HasMember type traits.
#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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the RemoveReference type trait.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side dense matrix expression.
Definition: DMatReduceExpr.h:818
ValueType value_type
Type of the underlying elements.
Definition: DMatReduceExpr.h:839
Generic wrapper for the min() function.
Definition: Min.h:80
CompositeType_t< MT > CT
Composite type of the dense matrix expression.
Definition: DMatReduceExpr.h:135
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatReduceExpr.h:809
Header file for the Min functor.
IteratorCategory iterator_category
The iterator category.
Definition: DMatReduceExpr.h:838
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatReduceExpr.h:252
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type,...
Definition: DenseVector.h:61
OP op_
The reduction operation.
Definition: DMatReduceExpr.h:1052
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatReduceExpr.h:1193
Macro for CUDA compatibility.
constexpr size_t rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:70
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatReduceExpr.h:1019
Generic wrapper for the multiplication operator.
Definition: Mult.h:80
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatReduceExpr.h:158
ElementType ValueType
Type of the underlying elements.
Definition: DMatReduceExpr.h:832
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
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
ElementType & ReferenceType
Reference return type.
Definition: DMatReduceExpr.h:834
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
Header file for the Max functor.
Operation operation() const
Returns a copy of the reduction operation.
Definition: DMatReduceExpr.h:240
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: DMatReduceExpr.h:157
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatReduceExpr.h:865
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DMatReduceExpr.h:1119
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatReduceExpr.h:230
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,...
Definition: Assert.h:101
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition: DenseVector.h:191
OP Operation
Data type of the custom unary operation.
Definition: DMatReduceExpr.h:821
Header file for the reduction flags.
Constraint on the transpose flag of vector types.
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