35 #ifndef _BLAZE_MATH_VIEWS_ROW_DENSE_H_ 36 #define _BLAZE_MATH_VIEWS_ROW_DENSE_H_ 125 template<
typename MT
128 class Row<MT,true,true,SF,CRAs...>
129 :
public View< DenseVector< Row<MT,true,true,SF,CRAs...>, true > >
130 ,
private RowData<CRAs...>
134 using DataType = RowData<CRAs...>;
135 using Operand = If_< IsExpression<MT>, MT, MT& >;
141 using This = Row<MT,
true,
true,SF,CRAs...>;
143 using BaseType = DenseVector<This,true>;
144 using ViewedType = MT;
148 using SIMDType = SIMDTrait_<ElementType>;
159 using ConstPointer = ConstPointer_<MT>;
162 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
173 enum :
bool { simdEnabled = MT::simdEnabled };
176 enum :
bool { smpAssignable = MT::smpAssignable };
182 template<
typename... RRAs >
183 explicit inline Row( MT& matrix, RRAs... args );
195 inline Reference operator[](
size_t index );
196 inline ConstReference operator[](
size_t index )
const;
198 inline ConstReference at(
size_t index )
const;
199 inline Pointer
data () noexcept;
200 inline ConstPointer
data () const noexcept;
202 inline ConstIterator begin () const;
203 inline ConstIterator
cbegin() const;
205 inline ConstIterator end () const;
206 inline ConstIterator
cend () const;
214 inline Row& operator=( initializer_list<
ElementType> list );
215 inline Row& operator=( const Row& rhs );
217 template< typename VT > inline Row& operator= ( const Vector<VT,true>& rhs );
218 template< typename VT > inline Row& operator+=( const Vector<VT,true>& rhs );
219 template< typename VT > inline Row& operator-=( const Vector<VT,true>& rhs );
220 template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
221 template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
222 template< typename VT > inline Row& operator%=( const Vector<VT,true>& rhs );
231 inline MT& operand() noexcept;
232 inline const MT& operand() const noexcept;
234 inline
size_t size() const noexcept;
235 inline
size_t spacing() const noexcept;
236 inline
size_t capacity() const noexcept;
245 template< typename Other > inline Row& scale( const Other& scalar );
252 template< typename VT >
253 struct VectorizedAssign {
254 enum :
bool { value = useOptimizedKernels &&
255 simdEnabled && VT::simdEnabled &&
256 IsSIMDCombinable< ElementType, ElementType_<VT> >::value };
262 template<
typename VT >
263 struct VectorizedAddAssign {
264 enum :
bool { value = useOptimizedKernels &&
265 simdEnabled && VT::simdEnabled &&
266 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
267 HasSIMDAdd< ElementType, ElementType_<VT> >::value };
273 template<
typename VT >
274 struct VectorizedSubAssign {
275 enum :
bool { value = useOptimizedKernels &&
276 simdEnabled && VT::simdEnabled &&
277 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
278 HasSIMDSub< ElementType, ElementType_<VT> >::value };
284 template<
typename VT >
285 struct VectorizedMultAssign {
286 enum :
bool { value = useOptimizedKernels &&
287 simdEnabled && VT::simdEnabled &&
288 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
289 HasSIMDMult< ElementType, ElementType_<VT> >::value };
295 template<
typename VT >
296 struct VectorizedDivAssign {
297 enum :
bool { value = useOptimizedKernels &&
298 simdEnabled && VT::simdEnabled &&
299 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
300 HasSIMDDiv< ElementType, ElementType_<VT> >::value };
313 template<
typename Other >
314 inline bool canAlias(
const Other* alias )
const noexcept;
316 template<
typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
317 inline bool canAlias(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept;
319 template<
typename Other >
320 inline bool isAliased(
const Other* alias )
const noexcept;
322 template<
typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
323 inline bool isAliased(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept;
325 inline bool isAligned () const noexcept;
326 inline
bool canSMPAssign() const noexcept;
337 template< typename VT >
338 inline
DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,true>& rhs );
340 template< typename VT >
341 inline
EnableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,true>& rhs );
343 template< typename VT > inline
void assign( const SparseVector<VT,true>& rhs );
345 template< typename VT >
346 inline
DisableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,true>& rhs );
348 template< typename VT >
349 inline
EnableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,true>& rhs );
351 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
353 template< typename VT >
354 inline
DisableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,true>& rhs );
356 template< typename VT >
357 inline
EnableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,true>& rhs );
359 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
361 template< typename VT >
362 inline
DisableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,true>& rhs );
364 template< typename VT >
365 inline
EnableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,true>& rhs );
367 template< typename VT > inline
void multAssign( const SparseVector<VT,true>& rhs );
369 template< typename VT >
370 inline
DisableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,true>& rhs );
372 template< typename VT >
373 inline
EnableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,true>& rhs );
386 template< typename MT2,
bool SO2,
bool DF2,
bool SF2,
size_t... CRAs2 > friend class Row;
424 template< typename MT
427 template< typename... RRAs >
428 inline Row<MT,true,true,SF,CRAs...>::Row( MT& matrix, RRAs... args )
429 : DataType( args... )
432 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
433 if( matrix_.rows() <=
row() ) {
463 template<
typename MT
466 inline typename Row<MT,
true,
true,SF,CRAs...>
::Reference 467 Row<MT,true,true,SF,CRAs...>::operator[](
size_t index )
470 return matrix_(
row(),index);
486 template<
typename MT
490 Row<MT,true,true,SF,CRAs...>::operator[](
size_t index )
const 493 return const_cast<const MT&
>( matrix_ )(
row(),index);
510 template<
typename MT
513 inline typename Row<MT,
true,
true,SF,CRAs...>
::Reference 514 Row<MT,true,true,SF,CRAs...>::at(
size_t index )
516 if( index >=
size() ) {
519 return (*
this)[index];
536 template<
typename MT
540 Row<MT,true,true,SF,CRAs...>::at(
size_t index )
const 542 if( index >=
size() ) {
545 return (*
this)[index];
560 template<
typename MT
563 inline typename Row<MT,
true,
true,SF,CRAs...>::Pointer
566 return matrix_.data(
row() );
581 template<
typename MT
584 inline typename Row<MT,
true,
true,SF,CRAs...>::ConstPointer
587 return matrix_.data(
row() );
601 template<
typename MT
604 inline typename Row<MT,
true,
true,SF,CRAs...>
::Iterator 607 return matrix_.begin(
row() );
621 template<
typename MT
627 return matrix_.cbegin(
row() );
641 template<
typename MT
647 return matrix_.cbegin(
row() );
661 template<
typename MT
664 inline typename Row<MT,
true,
true,SF,CRAs...>
::Iterator 667 return matrix_.end(
row() );
681 template<
typename MT
687 return matrix_.cend(
row() );
701 template<
typename MT
707 return matrix_.cend(
row() );
732 template<
typename MT
735 inline Row<MT,
true,
true,SF,CRAs...>&
736 Row<MT,true,true,SF,CRAs...>::operator=(
const ElementType& rhs )
738 decltype(
auto) left( derestrict( matrix_ ) );
740 const
size_t jbegin( ( IsUpper<MT>::value )
741 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
745 const
size_t jend ( ( IsLower<MT>::value )
746 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
751 for(
size_t j=jbegin; j<jend; ++j ) {
752 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_,
row(), j, rhs ) )
777 template<
typename MT
780 inline Row<MT,
true,
true,SF,CRAs...>&
781 Row<MT,true,true,SF,CRAs...>::operator=( initializer_list<ElementType> list )
783 if( list.size() >
size() ) {
787 if( IsRestricted<MT>::value ) {
788 const InitializerVector<ElementType,true> tmp( list,
size() );
789 if( !tryAssign( matrix_, tmp,
row(), 0UL ) ) {
794 decltype(
auto) left( derestrict( *this ) );
820 template< typename MT
823 inline Row<MT,true,true,SF,CRAs...>&
824 Row<MT,true,true,SF,CRAs...>::operator=( const Row& rhs )
826 if( &rhs ==
this )
return *
this;
828 if(
size() != rhs.size() ) {
832 if( !tryAssign( matrix_, rhs,
row(), 0UL ) ) {
836 decltype(
auto) left( derestrict( *this ) );
838 if( IsExpression<MT>::value && rhs.canAlias( &matrix_ ) ) {
868 template<
typename MT
871 template<
typename VT >
872 inline Row<MT,
true,
true,SF,CRAs...>&
873 Row<MT,true,true,SF,CRAs...>::operator=(
const Vector<VT,true>& rhs )
882 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
885 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
889 decltype(
auto) left( derestrict( *this ) );
891 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
892 const ResultType_<VT> tmp( right );
896 if( IsSparseVector<VT>::value )
923 template<
typename MT
926 template<
typename VT >
927 inline Row<MT,
true,
true,SF,CRAs...>&
937 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
940 if( !tryAddAssign( matrix_, right,
row(), 0UL ) ) {
944 decltype(
auto) left( derestrict( *this ) );
946 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
947 const ResultType_<VT> tmp( right );
976 template<
typename MT
979 template<
typename VT >
980 inline Row<MT,
true,
true,SF,CRAs...>&
990 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
993 if( !trySubAssign( matrix_, right,
row(), 0UL ) ) {
997 decltype(
auto) left( derestrict( *this ) );
999 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1000 const ResultType_<VT> tmp( right );
1028 template<
typename MT
1031 template<
typename VT >
1032 inline Row<MT,
true,
true,SF,CRAs...>&
1042 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1043 Right right( ~rhs );
1045 if( !tryMultAssign( matrix_, right,
row(), 0UL ) ) {
1049 decltype(
auto) left( derestrict( *this ) );
1051 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1052 const ResultType_<VT> tmp( right );
1079 template<
typename MT
1082 template<
typename VT >
1083 inline Row<MT,
true,
true,SF,CRAs...>&
1093 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
1094 Right right( ~rhs );
1096 if( !tryDivAssign( matrix_, right,
row(), 0UL ) ) {
1100 decltype(
auto) left( derestrict( *this ) );
1102 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1103 const ResultType_<VT> tmp( right );
1131 template<
typename MT
1134 template<
typename VT >
1135 inline Row<MT,
true,
true,SF,CRAs...>&
1136 Row<MT,true,true,SF,CRAs...>::operator%=(
const Vector<VT,true>& rhs )
1138 using blaze::assign;
1143 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
1149 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
1153 const CrossType right( *
this % (~rhs) );
1155 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
1159 decltype(
auto) left( derestrict( *this ) );
1161 assign( left, right );
1185 template< typename MT
1188 inline MT& Row<MT,true,true,SF,CRAs...>::operand() noexcept
1202 template<
typename MT
1205 inline const MT& Row<MT,true,true,SF,CRAs...>::operand() const noexcept
1219 template<
typename MT
1224 return matrix_.columns();
1239 template<
typename MT
1244 return matrix_.spacing();
1256 template<
typename MT
1261 return matrix_.capacity(
row() );
1276 template<
typename MT
1281 return matrix_.nonZeros(
row() );
1293 template<
typename MT
1298 matrix_.reset(
row() );
1325 template<
typename MT
1328 template<
typename Other >
1329 inline Row<MT,
true,
true,SF,CRAs...>&
1330 Row<MT,true,true,SF,CRAs...>::scale(
const Other& scalar )
1334 const size_t jbegin( ( IsUpper<MT>::value )
1335 ?( ( IsStrictlyUpper<MT>::value )
1339 const size_t jend ( ( IsLower<MT>::value )
1340 ?( ( IsStrictlyLower<MT>::value )
1345 for(
size_t j=jbegin; j<jend; ++j ) {
1346 matrix_(
row(),j) *= scalar;
1374 template<
typename MT
1377 template<
typename Other >
1378 inline bool Row<MT,true,true,SF,CRAs...>::canAlias(
const Other* alias )
const noexcept
1380 return matrix_.isAliased( alias );
1397 template<
typename MT
1400 template<
typename MT2
1405 Row<MT,true,true,SF,CRAs...>::canAlias(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
1407 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
1424 template<
typename MT
1427 template<
typename Other >
1428 inline bool Row<MT,true,true,SF,CRAs...>::isAliased(
const Other* alias )
const noexcept
1430 return matrix_.isAliased( alias );
1447 template<
typename MT
1450 template<
typename MT2
1455 Row<MT,true,true,SF,CRAs...>::isAliased(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
1457 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
1473 template<
typename MT
1476 inline bool Row<MT,true,true,SF,CRAs...>::isAligned() const noexcept
1478 return matrix_.isAligned();
1495 template<
typename MT
1498 inline bool Row<MT,true,true,SF,CRAs...>::canSMPAssign() const noexcept
1500 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1519 template<
typename MT
1523 Row<MT,true,true,SF,CRAs...>::load(
size_t index )
const noexcept
1525 return matrix_.load(
row(), index );
1544 template<
typename MT
1550 return matrix_.loada(
row(), index );
1569 template<
typename MT
1575 return matrix_.loadu(
row(), index );
1595 template<
typename MT
1599 Row<MT,true,true,SF,CRAs...>::store(
size_t index,
const SIMDType& value ) noexcept
1601 matrix_.store(
row(), index, value );
1621 template<
typename MT
1627 matrix_.storea(
row(), index, value );
1647 template<
typename MT
1653 matrix_.storeu(
row(), index, value );
1673 template<
typename MT
1679 matrix_.stream(
row(), index, value );
1697 template<
typename MT
1700 template<
typename VT >
1701 inline DisableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedAssign<VT> >
1702 Row<MT,true,true,SF,CRAs...>::assign(
const DenseVector<VT,true>& rhs )
1706 const size_t jpos( (~rhs).
size() &
size_t(-2) );
1707 for(
size_t j=0UL; j<jpos; j+=2UL ) {
1708 matrix_(
row(),j ) = (~rhs)[j ];
1709 matrix_(
row(),j+1UL) = (~rhs)[j+1UL];
1711 if( jpos < (~rhs).size() )
1712 matrix_(
row(),jpos) = (~rhs)[jpos];
1730 template<
typename MT
1733 template<
typename VT >
1734 inline EnableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedAssign<VT> >
1735 Row<MT,true,true,SF,CRAs...>::assign(
const DenseVector<VT,true>& rhs )
1741 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1745 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
1750 ConstIterator_<VT> right( (~rhs).
begin() );
1752 if( useStreaming &&
columns > ( cacheSize/(
sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
1754 for( ; j<jpos; j+=SIMDSIZE ) {
1755 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1757 for( ; remainder && j<
columns; ++j ) {
1758 *left = *right; ++left; ++right;
1763 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
1764 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1765 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1766 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1767 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1769 for( ; j<jpos; j+=SIMDSIZE ) {
1770 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1772 for( ; remainder && j<
columns; ++j ) {
1773 *left = *right; ++left; ++right;
1793 template<
typename MT
1796 template<
typename VT >
1797 inline void Row<MT,true,true,SF,CRAs...>::assign(
const SparseVector<VT,true>& rhs )
1801 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1802 matrix_(
row(),element->index()) = element->value();
1820 template<
typename MT
1823 template<
typename VT >
1824 inline DisableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
1825 Row<MT,true,true,SF,CRAs...>::addAssign(
const DenseVector<VT,true>& rhs )
1829 const size_t jpos( (~rhs).
size() &
size_t(-2) );
1830 for(
size_t j=0UL; j<jpos; j+=2UL ) {
1831 matrix_(
row(),j ) += (~rhs)[j ];
1832 matrix_(
row(),j+1UL) += (~rhs)[j+1UL];
1834 if( jpos < (~rhs).size() )
1835 matrix_(
row(),jpos) += (~rhs)[jpos];
1853 template<
typename MT
1856 template<
typename VT >
1857 inline EnableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
1858 Row<MT,true,true,SF,CRAs...>::addAssign(
const DenseVector<VT,true>& rhs )
1864 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1868 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
1873 ConstIterator_<VT> right( (~rhs).
begin() );
1875 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
1876 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1877 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1878 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1879 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1881 for( ; j<jpos; j+=SIMDSIZE ) {
1882 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1884 for( ; remainder && j<
columns; ++j ) {
1885 *left += *right; ++left; ++right;
1904 template<
typename MT
1907 template<
typename VT >
1908 inline void Row<MT,true,true,SF,CRAs...>::addAssign(
const SparseVector<VT,true>& rhs )
1912 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1913 matrix_(
row(),element->index()) += element->value();
1931 template<
typename MT
1934 template<
typename VT >
1935 inline DisableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
1936 Row<MT,true,true,SF,CRAs...>::subAssign(
const DenseVector<VT,true>& rhs )
1940 const size_t jpos( (~rhs).
size() &
size_t(-2) );
1941 for(
size_t j=0UL; j<jpos; j+=2UL ) {
1942 matrix_(
row(),j ) -= (~rhs)[j ];
1943 matrix_(
row(),j+1UL) -= (~rhs)[j+1UL];
1945 if( jpos < (~rhs).size() )
1946 matrix_(
row(),jpos) -= (~rhs)[jpos];
1964 template<
typename MT
1967 template<
typename VT >
1968 inline EnableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
1969 Row<MT,true,true,SF,CRAs...>::subAssign(
const DenseVector<VT,true>& rhs )
1975 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1979 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
1984 ConstIterator_<VT> right( (~rhs).
begin() );
1986 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
1987 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1988 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1989 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1990 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1992 for( ; j<jpos; j+=SIMDSIZE ) {
1993 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1995 for( ; remainder && j<
columns; ++j ) {
1996 *left -= *right; ++left; ++right;
2015 template<
typename MT
2018 template<
typename VT >
2019 inline void Row<MT,true,true,SF,CRAs...>::subAssign(
const SparseVector<VT,true>& rhs )
2023 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
2024 matrix_(
row(),element->index()) -= element->value();
2042 template<
typename MT
2045 template<
typename VT >
2046 inline DisableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2047 Row<MT,true,true,SF,CRAs...>::multAssign(
const DenseVector<VT,true>& rhs )
2051 const size_t jpos( (~rhs).
size() &
size_t(-2) );
2052 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2053 matrix_(
row(),j ) *= (~rhs)[j ];
2054 matrix_(
row(),j+1UL) *= (~rhs)[j+1UL];
2056 if( jpos < (~rhs).size() )
2057 matrix_(
row(),jpos) *= (~rhs)[jpos];
2075 template<
typename MT
2078 template<
typename VT >
2079 inline EnableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
2080 Row<MT,true,true,SF,CRAs...>::multAssign(
const DenseVector<VT,true>& rhs )
2086 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
2090 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
2095 ConstIterator_<VT> right( (~rhs).
begin() );
2097 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2098 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2099 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2100 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2101 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2103 for( ; j<jpos; j+=SIMDSIZE ) {
2104 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2106 for( ; remainder && j<
columns; ++j ) {
2107 *left *= *right; ++left; ++right;
2126 template<
typename MT
2129 template<
typename VT >
2130 inline void Row<MT,true,true,SF,CRAs...>::multAssign(
const SparseVector<VT,true>& rhs )
2138 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
2139 const size_t index( element->index() );
2140 for( ; j<index; ++j )
2142 matrix_(
row(),j) *= element->value();
2146 for( ; j<
size(); ++j ) {
2166 template<
typename MT
2169 template<
typename VT >
2170 inline DisableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2171 Row<MT,true,true,SF,CRAs...>::divAssign(
const DenseVector<VT,true>& rhs )
2175 const size_t jpos( (~rhs).
size() &
size_t(-2) );
2176 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2177 matrix_(
row(),j ) /= (~rhs)[j ];
2178 matrix_(
row(),j+1UL) /= (~rhs)[j+1UL];
2180 if( jpos < (~rhs).size() )
2181 matrix_(
row(),jpos) /= (~rhs)[jpos];
2199 template<
typename MT
2202 template<
typename VT >
2203 inline EnableIf_<
typename Row<MT,
true,
true,SF,CRAs...>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2204 Row<MT,true,true,SF,CRAs...>::divAssign(
const DenseVector<VT,true>& rhs )
2212 const size_t jpos(
columns &
size_t(-SIMDSIZE) );
2217 ConstIterator_<VT> right( (~rhs).
begin() );
2219 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2220 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2221 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2222 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2223 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2225 for( ; j<jpos; j+=SIMDSIZE ) {
2226 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2229 *left /= *right; ++left; ++right;
2256 template<
typename MT
2258 class Row<MT,false,true,false,CRAs...>
2259 :
public View< DenseVector< Row<MT,false,true,false,CRAs...>, true > >
2260 ,
private RowData<CRAs...>
2264 using DataType = RowData<CRAs...>;
2265 using Operand = If_< IsExpression<MT>, MT, MT& >;
2271 using This = Row<MT,
false,
true,
false,CRAs...>;
2273 using BaseType = DenseVector<This,true>;
2274 using ViewedType = MT;
2277 using ElementType = ElementType_<MT>;
2282 using ConstReference = ConstReference_<MT>;
2288 using ConstPointer = ConstPointer_<MT>;
2291 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
2297 template<
typename MatrixType
2298 ,
typename IteratorType >
2304 using IteratorCategory =
typename std::iterator_traits<IteratorType>::iterator_category;
2307 using ValueType =
typename std::iterator_traits<IteratorType>::value_type;
2310 using PointerType =
typename std::iterator_traits<IteratorType>::pointer;
2313 using ReferenceType =
typename std::iterator_traits<IteratorType>::reference;
2316 using DifferenceType =
typename std::iterator_traits<IteratorType>::difference_type;
2319 using iterator_category = IteratorCategory;
2320 using value_type = ValueType;
2321 using pointer = PointerType;
2322 using reference = ReferenceType;
2323 using difference_type = DifferenceType;
2329 inline RowIterator() noexcept
2330 : matrix_(
nullptr )
2344 inline RowIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
2345 : matrix_( &matrix )
2350 if( column_ != matrix_->columns() )
2351 pos_ = matrix_->begin( column_ ) + row_;
2360 template<
typename MatrixType2,
typename IteratorType2 >
2361 inline RowIterator(
const RowIterator<MatrixType2,IteratorType2>& it ) noexcept
2362 : matrix_( it.matrix_ )
2364 , column_( it.column_ )
2375 inline RowIterator&
operator+=(
size_t inc ) noexcept {
2378 if( column_ != matrix_->columns() )
2379 pos_ = matrix_->begin( column_ ) + row_;
2391 inline RowIterator&
operator-=(
size_t dec ) noexcept {
2394 if( column_ != matrix_->columns() )
2395 pos_ = matrix_->begin( column_ ) + row_;
2406 inline RowIterator& operator++() noexcept {
2409 if( column_ != matrix_->columns() )
2410 pos_ = matrix_->begin( column_ ) + row_;
2421 inline const RowIterator operator++(
int ) noexcept {
2422 const RowIterator tmp( *
this );
2433 inline RowIterator& operator--() noexcept {
2436 if( column_ != matrix_->columns() )
2437 pos_ = matrix_->begin( column_ ) + row_;
2448 inline const RowIterator operator--(
int ) noexcept {
2449 const RowIterator tmp( *
this );
2461 inline ReferenceType operator[](
size_t index )
const {
2463 const IteratorType pos( matrix_->begin( column_+index ) + row_ );
2473 inline ReferenceType
operator*()
const {
2483 inline PointerType operator->()
const {
2494 template<
typename MatrixType2,
typename IteratorType2 >
2495 inline bool operator==(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2496 return column_ == rhs.column_;
2506 template<
typename MatrixType2,
typename IteratorType2 >
2507 inline bool operator!=(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2508 return !( *
this == rhs );
2518 template<
typename MatrixType2,
typename IteratorType2 >
2519 inline bool operator<( const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2520 return column_ < rhs.column_;
2530 template<
typename MatrixType2,
typename IteratorType2 >
2531 inline bool operator>(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2532 return column_ > rhs.column_;
2542 template<
typename MatrixType2,
typename IteratorType2 >
2543 inline bool operator<=( const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2544 return column_ <= rhs.column_;
2554 template<
typename MatrixType2,
typename IteratorType2 >
2555 inline bool operator>=(
const RowIterator<MatrixType2,IteratorType2>& rhs )
const noexcept {
2556 return column_ >= rhs.column_;
2566 inline DifferenceType
operator-(
const RowIterator& rhs )
const noexcept {
2567 return column_ - rhs.column_;
2578 friend inline const RowIterator
operator+(
const RowIterator& it,
size_t inc ) noexcept {
2579 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2590 friend inline const RowIterator
operator+(
size_t inc,
const RowIterator& it ) noexcept {
2591 return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2602 friend inline const RowIterator
operator-(
const RowIterator& it,
size_t dec ) noexcept {
2603 return RowIterator( *it.matrix_, it.row_, it.column_-dec );
2609 MatrixType* matrix_;
2616 template<
typename MatrixType2,
typename IteratorType2 >
friend class RowIterator;
2623 using ConstIterator = RowIterator< const MT, ConstIterator_<MT> >;
2631 enum :
bool { simdEnabled =
false };
2634 enum :
bool { smpAssignable = MT::smpAssignable };
2640 template<
typename... RRAs >
2641 explicit inline Row( MT& matrix, RRAs... args );
2653 inline Reference operator[](
size_t index );
2654 inline ConstReference operator[](
size_t index )
const;
2656 inline ConstReference at(
size_t index )
const;
2657 inline Pointer
data () noexcept;
2658 inline ConstPointer
data () const noexcept;
2660 inline ConstIterator begin () const;
2661 inline ConstIterator
cbegin() const;
2663 inline ConstIterator end () const;
2664 inline ConstIterator
cend () const;
2671 inline Row& operator=( const ElementType& rhs );
2672 inline Row& operator=( initializer_list<ElementType> list );
2673 inline Row& operator=( const Row& rhs );
2675 template< typename VT > inline Row& operator= ( const Vector<VT,true>& rhs );
2676 template< typename VT > inline Row& operator+=( const Vector<VT,true>& rhs );
2677 template< typename VT > inline Row& operator-=( const Vector<VT,true>& rhs );
2678 template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
2679 template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
2680 template< typename VT > inline Row& operator%=( const Vector<VT,true>& rhs );
2687 using DataType::
row;
2689 inline MT& operand() noexcept;
2690 inline const MT& operand() const noexcept;
2692 inline
size_t size() const noexcept;
2693 inline
size_t spacing() const noexcept;
2694 inline
size_t capacity() const noexcept;
2696 inline
void reset();
2703 template< typename Other > inline Row& scale( const Other& scalar );
2710 template< typename Other >
2711 inline
bool canAlias( const Other* alias ) const noexcept;
2713 template< typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
2714 inline
bool canAlias( const Row<MT2,SO2,true,SF2,CRAs2...>* alias ) const noexcept;
2716 template< typename Other >
2717 inline
bool isAliased( const Other* alias ) const noexcept;
2719 template< typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
2720 inline
bool isAliased( const Row<MT2,SO2,true,SF2,CRAs2...>* alias ) const noexcept;
2722 inline
bool isAligned () const noexcept;
2723 inline
bool canSMPAssign() const noexcept;
2725 template< typename VT > inline
void assign ( const DenseVector <VT,true>& rhs );
2726 template< typename VT > inline
void assign ( const SparseVector<VT,true>& rhs );
2727 template< typename VT > inline
void addAssign ( const DenseVector <VT,true>& rhs );
2728 template< typename VT > inline
void addAssign ( const SparseVector<VT,true>& rhs );
2729 template< typename VT > inline
void subAssign ( const DenseVector <VT,true>& rhs );
2730 template< typename VT > inline
void subAssign ( const SparseVector<VT,true>& rhs );
2731 template< typename VT > inline
void multAssign( const DenseVector <VT,true>& rhs );
2732 template< typename VT > inline
void multAssign( const SparseVector<VT,true>& rhs );
2733 template< typename VT > inline
void divAssign ( const DenseVector <VT,true>& rhs );
2746 template< typename MT2,
bool SO2,
bool DF2,
bool SF2,
size_t... CRAs2 > friend class Row;
2785 template< typename MT
2787 template< typename... RRAs >
2788 inline Row<MT,false,true,false,CRAs...>::Row( MT& matrix, RRAs... args )
2789 : DataType( args... )
2790 , matrix_ ( matrix )
2792 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
2793 if( matrix_.rows() <=
row() ) {
2823 template<
typename MT
2825 inline typename Row<MT,
false,
true,
false,CRAs...>
::Reference 2826 Row<MT,false,true,false,CRAs...>::operator[](
size_t index )
2829 return matrix_(
row(),index);
2845 template<
typename MT
2848 Row<MT,false,true,false,CRAs...>::operator[](
size_t index )
const 2851 return const_cast<const MT&
>( matrix_ )(
row(),index);
2868 template<
typename MT
2870 inline typename Row<MT,
false,
true,
false,CRAs...>
::Reference 2871 Row<MT,false,true,false,CRAs...>::at(
size_t index )
2873 if( index >=
size() ) {
2876 return (*
this)[index];
2893 template<
typename MT
2896 Row<MT,false,true,false,CRAs...>::at(
size_t index )
const 2898 if( index >=
size() ) {
2901 return (*
this)[index];
2916 template<
typename MT
2918 inline typename Row<MT,
false,
true,
false,CRAs...>::Pointer
2921 return matrix_.data() +
row();
2936 template<
typename MT
2938 inline typename Row<MT,
false,
true,
false,CRAs...>::ConstPointer
2941 return matrix_.data() +
row();
2955 template<
typename MT
2957 inline typename Row<MT,
false,
true,
false,CRAs...>
::Iterator 2974 template<
typename MT
2993 template<
typename MT
3012 template<
typename MT
3014 inline typename Row<MT,
false,
true,
false,CRAs...>
::Iterator 3031 template<
typename MT
3050 template<
typename MT
3080 template<
typename MT
3082 inline Row<MT,
false,
true,
false,CRAs...>&
3083 Row<MT,false,true,false,CRAs...>::operator=(
const ElementType& rhs )
3085 decltype(
auto) left( derestrict( matrix_ ) );
3087 const
size_t jbegin( ( IsUpper<MT>::value )
3088 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3092 const
size_t jend ( ( IsLower<MT>::value )
3093 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3098 for(
size_t j=jbegin; j<jend; ++j ) {
3099 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_,
row(), j, rhs ) )
3100 left(
row(),j) = rhs;
3124 template<
typename MT
3126 inline Row<MT,
false,
true,
false,CRAs...>&
3127 Row<MT,false,true,false,CRAs...>::operator=( initializer_list<ElementType> list )
3129 if( list.size() >
size() ) {
3133 if( IsRestricted<MT>::value ) {
3134 const InitializerVector<ElementType,true> tmp( list,
size() );
3135 if( !tryAssign( matrix_, tmp,
row(), 0UL ) ) {
3140 decltype(
auto) left( derestrict( *this ) );
3142 std::fill(
std::copy( list.begin(), list.end(), left.begin() ), left.end(), ElementType() );
3166 template< typename MT
3168 inline Row<MT,false,true,false,CRAs...>&
3169 Row<MT,false,true,false,CRAs...>::operator=( const Row& rhs )
3171 if( &rhs ==
this )
return *
this;
3173 if(
size() != rhs.size() ) {
3177 if( !tryAssign( matrix_, rhs,
row(), 0UL ) ) {
3181 decltype(
auto) left( derestrict( *this ) );
3183 if( IsExpression<MT>::value && rhs.canAlias( &matrix_ ) ) {
3213 template<
typename MT
3215 template<
typename VT >
3216 inline Row<MT,
false,
true,
false,CRAs...>&
3217 Row<MT,false,true,false,CRAs...>::operator=(
const Vector<VT,true>& rhs )
3227 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
3228 Right right( ~rhs );
3230 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
3234 decltype(
auto) left( derestrict( *this ) );
3236 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3241 if( IsSparseVector<VT>::value )
3268 template<
typename MT
3270 template<
typename VT >
3271 inline Row<MT,
false,
true,
false,CRAs...>&
3281 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
3282 Right right( ~rhs );
3284 if( !tryAddAssign( matrix_, right,
row(), 0UL ) ) {
3288 decltype(
auto) left( derestrict( *this ) );
3290 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3291 const ResultType_<VT> tmp( right );
3320 template<
typename MT
3322 template<
typename VT >
3323 inline Row<MT,
false,
true,
false,CRAs...>&
3333 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
3334 Right right( ~rhs );
3336 if( !trySubAssign( matrix_, right,
row(), 0UL ) ) {
3340 decltype(
auto) left( derestrict( *this ) );
3342 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3343 const ResultType_<VT> tmp( right );
3371 template<
typename MT
3373 template<
typename VT >
3374 inline Row<MT,
false,
true,
false,CRAs...>&
3384 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
3385 Right right( ~rhs );
3387 if( !tryMultAssign( matrix_, right,
row(), 0UL ) ) {
3391 decltype(
auto) left( derestrict( *this ) );
3393 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3394 const ResultType_<VT> tmp( right );
3421 template<
typename MT
3423 template<
typename VT >
3424 inline Row<MT,
false,
true,
false,CRAs...>&
3434 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
3435 Right right( ~rhs );
3437 if( !tryDivAssign( matrix_, right,
row(), 0UL ) ) {
3441 decltype(
auto) left( derestrict( *this ) );
3443 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3444 const ResultType_<VT> tmp( right );
3472 template<
typename MT
3474 template<
typename VT >
3475 inline Row<MT,
false,
true,
false,CRAs...>&
3476 Row<MT,false,true,false,CRAs...>::operator%=(
const Vector<VT,true>& rhs )
3478 using blaze::assign;
3483 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
3489 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
3493 const CrossType right( *
this % (~rhs) );
3495 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
3499 decltype(
auto) left( derestrict( *this ) );
3501 assign( left, right );
3525 template< typename MT
3527 inline MT& Row<MT,false,true,false,CRAs...>::operand() noexcept
3541 template<
typename MT
3543 inline const MT& Row<MT,false,true,false,CRAs...>::operand() const noexcept
3557 template<
typename MT
3561 return matrix_.columns();
3576 template<
typename MT
3580 return matrix_.spacing();
3592 template<
typename MT
3596 return matrix_.columns();
3611 template<
typename MT
3616 size_t nonzeros( 0UL );
3618 for(
size_t j=0UL; j<
columns; ++j )
3634 template<
typename MT
3640 const size_t jbegin( ( IsUpper<MT>::value )
3641 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3645 const size_t jend ( ( IsLower<MT>::value )
3646 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3651 for(
size_t j=jbegin; j<jend; ++j )
3679 template<
typename MT
3681 template<
typename Other >
3682 inline Row<MT,
false,
true,
false,CRAs...>&
3683 Row<MT,false,true,false,CRAs...>::scale(
const Other& scalar )
3687 const size_t jbegin( ( IsUpper<MT>::value )
3688 ?( ( IsStrictlyUpper<MT>::value )
3692 const size_t jend ( ( IsLower<MT>::value )
3693 ?( ( IsStrictlyLower<MT>::value )
3698 for(
size_t j=jbegin; j<jend; ++j ) {
3699 matrix_(
row(),j) *= scalar;
3727 template<
typename MT
3729 template<
typename Other >
3730 inline bool Row<MT,false,true,false,CRAs...>::canAlias(
const Other* alias )
const noexcept
3732 return matrix_.isAliased( alias );
3749 template<
typename MT
3751 template<
typename MT2
3756 Row<MT,false,true,false,CRAs...>::canAlias(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
3758 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
3775 template<
typename MT
3777 template<
typename Other >
3778 inline bool Row<MT,false,true,false,CRAs...>::isAliased(
const Other* alias )
const noexcept
3780 return matrix_.isAliased( alias );
3797 template<
typename MT
3799 template<
typename MT2
3804 Row<MT,false,true,false,CRAs...>::isAliased(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
3806 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
3822 template<
typename MT
3824 inline bool Row<MT,false,true,false,CRAs...>::isAligned() const noexcept
3843 template<
typename MT
3845 inline bool Row<MT,false,true,false,CRAs...>::canSMPAssign() const noexcept
3847 return (
size() > SMP_DVECASSIGN_THRESHOLD );
3865 template<
typename MT
3867 template<
typename VT >
3868 inline void Row<MT,false,true,false,CRAs...>::assign(
const DenseVector<VT,true>& rhs )
3872 const size_t jpos( (~rhs).
size() &
size_t(-2) );
3873 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3874 matrix_(
row(),j ) = (~rhs)[j ];
3875 matrix_(
row(),j+1UL) = (~rhs)[j+1UL];
3877 if( jpos < (~rhs).size() )
3878 matrix_(
row(),jpos) = (~rhs)[jpos];
3896 template<
typename MT
3898 template<
typename VT >
3899 inline void Row<MT,false,true,false,CRAs...>::assign(
const SparseVector<VT,true>& rhs )
3903 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3904 matrix_(
row(),element->index()) = element->value();
3922 template<
typename MT
3924 template<
typename VT >
3925 inline void Row<MT,false,true,false,CRAs...>::addAssign(
const DenseVector<VT,true>& rhs )
3929 const size_t jpos( (~rhs).
size() &
size_t(-2) );
3930 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3931 matrix_(
row(),j ) += (~rhs)[j ];
3932 matrix_(
row(),j+1UL) += (~rhs)[j+1UL];
3934 if( jpos < (~rhs).size() )
3935 matrix_(
row(),jpos) += (~rhs)[jpos];
3953 template<
typename MT
3955 template<
typename VT >
3956 inline void Row<MT,false,true,false,CRAs...>::addAssign(
const SparseVector<VT,true>& rhs )
3960 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3961 matrix_(
row(),element->index()) += element->value();
3979 template<
typename MT
3981 template<
typename VT >
3982 inline void Row<MT,false,true,false,CRAs...>::subAssign(
const DenseVector<VT,true>& rhs )
3986 const size_t jpos( (~rhs).
size() &
size_t(-2) );
3987 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3988 matrix_(
row(),j ) -= (~rhs)[j ];
3989 matrix_(
row(),j+1UL) -= (~rhs)[j+1UL];
3991 if( jpos < (~rhs).size() )
3992 matrix_(
row(),jpos) -= (~rhs)[jpos];
4010 template<
typename MT
4012 template<
typename VT >
4013 inline void Row<MT,false,true,false,CRAs...>::subAssign(
const SparseVector<VT,true>& rhs )
4017 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
4018 matrix_(
row(),element->index()) -= element->value();
4036 template<
typename MT
4038 template<
typename VT >
4039 inline void Row<MT,false,true,false,CRAs...>::multAssign(
const DenseVector<VT,true>& rhs )
4043 const size_t jpos( (~rhs).
size() &
size_t(-2) );
4044 for(
size_t j=0UL; j<jpos; j+=2UL ) {
4045 matrix_(
row(),j ) *= (~rhs)[j ];
4046 matrix_(
row(),j+1UL) *= (~rhs)[j+1UL];
4048 if( jpos < (~rhs).size() )
4049 matrix_(
row(),jpos) *= (~rhs)[jpos];
4067 template<
typename MT
4069 template<
typename VT >
4070 inline void Row<MT,false,true,false,CRAs...>::multAssign(
const SparseVector<VT,true>& rhs )
4078 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
4079 const size_t index( element->index() );
4080 for( ; j<index; ++j )
4082 matrix_(
row(),j) *= element->value();
4086 for( ; j<
size(); ++j ) {
4106 template<
typename MT
4108 template<
typename VT >
4109 inline void Row<MT,false,true,false,CRAs...>::divAssign(
const DenseVector<VT,true>& rhs )
4113 const size_t jpos( (~rhs).
size() &
size_t(-2) );
4114 for(
size_t j=0UL; j<jpos; j+=2UL ) {
4115 matrix_(
row(),j ) /= (~rhs)[j ];
4116 matrix_(
row(),j+1UL) /= (~rhs)[j+1UL];
4118 if( jpos < (~rhs).size() )
4119 matrix_(
row(),jpos) /= (~rhs)[jpos];
4145 template<
typename MT
4147 class Row<MT,false,true,true,CRAs...>
4148 :
public View< DenseVector< Row<MT,false,true,true,CRAs...>, true > >
4149 ,
private RowData<CRAs...>
4153 using DataType = RowData<CRAs...>;
4154 using Operand = If_< IsExpression<MT>, MT, MT& >;
4160 using This = Row<MT,
false,
true,
true,CRAs...>;
4162 using BaseType = DenseVector<This,true>;
4163 using ViewedType = MT;
4166 using ElementType = ElementType_<MT>;
4167 using SIMDType = SIMDTrait_<ElementType>;
4172 using ConstReference = ConstReference_<MT>;
4178 using ConstPointer = ConstPointer_<MT>;
4181 using Pointer = If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, Pointer_<MT> >;
4184 using ConstIterator = ConstIterator_<MT>;
4192 enum :
bool { simdEnabled = MT::simdEnabled };
4195 enum :
bool { smpAssignable = MT::smpAssignable };
4201 template<
typename... RRAs >
4202 explicit inline Row( MT& matrix, RRAs... args );
4214 inline Reference operator[](
size_t index );
4215 inline ConstReference operator[](
size_t index )
const;
4217 inline ConstReference at(
size_t index )
const;
4218 inline Pointer
data () noexcept;
4219 inline ConstPointer
data () const noexcept;
4221 inline ConstIterator begin () const;
4222 inline ConstIterator
cbegin() const;
4224 inline ConstIterator end () const;
4225 inline ConstIterator
cend () const;
4232 inline Row& operator=( const ElementType& rhs );
4233 inline Row& operator=( initializer_list<ElementType> list );
4234 inline Row& operator=( const Row& rhs );
4236 template< typename VT > inline Row& operator= ( const Vector<VT,true>& rhs );
4237 template< typename VT > inline Row& operator+=( const Vector<VT,true>& rhs );
4238 template< typename VT > inline Row& operator-=( const Vector<VT,true>& rhs );
4239 template< typename VT > inline Row& operator*=( const Vector<VT,true>& rhs );
4240 template< typename VT > inline Row& operator/=( const DenseVector<VT,true>& rhs );
4241 template< typename VT > inline Row& operator%=( const Vector<VT,true>& rhs );
4248 using DataType::row;
4250 inline MT& operand() noexcept;
4251 inline const MT& operand() const noexcept;
4253 inline
size_t size() const noexcept;
4254 inline
size_t spacing() const noexcept;
4255 inline
size_t capacity() const noexcept;
4257 inline
void reset();
4264 template< typename Other > inline Row& scale( const Other& scalar );
4271 template< typename VT >
4272 struct VectorizedAssign {
4273 enum :
bool { value = useOptimizedKernels &&
4274 simdEnabled && VT::simdEnabled &&
4275 IsSIMDCombinable< ElementType, ElementType_<VT> >::value };
4281 template<
typename VT >
4282 struct VectorizedAddAssign {
4283 enum :
bool { value = useOptimizedKernels &&
4284 simdEnabled && VT::simdEnabled &&
4285 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4286 HasSIMDAdd< ElementType, ElementType_<VT> >::value };
4292 template<
typename VT >
4293 struct VectorizedSubAssign {
4294 enum :
bool { value = useOptimizedKernels &&
4295 simdEnabled && VT::simdEnabled &&
4296 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4297 HasSIMDSub< ElementType, ElementType_<VT> >::value };
4303 template<
typename VT >
4304 struct VectorizedMultAssign {
4305 enum :
bool { value = useOptimizedKernels &&
4306 simdEnabled && VT::simdEnabled &&
4307 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4308 HasSIMDMult< ElementType, ElementType_<VT> >::value };
4314 template<
typename VT >
4315 struct VectorizedDivAssign {
4316 enum :
bool { value = useOptimizedKernels &&
4317 simdEnabled && VT::simdEnabled &&
4318 IsSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4319 HasSIMDDiv< ElementType, ElementType_<VT> >::value };
4332 template<
typename Other >
4333 inline bool canAlias(
const Other* alias )
const noexcept;
4335 template<
typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
4336 inline bool canAlias(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept;
4338 template<
typename Other >
4339 inline bool isAliased(
const Other* alias )
const noexcept;
4341 template<
typename MT2,
bool SO2,
bool SF2,
size_t... CRAs2 >
4342 inline bool isAliased(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept;
4344 inline bool isAligned () const noexcept;
4345 inline
bool canSMPAssign() const noexcept;
4356 template< typename VT >
4357 inline
DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,true>& rhs );
4359 template< typename VT >
4360 inline
EnableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,true>& rhs );
4362 template< typename VT > inline
void assign( const SparseVector<VT,true>& rhs );
4364 template< typename VT >
4365 inline
DisableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,true>& rhs );
4367 template< typename VT >
4368 inline
EnableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,true>& rhs );
4370 template< typename VT > inline
void addAssign( const SparseVector<VT,true>& rhs );
4372 template< typename VT >
4373 inline
DisableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,true>& rhs );
4375 template< typename VT >
4376 inline
EnableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,true>& rhs );
4378 template< typename VT > inline
void subAssign( const SparseVector<VT,true>& rhs );
4380 template< typename VT >
4381 inline
DisableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,true>& rhs );
4383 template< typename VT >
4384 inline
EnableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,true>& rhs );
4386 template< typename VT > inline
void multAssign( const SparseVector<VT,true>& rhs );
4388 template< typename VT >
4389 inline
DisableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,true>& rhs );
4391 template< typename VT >
4392 inline
EnableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,true>& rhs );
4405 template< typename MT2,
bool SO2,
bool DF2,
bool SF2,
size_t... CRAs2 > friend class Row;
4444 template< typename MT
4446 template< typename... RRAs >
4447 inline Row<MT,false,true,true,CRAs...>::Row( MT& matrix, RRAs... args )
4448 : DataType( args... )
4449 , matrix_ ( matrix )
4451 if( !Contains< TypeList<RRAs...>,
Unchecked >::value ) {
4452 if( matrix_.rows() <=
row() ) {
4482 template<
typename MT
4484 inline typename Row<MT,
false,
true,
true,CRAs...>
::Reference 4485 Row<MT,false,true,true,CRAs...>::operator[](
size_t index )
4488 return matrix_(index,
row());
4504 template<
typename MT
4507 Row<MT,false,true,true,CRAs...>::operator[](
size_t index )
const 4510 return const_cast<const MT&
>( matrix_ )(index,
row());
4527 template<
typename MT
4529 inline typename Row<MT,
false,
true,
true,CRAs...>
::Reference 4530 Row<MT,false,true,true,CRAs...>::at(
size_t index )
4532 if( index >=
size() ) {
4535 return (*
this)[index];
4552 template<
typename MT
4555 Row<MT,false,true,true,CRAs...>::at(
size_t index )
const 4557 if( index >=
size() ) {
4560 return (*
this)[index];
4575 template<
typename MT
4577 inline typename Row<MT,
false,
true,
true,CRAs...>::Pointer
4580 return matrix_.data(
row() );
4595 template<
typename MT
4597 inline typename Row<MT,
false,
true,
true,CRAs...>::ConstPointer
4600 return matrix_.data(
row() );
4614 template<
typename MT
4616 inline typename Row<MT,
false,
true,
true,CRAs...>
::Iterator 4619 return matrix_.begin(
row() );
4633 template<
typename MT
4638 return matrix_.cbegin(
row() );
4652 template<
typename MT
4657 return matrix_.cbegin(
row() );
4671 template<
typename MT
4673 inline typename Row<MT,
false,
true,
true,CRAs...>
::Iterator 4676 return matrix_.end(
row() );
4690 template<
typename MT
4695 return matrix_.cend(
row() );
4709 template<
typename MT
4714 return matrix_.cend(
row() );
4735 template<
typename MT
4737 inline Row<MT,
false,
true,
true,CRAs...>&
4738 Row<MT,false,true,true,CRAs...>::operator=(
const ElementType& rhs )
4740 decltype(
auto) left( derestrict( matrix_ ) );
4742 const
size_t ibegin( ( IsLower<MT>::value )
4743 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4747 const
size_t iend ( ( IsUpper<MT>::value )
4748 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4753 for(
size_t i=ibegin; i<iend; ++i ) {
4754 if( !IsRestricted<MT>::value || IsTriangular<MT>::value || trySet( matrix_, i,
row(), rhs ) )
4755 left(i,
row()) = rhs;
4779 template<
typename MT
4781 inline Row<MT,
false,
true,
true,CRAs...>&
4782 Row<MT,false,true,true,CRAs...>::operator=( initializer_list<ElementType> list )
4784 if( list.size() >
size() ) {
4788 if( IsRestricted<MT>::value ) {
4789 const InitializerVector<ElementType,true> tmp( list,
size() );
4790 if( !tryAssign( matrix_, tmp,
row(), 0UL ) ) {
4795 decltype(
auto) left( derestrict( *this ) );
4797 std::fill(
std::copy( list.begin(), list.end(), left.begin() ), left.end(), ElementType() );
4821 template< typename MT
4823 inline Row<MT,false,true,true,CRAs...>&
4824 Row<MT,false,true,true,CRAs...>::operator=( const Row& rhs )
4826 if( &rhs ==
this )
return *
this;
4828 if(
size() != rhs.size() ) {
4832 if( !tryAssign( matrix_, rhs,
row(), 0UL ) ) {
4836 decltype(
auto) left( derestrict( *this ) );
4838 if( IsExpression<MT>::value && rhs.canAlias( &matrix_ ) ) {
4868 template<
typename MT
4870 template<
typename VT >
4871 inline Row<MT,
false,
true,
true,CRAs...>&
4872 Row<MT,false,true,true,CRAs...>::operator=(
const Vector<VT,true>& rhs )
4881 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
4882 Right right( ~rhs );
4884 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
4888 decltype(
auto) left( derestrict( *this ) );
4890 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4891 const ResultType_<VT> tmp( right );
4895 if( IsSparseVector<VT>::value )
4922 template<
typename MT
4924 template<
typename VT >
4925 inline Row<MT,
false,
true,
true,CRAs...>&
4935 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
4936 Right right( ~rhs );
4938 if( !tryAddAssign( matrix_, right,
row(), 0UL ) ) {
4942 decltype(
auto) left( derestrict( *this ) );
4944 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4945 const ResultType_<VT> tmp( right );
4974 template<
typename MT
4976 template<
typename VT >
4977 inline Row<MT,
false,
true,
true,CRAs...>&
4987 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
4988 Right right( ~rhs );
4990 if( !trySubAssign( matrix_, right,
row(), 0UL ) ) {
4994 decltype(
auto) left( derestrict( *this ) );
4996 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4997 const ResultType_<VT> tmp( right );
5025 template<
typename MT
5027 template<
typename VT >
5028 inline Row<MT,
false,
true,
true,CRAs...>&
5038 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
5039 Right right( ~rhs );
5041 if( !tryMultAssign( matrix_, right,
row(), 0UL ) ) {
5045 decltype(
auto) left( derestrict( *this ) );
5047 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
5048 const ResultType_<VT> tmp( right );
5075 template<
typename MT
5077 template<
typename VT >
5078 inline Row<MT,
false,
true,
true,CRAs...>&
5088 using Right = If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& >;
5089 Right right( ~rhs );
5091 if( !tryDivAssign( matrix_, right,
row(), 0UL ) ) {
5095 decltype(
auto) left( derestrict( *this ) );
5097 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
5098 const ResultType_<VT> tmp( right );
5126 template<
typename MT
5128 template<
typename VT >
5129 inline Row<MT,
false,
true,
true,CRAs...>&
5130 Row<MT,false,true,true,CRAs...>::operator%=(
const Vector<VT,true>& rhs )
5132 using blaze::assign;
5137 using CrossType = CrossTrait_< ResultType, ResultType_<VT> >;
5143 if(
size() != 3UL || (~rhs).
size() != 3UL ) {
5147 const CrossType right( *
this % (~rhs) );
5149 if( !tryAssign( matrix_, right,
row(), 0UL ) ) {
5153 decltype(
auto) left( derestrict( *this ) );
5155 assign( left, right );
5179 template< typename MT
5181 inline MT& Row<MT,false,true,true,CRAs...>::operand() noexcept
5195 template<
typename MT
5197 inline const MT& Row<MT,false,true,true,CRAs...>::operand() const noexcept
5211 template<
typename MT
5215 return matrix_.columns();
5230 template<
typename MT
5234 return matrix_.spacing();
5246 template<
typename MT
5250 return matrix_.capacity(
row() );
5265 template<
typename MT
5269 return matrix_.nonZeros(
row() );
5281 template<
typename MT
5285 matrix_.reset(
row() );
5312 template<
typename MT
5314 template<
typename Other >
5315 inline Row<MT,
false,
true,
true,CRAs...>&
5316 Row<MT,false,true,true,CRAs...>::scale(
const Other& scalar )
5320 const size_t ibegin( ( IsLower<MT>::value )
5321 ?( ( IsStrictlyLower<MT>::value )
5325 const size_t iend ( ( IsUpper<MT>::value )
5326 ?( ( IsStrictlyUpper<MT>::value )
5331 for(
size_t i=ibegin; i<iend; ++i ) {
5332 matrix_(i,
row()) *= scalar;
5360 template<
typename MT
5362 template<
typename Other >
5363 inline bool Row<MT,false,true,true,CRAs...>::canAlias(
const Other* alias )
const noexcept
5365 return matrix_.isAliased( alias );
5382 template<
typename MT
5384 template<
typename MT2
5389 Row<MT,false,true,true,CRAs...>::canAlias(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
5391 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
5408 template<
typename MT
5410 template<
typename Other >
5411 inline bool Row<MT,false,true,true,CRAs...>::isAliased(
const Other* alias )
const noexcept
5413 return matrix_.isAliased( alias );
5430 template<
typename MT
5432 template<
typename MT2
5437 Row<MT,false,true,true,CRAs...>::isAliased(
const Row<MT2,SO2,true,SF2,CRAs2...>* alias )
const noexcept
5439 return matrix_.isAliased( &alias->matrix_ ) && (
row() == alias->row() );
5455 template<
typename MT
5457 inline bool Row<MT,false,true,true,CRAs...>::isAligned() const noexcept
5459 return matrix_.isAligned();
5476 template<
typename MT
5478 inline bool Row<MT,false,true,true,CRAs...>::canSMPAssign() const noexcept
5480 return (
size() > SMP_DVECASSIGN_THRESHOLD );
5499 template<
typename MT
5502 Row<MT,false,true,true,CRAs...>::load(
size_t index )
const noexcept
5504 return matrix_.load( index,
row() );
5523 template<
typename MT
5528 return matrix_.loada( index,
row() );
5547 template<
typename MT
5552 return matrix_.loadu( index,
row() );
5572 template<
typename MT
5575 Row<MT,false,true,true,CRAs...>::store(
size_t index,
const SIMDType& value ) noexcept
5577 matrix_.store( index,
row(), value );
5597 template<
typename MT
5602 matrix_.storea( index,
row(), value );
5622 template<
typename MT
5627 matrix_.storeu( index,
row(), value );
5647 template<
typename MT
5652 matrix_.stream( index,
row(), value );
5670 template<
typename MT
5672 template<
typename VT >
5673 inline DisableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedAssign<VT> >
5674 Row<MT,false,true,true,CRAs...>::assign(
const DenseVector<VT,true>& rhs )
5678 const size_t ipos( (~rhs).
size() &
size_t(-2) );
5679 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5680 matrix_(i ,
row()) = (~rhs)[i ];
5681 matrix_(i+1UL,
row()) = (~rhs)[i+1UL];
5683 if( ipos < (~rhs).size() )
5684 matrix_(ipos,
row()) = (~rhs)[ipos];
5702 template<
typename MT
5704 template<
typename VT >
5705 inline EnableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedAssign<VT> >
5706 Row<MT,false,true,true,CRAs...>::assign(
const DenseVector<VT,true>& rhs )
5712 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5716 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
5721 ConstIterator_<VT> right( (~rhs).
begin() );
5723 if( useStreaming &&
rows > ( cacheSize/(
sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
5725 for( ; i<ipos; i+=SIMDSIZE ) {
5726 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5728 for( ; remainder && i<
rows; ++i ) {
5729 *left = *right; ++left; ++right;
5734 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5735 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5736 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5737 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5738 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5740 for( ; i<ipos; i+=SIMDSIZE ) {
5741 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5743 for( ; remainder && i<
rows; ++i ) {
5744 *left = *right; ++left; ++right;
5764 template<
typename MT
5766 template<
typename VT >
5767 inline void Row<MT,false,true,true,CRAs...>::assign(
const SparseVector<VT,true>& rhs )
5771 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5772 matrix_(element->index(),
row()) = element->value();
5790 template<
typename MT
5792 template<
typename VT >
5793 inline DisableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
5794 Row<MT,false,true,true,CRAs...>::addAssign(
const DenseVector<VT,true>& rhs )
5798 const size_t ipos( (~rhs).
size() &
size_t(-2) );
5799 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5800 matrix_(i ,
row()) += (~rhs)[i ];
5801 matrix_(i+1UL,
row()) += (~rhs)[i+1UL];
5803 if( ipos < (~rhs).size() )
5804 matrix_(ipos,
row()) += (~rhs)[ipos];
5822 template<
typename MT
5824 template<
typename VT >
5825 inline EnableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
5826 Row<MT,false,true,true,CRAs...>::addAssign(
const DenseVector<VT,true>& rhs )
5832 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5836 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
5841 ConstIterator_<VT> right( (~rhs).
begin() );
5843 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5844 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5845 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5846 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5847 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5849 for( ; i<ipos; i+=SIMDSIZE ) {
5850 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5852 for( ; remainder && i<
rows; ++i ) {
5853 *left += *right; ++left; ++right;
5872 template<
typename MT
5874 template<
typename VT >
5875 inline void Row<MT,false,true,true,CRAs...>::addAssign(
const SparseVector<VT,true>& rhs )
5879 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5880 matrix_(element->index(),
row()) += element->value();
5898 template<
typename MT
5900 template<
typename VT >
5901 inline DisableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
5902 Row<MT,false,true,true,CRAs...>::subAssign(
const DenseVector<VT,true>& rhs )
5906 const size_t ipos( (~rhs).
size() &
size_t(-2) );
5907 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5908 matrix_(i ,
row()) -= (~rhs)[i ];
5909 matrix_(i+1UL,
row()) -= (~rhs)[i+1UL];
5911 if( ipos < (~rhs).size() )
5912 matrix_(ipos,
row()) -= (~rhs)[ipos];
5930 template<
typename MT
5932 template<
typename VT >
5933 inline EnableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
5934 Row<MT,false,true,true,CRAs...>::subAssign(
const DenseVector<VT,true>& rhs )
5940 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5944 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
5949 ConstIterator_<VT> right( (~rhs).
begin() );
5951 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5952 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5953 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5954 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5955 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5957 for( ; i<ipos; i+=SIMDSIZE ) {
5958 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5960 for( ; remainder && i<
rows; ++i ) {
5961 *left -= *right; ++left; ++right;
5980 template<
typename MT
5982 template<
typename VT >
5983 inline void Row<MT,false,true,true,CRAs...>::subAssign(
const SparseVector<VT,true>& rhs )
5987 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5988 matrix_(element->index(),
row()) -= element->value();
6006 template<
typename MT
6008 template<
typename VT >
6009 inline DisableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
6010 Row<MT,false,true,true,CRAs...>::multAssign(
const DenseVector<VT,true>& rhs )
6014 const size_t ipos( (~rhs).
size() &
size_t(-2) );
6015 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6016 matrix_(i ,
row()) *= (~rhs)[i ];
6017 matrix_(i+1UL,
row()) *= (~rhs)[i+1UL];
6019 if( ipos < (~rhs).size() )
6020 matrix_(ipos,
row()) *= (~rhs)[ipos];
6038 template<
typename MT
6040 template<
typename VT >
6041 inline EnableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
6042 Row<MT,false,true,true,CRAs...>::multAssign(
const DenseVector<VT,true>& rhs )
6048 constexpr
bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
6052 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
6057 ConstIterator_<VT> right( (~rhs).
begin() );
6059 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6060 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6061 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6062 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6063 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6065 for( ; i<ipos; i+=SIMDSIZE ) {
6066 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6068 for( ; remainder && i<
rows; ++i ) {
6069 *left *= *right; ++left; ++right;
6088 template<
typename MT
6090 template<
typename VT >
6091 inline void Row<MT,false,true,true,CRAs...>::multAssign(
const SparseVector<VT,true>& rhs )
6099 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element ) {
6100 const size_t index( element->index() );
6101 for( ; i<index; ++i )
6103 matrix_(i,
row()) *= element->value();
6107 for( ; i<
size(); ++i ) {
6127 template<
typename MT
6129 template<
typename VT >
6130 inline DisableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
6131 Row<MT,false,true,true,CRAs...>::divAssign(
const DenseVector<VT,true>& rhs )
6135 const size_t ipos( (~rhs).
size() &
size_t(-2) );
6136 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6137 matrix_(i ,
row()) /= (~rhs)[i ];
6138 matrix_(i+1UL,
row()) /= (~rhs)[i+1UL];
6140 if( ipos < (~rhs).size() )
6141 matrix_(ipos,
row()) /= (~rhs)[ipos];
6159 template<
typename MT
6161 template<
typename VT >
6162 inline EnableIf_<
typename Row<MT,
false,
true,
true,CRAs...>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
6163 Row<MT,false,true,true,CRAs...>::divAssign(
const DenseVector<VT,true>& rhs )
6171 const size_t ipos(
rows &
size_t(-SIMDSIZE) );
6176 ConstIterator_<VT> right( (~rhs).
begin() );
6178 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6179 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6180 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6181 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6182 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6184 for( ; i<ipos; i+=SIMDSIZE ) {
6185 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6187 for( ; i<
rows; ++i ) {
6188 *left /= *right; ++left; ++right;
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
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:131
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the implementation of the RowData class template.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the IsUniUpper type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
Header file for the View base class.
Header file for the row trait.
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:164
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:701
EnableIf_< IsDenseVector< VT1 > > smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:193
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:60
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
Header file for the IsUniLower type trait.
typename RowTrait< MT, CRAs... >::Type RowTrait_
Auxiliary alias declaration for the RowTrait type trait.The RowTrait_ alias declaration provides a co...
Definition: RowTrait.h:145
EnableIf_< IsDenseMatrix< MT1 > > smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:133
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:474
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:408
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the implementation of the Row base template.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
Header file for the If class template.
Header file for the implementation of a vector representation of an initializer list.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
EnableIf_< IsDenseMatrix< MT1 > > smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:102
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the HasSIMDAdd type trait.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:367
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:443
Header file for the Not class template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for all SIMD functionality.
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
Constraint on the data type.
Header file for the IsTriangular type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:61
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
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:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the IsPadded type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:75
Header file for the IsSIMDCombinable type trait.
Header file for the IsSparseVector type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
Header file for the HasSIMDMult type trait.
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the cross product trait.
Header file for the Unique class template.
Check< false > Unchecked
Type of the blaze::unchecked instance.blaze::Unchecked is the type of the blaze::unchecked instance...
Definition: Check.h:96
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
EnableIf_< IsDenseVector< VT1 > > smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:222
Header file for the reset shim.
Header file for the cache size of the target architecture.
#define BLAZE_CONSTRAINT_MUST_NOT_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:79
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Constraints on the storage order of matrix types.
Header file for the HasMutableDataAccess type trait.
#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
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE EnableIf_< And< IsIntegral< T1 >, HasSize< T1, 1UL > > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:76
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
#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
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
Header file for the HasSIMDDiv type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
#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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
Header file for the IsUpper type trait.
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Header file for the IsRestricted type trait.
System settings for the inline keywords.
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
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Constraint on the data type.