35#ifndef _BLAZE_MATH_DENSE_CUSTOMVECTOR_H_
36#define _BLAZE_MATH_DENSE_CUSTOMVECTOR_H_
399template<
typename Type
406 :
public DenseVector< CustomVector<Type,AF,PF,TF,Tag,RT>, TF >
437 template<
typename NewType >
447 template<
size_t NewN >
511 template< typename Other,
size_t Dim >
512 inline
CustomVector& operator=( const Other (&array)[Dim] );
514 template< typename Other,
size_t Dim >
515 inline
CustomVector& operator=( const std::array<Other,Dim>& array );
524 template< typename VT > inline
CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
532 inline
size_t size() const noexcept;
545 template< typename Other > inline
CustomVector& scale( const Other& scalar );
561 template< typename VT >
562 static constexpr
bool VectorizedAssign_v =
563 ( useOptimizedKernels &&
572 template< typename VT >
573 static constexpr
bool VectorizedAddAssign_v =
574 ( VectorizedAssign_v<VT> &&
582 template< typename VT >
583 static constexpr
bool VectorizedSubAssign_v =
584 ( VectorizedAssign_v<VT> &&
592 template< typename VT >
593 static constexpr
bool VectorizedMultAssign_v =
594 ( VectorizedAssign_v<VT> &&
602 template< typename VT >
603 static constexpr
bool VectorizedDivAssign_v =
604 ( VectorizedAssign_v<VT> &&
618 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
619 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
633 template< typename VT >
636 template< typename VT >
637 inline auto
assign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedAssign_v<VT> >;
641 template< typename VT >
644 template< typename VT >
649 template< typename VT >
652 template< typename VT >
657 template< typename VT >
660 template< typename VT >
665 template< typename VT >
668 template< typename VT >
709template< typename
Type
740template<
typename Type
750 if( ptr ==
nullptr ) {
783template<
typename Type
807template<
typename Type
825template<
typename Type
854template<
typename Type
888template<
typename Type
912template<
typename Type
937template<
typename Type
946 if( index >=
size_ ) {
949 return (*
this)[index];
964template<
typename Type
973 if( index >=
size_ ) {
976 return (*
this)[index];
988template<
typename Type
1009template<
typename Type
1028template<
typename Type
1047template<
typename Type
1066template<
typename Type
1085template<
typename Type
1104template<
typename Type
1123template<
typename Type
1151template<
typename Type
1160 for(
size_t i=0UL; i<
size_; ++i )
1191template<
typename Type
1200 if( list.size() >
size_ ) {
1204 std::fill( std::copy( list.begin(), list.end(),
v_ ),
v_+
size_,
Type() );
1239template<
typename Type
1245template<
typename Other
1250 if(
size_ != Dim ) {
1254 for(
size_t i=0UL; i<Dim; ++i )
1290template<
typename Type
1296template<
typename Other
1301 if(
size_ != Dim ) {
1305 for(
size_t i=0UL; i<Dim; ++i )
1323template<
typename Type
1349template<
typename Type
1381template<
typename Type
1387template<
typename VT >
1393 if( (*rhs).size() !=
size_ ) {
1397 if( (*rhs).canAlias(
this ) ) {
1422template<
typename Type
1428template<
typename VT >
1434 if( (*rhs).size() !=
size_ ) {
1438 if( (*rhs).canAlias(
this ) ) {
1462template<
typename Type
1468template<
typename VT >
1474 if( (*rhs).size() !=
size_ ) {
1478 if( (*rhs).canAlias(
this ) ) {
1502template<
typename Type
1508template<
typename VT >
1522 if( (*rhs).size() !=
size_ ) {
1527 const MultType tmp( *
this * (*rhs) );
1551template<
typename Type
1557template<
typename VT >
1559 CustomVector<Type,AF,PF,TF,Tag,RT>::operator/=(
const DenseVector<VT,TF>& rhs )
1572 if( (*rhs).size() !=
size_ ) {
1576 if( (*rhs).canAlias(
this ) ) {
1577 const DivType tmp( *
this / (*rhs) );
1600template<
typename Type
1606template<
typename VT >
1610 using blaze::assign;
1623 if(
size_ != 3UL || (*rhs).size() != 3UL ) {
1627 const CrossType tmp( *
this % (*rhs) );
1648template<
typename Type
1669template<
typename Type
1687template<
typename Type
1709template<
typename Type
1717 size_t nonzeros( 0 );
1719 for(
size_t i=0UL; i<
size_; ++i ) {
1734template<
typename Type
1743 for(
size_t i=0UL; i<
size_; ++i )
1757template<
typename Type
1777template<
typename Type
1822template<
typename Type
1828template<
typename Other >
1830 CustomVector<Type,AF,PF,TF,Tag,RT>::scale(
const Other& scalar )
1832 for(
size_t i=0UL; i<
size_; ++i )
1869template<
typename Type
1908template<
typename Type
1941template<
typename Type
1947template<
typename Other >
1950 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
1965template<
typename Type
1971template<
typename Other >
1974 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
1988template<
typename Type
2011template<
typename Type
2019 return (
size() > SMP_DVECASSIGN_THRESHOLD );
2036template<
typename Type
2046 return loada( index );
2048 return loadu( index );
2066template<
typename Type
2102template<
typename Type
2136template<
typename Type
2166template<
typename Type
2202template<
typename Type
2237template<
typename Type
2271template<
typename Type
2277template<
typename VT >
2286 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2287 v_[i ] = (*rhs)[i ];
2288 v_[i+1UL] = (*rhs)[i+1UL];
2290 if( ipos < (*rhs).size() )
2291 v_[ipos] = (*rhs)[ipos];
2307template<
typename Type
2313template<
typename VT >
2324 if( AF && useStreaming &&
size_ > ( cacheSize/(
sizeof(
Type) * 3UL ) ) && !(*rhs).isAliased(
this ) )
2329 stream( i, (*rhs).load(i) );
2331 for( ; i<
size_; ++i ) {
2343 for( ; i<i4way; i+=
SIMDSIZE*4UL ) {
2350 store( i, it.load() );
2352 for( ; i<
size_; ++i, ++it ) {
2371template<
typename Type
2377template<
typename VT >
2382 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2383 v_[element->index()] = element->value();
2399template<
typename Type
2405template<
typename VT >
2414 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2415 v_[i ] += (*rhs)[i ];
2416 v_[i+1UL] += (*rhs)[i+1UL];
2418 if( ipos < (*rhs).size() )
2419 v_[ipos] += (*rhs)[ipos];
2435template<
typename Type
2441template<
typename VT >
2458 for( ; i<i4way; i+=
SIMDSIZE*4UL ) {
2467 for( ; i<
size_; ++i, ++it ) {
2485template<
typename Type
2491template<
typename VT >
2496 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2497 v_[element->index()] += element->value();
2513template<
typename Type
2519template<
typename VT >
2528 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2529 v_[i ] -= (*rhs)[i ];
2530 v_[i+1UL] -= (*rhs)[i+1UL];
2532 if( ipos < (*rhs).size() )
2533 v_[ipos] -= (*rhs)[ipos];
2549template<
typename Type
2555template<
typename VT >
2572 for( ; i<i4way; i+=
SIMDSIZE*4UL ) {
2581 for( ; i<
size_; ++i, ++it ) {
2599template<
typename Type
2605template<
typename VT >
2610 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2611 v_[element->index()] -= element->value();
2627template<
typename Type
2633template<
typename VT >
2642 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2643 v_[i ] *= (*rhs)[i ];
2644 v_[i+1UL] *= (*rhs)[i+1UL];
2646 if( ipos < (*rhs).size() )
2647 v_[ipos] *= (*rhs)[ipos];
2663template<
typename Type
2669template<
typename VT >
2686 for( ; i<i4way; i+=
SIMDSIZE*4UL ) {
2695 for( ; i<
size_; ++i, ++it ) {
2713template<
typename Type
2719template<
typename VT >
2728 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
2729 v_[element->index()] = tmp[element->index()] * element->value();
2745template<
typename Type
2751template<
typename VT >
2760 for(
size_t i=0UL; i<ipos; i+=2UL ) {
2761 v_[i ] /= (*rhs)[i ];
2762 v_[i+1UL] /= (*rhs)[i+1UL];
2764 if( ipos < (*rhs).size() )
2765 v_[ipos] /= (*rhs)[ipos];
2781template<
typename Type
2787template<
typename VT >
2804 for( ; i<i4way; i+=
SIMDSIZE*4UL ) {
2813 for( ; i<
size_; ++i, ++it ) {
2840template<
typename Type
2846 :
public DenseVector< CustomVector<Type,AF,padded,TF,Tag,RT>, TF >
2877 template<
typename NewType >
2887 template<
size_t NewN >
2889 using RRT = Resize_t<RT,NewN>;
2948 inline
CustomVector& operator=( initializer_list<Type> list );
2950 template< typename Other,
size_t Dim >
2951 inline
CustomVector& operator=( const Other (&array)[Dim] );
2953 template< typename Other,
size_t Dim >
2954 inline
CustomVector& operator=( const std::array<Other,Dim>& array );
2959 template< typename VT > inline
CustomVector& operator= ( const Vector<VT,TF>& rhs );
2960 template< typename VT > inline
CustomVector& operator+=( const Vector<VT,TF>& rhs );
2961 template< typename VT > inline
CustomVector& operator-=( const Vector<VT,TF>& rhs );
2962 template< typename VT > inline
CustomVector& operator*=( const Vector<VT,TF>& rhs );
2963 template< typename VT > inline
CustomVector& operator/=( const DenseVector<VT,TF>& rhs );
2964 template< typename VT > inline
CustomVector& operator%=( const Vector<VT,TF>& rhs );
2971 inline
size_t size() const noexcept;
2972 inline
size_t spacing() const noexcept;
2973 inline
size_t capacity() const noexcept;
2975 inline
void reset();
2976 inline
void clear();
2984 template< typename Other > inline
CustomVector& scale( const Other& scalar );
2991 inline
void reset( Type* ptr,
size_t n,
size_t nn );
2998 template< typename VT >
2999 static constexpr
bool VectorizedAssign_v =
3000 ( useOptimizedKernels &&
3007 template< typename VT >
3008 static constexpr
bool VectorizedAddAssign_v =
3009 ( VectorizedAssign_v<VT> &&
3015 template< typename VT >
3016 static constexpr
bool VectorizedSubAssign_v =
3017 ( VectorizedAssign_v<VT> &&
3023 template< typename VT >
3024 static constexpr
bool VectorizedMultAssign_v =
3025 ( VectorizedAssign_v<VT> &&
3031 template< typename VT >
3032 static constexpr
bool VectorizedDivAssign_v =
3033 ( VectorizedAssign_v<VT> &&
3046 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
3047 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
3049 inline
bool isAligned () const noexcept;
3061 template< typename VT >
3062 inline auto
assign( const DenseVector<VT,TF>& rhs ) ->
DisableIf_t< VectorizedAssign_v<VT> >;
3064 template< typename VT >
3065 inline auto
assign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedAssign_v<VT> >;
3067 template< typename VT > inline
void assign( const SparseVector<VT,TF>& rhs );
3069 template< typename VT >
3070 inline auto
addAssign( const DenseVector<VT,TF>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<VT> >;
3072 template< typename VT >
3073 inline auto
addAssign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<VT> >;
3075 template< typename VT > inline
void addAssign( const SparseVector<VT,TF>& rhs );
3077 template< typename VT >
3078 inline auto
subAssign( const DenseVector<VT,TF>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<VT> >;
3080 template< typename VT >
3081 inline auto
subAssign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<VT> >;
3083 template< typename VT > inline
void subAssign( const SparseVector<VT,TF>& rhs );
3085 template< typename VT >
3086 inline auto
multAssign( const DenseVector<VT,TF>& rhs ) ->
DisableIf_t< VectorizedMultAssign_v<VT> >;
3088 template< typename VT >
3089 inline auto
multAssign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedMultAssign_v<VT> >;
3091 template< typename VT > inline
void multAssign( const SparseVector<VT,TF>& rhs );
3093 template< typename VT >
3094 inline auto
divAssign( const DenseVector<VT,TF>& rhs ) ->
DisableIf_t< VectorizedDivAssign_v<VT> >;
3096 template< typename VT >
3097 inline auto
divAssign( const DenseVector<VT,TF>& rhs ) ->
EnableIf_t< VectorizedDivAssign_v<VT> >;
3138template< typename Type
3174template<
typename Type
3186 if( ptr ==
nullptr ) {
3199 for(
size_t i=
size_; i<capacity_; ++i )
3215template<
typename Type
3222 , capacity_( v.capacity_ )
3235template<
typename Type
3242 , capacity_( v.capacity_ )
3267template<
typename Type
3302template<
typename Type
3327template<
typename Type
3353template<
typename Type
3361 if( index >= size_ ) {
3364 return (*
this)[index];
3381template<
typename Type
3389 if( index >= size_ ) {
3392 return (*
this)[index];
3406template<
typename Type
3428template<
typename Type
3448template<
typename Type
3456 return Iterator( v_ );
3468template<
typename Type
3476 return ConstIterator( v_ );
3488template<
typename Type
3496 return ConstIterator( v_ );
3508template<
typename Type
3516 return Iterator( v_+size_ );
3528template<
typename Type
3536 return ConstIterator( v_+size_ );
3548template<
typename Type
3556 return ConstIterator( v_+size_ );
3577template<
typename Type
3585 for(
size_t i=0UL; i<size_; ++i )
3618template<
typename Type
3626 if( list.size() > size_ ) {
3630 std::fill( std::copy( list.begin(), list.end(), v_ ), v_+capacity_,
Type() );
3667template<
typename Type
3672template<
typename Other
3677 if( size_ != Dim ) {
3681 for(
size_t i=0UL; i<Dim; ++i )
3719template<
typename Type
3724template<
typename Other
3729 if( size_ != Dim ) {
3733 for(
size_t i=0UL; i<Dim; ++i )
3753template<
typename Type
3761 if( rhs.size() != size_ ) {
3780template<
typename Type
3789 capacity_ = rhs.capacity_;
3793 rhs.capacity_ = 0UL;
3815template<
typename Type
3820template<
typename VT >
3826 if( (*rhs).size() != size_ ) {
3830 if( (*rhs).canAlias(
this ) ) {
3857template<
typename Type
3862template<
typename VT >
3864 CustomVector<Type,AF,padded,TF,Tag,RT>::operator+=(
const Vector<VT,TF>& rhs )
3868 if( (*rhs).size() != size_ ) {
3872 if( (*rhs).canAlias(
this ) ) {
3898template<
typename Type
3903template<
typename VT >
3905 CustomVector<Type,AF,padded,TF,Tag,RT>::operator-=(
const Vector<VT,TF>& rhs )
3909 if( (*rhs).size() != size_ ) {
3913 if( (*rhs).canAlias(
this ) ) {
3939template<
typename Type
3944template<
typename VT >
3946 CustomVector<Type,AF,padded,TF,Tag,RT>::operator*=(
const Vector<VT,TF>& rhs )
3958 if( (*rhs).size() != size_ ) {
3963 const MultType tmp( *
this * (*rhs) );
3989template<
typename Type
3994template<
typename VT >
4009 if( (*rhs).size() != size_ ) {
4013 if( (*rhs).canAlias(
this ) ) {
4014 const DivType tmp( *
this / (*rhs) );
4039template<
typename Type
4044template<
typename VT >
4046 CustomVector<Type,AF,padded,TF,Tag,RT>::operator%=(
const Vector<VT,TF>& rhs )
4048 using blaze::assign;
4061 if( size_ != 3UL || (*rhs).size() != 3UL ) {
4065 const CrossType tmp( *
this % (*rhs) );
4066 assign( *
this, tmp );
4088template<
typename Type
4110template<
typename Type
4129template<
typename Type
4152template<
typename Type
4159 size_t nonzeros( 0 );
4161 for(
size_t i=0UL; i<size_; ++i ) {
4178template<
typename Type
4186 for(
size_t i=0UL; i<size_; ++i )
4202template<
typename Type
4224template<
typename Type
4233 swap( size_, v.size_ );
4234 swap( capacity_, v.capacity_ );
4271template<
typename Type
4276template<
typename Other >
4278 CustomVector<Type,AF,padded,TF,Tag,RT>::scale(
const Other& scalar )
4280 for(
size_t i=0UL; i<size_; ++i )
4319template<
typename Type
4352template<
typename Type
4357template<
typename Other >
4360 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
4377template<
typename Type
4382template<
typename Other >
4385 return static_cast<const void*
>( this ) ==
static_cast<const void*
>( alias );
4401template<
typename Type
4425template<
typename Type
4432 return (
size() > SMP_DVECASSIGN_THRESHOLD );
4451template<
typename Type
4460 return loada( index );
4462 return loadu( index );
4482template<
typename Type
4499 return loada( v_+index );
4519template<
typename Type
4534 return loadu( v_+index );
4554template<
typename Type
4585template<
typename Type
4602 storea( v_+index, value );
4622template<
typename Type
4637 storeu( v_+index, value );
4658template<
typename Type
4674 stream( v_+index, value );
4692template<
typename Type
4697template<
typename VT >
4706 for(
size_t i=0UL; i<ipos; i+=2UL ) {
4707 v_[i ] = (*rhs)[i ];
4708 v_[i+1UL] = (*rhs)[i+1UL];
4710 if( ipos < (*rhs).size() )
4711 v_[ipos] = (*rhs)[ipos];
4729template<
typename Type
4734template<
typename VT >
4744 const size_t ipos( remainder ?
prevMultiple( size_, SIMDSIZE ) : size_ );
4747 if( AF && useStreaming && size_ > ( cacheSize/(
sizeof(
Type) * 3UL ) ) && !(*rhs).isAliased(
this ) )
4751 for( ; i<ipos; i+=SIMDSIZE ) {
4752 stream( i, (*rhs).load(i) );
4754 for( ; remainder && i<size_; ++i ) {
4760 const size_t i4way(
prevMultiple( size_, SIMDSIZE*4UL ) );
4766 for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4767 store( i , it.load() ); it += SIMDSIZE;
4768 store( i+SIMDSIZE , it.load() ); it += SIMDSIZE;
4769 store( i+SIMDSIZE*2UL, it.load() ); it += SIMDSIZE;
4770 store( i+SIMDSIZE*3UL, it.load() ); it += SIMDSIZE;
4772 for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4773 store( i, it.load() );
4775 for( ; remainder && i<size_; ++i, ++it ) {
4796template<
typename Type
4801template<
typename VT >
4806 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
4807 v_[element->index()] = element->value();
4825template<
typename Type
4830template<
typename VT >
4839 for(
size_t i=0UL; i<ipos; i+=2UL ) {
4840 v_[i ] += (*rhs)[i ];
4841 v_[i+1UL] += (*rhs)[i+1UL];
4843 if( ipos < (*rhs).size() )
4844 v_[ipos] += (*rhs)[ipos];
4862template<
typename Type
4867template<
typename VT >
4877 const size_t ipos( remainder ?
prevMultiple( size_, SIMDSIZE ) : size_ );
4880 const size_t i4way(
prevMultiple( size_, SIMDSIZE*4UL ) );
4886 for( ; i<i4way; i+=SIMDSIZE*4UL ) {
4887 store( i , load(i ) + it.load() ); it += SIMDSIZE;
4888 store( i+SIMDSIZE , load(i+SIMDSIZE ) + it.load() ); it += SIMDSIZE;
4889 store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) + it.load() ); it += SIMDSIZE;
4890 store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) + it.load() ); it += SIMDSIZE;
4892 for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
4893 store( i, load(i) + it.load() );
4895 for( ; remainder && i<size_; ++i, ++it ) {
4915template<
typename Type
4920template<
typename VT >
4925 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
4926 v_[element->index()] += element->value();
4944template<
typename Type
4949template<
typename VT >
4958 for(
size_t i=0UL; i<ipos; i+=2UL ) {
4959 v_[i ] -= (*rhs)[i ];
4960 v_[i+1UL] -= (*rhs)[i+1UL];
4962 if( ipos < (*rhs).size() )
4963 v_[ipos] -= (*rhs)[ipos];
4981template<
typename Type
4986template<
typename VT >
4996 const size_t ipos( remainder ?
prevMultiple( size_, SIMDSIZE ) : size_ );
4999 const size_t i4way(
prevMultiple( size_, SIMDSIZE*4UL ) );
5005 for( ; i<i4way; i+=SIMDSIZE*4UL ) {
5006 store( i , load(i ) - it.load() ); it += SIMDSIZE;
5007 store( i+SIMDSIZE , load(i+SIMDSIZE ) - it.load() ); it += SIMDSIZE;
5008 store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) - it.load() ); it += SIMDSIZE;
5009 store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) - it.load() ); it += SIMDSIZE;
5011 for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
5012 store( i, load(i) - it.load() );
5014 for( ; remainder && i<size_; ++i, ++it ) {
5034template<
typename Type
5039template<
typename VT >
5044 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
5045 v_[element->index()] -= element->value();
5063template<
typename Type
5068template<
typename VT >
5077 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5078 v_[i ] *= (*rhs)[i ];
5079 v_[i+1UL] *= (*rhs)[i+1UL];
5081 if( ipos < (*rhs).size() )
5082 v_[ipos] *= (*rhs)[ipos];
5100template<
typename Type
5105template<
typename VT >
5115 const size_t ipos( remainder ?
prevMultiple( size_, SIMDSIZE ) : size_ );
5118 const size_t i4way(
prevMultiple( size_, SIMDSIZE*4UL ) );
5124 for( ; i<i4way; i+=SIMDSIZE*4UL ) {
5125 store( i , load(i ) * it.load() ); it += SIMDSIZE;
5126 store( i+SIMDSIZE , load(i+SIMDSIZE ) * it.load() ); it += SIMDSIZE;
5127 store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) * it.load() ); it += SIMDSIZE;
5128 store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) * it.load() ); it += SIMDSIZE;
5130 for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
5131 store( i, load(i) * it.load() );
5133 for( ; remainder && i<size_; ++i, ++it ) {
5153template<
typename Type
5158template<
typename VT >
5163 const ResultType tmp(
serial( *
this ) );
5167 for(
auto element=(*rhs).begin(); element!=(*rhs).end(); ++element )
5168 v_[element->index()] = tmp[element->index()] * element->value();
5186template<
typename Type
5191template<
typename VT >
5200 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5201 v_[i ] /= (*rhs)[i ];
5202 v_[i+1UL] /= (*rhs)[i+1UL];
5204 if( ipos < (*rhs).size() )
5205 v_[ipos] /= (*rhs)[ipos];
5223template<
typename Type
5228template<
typename VT >
5239 const size_t i4way(
prevMultiple( size_, SIMDSIZE*4UL ) );
5245 for( ; i<i4way; i+=SIMDSIZE*4UL ) {
5246 store( i , load(i ) / it.load() ); it += SIMDSIZE;
5247 store( i+SIMDSIZE , load(i+SIMDSIZE ) / it.load() ); it += SIMDSIZE;
5248 store( i+SIMDSIZE*2UL, load(i+SIMDSIZE*2UL) / it.load() ); it += SIMDSIZE;
5249 store( i+SIMDSIZE*3UL, load(i+SIMDSIZE*3UL) / it.load() ); it += SIMDSIZE;
5251 for( ; i<ipos; i+=SIMDSIZE, it+=SIMDSIZE ) {
5252 store( i, load(i) / it.load() );
5254 for( ; i<size_; ++i, ++it ) {
5277template< RelaxationFlag RF,
typename Type, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5280template<
typename Type, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5283template<
typename Type, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5284void swap(
CustomVector<Type,AF,PF,TF,Tag,RT>& a,
CustomVector<Type,AF,PF,TF,Tag,RT>& b )
noexcept;
5326 return ( v.
size() == 0UL );
5352template<
typename Type
5360 return ( v.size() <= v.capacity() );
5373template<
typename Type
5379inline void swap(
CustomVector<Type,AF,PF,TF,Tag,RT>& a,
CustomVector<Type,AF,PF,TF,Tag,RT>& b )
noexcept
5396template<
typename T, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5397struct HasConstDataAccess< CustomVector<T,AF,PF,TF,Tag,RT> >
5414template<
typename T, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5432template<
typename T, AlignmentFlag AF, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5450template<
typename T, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5468template<
typename T, PaddingFlag PF,
bool TF,
typename Tag,
typename RT >
5486template<
typename T, AlignmentFlag AF,
bool TF,
typename Tag,
typename RT >
Header file for auxiliary alias declarations.
typename T1::template Rebind< T2 >::Other Rebind_t
Alias declaration for nested Rebind class templates.
Definition Aliases.h:350
typename T::template Resize< Ns... >::Other Resize_t
Alias declaration for nested Resize class templates.
Definition Aliases.h:430
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.
Definition Aliases.h:130
typename ResultType_t< T >::TagType TagType_t
Alias declaration for nested TagType type definitions.
Definition Aliases.h:530
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition Aliases.h:450
Header file for the alignment check function.
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Constraint on the data type.
Header file for the cross product trait.
Header file for the CustomTransposeType type trait.
Header file for the DenseIterator class template.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the HasSIMDAdd type trait.
Header file for the HasSIMDDiv type trait.
Header file for the HasSIMDMult type trait.
Header file for the HasSIMDSub type trait.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the IsCustom type trait.
Header file for the isDefault shim.
Header file for the IsPadded type trait.
Header file for the IsSIMDCombinable type trait.
Header file for the IsSMPAssignable type trait.
Header file for the IsSparseVector type trait.
Header file for the IsVectorizable type trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Header file for the nextMultiple shim.
Header file for the padding flag enumeration.
Constraint on the data type.
Header file for the prevMultiple shim.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveConst type trait.
Header file for all SIMD functionality.
Constraint on the data type.
Constraint on the data type.
Efficient implementation of a customizable vector.
Definition CustomVector.h:407
auto divAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedDivAssign_v< VT > >
size_t size() const noexcept
BLAZE_ALWAYS_INLINE void store(size_t index, const SIMDType &value) noexcept
CustomVector & operator=(const Type &rhs)
Homogenous assignment to all vector elements.
Definition CustomVector.h:1158
CustomVector< Type, AF, PF, TF, Tag, RT > This
Type of this CustomVector instance.
Definition CustomVector.h:410
SIMDTrait_t< ElementType > SIMDType
SIMD type of the vector elements.
Definition CustomVector.h:420
bool canSMPAssign() const noexcept
const Type & ReturnType
Return type for expression template evaluations.
Definition CustomVector.h:422
Type ElementType
Type of the vector elements.
Definition CustomVector.h:419
ConstIterator cbegin() const noexcept
bool isAligned() const noexcept
bool isAliased(const Other *alias) const noexcept
Iterator begin() noexcept
Reference at(size_t index)
Checked access to the vector elements.
Definition CustomVector.h:944
CustomVector()
The default constructor for CustomVector.
Definition CustomVector.h:715
CustomTransposeType_t< RT > TransposeType
Transpose type for expression template evaluations.
Definition CustomVector.h:417
BLAZE_ALWAYS_INLINE void storeu(size_t index, const SIMDType &value) noexcept
static constexpr size_t SIMDSIZE
Definition CustomVector.h:611
auto subAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedSubAssign_v< VT > >
const Type & ConstReference
Reference to a constant vector value.
Definition CustomVector.h:426
Type & Reference
Reference to a non-constant vector value.
Definition CustomVector.h:425
BLAZE_ALWAYS_INLINE SIMDType load(size_t index) const noexcept
Tag TagType
Tag type of this CustomVector instance.
Definition CustomVector.h:421
size_t capacity() const noexcept
const Type * ConstPointer
Pointer to a constant vector value.
Definition CustomVector.h:428
size_t size_
Definition CustomVector.h:677
BLAZE_ALWAYS_INLINE SIMDType loada(size_t index) const noexcept
ConstReference at(size_t index) const
Checked access to the vector elements.
Definition CustomVector.h:971
NewType * v_
Definition CustomVector.h:678
bool canAlias(const Other *alias) const noexcept
RT ResultType
Result type for expression template evaluations.
Definition CustomVector.h:414
BLAZE_ALWAYS_INLINE void stream(size_t index, const SIMDType &value) noexcept
static constexpr bool simdEnabled
Definition CustomVector.h:460
DenseVector< This, TF > BaseType
Base type of this CustomVector instance.
Definition CustomVector.h:411
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the vector elements.
Definition CustomVector.h:895
BLAZE_ALWAYS_INLINE void storea(size_t index, const SIMDType &value) noexcept
CustomVector(Type *ptr, size_t n)
Constructor for an unpadded custom vector of size n.
Definition CustomVector.h:746
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t index) const noexcept
static constexpr bool smpAssignable
Definition CustomVector.h:466
CustomVector(const CustomVector &v)
The copy constructor for CustomVector.
Definition CustomVector.h:813
auto addAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAddAssign_v< VT > >
Type * Pointer
Pointer to a non-constant vector value.
Definition CustomVector.h:427
void swap(CustomVector &v) noexcept
auto assign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAssign_v< VT > >
Pointer data() noexcept
Low-level data access to the vector elements.
Definition CustomVector.h:995
size_t spacing() const noexcept
const CustomVector & CompositeType
Data type for composite expression templates.
Definition CustomVector.h:423
~CustomVector()
The destructor for CustomVector.
Definition CustomVector.h:860
ConstIterator cend() const noexcept
ConstReference operator[](size_t index) const noexcept
Subscript operator for the direct access to the vector elements.
Definition CustomVector.h:919
CustomVector(CustomVector &&v) noexcept
The move constructor for CustomVector.
Definition CustomVector.h:831
DenseIterator< const Type, AF > ConstIterator
Iterator over constant elements.
Definition CustomVector.h:431
CustomVector(Type *ptr, size_t n, size_t nn)
Constructor for a padded custom vector of size n and capacity nn.
Definition CustomVector.h:789
DenseIterator< Type, AF > Iterator
Iterator over non-constant elements.
Definition CustomVector.h:430
auto multAssign(const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedMultAssign_v< VT > >
Implementation of a generic iterator for dense vectors and matrices.
Definition DenseIterator.h:60
Base class for N-dimensional dense vectors.
Definition DenseVector.h:77
Base class for sparse vectors.
Definition SparseVector.h:72
Base class for N-dimensional vectors.
Definition Vector.h:82
Initializer list type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Header file for the DenseVector base class.
Header file for the SparseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.
Definition Vectorizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition Const.h:79
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TAG(A, B)
Data type constraint.
Definition SameTag.h:68
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition Reference.h:79
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition DiagonalMatrix.h:225
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition DenseVector.h:61
typename CrossTrait< T1, T2 >::Type CrossTrait_t
Auxiliary alias declaration for the CrossTrait class template.
Definition CrossTrait.h:138
typename DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.
Definition DivTrait.h:164
typename MultTrait< T1, T2 >::Type MultTrait_t
Auxiliary alias declaration for the MultTrait class template.
Definition MultTrait.h:165
constexpr bool HasSIMDSub_v
Auxiliary variable template for the HasSIMDSub type trait.
Definition HasSIMDSub.h:187
constexpr bool IsSIMDCombinable_v
Auxiliary variable template for the IsSIMDCombinable type trait.
Definition IsSIMDCombinable.h:137
constexpr bool HasSIMDAdd_v
Auxiliary variable template for the HasSIMDAdd type trait.
Definition HasSIMDAdd.h:187
constexpr bool HasSIMDDiv_v
Auxiliary variable template for the HasSIMDDiv type trait.
Definition HasSIMDDiv.h:173
constexpr bool IsSMPAssignable_v
Auxiliary variable template for the IsSMPAssignable type trait.
Definition IsSMPAssignable.h:132
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.
Definition HasSIMDMult.h:188
constexpr bool IsSparseVector_v
Auxiliary variable template for the IsSparseVector type trait.
Definition IsSparseVector.h:124
constexpr bool IsPadded_v
Auxiliary variable template for the IsPadded type trait.
Definition IsPadded.h:134
typename CustomTransposeType< T >::Type CustomTransposeType_t
Auxiliary alias declaration for the CustomTransposeType type trait.
Definition CustomTransposeType.h:83
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition RelaxationFlag.h:66
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition PrevMultiple.h:68
BLAZE_ALWAYS_INLINE constexpr auto nextMultiple(T1 value, T2 factor) noexcept
Rounds up an integral value to the next multiple of a given factor.
Definition NextMultiple.h:68
PaddingFlag
Padding flag for (un-)padded vectors and matrices.
Definition PaddingFlag.h:77
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition AlignmentFlag.h:63
@ padded
Flag for padded vectors and matrices.
Definition PaddingFlag.h:79
@ aligned
Flag for aligned vectors and matrices.
Definition AlignmentFlag.h:65
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition Matrix.h:960
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition Matrix.h:806
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition Matrix.h:676
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition Assert.h:117
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition SIMDTrait.h:315
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition Storea.h:78
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition Storeu.h:75
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< 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:74
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition Loadu.h:76
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition Loada.h:79
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition DenseVector.h:221
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition DenseMatrix.h:162
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:100
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition DenseVector.h:192
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition DenseMatrix.h:131
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition StaticAssert.h:112
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition Inline.h:85
constexpr bool IsVectorizable_v
Auxiliary variable template for the IsVectorizable type trait.
Definition IsVectorizable.h:157
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
BoolConstant< true > TrueType
Type traits base class.
Definition IntegralConstant.h:132
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition AlignmentCheck.h:68
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:175
Header file for the exception macros of the math module.
Header file for all forward declarations of the math module.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for all forward declarations for dense vectors and matrices.
Header file for the clear shim.
Header file for the serial shim.
Rebind mechanism to obtain a CustomVector with different data/element type.
Definition CustomVector.h:438
Rebind_t< RT, RemoveConst_t< NewType > > RRT
The rebound result type.
Definition CustomVector.h:439
CustomVector< NewType, AF, PF, TF, Tag, RRT > Other
The type of the other CustomVector.
Definition CustomVector.h:440
Resize mechanism to obtain a CustomVector with a different fixed number of elements.
Definition CustomVector.h:448
CustomVector< Type, AF, PF, TF, Tag, RRT > Other
The type of the other CustomVector.
Definition CustomVector.h:450
Resize_t< RT, NewN > RRT
The resized result type.
Definition CustomVector.h:449
Compile time check for low-level access to mutable data.
Definition HasMutableDataAccess.h:76
Compile time check for the alignment of data types.
Definition IsAligned.h:88
Compile time check for the memory layout of data types.
Definition IsContiguous.h:87
Compile time check for custom data types.
Definition IsCustom.h:88
Compile time check for data types with padding.
Definition IsPadded.h:77
Header file for the cache size of the target architecture.
System settings for the inline keywords.
System settings for performance optimizations.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for basic type definitions.