35 #ifndef _BLAZE_MATH_VIEWS_COLUMN_DENSE_H_
36 #define _BLAZE_MATH_VIEWS_COLUMN_DENSE_H_
119 template<
typename MT
121 class Column<MT,true,true,SF>
122 :
public DenseVector< Column<MT,true,true,SF>, false >
128 typedef If_< IsExpression<MT>, MT, MT& > Operand;
133 typedef Column<MT,true,true,SF>
This;
134 typedef DenseVector<This,false>
BaseType;
138 typedef SIMDTrait_<ElementType> SIMDType;
149 typedef const ElementType* ConstPointer;
152 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
163 enum :
bool { simdEnabled = MT::simdEnabled };
166 enum :
bool { smpAssignable = MT::smpAssignable };
172 explicit inline Column( Operand matrix,
size_t index );
184 inline Reference operator[](
size_t index );
185 inline ConstReference operator[](
size_t index )
const;
186 inline Reference at(
size_t index );
187 inline ConstReference at(
size_t index )
const;
188 inline Pointer data () noexcept;
189 inline ConstPointer data () const noexcept;
190 inline Iterator
begin ();
191 inline ConstIterator begin () const;
192 inline ConstIterator
cbegin() const;
193 inline Iterator
end ();
194 inline ConstIterator end () const;
195 inline ConstIterator
cend () const;
202 inline Column& operator=( const ElementType& rhs );
203 inline Column& operator=( initializer_list<ElementType> list );
204 inline Column& operator=( const Column& rhs );
206 template< typename VT > inline Column& operator= ( const Vector<VT,false>& rhs );
207 template< typename VT > inline Column& operator+=( const Vector<VT,false>& rhs );
208 template< typename VT > inline Column& operator-=( const Vector<VT,false>& rhs );
209 template< typename VT > inline Column& operator*=( const DenseVector<VT,false>& rhs );
210 template< typename VT > inline Column& operator*=( const SparseVector<VT,false>& rhs );
211 template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
213 template< typename Other >
214 inline
EnableIf_< IsNumeric<Other>, Column >& operator*=( Other rhs );
216 template< typename Other >
217 inline
EnableIf_< IsNumeric<Other>, Column >& operator/=( Other rhs );
224 inline
size_t size() const noexcept;
225 inline
size_t capacity() const noexcept;
228 template< typename Other > inline Column& scale( const Other& scalar );
235 template< typename VT >
236 struct VectorizedAssign {
238 simdEnabled && VT::simdEnabled &&
239 AreSIMDCombinable< ElementType, ElementType_<VT> >::value };
245 template<
typename VT >
246 struct VectorizedAddAssign {
248 simdEnabled && VT::simdEnabled &&
249 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
250 HasSIMDAdd< ElementType, ElementType_<VT> >::value };
256 template<
typename VT >
257 struct VectorizedSubAssign {
259 simdEnabled && VT::simdEnabled &&
260 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
261 HasSIMDSub< ElementType, ElementType_<VT> >::value };
267 template<
typename VT >
268 struct VectorizedMultAssign {
270 simdEnabled && VT::simdEnabled &&
271 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
272 HasSIMDMult< ElementType, ElementType_<VT> >::value };
278 template<
typename VT >
279 struct VectorizedDivAssign {
281 simdEnabled && VT::simdEnabled &&
282 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
283 HasSIMDDiv< ElementType, ElementType_<VT> >::value };
296 template<
typename Other >
297 inline bool canAlias(
const Other* alias )
const noexcept;
299 template<
typename MT2,
bool SO2,
bool SF2 >
300 inline bool canAlias(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept;
302 template<
typename Other >
303 inline bool isAliased(
const Other* alias )
const noexcept;
305 template<
typename MT2,
bool SO2,
bool SF2 >
306 inline bool isAliased(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept;
308 inline bool isAligned () const noexcept;
309 inline
bool canSMPAssign() const noexcept;
320 template< typename VT >
321 inline
DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,false>& rhs );
323 template< typename VT >
324 inline
EnableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,false>& rhs );
326 template< typename VT > inline
void assign( const SparseVector<VT,false>& rhs );
328 template< typename VT >
329 inline
DisableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,false>& rhs );
331 template< typename VT >
332 inline
EnableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,false>& rhs );
334 template< typename VT > inline
void addAssign( const SparseVector<VT,false>& rhs );
336 template< typename VT >
337 inline
DisableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,false>& rhs );
339 template< typename VT >
340 inline
EnableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,false>& rhs );
342 template< typename VT > inline
void subAssign( const SparseVector<VT,false>& rhs );
344 template< typename VT >
345 inline
DisableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,false>& rhs );
347 template< typename VT >
348 inline
EnableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,false>& rhs );
350 template< typename VT > inline
void multAssign( const SparseVector<VT,false>& rhs );
352 template< typename VT >
353 inline
DisableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,false>& rhs );
355 template< typename VT >
356 inline
EnableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,false>& rhs );
370 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 > friend class Column;
372 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
373 friend
bool isIntact( const Column<MT2,SO2,DF2,SF2>&
column ) noexcept;
375 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
376 friend
bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
378 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
379 friend
bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
381 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
382 friend
bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
384 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
385 friend
bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
387 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
388 friend
bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
390 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
391 friend
bool tryDivAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
393 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
426 template< typename MT
428 inline Column<MT,true,true,SF>::Column( Operand matrix,
size_t index )
432 if( matrix_.columns() <= index ) {
458 template<
typename MT
463 return matrix_(index,col_);
479 template<
typename MT
482 Column<MT,true,true,SF>::operator[](
size_t index )
const
485 return const_cast<const MT&
>( matrix_ )(index,col_);
502 template<
typename MT
506 if( index >=
size() ) {
509 return (*
this)[index];
526 template<
typename MT
529 Column<MT,true,true,SF>::at(
size_t index )
const
531 if( index >=
size() ) {
534 return (*
this)[index];
549 template<
typename MT
551 inline typename Column<MT,true,true,SF>::Pointer Column<MT,true,true,SF>::data() noexcept
553 return matrix_.data( col_ );
568 template<
typename MT
570 inline typename Column<MT,true,true,SF>::ConstPointer Column<MT,true,true,SF>::data() const noexcept
572 return matrix_.data( col_ );
586 template<
typename MT
590 return matrix_.begin( col_ );
604 template<
typename MT
608 return matrix_.cbegin( col_ );
622 template<
typename MT
626 return matrix_.cbegin( col_ );
640 template<
typename MT
644 return matrix_.end( col_ );
658 template<
typename MT
662 return matrix_.cend( col_ );
676 template<
typename MT
680 return matrix_.cend( col_ );
705 template<
typename MT
707 inline Column<MT,true,true,SF>& Column<MT,true,true,SF>::operator=(
const ElementType& rhs )
709 const size_t ibegin( ( IsLower<MT>::value )
710 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
714 const size_t iend ( ( IsUpper<MT>::value )
715 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
720 for(
size_t i=ibegin; i<iend; ++i )
721 matrix_(i,col_) = rhs;
742 template<
typename MT
744 inline Column<MT,true,true,SF>& Column<MT,true,true,SF>::operator=( initializer_list<ElementType> list )
746 if( list.size() >
size() ) {
774 template<
typename MT
776 inline Column<MT,true,true,SF>& Column<MT,true,true,SF>::operator=(
const Column& rhs )
778 if( &rhs ==
this )
return *
this;
780 if(
size() != rhs.size() ) {
784 if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
788 DerestrictTrait_<This> left( derestrict( *
this ) );
814 template<
typename MT
816 template<
typename VT >
817 inline Column<MT,true,true,SF>& Column<MT,true,true,SF>::operator=(
const Vector<VT,false>& rhs )
826 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
829 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
833 DerestrictTrait_<This> left( derestrict( *
this ) );
835 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
836 const ResultType_<VT> tmp( right );
840 if( IsSparseVector<VT>::value )
867 template<
typename MT
869 template<
typename VT >
879 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
882 if( !tryAddAssign( matrix_, right, 0UL, col_ ) ) {
886 DerestrictTrait_<This> left( derestrict( *
this ) );
888 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
889 const ResultType_<VT> tmp( right );
918 template<
typename MT
920 template<
typename VT >
930 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
933 if( !trySubAssign( matrix_, right, 0UL, col_ ) ) {
937 DerestrictTrait_<This> left( derestrict( *
this ) );
939 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
940 const ResultType_<VT> tmp( right );
968 template<
typename MT
970 template<
typename VT >
980 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
983 if( !tryMultAssign( matrix_, right, 0UL, col_ ) ) {
987 DerestrictTrait_<This> left( derestrict( *
this ) );
989 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
990 const ResultType_<VT> tmp( right );
1018 template<
typename MT
1020 template<
typename VT >
1031 const ResultType right( *
this * (~rhs) );
1033 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
1037 DerestrictTrait_<This> left( derestrict( *
this ) );
1061 template<
typename MT
1063 template<
typename VT >
1073 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
1074 Right right( ~rhs );
1076 if( !tryDivAssign( matrix_, right, 0UL, col_ ) ) {
1080 DerestrictTrait_<This> left( derestrict( *
this ) );
1082 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1083 const ResultType_<VT> tmp( right );
1109 template<
typename MT
1111 template<
typename Other >
1112 inline EnableIf_< IsNumeric<Other>, Column<MT,true,true,SF> >&
1117 return operator=( (*
this) * rhs );
1136 template<
typename MT
1138 template<
typename Other >
1139 inline EnableIf_< IsNumeric<Other>, Column<MT,true,true,SF> >&
1146 return operator=( (*
this) / rhs );
1166 template<
typename MT
1170 return matrix_.rows();
1182 template<
typename MT
1186 return matrix_.capacity( col_ );
1201 template<
typename MT
1205 return matrix_.nonZeros( col_ );
1217 template<
typename MT
1221 matrix_.reset( col_ );
1238 template<
typename MT
1240 template<
typename Other >
1241 inline Column<MT,true,true,SF>& Column<MT,true,true,SF>::scale(
const Other& scalar )
1245 const size_t ibegin( ( IsLower<MT>::value )
1246 ?( ( IsStrictlyLower<MT>::value )
1250 const size_t iend ( ( IsUpper<MT>::value )
1251 ?( ( IsStrictlyUpper<MT>::value )
1256 for(
size_t i=ibegin; i<iend; ++i ) {
1257 matrix_(i,col_) *= scalar;
1285 template<
typename MT
1287 template<
typename Other >
1288 inline bool Column<MT,true,true,SF>::canAlias(
const Other* alias )
const noexcept
1290 return matrix_.isAliased( alias );
1307 template<
typename MT
1309 template<
typename MT2
1312 inline bool Column<MT,true,true,SF>::canAlias(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
1314 return matrix_.isAliased( alias->matrix_ ) && ( col_ == alias->col_ );
1331 template<
typename MT
1333 template<
typename Other >
1334 inline bool Column<MT,true,true,SF>::isAliased(
const Other* alias )
const noexcept
1336 return matrix_.isAliased( alias );
1353 template<
typename MT
1355 template<
typename MT2
1358 inline bool Column<MT,true,true,SF>::isAliased(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
1360 return matrix_.isAliased( &alias->matrix_ ) && ( col_ == alias->col_ );
1376 template<
typename MT
1378 inline bool Column<MT,true,true,SF>::isAligned() const noexcept
1380 return matrix_.isAligned();
1397 template<
typename MT
1399 inline bool Column<MT,true,true,SF>::canSMPAssign() const noexcept
1401 return (
size() > SMP_DVECASSIGN_THRESHOLD );
1419 template<
typename MT
1422 Column<MT,true,true,SF>::load(
size_t index )
const noexcept
1424 return matrix_.load( index, col_ );
1443 template<
typename MT
1448 return matrix_.loada( index, col_ );
1467 template<
typename MT
1472 return matrix_.loadu( index, col_ );
1491 template<
typename MT
1494 Column<MT,true,true,SF>::store(
size_t index,
const SIMDType& value ) noexcept
1496 matrix_.store( index, col_, value );
1516 template<
typename MT
1521 matrix_.storea( index, col_, value );
1541 template<
typename MT
1546 matrix_.storeu( index, col_, value );
1566 template<
typename MT
1571 matrix_.stream( index, col_, value );
1589 template<
typename MT
1591 template<
typename VT >
1592 inline DisableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedAssign<VT> >
1593 Column<MT,true,true,SF>::assign(
const DenseVector<VT,false>& rhs )
1597 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1598 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1599 matrix_(i ,col_) = (~rhs)[i ];
1600 matrix_(i+1UL,col_) = (~rhs)[i+1UL];
1602 if( ipos < (~rhs).size() )
1603 matrix_(ipos,col_) = (~rhs)[ipos];
1621 template<
typename MT
1623 template<
typename VT >
1624 inline EnableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedAssign<VT> >
1625 Column<MT,true,true,SF>::assign(
const DenseVector<VT,false>& rhs )
1631 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1634 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
1638 Iterator left(
begin() );
1639 ConstIterator_<VT> right( (~rhs).
begin() );
1643 for( ; i<ipos; i+=SIMDSIZE ) {
1644 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1646 for( ; remainder && i<
rows; ++i ) {
1647 *left = *right; ++left; ++right;
1652 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
1653 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1654 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1655 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1656 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1658 for( ; i<ipos; i+=SIMDSIZE ) {
1659 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1661 for( ; remainder && i<
rows; ++i ) {
1662 *left = *right; ++left; ++right;
1682 template<
typename MT
1684 template<
typename VT >
1685 inline void Column<MT,true,true,SF>::assign(
const SparseVector<VT,false>& rhs )
1689 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1690 matrix_(element->index(),col_) = element->value();
1708 template<
typename MT
1710 template<
typename VT >
1711 inline DisableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
1712 Column<MT,true,true,SF>::addAssign(
const DenseVector<VT,false>& rhs )
1716 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1717 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1718 matrix_(i ,col_) += (~rhs)[i ];
1719 matrix_(i+1UL,col_) += (~rhs)[i+1UL];
1721 if( ipos < (~rhs).size() )
1722 matrix_(ipos,col_) += (~rhs)[ipos];
1740 template<
typename MT
1742 template<
typename VT >
1743 inline EnableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
1744 Column<MT,true,true,SF>::addAssign(
const DenseVector<VT,false>& rhs )
1750 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1753 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
1757 Iterator left(
begin() );
1758 ConstIterator_<VT> right( (~rhs).
begin() );
1760 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
1761 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1762 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1763 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1764 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1766 for( ; i<ipos; i+=SIMDSIZE ) {
1767 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1769 for( ; remainder && i<
rows; ++i ) {
1770 *left += *right; ++left; ++right;
1789 template<
typename MT
1791 template<
typename VT >
1792 inline void Column<MT,true,true,SF>::addAssign(
const SparseVector<VT,false>& rhs )
1796 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1797 matrix_(element->index(),col_) += element->value();
1815 template<
typename MT
1817 template<
typename VT >
1818 inline DisableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
1819 Column<MT,true,true,SF>::subAssign(
const DenseVector<VT,false>& rhs )
1823 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1824 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1825 matrix_(i ,col_) -= (~rhs)[i ];
1826 matrix_(i+1UL,col_) -= (~rhs)[i+1UL];
1828 if( ipos < (~rhs).size() )
1829 matrix_(ipos,col_) -= (~rhs)[ipos];
1847 template<
typename MT
1849 template<
typename VT >
1850 inline EnableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
1851 Column<MT,true,true,SF>::subAssign(
const DenseVector<VT,false>& rhs )
1857 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1860 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
1864 Iterator left(
begin() );
1865 ConstIterator_<VT> right( (~rhs).
begin() );
1867 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
1868 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1869 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1870 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1871 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1873 for( ; i<ipos; i+=SIMDSIZE ) {
1874 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1876 for( ; remainder && i<
rows; ++i ) {
1877 *left -= *right; ++left; ++right;
1896 template<
typename MT
1898 template<
typename VT >
1899 inline void Column<MT,true,true,SF>::subAssign(
const SparseVector<VT,false>& rhs )
1903 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
1904 matrix_(element->index(),col_) -= element->value();
1922 template<
typename MT
1924 template<
typename VT >
1925 inline DisableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
1926 Column<MT,true,true,SF>::multAssign(
const DenseVector<VT,false>& rhs )
1930 const size_t ipos( (~rhs).
size() &
size_t(-2) );
1931 for(
size_t i=0UL; i<ipos; i+=2UL ) {
1932 matrix_(i ,col_) *= (~rhs)[i ];
1933 matrix_(i+1UL,col_) *= (~rhs)[i+1UL];
1935 if( ipos < (~rhs).size() )
1936 matrix_(ipos,col_) *= (~rhs)[ipos];
1954 template<
typename MT
1956 template<
typename VT >
1957 inline EnableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
1958 Column<MT,true,true,SF>::multAssign(
const DenseVector<VT,false>& rhs )
1964 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1967 const size_t ipos( ( remainder )?(
rows &
size_t(-SIMDSIZE) ):(
rows ) );
1971 Iterator left(
begin() );
1972 ConstIterator_<VT> right( (~rhs).
begin() );
1974 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
1975 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1976 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1977 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1978 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1980 for( ; i<ipos; i+=SIMDSIZE ) {
1981 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
1983 for( ; remainder && i<
rows; ++i ) {
1984 *left *= *right; ++left, ++right;
2003 template<
typename MT
2005 template<
typename VT >
2006 inline void Column<MT,true,true,SF>::multAssign(
const SparseVector<VT,false>& rhs )
2010 const ResultType tmp(
serial( *
this ) );
2014 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
2015 matrix_(element->index(),col_) = tmp[element->index()] * element->value();
2033 template<
typename MT
2035 template<
typename VT >
2036 inline DisableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2037 Column<MT,true,true,SF>::divAssign(
const DenseVector<VT,false>& rhs )
2041 const size_t ipos( (~rhs).
size() &
size_t(-2) );
2042 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2043 matrix_(i ,col_) /= (~rhs)[i ];
2044 matrix_(i+1UL,col_) /= (~rhs)[i+1UL];
2046 if( ipos < (~rhs).size() )
2047 matrix_(ipos,col_) /= (~rhs)[ipos];
2065 template<
typename MT
2067 template<
typename VT >
2068 inline EnableIf_< typename Column<MT,true,true,SF>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
2069 Column<MT,true,true,SF>::divAssign(
const DenseVector<VT,false>& rhs )
2077 const size_t ipos(
rows &
size_t(-SIMDSIZE) );
2081 Iterator left(
begin() );
2082 ConstIterator_<VT> right( (~rhs).
begin() );
2084 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
2085 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2086 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2087 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2088 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2090 for( ; i<ipos; i+=SIMDSIZE ) {
2091 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2093 for( ; i<
rows; ++i ) {
2094 *left /= *right; ++left; ++right;
2121 template<
typename MT >
2122 class Column<MT,false,true,false>
2123 :
public DenseVector< Column<MT,false,true,false>, false >
2129 typedef If_< IsExpression<MT>, MT, MT& > Operand;
2134 typedef Column<MT,false,true,false>
This;
2135 typedef DenseVector<This,false>
BaseType;
2149 typedef const ElementType* ConstPointer;
2152 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
2158 template<
typename MatrixType >
2159 class ColumnIterator
2164 typedef If_< IsConst<MatrixType>, ConstReference_<MatrixType>, Reference_<MatrixType> >
Reference;
2166 typedef std::random_access_iterator_tag IteratorCategory;
2167 typedef RemoveReference_<Reference> ValueType;
2168 typedef ValueType* PointerType;
2169 typedef Reference ReferenceType;
2170 typedef ptrdiff_t DifferenceType;
2173 typedef IteratorCategory iterator_category;
2174 typedef ValueType value_type;
2175 typedef PointerType pointer;
2176 typedef ReferenceType reference;
2177 typedef DifferenceType difference_type;
2183 inline ColumnIterator() noexcept
2184 : matrix_(
nullptr )
2197 inline ColumnIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
2198 : matrix_( &matrix )
2209 template<
typename MatrixType2 >
2210 inline ColumnIterator(
const ColumnIterator<MatrixType2>& it ) noexcept
2211 : matrix_( it.matrix_ )
2213 , column_( it.column_ )
2223 inline ColumnIterator&
operator+=(
size_t inc ) noexcept {
2235 inline ColumnIterator&
operator-=(
size_t dec ) noexcept {
2246 inline ColumnIterator& operator++() noexcept {
2257 inline const ColumnIterator operator++(
int ) noexcept {
2258 const ColumnIterator tmp( *
this );
2269 inline ColumnIterator& operator--() noexcept {
2280 inline const ColumnIterator operator--(
int ) noexcept {
2281 const ColumnIterator tmp( *
this );
2293 inline ReferenceType operator[](
size_t index )
const {
2294 return (*matrix_)(row_+index,column_);
2303 inline ReferenceType
operator*()
const {
2304 return (*matrix_)(row_,column_);
2313 inline PointerType operator->()
const {
2314 return &(*matrix_)(row_,column_);
2324 template<
typename MatrixType2 >
2325 inline bool operator==(
const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2326 return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2336 template<
typename MatrixType2 >
2337 inline bool operator!=(
const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2338 return !( *
this == rhs );
2348 template<
typename MatrixType2 >
2349 inline bool operator<( const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2350 return ( matrix_ == rhs.matrix_ ) && ( row_ < rhs.row_ ) && ( column_ == rhs.column_ );
2360 template<
typename MatrixType2 >
2361 inline bool operator>(
const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2362 return ( matrix_ == rhs.matrix_ ) && ( row_ > rhs.row_ ) && ( column_ == rhs.column_ );
2372 template<
typename MatrixType2 >
2373 inline bool operator<=( const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2374 return ( matrix_ == rhs.matrix_ ) && ( row_ <= rhs.row_ ) && ( column_ == rhs.column_ );
2384 template<
typename MatrixType2 >
2385 inline bool operator>=(
const ColumnIterator<MatrixType2>& rhs )
const noexcept {
2386 return ( matrix_ == rhs.matrix_ ) && ( row_ >= rhs.row_ ) && ( column_ == rhs.column_ );
2396 inline DifferenceType
operator-(
const ColumnIterator& rhs )
const noexcept {
2397 return row_ - rhs.row_;
2408 friend inline const ColumnIterator
operator+(
const ColumnIterator& it,
size_t inc ) noexcept {
2409 return ColumnIterator( *it.matrix_, it.row_+inc, it.column_ );
2420 friend inline const ColumnIterator
operator+(
size_t inc,
const ColumnIterator& it ) noexcept {
2421 return ColumnIterator( *it.matrix_, it.row_+inc, it.column_ );
2432 friend inline const ColumnIterator
operator-(
const ColumnIterator& it,
size_t dec ) noexcept {
2433 return ColumnIterator( *it.matrix_, it.row_-dec, it.column_ );
2439 MatrixType* matrix_;
2445 template<
typename MatrixType2 >
friend class ColumnIterator;
2460 enum :
bool { simdEnabled =
false };
2463 enum :
bool { smpAssignable = MT::smpAssignable };
2469 explicit inline Column( Operand matrix,
size_t index );
2481 inline Reference operator[](
size_t index );
2482 inline ConstReference operator[](
size_t index )
const;
2483 inline Reference at(
size_t index );
2484 inline ConstReference at(
size_t index )
const;
2485 inline Pointer data () noexcept;
2486 inline ConstPointer data () const noexcept;
2487 inline Iterator
begin ();
2488 inline ConstIterator begin () const;
2489 inline ConstIterator
cbegin() const;
2490 inline Iterator
end ();
2491 inline ConstIterator end () const;
2492 inline ConstIterator
cend () const;
2499 inline Column& operator=( const ElementType& rhs );
2500 inline Column& operator=( initializer_list<ElementType> list );
2501 inline Column& operator=( const Column& rhs );
2503 template< typename VT > inline Column& operator= ( const Vector<VT,false>& rhs );
2504 template< typename VT > inline Column& operator+=( const Vector<VT,false>& rhs );
2505 template< typename VT > inline Column& operator-=( const Vector<VT,false>& rhs );
2506 template< typename VT > inline Column& operator*=( const DenseVector<VT,false>& rhs );
2507 template< typename VT > inline Column& operator*=( const SparseVector<VT,false>& rhs );
2508 template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
2510 template< typename Other >
2511 inline
EnableIf_< IsNumeric<Other>, Column >& operator*=( Other rhs );
2513 template< typename Other >
2514 inline
EnableIf_< IsNumeric<Other>, Column >& operator/=( Other rhs );
2521 inline
size_t size() const noexcept;
2522 inline
size_t capacity() const noexcept;
2524 inline
void reset();
2525 template< typename Other > inline Column& scale( const Other& scalar );
2533 template< typename Other >
2534 inline
bool canAlias ( const Other* alias ) const noexcept;
2536 template< typename MT2,
bool SO2,
bool SF2 >
2537 inline
bool canAlias ( const Column<MT2,SO2,true,SF2>* alias ) const noexcept;
2539 template< typename Other >
2540 inline
bool isAliased( const Other* alias ) const noexcept;
2542 template< typename MT2,
bool SO2,
bool SF2 >
2543 inline
bool isAliased( const Column<MT2,SO2,true,SF2>* alias ) const noexcept;
2545 inline
bool isAligned () const noexcept;
2546 inline
bool canSMPAssign() const noexcept;
2548 template< typename VT > inline
void assign ( const DenseVector <VT,false>& rhs );
2549 template< typename VT > inline
void assign ( const SparseVector<VT,false>& rhs );
2550 template< typename VT > inline
void addAssign ( const DenseVector <VT,false>& rhs );
2551 template< typename VT > inline
void addAssign ( const SparseVector<VT,false>& rhs );
2552 template< typename VT > inline
void subAssign ( const DenseVector <VT,false>& rhs );
2553 template< typename VT > inline
void subAssign ( const SparseVector<VT,false>& rhs );
2554 template< typename VT > inline
void multAssign( const DenseVector <VT,false>& rhs );
2555 template< typename VT > inline
void multAssign( const SparseVector<VT,false>& rhs );
2556 template< typename VT > inline
void divAssign ( const DenseVector <VT,false>& rhs );
2570 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 > friend class Column;
2572 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2573 friend
bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
2575 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2576 friend
bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
2578 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2579 friend
bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
2581 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2582 friend
bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
2584 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2585 friend
bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
2587 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2588 friend
bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
2590 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
2591 friend
bool tryDivAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
2593 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
2594 friend
DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
2627 template< typename MT >
2628 inline Column<MT,false,true,false>::Column( Operand matrix,
size_t index )
2632 if( matrix_.columns() <= index ) {
2658 template<
typename MT >
2660 Column<MT,false,true,false>::operator[](
size_t index )
2663 return matrix_(index,col_);
2679 template<
typename MT >
2681 Column<MT,false,true,false>::operator[](
size_t index )
const
2684 return const_cast<const MT&
>( matrix_ )(index,col_);
2701 template<
typename MT >
2703 Column<MT,false,true,false>::at(
size_t index )
2705 if( index >=
size() ) {
2708 return (*
this)[index];
2725 template<
typename MT >
2727 Column<MT,false,true,false>::at(
size_t index )
const
2729 if( index >=
size() ) {
2732 return (*
this)[index];
2747 template<
typename MT >
2748 inline typename Column<MT,false,true,false>::Pointer Column<MT,false,true,false>::data() noexcept
2750 return matrix_.data() + col_;
2765 template<
typename MT >
2766 inline typename Column<MT,false,true,false>::ConstPointer Column<MT,false,true,false>::data() const noexcept
2768 return matrix_.data() + col_;
2782 template<
typename MT >
2785 return Iterator( matrix_, 0UL, col_ );
2799 template<
typename MT >
2817 template<
typename MT >
2835 template<
typename MT >
2852 template<
typename MT >
2870 template<
typename MT >
2899 template<
typename MT >
2900 inline Column<MT,false,true,false>&
2901 Column<MT,false,true,false>::operator=(
const ElementType& rhs )
2903 const size_t ibegin( ( IsLower<MT>::value )
2904 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
2908 const size_t iend ( ( IsUpper<MT>::value )
2909 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
2914 for(
size_t i=ibegin; i<iend; ++i )
2915 matrix_(i,col_) = rhs;
2936 template<
typename MT >
2937 inline Column<MT,false,true,false>&
2938 Column<MT,false,true,false>::operator=( initializer_list<ElementType> list )
2940 if( list.size() >
size() ) {
2968 template<
typename MT >
2969 inline Column<MT,false,true,false>&
2970 Column<MT,false,true,false>::operator=(
const Column& rhs )
2972 if( &rhs ==
this )
return *
this;
2974 if(
size() != rhs.size() ) {
2978 if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
2982 DerestrictTrait_<This> left( derestrict( *
this ) );
3008 template<
typename MT >
3009 template<
typename VT >
3010 inline Column<MT,false,true,false>&
3011 Column<MT,false,true,false>::operator=(
const Vector<VT,false>& rhs )
3021 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
3022 Right right( ~rhs );
3024 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
3028 DerestrictTrait_<This> left( derestrict( *
this ) );
3030 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3031 const ResultType tmp( right );
3035 if( IsSparseVector<VT>::value )
3062 template<
typename MT >
3063 template<
typename VT >
3064 inline Column<MT,false,true,false>&
3074 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
3075 Right right( ~rhs );
3077 if( !tryAddAssign( matrix_, right, 0UL, col_ ) ) {
3081 DerestrictTrait_<This> left( derestrict( *
this ) );
3083 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3084 const ResultType_<VT> tmp( right );
3113 template<
typename MT >
3114 template<
typename VT >
3115 inline Column<MT,false,true,false>&
3125 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
3126 Right right( ~rhs );
3128 if( !trySubAssign( matrix_, right, 0UL, col_ ) ) {
3132 DerestrictTrait_<This> left( derestrict( *
this ) );
3134 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3135 const ResultType_<VT> tmp( right );
3163 template<
typename MT >
3164 template<
typename VT >
3165 inline Column<MT,false,true,false>&
3175 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
3176 Right right( ~rhs );
3178 if( !tryMultAssign( matrix_, right, 0UL, col_ ) ) {
3182 DerestrictTrait_<This> left( derestrict( *
this ) );
3184 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3185 const ResultType_<VT> tmp( right );
3213 template<
typename MT >
3214 template<
typename VT >
3215 inline Column<MT,false,true,false>&
3226 const ResultType right( *
this * (~rhs) );
3228 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
3232 DerestrictTrait_<This> left( derestrict( *
this ) );
3256 template<
typename MT >
3257 template<
typename VT >
3258 inline Column<MT,false,true,false>&
3268 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
3269 Right right( ~rhs );
3271 if( !tryDivAssign( matrix_, right, 0UL, col_ ) ) {
3275 DerestrictTrait_<This> left( derestrict( *
this ) );
3277 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3278 const ResultType_<VT> tmp( right );
3304 template<
typename MT >
3305 template<
typename Other >
3306 inline EnableIf_< IsNumeric<Other>, Column<MT,false,true,false> >&
3311 return operator=( (*
this) * rhs );
3330 template<
typename MT >
3331 template<
typename Other >
3332 inline EnableIf_< IsNumeric<Other>, Column<MT,false,true,false> >&
3339 return operator=( (*
this) / rhs );
3359 template<
typename MT >
3362 return matrix_.rows();
3374 template<
typename MT >
3377 return matrix_.rows();
3392 template<
typename MT >
3396 size_t nonzeros( 0UL );
3398 for(
size_t i=0UL; i<
rows; ++i )
3414 template<
typename MT >
3419 const size_t ibegin( ( IsLower<MT>::value )
3420 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3424 const size_t iend ( ( IsUpper<MT>::value )
3425 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3430 for(
size_t i=ibegin; i<iend; ++i )
3431 clear( matrix_(i,col_) );
3448 template<
typename MT >
3449 template<
typename Other >
3450 inline Column<MT,false,true,false>& Column<MT,false,true,false>::scale(
const Other& scalar )
3454 const size_t ibegin( ( IsLower<MT>::value )
3455 ?( ( IsStrictlyLower<MT>::value )
3459 const size_t iend ( ( IsUpper<MT>::value )
3460 ?( ( IsStrictlyUpper<MT>::value )
3465 for(
size_t i=ibegin; i<iend; ++i ) {
3466 matrix_(i,col_) *= scalar;
3494 template<
typename MT >
3495 template<
typename Other >
3496 inline bool Column<MT,false,true,false>::canAlias(
const Other* alias )
const noexcept
3498 return matrix_.isAliased( alias );
3515 template<
typename MT >
3516 template<
typename MT2
3519 inline bool Column<MT,false,true,false>::canAlias(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
3521 return matrix_.isAliased( &alias->matrix_ ) && ( col_ == alias->col_ );
3538 template<
typename MT >
3539 template<
typename Other >
3540 inline bool Column<MT,false,true,false>::isAliased(
const Other* alias )
const noexcept
3542 return matrix_.isAliased( alias );
3559 template<
typename MT >
3560 template<
typename MT2
3563 inline bool Column<MT,false,true,false>::isAliased(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
3565 return matrix_.isAliased( &alias->matrix_ ) && ( col_ == alias->col_ );
3581 template<
typename MT >
3582 inline bool Column<MT,false,true,false>::isAligned() const noexcept
3601 template<
typename MT >
3602 inline bool Column<MT,false,true,false>::canSMPAssign() const noexcept
3604 return (
size() > SMP_DVECASSIGN_THRESHOLD );
3622 template<
typename MT >
3623 template<
typename VT >
3624 inline void Column<MT,false,true,false>::assign(
const DenseVector<VT,false>& rhs )
3628 const size_t ipos( (~rhs).
size() &
size_t(-2) );
3629 for(
size_t i=0UL; i<ipos; i+=2UL ) {
3630 matrix_(i ,col_) = (~rhs)[i ];
3631 matrix_(i+1UL,col_) = (~rhs)[i+1UL];
3633 if( ipos < (~rhs).size() )
3634 matrix_(ipos,col_) = (~rhs)[ipos];
3652 template<
typename MT >
3653 template<
typename VT >
3654 inline void Column<MT,false,true,false>::assign(
const SparseVector<VT,false>& rhs )
3658 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3659 matrix_(element->index(),col_) = element->value();
3677 template<
typename MT >
3678 template<
typename VT >
3679 inline void Column<MT,false,true,false>::addAssign(
const DenseVector<VT,false>& rhs )
3683 const size_t ipos( (~rhs).
size() &
size_t(-2) );
3684 for(
size_t i=0UL; i<ipos; i+=2UL ) {
3685 matrix_(i ,col_) += (~rhs)[i ];
3686 matrix_(i+1UL,col_) += (~rhs)[i+1UL];
3688 if( ipos < (~rhs).size() )
3689 matrix_(ipos,col_) += (~rhs)[ipos];
3707 template<
typename MT >
3708 template<
typename VT >
3709 inline void Column<MT,false,true,false>::addAssign(
const SparseVector<VT,false>& rhs )
3713 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3714 matrix_(element->index(),col_) += element->value();
3732 template<
typename MT >
3733 template<
typename VT >
3734 inline void Column<MT,false,true,false>::subAssign(
const DenseVector<VT,false>& rhs )
3738 const size_t ipos( (~rhs).
size() &
size_t(-2) );
3739 for(
size_t i=0UL; i<ipos; i+=2UL ) {
3740 matrix_(i ,col_) -= (~rhs)[i ];
3741 matrix_(i+1UL,col_) -= (~rhs)[i+1UL];
3743 if( ipos < (~rhs).size() )
3744 matrix_(ipos,col_) -= (~rhs)[ipos];
3762 template<
typename MT >
3763 template<
typename VT >
3764 inline void Column<MT,false,true,false>::subAssign(
const SparseVector<VT,false>& rhs )
3768 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3769 matrix_(element->index(),col_) -= element->value();
3787 template<
typename MT >
3788 template<
typename VT >
3789 inline void Column<MT,false,true,false>::multAssign(
const DenseVector<VT,false>& rhs )
3793 const size_t ipos( (~rhs).
size() &
size_t(-2) );
3794 for(
size_t i=0UL; i<ipos; i+=2UL ) {
3795 matrix_(i ,col_) *= (~rhs)[i ];
3796 matrix_(i+1UL,col_) *= (~rhs)[i+1UL];
3798 if( ipos < (~rhs).size() )
3799 matrix_(ipos,col_) *= (~rhs)[ipos];
3817 template<
typename MT >
3818 template<
typename VT >
3819 inline void Column<MT,false,true,false>::multAssign(
const SparseVector<VT,false>& rhs )
3823 const ResultType tmp(
serial( *
this ) );
3827 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
3828 matrix_(element->index(),col_) = tmp[element->index()] * element->value();
3846 template<
typename MT >
3847 template<
typename VT >
3848 inline void Column<MT,false,true,false>::divAssign(
const DenseVector<VT,false>& rhs )
3852 const size_t ipos( (~rhs).
size() &
size_t(-2) );
3853 for(
size_t i=0UL; i<ipos; i+=2UL ) {
3854 matrix_(i ,col_) /= (~rhs)[i ];
3855 matrix_(i+1UL,col_) /= (~rhs)[i+1UL];
3857 if( ipos < (~rhs).size() )
3858 matrix_(ipos,col_) /= (~rhs)[ipos];
3884 template<
typename MT >
3885 class Column<MT,false,true,true>
3886 :
public DenseVector< Column<MT,false,true,true>, false >
3892 typedef If_< IsExpression<MT>, MT, MT& > Operand;
3897 typedef Column<MT,false,true,true>
This;
3898 typedef DenseVector<This,false>
BaseType;
3902 typedef SIMDTrait_<ElementType> SIMDType;
3913 typedef const ElementType* ConstPointer;
3916 typedef If_< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >, ConstPointer, ElementType* > Pointer;
3927 enum :
bool { simdEnabled = MT::simdEnabled };
3930 enum :
bool { smpAssignable = MT::smpAssignable };
3936 explicit inline Column( Operand matrix,
size_t index );
3948 inline Reference operator[](
size_t index );
3949 inline ConstReference operator[](
size_t index )
const;
3950 inline Reference at(
size_t index );
3951 inline ConstReference at(
size_t index )
const;
3952 inline Pointer data () noexcept;
3953 inline ConstPointer data () const noexcept;
3954 inline Iterator begin ();
3955 inline ConstIterator begin () const;
3956 inline ConstIterator
cbegin() const;
3957 inline Iterator end ();
3958 inline ConstIterator end () const;
3959 inline ConstIterator
cend () const;
3966 inline Column& operator=( const ElementType& rhs );
3967 inline Column& operator=( initializer_list<ElementType> list );
3968 inline Column& operator=( const Column& rhs );
3970 template< typename VT > inline Column& operator= ( const Vector<VT,false>& rhs );
3971 template< typename VT > inline Column& operator+=( const Vector<VT,false>& rhs );
3972 template< typename VT > inline Column& operator-=( const Vector<VT,false>& rhs );
3973 template< typename VT > inline Column& operator*=( const DenseVector<VT,false>& rhs );
3974 template< typename VT > inline Column& operator*=( const SparseVector<VT,false>& rhs );
3975 template< typename VT > inline Column& operator/=( const DenseVector<VT,false>& rhs );
3977 template< typename Other >
3978 inline
EnableIf_< IsNumeric<Other>, Column >& operator*=( Other rhs );
3980 template< typename Other >
3981 inline
EnableIf_< IsNumeric<Other>, Column >& operator/=( Other rhs );
3988 inline
size_t size() const noexcept;
3989 inline
size_t capacity() const noexcept;
3991 inline
void reset();
3992 template< typename Other > inline Column& scale( const Other& scalar );
3999 template< typename VT >
4000 struct VectorizedAssign {
4002 simdEnabled && VT::simdEnabled &&
4003 AreSIMDCombinable< ElementType, ElementType_<VT> >::value };
4009 template<
typename VT >
4010 struct VectorizedAddAssign {
4012 simdEnabled && VT::simdEnabled &&
4013 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4014 HasSIMDAdd< ElementType, ElementType_<VT> >::value };
4020 template<
typename VT >
4021 struct VectorizedSubAssign {
4023 simdEnabled && VT::simdEnabled &&
4024 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4025 HasSIMDSub< ElementType, ElementType_<VT> >::value };
4031 template<
typename VT >
4032 struct VectorizedMultAssign {
4034 simdEnabled && VT::simdEnabled &&
4035 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4036 HasSIMDMult< ElementType, ElementType_<VT> >::value };
4042 template<
typename VT >
4043 struct VectorizedDivAssign {
4045 simdEnabled && VT::simdEnabled &&
4046 AreSIMDCombinable< ElementType, ElementType_<VT> >::value &&
4047 HasSIMDDiv< ElementType, ElementType_<VT> >::value };
4060 template<
typename Other >
4061 inline bool canAlias(
const Other* alias )
const noexcept;
4063 template<
typename MT2,
bool SO2,
bool SF2 >
4064 inline bool canAlias(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept;
4066 template<
typename Other >
4067 inline bool isAliased(
const Other* alias )
const noexcept;
4069 template<
typename MT2,
bool SO2,
bool SF2 >
4070 inline bool isAliased(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept;
4072 inline bool isAligned () const noexcept;
4073 inline
bool canSMPAssign() const noexcept;
4084 template< typename VT >
4085 inline
DisableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,false>& rhs );
4087 template< typename VT >
4088 inline
EnableIf_< VectorizedAssign<VT> > assign( const DenseVector<VT,false>& rhs );
4090 template< typename VT > inline
void assign( const SparseVector<VT,false>& rhs );
4092 template< typename VT >
4093 inline
DisableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,false>& rhs );
4095 template< typename VT >
4096 inline
EnableIf_< VectorizedAddAssign<VT> > addAssign( const DenseVector<VT,false>& rhs );
4098 template< typename VT > inline
void addAssign( const SparseVector<VT,false>& rhs );
4100 template< typename VT >
4101 inline
DisableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,false>& rhs );
4103 template< typename VT >
4104 inline
EnableIf_< VectorizedSubAssign<VT> > subAssign( const DenseVector<VT,false>& rhs );
4106 template< typename VT > inline
void subAssign( const SparseVector<VT,false>& rhs );
4108 template< typename VT >
4109 inline
DisableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,false>& rhs );
4111 template< typename VT >
4112 inline
EnableIf_< VectorizedMultAssign<VT> > multAssign( const DenseVector<VT,false>& rhs );
4114 template< typename VT > inline
void multAssign( const SparseVector<VT,false>& rhs );
4116 template< typename VT >
4117 inline
DisableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,false>& rhs );
4119 template< typename VT >
4120 inline
EnableIf_< VectorizedDivAssign<VT> > divAssign( const DenseVector<VT,false>& rhs );
4134 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 > friend class Column;
4136 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4137 friend
bool isIntact( const Column<MT2,SO2,DF2,SF2>& column ) noexcept;
4139 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4140 friend
bool isSame( const Column<MT2,SO2,DF2,SF2>& a, const Column<MT2,SO2,DF2,SF2>& b ) noexcept;
4142 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4143 friend
bool tryAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
4145 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4146 friend
bool tryAddAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
4148 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4149 friend
bool trySubAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
4151 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4152 friend
bool tryMultAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
4154 template< typename MT2,
bool SO2,
bool DF2,
bool SF2, typename VT >
4155 friend
bool tryDivAssign( const Column<MT2,SO2,DF2,SF2>& lhs, const Vector<VT,false>& rhs,
size_t index );
4157 template< typename MT2,
bool SO2,
bool DF2,
bool SF2 >
4158 friend
DerestrictTrait_< Column<MT2,SO2,DF2,SF2> > derestrict( Column<MT2,SO2,DF2,SF2>& column );
4191 template< typename MT >
4192 inline Column<MT,false,true,true>::Column( Operand matrix,
size_t index )
4196 if( matrix_.columns() <= index ) {
4222 template<
typename MT >
4224 Column<MT,false,true,true>::operator[](
size_t index )
4227 return matrix_(col_,index);
4243 template<
typename MT >
4245 Column<MT,false,true,true>::operator[](
size_t index )
const
4248 return const_cast<const MT&
>( matrix_ )(index,col_);
4265 template<
typename MT >
4267 Column<MT,false,true,true>::at(
size_t index )
4269 if( index >=
size() ) {
4272 return (*
this)[index];
4289 template<
typename MT >
4291 Column<MT,false,true,true>::at(
size_t index )
const
4293 if( index >=
size() ) {
4296 return (*
this)[index];
4311 template<
typename MT >
4312 inline typename Column<MT,false,true,true>::Pointer Column<MT,false,true,true>::data() noexcept
4314 return matrix_.data( col_ );
4329 template<
typename MT >
4330 inline typename Column<MT,false,true,true>::ConstPointer
4331 Column<MT,false,true,true>::data() const noexcept
4333 return matrix_.data( col_ );
4347 template<
typename MT >
4350 return matrix_.begin( col_ );
4364 template<
typename MT >
4367 return matrix_.cbegin( col_ );
4381 template<
typename MT >
4384 return matrix_.cbegin( col_ );
4398 template<
typename MT >
4401 return matrix_.end( col_ );
4415 template<
typename MT >
4418 return matrix_.cend( col_ );
4432 template<
typename MT >
4435 return matrix_.cend( col_ );
4456 template<
typename MT >
4457 inline Column<MT,false,true,true>& Column<MT,false,true,true>::operator=(
const ElementType& rhs )
4459 const size_t jbegin( ( IsUpper<MT>::value )
4460 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4464 const size_t jend ( ( IsLower<MT>::value )
4465 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4470 for(
size_t j=jbegin; j<jend; ++j )
4471 matrix_(col_,j) = rhs;
4492 template<
typename MT >
4493 inline Column<MT,false,true,true>&
4494 Column<MT,false,true,true>::operator=( initializer_list<ElementType> list )
4496 if( list.size() >
size() ) {
4524 template<
typename MT >
4525 inline Column<MT,false,true,true>& Column<MT,false,true,true>::operator=(
const Column& rhs )
4527 if( &rhs ==
this )
return *
this;
4529 if(
size() != rhs.size() ) {
4533 if( !tryAssign( matrix_, rhs, 0UL, col_ ) ) {
4537 DerestrictTrait_<This> left( derestrict( *
this ) );
4563 template<
typename MT >
4564 template<
typename VT >
4565 inline Column<MT,false,true,true>&
4566 Column<MT,false,true,true>::operator=(
const Vector<VT,false>& rhs )
4575 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4576 Right right( ~rhs );
4578 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4582 DerestrictTrait_<This> left( derestrict( *
this ) );
4584 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4585 const ResultType_<VT> tmp( right );
4589 if( IsSparseVector<VT>::value )
4616 template<
typename MT >
4617 template<
typename VT >
4618 inline Column<MT,false,true,true>&
4628 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4629 Right right( ~rhs );
4631 if( !tryAddAssign( matrix_, right, 0UL, col_ ) ) {
4635 DerestrictTrait_<This> left( derestrict( *
this ) );
4637 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4638 const ResultType_<VT> tmp( right );
4667 template<
typename MT >
4668 template<
typename VT >
4669 inline Column<MT,false,true,true>&
4679 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4680 Right right( ~rhs );
4682 if( !trySubAssign( matrix_, right, 0UL, col_ ) ) {
4686 DerestrictTrait_<This> left( derestrict( *
this ) );
4688 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4689 const ResultType_<VT> tmp( right );
4717 template<
typename MT >
4718 template<
typename VT >
4719 inline Column<MT,false,true,true>&
4729 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4730 Right right( ~rhs );
4732 if( !tryMultAssign( matrix_, right, 0UL, col_ ) ) {
4736 DerestrictTrait_<This> left( derestrict( *
this ) );
4738 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4739 const ResultType_<VT> tmp( right );
4767 template<
typename MT >
4768 template<
typename VT >
4769 inline Column<MT,false,true,true>&
4780 const ResultType right( *
this * (~rhs) );
4782 if( !tryAssign( matrix_, right, 0UL, col_ ) ) {
4786 DerestrictTrait_<This> left( derestrict( *
this ) );
4810 template<
typename MT >
4811 template<
typename VT >
4812 inline Column<MT,false,true,true>&
4822 typedef If_< IsRestricted<MT>, CompositeType_<VT>,
const VT& > Right;
4823 Right right( ~rhs );
4825 if( !tryDivAssign( matrix_, right, 0UL, col_ ) ) {
4829 DerestrictTrait_<This> left( derestrict( *
this ) );
4831 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4832 const ResultType_<VT> tmp( right );
4858 template<
typename MT >
4859 template<
typename Other >
4860 inline EnableIf_< IsNumeric<Other>, Column<MT,false,true,true> >&
4865 return operator=( (*
this) * rhs );
4884 template<
typename MT >
4885 template<
typename Other >
4886 inline EnableIf_< IsNumeric<Other>, Column<MT,false,true,true> >&
4893 return operator=( (*
this) / rhs );
4913 template<
typename MT >
4916 return matrix_.rows();
4928 template<
typename MT >
4931 return matrix_.capacity( col_ );
4946 template<
typename MT >
4949 return matrix_.nonZeros( col_ );
4961 template<
typename MT >
4964 matrix_.reset( col_ );
4981 template<
typename MT >
4982 template<
typename Other >
4983 inline Column<MT,false,true,true>& Column<MT,false,true,true>::scale(
const Other& scalar )
4987 const size_t jbegin( ( IsUpper<MT>::value )
4988 ?( ( IsStrictlyUpper<MT>::value )
4992 const size_t jend ( ( IsLower<MT>::value )
4993 ?( ( IsStrictlyLower<MT>::value )
4998 for(
size_t j=jbegin; j<jend; ++j ) {
4999 matrix_(col_,j) *= scalar;
5027 template<
typename MT >
5028 template<
typename Other >
5029 inline bool Column<MT,false,true,true>::canAlias(
const Other* alias )
const noexcept
5031 return matrix_.isAliased( alias );
5048 template<
typename MT >
5049 template<
typename MT2
5052 inline bool Column<MT,false,true,true>::canAlias(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
5054 return matrix_.isAliased( alias->matrix_ ) && ( col_ == alias->col_ );
5071 template<
typename MT >
5072 template<
typename Other >
5073 inline bool Column<MT,false,true,true>::isAliased(
const Other* alias )
const noexcept
5075 return matrix_.isAliased( alias );
5092 template<
typename MT >
5093 template<
typename MT2
5096 inline bool Column<MT,false,true,true>::isAliased(
const Column<MT2,SO2,true,SF2>* alias )
const noexcept
5098 return matrix_.isAliased( &alias->matrix_ ) && ( col_ == alias->col_ );
5114 template<
typename MT >
5115 inline bool Column<MT,false,true,true>::isAligned() const noexcept
5117 return matrix_.isAligned();
5134 template<
typename MT >
5135 inline bool Column<MT,false,true,true>::canSMPAssign() const noexcept
5137 return (
size() > SMP_DVECASSIGN_THRESHOLD );
5155 template<
typename MT >
5157 Column<MT,false,true,true>::load(
size_t index )
const noexcept
5159 return matrix_.load( col_, index );
5178 template<
typename MT >
5182 return matrix_.loada( col_, index );
5201 template<
typename MT >
5205 return matrix_.loadu( col_, index );
5224 template<
typename MT >
5226 Column<MT,false,true,true>::store(
size_t index,
const SIMDType& value ) noexcept
5228 matrix_.store( col_, index, value );
5248 template<
typename MT >
5252 matrix_.storea( col_, index, value );
5272 template<
typename MT >
5276 matrix_.storeu( col_, index, value );
5296 template<
typename MT >
5300 matrix_.stream( col_, index, value );
5318 template<
typename MT >
5319 template<
typename VT >
5320 inline DisableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedAssign<VT> >
5321 Column<MT,false,true,true>::assign(
const DenseVector<VT,false>& rhs )
5325 const size_t jpos( (~rhs).
size() &
size_t(-2) );
5326 for(
size_t j=0UL; j<jpos; j+=2UL ) {
5327 matrix_(col_,j ) = (~rhs)[j ];
5328 matrix_(col_,j+1UL) = (~rhs)[j+1UL];
5330 if( jpos < (~rhs).size() )
5331 matrix_(col_,jpos) = (~rhs)[jpos];
5349 template<
typename MT >
5350 template<
typename VT >
5351 inline EnableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedAssign<VT> >
5352 Column<MT,false,true,true>::assign(
const DenseVector<VT,false>& rhs )
5358 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5361 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
5365 Iterator left(
begin() );
5366 ConstIterator_<VT> right( (~rhs).
begin() );
5370 for( ; j<jpos; j+=SIMDSIZE ) {
5371 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5373 for( ; remainder && j<
columns; ++j ) {
5374 *left = *right; ++left; ++right;
5379 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
5380 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5381 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5382 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5383 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5385 for( ; j<jpos; j+=SIMDSIZE ) {
5386 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5388 for( ; remainder && j<
columns; ++j ) {
5389 *left = *right; ++left; ++right;
5409 template<
typename MT >
5410 template<
typename VT >
5411 inline void Column<MT,false,true,true>::assign(
const SparseVector<VT,false>& rhs )
5415 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5416 matrix_(col_,element->index()) = element->value();
5434 template<
typename MT >
5435 template<
typename VT >
5436 inline DisableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
5437 Column<MT,false,true,true>::addAssign(
const DenseVector<VT,false>& rhs )
5441 const size_t jpos( (~rhs).
size() &
size_t(-2) );
5442 for(
size_t j=0UL; j<jpos; j+=2UL ) {
5443 matrix_(col_,j ) += (~rhs)[j ];
5444 matrix_(col_,j+1UL) += (~rhs)[j+1UL];
5446 if( jpos < (~rhs).size() )
5447 matrix_(col_,jpos) += (~rhs)[jpos];
5465 template<
typename MT >
5466 template<
typename VT >
5467 inline EnableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >
5468 Column<MT,false,true,true>::addAssign(
const DenseVector<VT,false>& rhs )
5474 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5477 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
5481 Iterator left(
begin() );
5482 ConstIterator_<VT> right( (~rhs).
begin() );
5484 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
5485 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5486 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5487 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5488 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5490 for( ; j<jpos; j+=SIMDSIZE ) {
5491 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5493 for( ; remainder && j<
columns; ++j ) {
5494 *left += *right; ++left; ++right;
5513 template<
typename MT >
5514 template<
typename VT >
5515 inline void Column<MT,false,true,true>::addAssign(
const SparseVector<VT,false>& rhs )
5519 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5520 matrix_(col_,element->index()) += element->value();
5538 template<
typename MT >
5539 template<
typename VT >
5540 inline DisableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
5541 Column<MT,false,true,true>::subAssign(
const DenseVector<VT,false>& rhs )
5545 const size_t jpos( (~rhs).
size() &
size_t(-2) );
5546 for(
size_t j=0UL; j<jpos; j+=2UL ) {
5547 matrix_(col_,j ) -= (~rhs)[j ];
5548 matrix_(col_,j+1UL) -= (~rhs)[j+1UL];
5550 if( jpos < (~rhs).size() )
5551 matrix_(col_,jpos) -= (~rhs)[jpos];
5569 template<
typename MT >
5570 template<
typename VT >
5571 inline EnableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >
5572 Column<MT,false,true,true>::subAssign(
const DenseVector<VT,false>& rhs )
5578 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5581 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
5585 Iterator left(
begin() );
5586 ConstIterator_<VT> right( (~rhs).
begin() );
5588 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
5589 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5590 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5591 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5592 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5594 for( ; j<jpos; j+=SIMDSIZE ) {
5595 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5597 for( ; remainder && j<
columns; ++j ) {
5598 *left -= *right; ++left; ++right;
5617 template<
typename MT >
5618 template<
typename VT >
5619 inline void Column<MT,false,true,true>::subAssign(
const SparseVector<VT,false>& rhs )
5623 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5624 matrix_(col_,element->index()) -= element->value();
5642 template<
typename MT >
5643 template<
typename VT >
5644 inline DisableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
5645 Column<MT,false,true,true>::multAssign(
const DenseVector<VT,false>& rhs )
5649 const size_t jpos( (~rhs).
size() &
size_t(-2) );
5650 for(
size_t j=0UL; j<jpos; j+=2UL ) {
5651 matrix_(col_,j ) *= (~rhs)[j ];
5652 matrix_(col_,j+1UL) *= (~rhs)[j+1UL];
5654 if( jpos < (~rhs).size() )
5655 matrix_(col_,jpos) *= (~rhs)[jpos];
5673 template<
typename MT >
5674 template<
typename VT >
5675 inline EnableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >
5676 Column<MT,false,true,true>::multAssign(
const DenseVector<VT,false>& rhs )
5682 const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5685 const size_t jpos( ( remainder )?(
columns &
size_t(-SIMDSIZE) ):(
columns ) );
5689 Iterator left(
begin() );
5690 ConstIterator_<VT> right( (~rhs).
begin() );
5692 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
5693 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5694 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5695 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5696 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5698 for( ; j<jpos; j+=SIMDSIZE ) {
5699 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5701 for( ; remainder && j<
columns; ++j ) {
5702 *left *= *right; ++left; ++right;
5721 template<
typename MT >
5722 template<
typename VT >
5723 inline void Column<MT,false,true,true>::multAssign(
const SparseVector<VT,false>& rhs )
5727 const ResultType tmp(
serial( *
this ) );
5731 for( ConstIterator_<VT> element=(~rhs).
begin(); element!=(~rhs).
end(); ++element )
5732 matrix_(col_,element->index()) = tmp[element->index()] * element->value();
5750 template<
typename MT >
5751 template<
typename VT >
5752 inline DisableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
5753 Column<MT,false,true,true>::divAssign(
const DenseVector<VT,false>& rhs )
5757 const size_t jpos( (~rhs).
size() &
size_t(-2) );
5758 for(
size_t j=0UL; j<jpos; j+=2UL ) {
5759 matrix_(col_,j ) /= (~rhs)[j ];
5760 matrix_(col_,j+1UL) /= (~rhs)[j+1UL];
5762 if( jpos < (~rhs).size() )
5763 matrix_(col_,jpos) /= (~rhs)[jpos];
5781 template<
typename MT >
5782 template<
typename VT >
5783 inline EnableIf_< typename Column<MT,false,true,true>::BLAZE_TEMPLATE VectorizedDivAssign<VT> >
5784 Column<MT,false,true,true>::divAssign(
const DenseVector<VT,false>& rhs )
5792 const size_t jpos(
columns &
size_t(-SIMDSIZE) );
5796 Iterator left(
begin() );
5797 ConstIterator_<VT> right( (~rhs).
begin() );
5799 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
5800 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5801 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5802 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5803 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5805 for( ; j<jpos; j+=SIMDSIZE ) {
5806 left.store( left.load() / right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5809 *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.
constexpr bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#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.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
Header file for the View base class.
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
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: ColumnVector.h:61
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:160
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
#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
constexpr size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
#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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
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:188
Header file for the implementation of the Column base template.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
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:699
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
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:223
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
Header file for the DenseVector base class.
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#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
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:442
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
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:384
#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:731
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
System settings for performance optimizations.
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
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.
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:129
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
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:298
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Header file for the std::initializer_list aliases.
Constraint on the transpose flag of vector types.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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.
constexpr bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Optimizations.h:68
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#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:98
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.
Header file for the Not class template.
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:330
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.
#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
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
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:553
Header file for the IsPadded type trait.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
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 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.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
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:1285
Header file for run time assertion macros.
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 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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the column trait.
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.
#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:223
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:314
#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
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
Header file for the AreSIMDCombinable type trait.
Header file for the HasSIMDDiv type trait.
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
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:1303
Header file for the IsUpper type trait.
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
Header file for the TrueType type/value trait base class.
Header file for the IsExpression type trait class.