35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATREDUCEEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATREDUCEEXPR_H_
130 :
public MatReduceExpr< DenseVector< DMatReduceExpr<MT,OP,columnwise>, true >, columnwise >
146 template<
typename VT >
147 static constexpr bool UseSMPAssign_v = ( !MT::smpAssignable && RequiresEvaluation_v<MT> );
175 static constexpr bool simdEnabled =
false;
178 static constexpr bool smpAssignable = MT::smpAssignable;
189 , op_( std::move(op) )
213 if( index >= dm_.columns() ) {
216 return (*
this)[index];
225 inline size_t size() const noexcept {
226 return dm_.columns();
256 template<
typename T >
257 inline bool canAlias(
const T* alias )
const noexcept {
258 return ( dm_.isAliased( alias ) );
268 template<
typename T >
269 inline bool isAliased(
const T* alias )
const noexcept {
270 return ( dm_.isAliased( alias ) );
290 return dm_.canSMPAssign() || (
size() > SMP_DMATREDUCE_THRESHOLD );
312 template<
typename VT1 >
319 const size_t M( rhs.dm_.rows() );
329 for(
size_t i=1UL; i<M; ++i ) {
348 template<
typename VT1 >
359 const ResultType tmp(
serial( rhs ) );
378 template<
typename VT1 >
379 friend inline void addAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
385 if( rhs.dm_.rows() == 0UL ) {
388 else if( IsSame_v<OP,Add> ) {
389 CT tmp(
serial( rhs.dm_ ) );
390 const size_t M( tmp.rows() );
391 for(
size_t i=0UL; i<M; ++i ) {
396 const ResultType tmp(
serial( rhs ) );
397 addAssign( *lhs, tmp );
416 template<
typename VT1 >
417 friend inline void addAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
427 const ResultType tmp(
serial( rhs ) );
428 addAssign( *lhs, tmp );
446 template<
typename VT1 >
447 friend inline void subAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
453 if( rhs.dm_.rows() == 0UL ) {
456 else if( IsSame_v<OP,Add> ) {
457 CT tmp(
serial( rhs.dm_ ) );
458 const size_t M( tmp.rows() );
459 for(
size_t i=0UL; i<M; ++i ) {
464 const ResultType tmp(
serial( rhs ) );
465 subAssign( *lhs, tmp );
484 template<
typename VT1 >
485 friend inline void subAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
495 const ResultType tmp(
serial( rhs ) );
496 subAssign( *lhs, tmp );
514 template<
typename VT1 >
515 friend inline void multAssign( DenseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
521 if( rhs.dm_.rows() == 0UL ) {
524 else if( IsSame_v<OP,Mult> ) {
525 CT tmp(
serial( rhs.dm_ ) );
526 const size_t M( tmp.rows() );
527 for(
size_t i=0UL; i<M; ++i ) {
532 const ResultType tmp(
serial( rhs ) );
533 multAssign( *lhs, tmp );
552 template<
typename VT1 >
553 friend inline void multAssign( SparseVector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
563 const ResultType tmp(
serial( rhs ) );
564 multAssign( *lhs, tmp );
582 template<
typename VT1 >
583 friend inline void divAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
593 const ResultType tmp(
serial( rhs ) );
594 divAssign( *lhs, tmp );
613 template<
typename VT1 >
614 friend inline auto smpAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
615 -> EnableIf_t< UseSMPAssign_v<VT1> >
621 const RT tmp( rhs.dm_ );
622 smpAssign( *lhs, reduce<columnwise>( tmp, rhs.op_ ) );
642 template<
typename VT1 >
643 friend inline auto smpAddAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
644 -> EnableIf_t< UseSMPAssign_v<VT1> >
650 const RT tmp( rhs.dm_ );
651 smpAddAssign( *lhs, reduce<columnwise>( tmp, rhs.op_ ) );
671 template<
typename VT1 >
672 friend inline auto smpSubAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
673 -> EnableIf_t< UseSMPAssign_v<VT1> >
679 const RT tmp( rhs.dm_ );
680 smpSubAssign( *lhs, reduce<columnwise>( tmp, rhs.op_ ) );
700 template<
typename VT1 >
701 friend inline auto smpMultAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
702 -> EnableIf_t< UseSMPAssign_v<VT1> >
708 const RT tmp( rhs.dm_ );
729 template<
typename VT1 >
730 friend inline auto smpDivAssign( Vector<VT1,true>& lhs,
const DMatReduceExpr& rhs )
731 -> EnableIf_t< UseSMPAssign_v<VT1> >
737 const RT tmp( rhs.dm_ );
738 smpDivAssign( *lhs, reduce<columnwise>( tmp, rhs.op_ ) );
771 :
public MatReduceExpr< DenseVector< DMatReduceExpr<MT,OP,rowwise>, false >, rowwise >
787 static constexpr bool useAssign = RequiresEvaluation_v<MT>;
791 template<
typename VT >
792 static constexpr bool UseAssign_v = useAssign;
803 template<
typename VT >
804 static constexpr bool UseSMPAssign_v = ( !MT::smpAssignable && useAssign );
863 , op_ ( std::move(op) )
908 return ConstIterator( index_++ );
929 return ConstIterator( index_-- );
950 return index_ == rhs.index_;
961 return index_ != rhs.index_;
971 inline bool operator<(
const ConstIterator& rhs )
const {
972 return index_ < rhs.index_;
982 inline bool operator>(
const ConstIterator& rhs )
const {
983 return index_ > rhs.index_;
994 return index_ <= rhs.index_;
1005 return index_ >= rhs.index_;
1016 return index_ - rhs.index_;
1027 friend inline const ConstIterator
operator+(
const ConstIterator& it,
size_t inc ) {
1028 return ConstIterator( it.index_ + inc );
1039 friend inline const ConstIterator
operator+(
size_t inc,
const ConstIterator& it ) {
1040 return ConstIterator( it.index_ + inc );
1051 friend inline const ConstIterator
operator-(
const ConstIterator& it,
size_t dec ) {
1052 return ConstIterator( it.index_ - dec );
1067 static constexpr bool simdEnabled =
false;
1070 static constexpr bool smpAssignable = MT::smpAssignable;
1081 , op_( std::move(op) )
1105 if( index >= dm_.rows() ) {
1108 return (*
this)[index];
1118 return ConstIterator( dm_, 0UL, op_ );
1127 inline ConstIterator
end()
const {
1128 return ConstIterator( dm_,
size(), op_ );
1137 inline size_t size() const noexcept {
1168 template<
typename T >
1169 inline bool canAlias(
const T* alias )
const noexcept {
1170 return ( dm_.isAliased( alias ) );
1180 template<
typename T >
1182 return ( dm_.isAliased( alias ) );
1202 return dm_.canSMPAssign() || (
size() > SMP_DMATREDUCE_THRESHOLD );
1226 template<
typename VT1 >
1235 assign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1254 template<
typename VT1 >
1262 const RT tmp(
serial( rhs.dm_ ) );
1263 addAssign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1283 template<
typename VT1 >
1284 friend inline auto subAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1285 -> EnableIf_t< UseAssign_v<VT1> >
1291 const RT tmp(
serial( rhs.dm_ ) );
1292 subAssign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1312 template<
typename VT1 >
1313 friend inline auto multAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1314 -> EnableIf_t< UseAssign_v<VT1> >
1320 const RT tmp(
serial( rhs.dm_ ) );
1321 multAssign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1340 template<
typename VT1 >
1341 friend inline auto divAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1342 -> EnableIf_t< UseAssign_v<VT1> >
1348 const RT tmp(
serial( rhs.dm_ ) );
1349 divAssign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1368 template<
typename VT1 >
1369 friend inline auto smpAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1370 -> EnableIf_t< UseSMPAssign_v<VT1> >
1376 const RT tmp( rhs.dm_ );
1377 smpAssign( *lhs, reduce<rowwise>( tmp, rhs.op_ ) );
1397 template<
typename VT1 >
1398 friend inline auto smpAddAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1399 -> EnableIf_t< UseSMPAssign_v<VT1> >
1405 const RT tmp( rhs.dm_ );
1426 template<
typename VT1 >
1427 friend inline auto smpSubAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1428 -> EnableIf_t< UseSMPAssign_v<VT1> >
1434 const RT tmp( rhs.dm_ );
1455 template<
typename VT1 >
1456 friend inline auto smpMultAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1457 -> EnableIf_t< UseSMPAssign_v<VT1> >
1463 const RT tmp( rhs.dm_ );
1484 template<
typename VT1 >
1485 friend inline auto smpDivAssign( Vector<VT1,false>& lhs,
const DMatReduceExpr& rhs )
1486 -> EnableIf_t< UseSMPAssign_v<VT1> >
1492 const RT tmp( rhs.dm_ );
1521template<
typename MT
1523struct DMatReduceExprHelper
1527 using CT = RemoveReference_t< CompositeType_t<MT> >;
1530 using ET = RemoveCV_t< ElementType_t<CT> >;
1534 static constexpr bool value =
1535 ( CT::simdEnabled &&
1536 If_t< HasSIMDEnabled_v<OP>, GetSIMDEnabled<OP,ET,ET>, HasLoad<OP> >::value );
1564template<
typename MT
1566inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, OP op )
1567 -> DisableIf_t< DMatReduceExprHelper<MT,OP>::value, RemoveCV_t< ReduceTrait_t<MT,OP> > >
1569 using CT = CompositeType_t<MT>;
1570 using RT = RemoveCV_t< ReduceTrait_t<MT,OP> >;
1572 const size_t M( (*dm).rows() );
1573 const size_t N( (*dm).columns() );
1575 if( M == 0UL || N == 0UL )
return RT{};
1576 if( M == 1UL && N == 1UL )
return (*dm)(0UL,0UL);
1586 redux0 = tmp(0UL,0UL);
1588 for(
size_t j=1UL; j<N; ++j ) {
1589 redux0 = op( redux0, tmp(0UL,j) );
1595 for( ; (i+2UL) <= M; i+=2UL )
1597 RT redux1( tmp(i ,0UL) );
1598 RT redux2( tmp(i+1UL,0UL) );
1600 for(
size_t j=1UL; j<N; ++j ) {
1601 redux1 = op( redux1, tmp(i ,j) );
1602 redux2 = op( redux2, tmp(i+1UL,j) );
1605 redux1 = op( redux1, redux2 );
1606 redux0 = op( redux0, redux1 );
1611 RT redux1( tmp(i,0UL) );
1613 for(
size_t j=1UL; j<N; ++j ) {
1614 redux1 = op( redux1, tmp(i,j) );
1617 redux0 = op( redux0, redux1 );
1639template<
typename MT
1641inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, OP op )
1642 -> EnableIf_t< DMatReduceExprHelper<MT,OP>::value, RemoveCV_t< ElementType_t<MT> > >
1644 using CT = CompositeType_t<MT>;
1645 using ET = RemoveCV_t< ElementType_t<MT> >;
1647 const size_t M( (*dm).rows() );
1648 const size_t N( (*dm).columns() );
1650 if( M == 0UL || N == 0UL )
return ET{};
1659 alignas( AlignmentOf_v<ET> ) ET array1[SIMDSIZE];
1660 alignas( AlignmentOf_v<ET> ) ET array2[SIMDSIZE];
1661 alignas( AlignmentOf_v<ET> ) ET array3[SIMDSIZE];
1662 alignas( AlignmentOf_v<ET> ) ET array4[SIMDSIZE];
1671 SIMDTrait_t<ET> xmm1;
1674 xmm1 = tmp.load(0UL,0UL);
1675 size_t j( SIMDSIZE );
1677 for( ; j<jpos; j+=SIMDSIZE ) {
1678 xmm1 = op( xmm1, tmp.load(0UL,j) );
1686 array1[0UL] = op( array1[0UL], tmp(0UL,j) );
1689 xmm1 =
loada( array1 );
1695 for( ; (i+4UL) <= M; i+=4UL )
1697 xmm1 = op( xmm1, tmp.load(i,0UL) );
1698 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1699 SIMDTrait_t<ET> xmm3( tmp.load(i+2UL,0UL) );
1700 SIMDTrait_t<ET> xmm4( tmp.load(i+3UL,0UL) );
1701 size_t j( SIMDSIZE );
1703 for( ; j<jpos; j+=SIMDSIZE ) {
1704 xmm1 = op( xmm1, tmp.load(i ,j) );
1705 xmm2 = op( xmm2, tmp.load(i+1UL,j) );
1706 xmm3 = op( xmm3, tmp.load(i+2UL,j) );
1707 xmm4 = op( xmm4, tmp.load(i+3UL,j) );
1718 array1[0UL] = op( array1[0UL], tmp(i ,j) );
1719 array2[0UL] = op( array2[0UL], tmp(i+1UL,j) );
1720 array3[0UL] = op( array3[0UL], tmp(i+2UL,j) );
1721 array4[0UL] = op( array4[0UL], tmp(i+3UL,j) );
1724 xmm1 =
loada( array1 );
1725 xmm2 =
loada( array2 );
1726 xmm3 =
loada( array3 );
1727 xmm4 =
loada( array4 );
1730 xmm1 = op( xmm1, xmm2 );
1731 xmm3 = op( xmm3, xmm4 );
1732 xmm1 = op( xmm1, xmm3 );
1737 xmm1 = op( xmm1, tmp.load(i,0UL) );
1738 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1739 size_t j( SIMDSIZE );
1741 for( ; j<jpos; j+=SIMDSIZE ) {
1742 xmm1 = op( xmm1, tmp.load(i ,j) );
1743 xmm2 = op( xmm2, tmp.load(i+1UL,j) );
1752 array1[0UL] = op( array1[0UL], tmp(i ,j) );
1753 array2[0UL] = op( array2[0UL], tmp(i+1UL,j) );
1756 xmm1 =
loada( array1 );
1757 xmm2 =
loada( array2 );
1760 xmm1 = op( xmm1, xmm2 );
1767 xmm1 = op( xmm1, tmp.load(i,0UL) );
1768 size_t j( SIMDSIZE );
1770 for( ; j<jpos; j+=SIMDSIZE ) {
1771 xmm1 = op( xmm1, tmp.load(i,j) );
1779 array1[0] = op( array1[0], tmp(i,j) );
1782 xmm1 =
loada( array1 );
1786 redux =
reduce( xmm1, op );
1791 redux = tmp(0UL,0UL);
1792 for(
size_t j=1UL; j<N; ++j ) {
1793 redux = op( redux, tmp(0UL,j) );
1796 for(
size_t i=1UL; i<M; ++i ) {
1797 for(
size_t j=0UL; j<N; ++j ) {
1798 redux = op( redux, tmp(i,j) );
1821template<
typename MT >
1822inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Add )
1823 -> EnableIf_t< DMatReduceExprHelper<MT,Add>::value, RemoveCV_t< ElementType_t<MT> > >
1825 using CT = CompositeType_t<MT>;
1826 using ET = RemoveCV_t< ElementType_t<MT> >;
1828 const size_t M( (*dm).rows() );
1829 const size_t N( (*dm).columns() );
1831 if( M == 0UL || N == 0UL )
return ET{};
1838 constexpr bool remainder( !
IsPadded_v< RemoveReference_t<CT> > );
1843 if( !remainder || N >= SIMDSIZE )
1845 const size_t jpos( remainder ?
prevMultiple( N, SIMDSIZE ) : N );
1848 SIMDTrait_t<ET> xmm1;
1851 for( ; (i+4UL) <= M; i+=4UL )
1853 xmm1 += tmp.load(i,0UL);
1854 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1855 SIMDTrait_t<ET> xmm3( tmp.load(i+2UL,0UL) );
1856 SIMDTrait_t<ET> xmm4( tmp.load(i+3UL,0UL) );
1857 size_t j( SIMDSIZE );
1859 for( ; j<jpos; j+=SIMDSIZE ) {
1860 xmm1 += tmp.load(i ,j);
1861 xmm2 += tmp.load(i+1UL,j);
1862 xmm3 += tmp.load(i+2UL,j);
1863 xmm4 += tmp.load(i+3UL,j);
1865 for( ; remainder && j<N; ++j ) {
1867 redux += tmp(i+1UL,j);
1868 redux += tmp(i+2UL,j);
1869 redux += tmp(i+3UL,j);
1879 xmm1 += tmp.load(i,0UL);
1880 SIMDTrait_t<ET> xmm2( tmp.load(i+1UL,0UL) );
1881 size_t j( SIMDSIZE );
1883 for( ; j<jpos; j+=SIMDSIZE ) {
1884 xmm1 += tmp.load(i ,j);
1885 xmm2 += tmp.load(i+1UL,j);
1887 for( ; remainder && j<N; ++j ) {
1889 redux += tmp(i+1UL,j);
1899 xmm1 += tmp.load(i,0UL);
1900 size_t j( SIMDSIZE );
1902 for( ; j<jpos; j+=SIMDSIZE ) {
1903 xmm1 += tmp.load(i,j);
1905 for( ; remainder && j<N; ++j ) {
1910 redux +=
sum( xmm1 );
1914 for(
size_t i=0UL; i<M; ++i ) {
1915 for(
size_t j=0UL; j<N; ++j ) {
1939template<
typename MT >
1940inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Min )
1941 -> EnableIf_t< IsUniform_v<MT>, RemoveCV_t< ElementType_t<MT> > >
1943 return (*dm)(0UL,0UL);
1960template<
typename MT >
1961inline auto dmatreduce(
const DenseMatrix<MT,false>& dm, Max )
1962 -> EnableIf_t< IsUniform_v<MT>, RemoveCV_t< ElementType_t<MT> > >
1964 return (*dm)(0UL,0UL);
1983template<
typename MT
1985inline RemoveCV_t< ElementType_t<MT> > dmatreduce(
const DenseMatrix<MT,true>& dm, OP op )
1987 return dmatreduce(
trans( *dm ), std::move(op) );
2022template<
typename MT
2029 return dmatreduce( *dm, std::move(op) );
2043template< ReductionFlag RF
2046inline const DMatReduceExpr<MT,OP,RF> reduce_backend(
const DenseMatrix<MT,false>& dm, OP op )
2048 using ReturnType =
const DMatReduceExpr<MT,OP,RF>;
2049 return ReturnType( *dm, std::move(op) );
2067inline decltype(
auto) reduce_backend(
const DenseMatrix<MT,true>& dm, OP op )
2069 constexpr ReductionFlag RF2( RF == rowwise ? columnwise : rowwise );
2070 return trans( reduce<RF2>(
trans( *dm ), std::move(op) ) );
2132 return reduce_backend<RF>( *dm, std::move(op) );
2154template<
typename MT
2198template< ReductionFlag RF
2205 return reduce<RF>( *dm,
Add() );
2227template<
typename MT
2271template< ReductionFlag RF
2278 return reduce<RF>( *dm,
Mult() );
2301template<
typename MT
2342template< ReductionFlag RF
2349 return reduce<RF>( *dm,
Min() );
2372template<
typename MT
2413template< ReductionFlag RF
2420 return reduce<RF>( *dm,
Max() );
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Constraints on the storage order of matrix types.
Constraint on the transpose flag of vector types.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasLoad type trait.
Header file for the HasMember type traits.
Macro for CUDA compatibility.
Header file for the If class template.
Header file for the IsExpression type trait class.
Header file for the IsPadded type trait.
Header file for the IsSIMDEnabled type trait.
Header file for the IsSame and IsStrictlySame type traits.
Deactivation of problematic macros.
Header file for the prevMultiple shim.
Header file for the reduce trait.
Header file for the reduction flags.
constexpr ReductionFlag columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:97
constexpr ReductionFlag rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:77
size_t ReductionFlag
Type of the reduction flags.
Definition: ReductionFlag.h:57
Header file for the RemoveCV type trait.
Header file for the RemoveReference type trait.
Constraints on the storage order of matrix types.
Constraint on the transpose flag of vector types.
Header file for all SIMD functionality.
Expression object for column-wise row-major dense matrix reduction operations.
Definition: DMatReduceExpr.h:132
ReduceTrait_t< RT, OP, columnwise > ResultType
Result type for expression template evaluations.
Definition: DMatReduceExpr.h:159
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatReduceExpr.h:164
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatReduceExpr.h:269
ResultType_t< MT > RT
Result type of the dense matrix expression.
Definition: DMatReduceExpr.h:135
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatReduceExpr.h:163
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatReduceExpr.h:161
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatReduceExpr.h:279
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatReduceExpr.h:289
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatReduceExpr.h:160
Operation op_
The reduction operation.
Definition: DMatReduceExpr.h:297
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatReduceExpr.h:235
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: DMatReduceExpr.h:162
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatReduceExpr.h:225
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DMatReduceExpr.h:199
DMatReduceExpr(const MT &dm, OP op) noexcept
Constructor for the DMatReduceExpr class.
Definition: DMatReduceExpr.h:187
CompositeType_t< MT > CT
Composite type of the dense matrix expression.
Definition: DMatReduceExpr.h:136
Operation operation() const
Returns a copy of the reduction operation.
Definition: DMatReduceExpr.h:245
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:296
OP Operation
Data type of the custom unary operation.
Definition: DMatReduceExpr.h:170
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatReduceExpr.h:257
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DMatReduceExpr.h:212
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side dense matrix expression.
Definition: DMatReduceExpr.h:167
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatReduceExpr.h:917
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:949
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:993
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatReduceExpr.h:1015
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:982
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatReduceExpr.h:873
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatReduceExpr.h:907
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatReduceExpr.h:885
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatReduceExpr.h:938
OP op_
The reduction operation.
Definition: DMatReduceExpr.h:1060
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatReduceExpr.h:1027
ConstIterator(Operand dm, size_t index, OP op)
Constructor for the ConstIterator class.
Definition: DMatReduceExpr.h:860
ReferenceType reference
Reference return type.
Definition: DMatReduceExpr.h:849
ElementType * PointerType
Pointer return type.
Definition: DMatReduceExpr.h:841
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:1058
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatReduceExpr.h:1051
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:971
size_t index_
Index to the current matrix row.
Definition: DMatReduceExpr.h:1059
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatReduceExpr.h:839
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatReduceExpr.h:1039
PointerType pointer
Pointer return type.
Definition: DMatReduceExpr.h:848
ElementType & ReferenceType
Reference return type.
Definition: DMatReduceExpr.h:842
ValueType value_type
Type of the underlying elements.
Definition: DMatReduceExpr.h:847
IteratorCategory iterator_category
The iterator category.
Definition: DMatReduceExpr.h:846
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:1004
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatReduceExpr.h:960
ElementType ValueType
Type of the underlying elements.
Definition: DMatReduceExpr.h:840
DifferenceType difference_type
Difference between two iterators.
Definition: DMatReduceExpr.h:850
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatReduceExpr.h:843
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatReduceExpr.h:928
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatReduceExpr.h:896
Expression object for row-wise row-major dense matrix reduction operations.
Definition: DMatReduceExpr.h:773
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatReduceExpr.h:1147
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side dense matrix expression.
Definition: DMatReduceExpr.h:826
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: DMatReduceExpr.h:1104
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatReduceExpr.h:818
ResultType_t< MT > RT
Result type of the dense matrix expression.
Definition: DMatReduceExpr.h:776
Operation operation() const
Returns a copy of the reduction operation.
Definition: DMatReduceExpr.h:1157
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatReduceExpr.h:1191
ReduceTrait_t< RT, OP, rowwise > ResultType
Result type for expression template evaluations.
Definition: DMatReduceExpr.h:816
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: DMatReduceExpr.h:1117
SIMDTrait_t< ElementType > SIMDType
Resulting SIMD element type.
Definition: DMatReduceExpr.h:819
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatReduceExpr.h:1137
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: DMatReduceExpr.h:1091
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatReduceExpr.h:817
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatReduceExpr.h:1169
If_t< useAssign, const ResultType, const DMatReduceExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatReduceExpr.h:823
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatReduceExpr.h:1201
const ElementType ReturnType
Return type for expression template evaluations.
Definition: DMatReduceExpr.h:820
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: DMatReduceExpr.h:1127
Operation op_
The reduction operation.
Definition: DMatReduceExpr.h:1209
OP Operation
Data type of the custom unary operation.
Definition: DMatReduceExpr.h:829
Operand dm_
Dense matrix of the reduction expression.
Definition: DMatReduceExpr.h:1208
DMatReduceExpr(const MT &dm, OP op) noexcept
Constructor for the DMatReduceExpr class.
Definition: DMatReduceExpr.h:1079
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatReduceExpr.h:1181
Base template for row-major dense matrix partial reduction operations.
Definition: DMatReduceExpr.h:108
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
Base class for N-dimensional vectors.
Definition: Vector.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 DenseVector base class.
Header file for the MatReduceExpr base class.
Header file for the Add functor.
Header file for the Mult functor.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of each row/columns of the dense matrix.
Definition: DMatReduceExpr.h:2416
decltype(auto) prod(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of multiplication.
Definition: DMatReduceExpr.h:2274
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition: DMatDMatMapExpr.h:1144
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) reduce(const DenseMatrix< MT, SO > &dm, OP op)
Performs a custom reduction operation on the given dense matrix.
Definition: DMatReduceExpr.h:2126
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2201
decltype(auto) min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of each row/columns of the dense matrix.
Definition: DMatReduceExpr.h:2345
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.
Definition: RowVector.h:61
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.
Definition: ReduceTrait.h:150
constexpr bool IsPadded_v
Auxiliary variable template for the IsPadded type trait.
Definition: IsPadded.h:134
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition: PrevMultiple.h:68
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition: SIMDTrait.h:315
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
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
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:221
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 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:192
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
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.
Definition: StaticAssert.h:123
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Header file for the Max functor.
Header file for the Min functor.
Header file for the serial shim.
Generic wrapper for the addition operator.
Definition: Add.h:85
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all matrix reduction expression templates.
Definition: MatReduceExpr.h:70
Generic wrapper for the max() function.
Definition: Max.h:82
Generic wrapper for the min() function.
Definition: Min.h:82
Generic wrapper for the multiplication operator.
Definition: Mult.h:82
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.