35 #ifndef _BLAZE_MATH_SPARSE_COMPRESSEDVECTOR_H_
36 #define _BLAZE_MATH_SPARSE_COMPRESSEDVECTOR_H_
186 template<
typename Type
199 struct Element :
public ElementBase
203 template<
typename Other >
204 inline Element&
operator=(
const Other& rhs )
206 ElementBase::operator=( rhs );
233 template<
typename ET >
270 inline Reference operator[](
size_t index ) noexcept;
271 inline ConstReference operator[](
size_t index ) const noexcept;
272 inline Reference
at(
size_t index );
273 inline ConstReference
at(
size_t index ) const;
274 inline Iterator
begin () noexcept;
275 inline ConstIterator
begin () const noexcept;
276 inline ConstIterator
cbegin() const noexcept;
277 inline Iterator
end () noexcept;
278 inline ConstIterator
end () const noexcept;
279 inline ConstIterator
cend () const noexcept;
286 inline CompressedVector& operator=( const CompressedVector& rhs );
287 inline CompressedVector& operator=( CompressedVector&& rhs ) noexcept;
289 template< typename VT > inline CompressedVector& operator= ( const
DenseVector<VT,TF>& rhs );
290 template< typename VT > inline CompressedVector& operator= ( const
SparseVector<VT,TF>& rhs );
291 template< typename VT > inline CompressedVector& operator+=( const
Vector<VT,TF>& rhs );
292 template< typename VT > inline CompressedVector& operator-=( const
Vector<VT,TF>& rhs );
293 template< typename VT > inline CompressedVector& operator*=( const
DenseVector<VT,TF>& rhs );
294 template< typename VT > inline CompressedVector& operator*=( const
SparseVector<VT,TF>& rhs );
295 template< typename VT > inline CompressedVector& operator/=( const
DenseVector<VT,TF>& rhs );
297 template< typename Other >
300 template< typename Other >
308 inline
size_t size() const noexcept;
309 inline
size_t capacity() const noexcept;
313 inline Iterator
set (
size_t index, const Type& value );
314 inline Iterator
insert(
size_t index, const Type& value );
315 inline
void erase (
size_t index );
316 inline Iterator
erase ( Iterator pos );
317 inline Iterator
erase ( Iterator first, Iterator last );
318 inline
void resize(
size_t n,
bool preserve=true );
320 template< typename Other > inline CompressedVector& scale( const Other& scalar );
321 inline
void swap( CompressedVector& sv ) noexcept;
328 inline Iterator
find (
size_t index );
329 inline ConstIterator
find (
size_t index ) const;
331 inline ConstIterator
lowerBound(
size_t index ) const;
333 inline ConstIterator
upperBound(
size_t index ) const;
340 inline
void append(
size_t index, const Type& value,
bool check=false );
347 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
348 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
367 Iterator
insert( Iterator pos,
size_t index, const Type& value );
405 template< typename Type
407 const Type CompressedVector<Type,TF>::zero_ = Type();
421 template< typename Type
423 inline CompressedVector<Type,TF>::CompressedVector() noexcept
437 template<
typename Type
454 template<
typename Type
473 template<
typename Type
491 template<
typename Type
512 template<
typename Type
514 template<
typename VT >
516 : size_ ( (~dv).
size() )
532 template<
typename Type
534 template<
typename VT >
536 : size_ ( (~sv).
size() )
558 template<
typename Type
586 template<
typename Type
604 template<
typename Type
611 const ConstIterator pos( lowerBound( index ) );
613 if( pos ==
end_ || pos->index_ != index )
633 template<
typename Type
638 if( index >= size_ ) {
641 return (*
this)[index];
658 template<
typename Type
663 if( index >= size_ ) {
666 return (*
this)[index];
676 template<
typename Type
690 template<
typename Type
705 template<
typename Type
720 template<
typename Type
734 template<
typename Type
749 template<
typename Type
776 template<
typename Type
781 if( &rhs ==
this )
return *
this;
783 const size_t nonzeros( rhs.
nonZeros() );
786 Iterator newBegin( allocate<Element>( nonzeros ) );
810 template<
typename Type
824 rhs.begin_ =
nullptr;
841 template<
typename Type
843 template<
typename VT >
849 if( (~rhs).canAlias(
this ) ) {
854 size_ = (~rhs).
size();
856 assign( *
this, ~rhs );
873 template<
typename Type
875 template<
typename VT >
886 size_ = (~rhs).
size();
888 assign( *
this, ~rhs );
906 template<
typename Type
908 template<
typename VT >
911 using blaze::addAssign;
913 if( (~rhs).
size() != size_ ) {
917 addAssign( *
this, ~rhs );
934 template<
typename Type
936 template<
typename VT >
939 using blaze::subAssign;
941 if( (~rhs).
size() != size_ ) {
945 subAssign( *
this, ~rhs );
963 template<
typename Type
965 template<
typename VT >
969 using blaze::multAssign;
971 if( (~rhs).
size() != size_ ) {
975 if( (~rhs).canAlias(
this ) ) {
981 multAssign( *
this, tmp );
1000 template<
typename Type
1002 template<
typename VT >
1006 if( (~rhs).
size() != size_ ) {
1028 template<
typename Type
1030 template<
typename VT >
1033 using blaze::divAssign;
1035 if( (~rhs).
size() != size_ ) {
1039 if( (~rhs).canAlias(
this ) ) {
1045 divAssign( *
this, tmp );
1064 template<
typename Type
1066 template<
typename Other >
1070 for( Iterator element=
begin_; element!=
end_; ++element )
1071 element->value_ *= rhs;
1089 template<
typename Type
1091 template<
typename Other >
1103 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1104 for( Iterator element=
begin_; element!=
end_; ++element )
1105 element->value_ *= tmp;
1108 for( Iterator element=
begin_; element!=
end_; ++element )
1109 element->value_ /= rhs;
1130 template<
typename Type
1144 template<
typename Type
1161 template<
typename Type
1175 template<
typename Type
1191 template<
typename Type
1212 template<
typename Type
1219 const Iterator pos( lowerBound( index ) );
1221 if( pos !=
end_ && pos->index_ == index ) {
1222 pos->value() = value;
1225 else return insert( pos, index, value );
1242 template<
typename Type
1249 const Iterator pos( lowerBound( index ) );
1251 if( pos !=
end_ && pos->index_ == index ) {
1255 return insert( pos, index, value );
1269 template<
typename Type
1275 std::move_backward( pos,
end_,
end_+1 );
1276 pos->value_ = value;
1277 pos->index_ = index;
1283 size_t newCapacity( extendCapacity() );
1285 Iterator newBegin = allocate<Element>( newCapacity );
1286 Iterator tmp = std::move(
begin_, pos, newBegin );
1287 tmp->value_ = value;
1288 tmp->index_ = index;
1289 end_ = std::move( pos,
end_, tmp+1 );
1309 template<
typename Type
1315 const Iterator pos( find( index ) );
1317 end_ = std::move( pos+1,
end_, pos );
1330 template<
typename Type
1337 end_ = std::move( pos+1,
end_, pos );
1352 template<
typename Type
1362 end_ = std::move( last,
end_, first );
1382 template<
typename Type
1387 end_ = lowerBound( n );
1407 template<
typename Type
1412 const size_t newCapacity( n );
1415 Iterator newBegin = allocate<Element>( newCapacity );
1433 template<
typename Type
1435 template<
typename Other >
1438 for( Iterator element=
begin_; element!=
end_; ++element )
1439 element->value_ *= scalar;
1451 template<
typename Type
1471 template<
typename Type
1479 nonzeros =
max( nonzeros, 7UL );
1480 nonzeros =
min( nonzeros, size_ );
1510 template<
typename Type
1514 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).find( index ) );
1532 template<
typename Type
1536 const ConstIterator pos( lowerBound( index ) );
1537 if( pos !=
end_ && pos->index_ == index )
1556 template<
typename Type
1561 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).lowerBound( index ) );
1578 template<
typename Type
1583 return std::lower_bound(
begin_,
end_, index,
1584 [](
const Element& element,
size_t i )
1586 return element.index() < i;
1604 template<
typename Type
1609 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).upperBound( index ) );
1626 template<
typename Type
1631 return std::upper_bound(
begin_,
end_, index,
1632 [](
size_t i,
const Element& element )
1634 return i < element.index();
1672 template<
typename Type
1680 end_->value_ = value;
1683 end_->index_ = index;
1708 template<
typename Type
1710 template<
typename Other >
1713 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1728 template<
typename Type
1730 template<
typename Other >
1733 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1748 template<
typename Type
1768 template<
typename Type
1770 template<
typename VT >
1776 size_t nonzeros( 0UL );
1778 for(
size_t i=0UL; i<size_; ++i )
1781 reserve( extendCapacity() );
1783 end_->value_ = (~rhs)[i];
1806 template<
typename Type
1808 template<
typename VT >
1821 append( element->index(), element->value() );
1837 template<
typename Type
1839 template<
typename VT >
1850 const AddType tmp(
serial( *
this + (~rhs) ) );
1868 template<
typename Type
1870 template<
typename VT >
1892 template<
typename Type
1894 template<
typename VT >
1905 const SubType tmp(
serial( *
this - (~rhs) ) );
1923 template<
typename Type
1925 template<
typename VT >
1947 template<
typename Type
1949 template<
typename VT >
1956 for( Iterator element=
begin_; element!=
end_; ++element ) {
1957 element->value_ *= (~rhs)[element->index_];
1974 template<
typename Type
1976 template<
typename VT >
1983 for( Iterator element=
begin_; element!=
end_; ++element ) {
1984 element->value_ /= (~rhs)[element->index_];
2001 template<
typename Type,
bool TF >
2004 template<
typename Type,
bool TF >
2007 template<
typename Type,
bool TF >
2010 template<
typename Type,
bool TF >
2013 template<
typename Type,
bool TF >
2026 template<
typename Type
2042 template<
typename Type
2068 template<
typename Type
2072 return ( v.
size() == 0UL );
2095 template<
typename Type
2099 return ( v.nonZeros() <= v.capacity() );
2112 template<
typename Type
2131 template<
typename T,
bool TF >
2132 struct IsResizable< CompressedVector<T,TF> > :
public TrueType
2148 template<
typename T1,
bool TF,
typename T2,
size_t N >
2149 struct AddTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2151 using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2154 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2155 struct AddTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2157 using Type = StaticVector< AddTrait_<T1,T2>, N, TF >;
2160 template<
typename T1,
bool TF,
typename T2,
size_t N >
2161 struct AddTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2163 using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2166 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2167 struct AddTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2169 using Type = HybridVector< AddTrait_<T1,T2>, N, TF >;
2172 template<
typename T1,
bool TF,
typename T2 >
2173 struct AddTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2175 using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2178 template<
typename T1,
bool TF,
typename T2 >
2179 struct AddTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2181 using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2184 template<
typename T1,
bool TF,
typename T2,
bool AF,
bool PF >
2185 struct AddTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2187 using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2190 template<
typename T1,
bool AF,
bool PF,
bool TF,
typename T2 >
2191 struct AddTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2193 using Type = DynamicVector< AddTrait_<T1,T2>, TF >;
2196 template<
typename T1,
bool TF,
typename T2 >
2197 struct AddTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2199 using Type = CompressedVector< AddTrait_<T1,T2>, TF >;
2215 template<
typename T1,
bool TF,
typename T2,
size_t N >
2216 struct SubTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2218 using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2221 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2222 struct SubTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2224 using Type = StaticVector< SubTrait_<T1,T2>, N, TF >;
2227 template<
typename T1,
bool TF,
typename T2,
size_t N >
2228 struct SubTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2230 using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2233 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2234 struct SubTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2236 using Type = HybridVector< SubTrait_<T1,T2>, N, TF >;
2239 template<
typename T1,
bool TF,
typename T2 >
2240 struct SubTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2242 using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2245 template<
typename T1,
bool TF,
typename T2 >
2246 struct SubTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2248 using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2251 template<
typename T1,
bool TF,
typename T2,
bool AF,
bool PF >
2252 struct SubTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2254 using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2257 template<
typename T1,
bool AF,
bool PF,
bool TF,
typename T2 >
2258 struct SubTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2260 using Type = DynamicVector< SubTrait_<T1,T2>, TF >;
2263 template<
typename T1,
bool TF,
typename T2 >
2264 struct SubTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2266 using Type = CompressedVector< SubTrait_<T1,T2>, TF >;
2282 template<
typename T1,
bool TF,
typename T2 >
2283 struct MultTrait< CompressedVector<T1,TF>, T2,
EnableIf_< IsNumeric<T2> > >
2285 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2288 template<
typename T1,
typename T2,
bool TF >
2289 struct MultTrait< T1, CompressedVector<T2,TF>,
EnableIf_< IsNumeric<T1> > >
2291 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2294 template<
typename T1,
bool TF,
typename T2,
size_t N >
2295 struct MultTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2297 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2300 template<
typename T1,
typename T2,
size_t N >
2301 struct MultTrait< CompressedVector<T1,false>, StaticVector<T2,N,true> >
2303 using Type = CompressedMatrix< MultTrait_<T1,T2>,
true >;
2306 template<
typename T1,
typename T2,
size_t N >
2307 struct MultTrait< CompressedVector<T1,true>, StaticVector<T2,N,false> >
2309 using Type = MultTrait_<T1,T2>;
2312 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2313 struct MultTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2315 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2318 template<
typename T1,
size_t N,
typename T2 >
2319 struct MultTrait< StaticVector<T1,N,false>, CompressedVector<T2,true> >
2321 using Type = CompressedMatrix< MultTrait_<T1,T2>,
false >;
2324 template<
typename T1,
size_t N,
typename T2 >
2325 struct MultTrait< StaticVector<T1,N,true>, CompressedVector<T2,false> >
2327 using Type = MultTrait_<T1,T2>;
2330 template<
typename T1,
bool TF,
typename T2,
size_t N >
2331 struct MultTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2333 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2336 template<
typename T1,
typename T2,
size_t N >
2337 struct MultTrait< CompressedVector<T1,false>, HybridVector<T2,N,true> >
2339 using Type = CompressedMatrix< MultTrait_<T1,T2>,
true >;
2342 template<
typename T1,
typename T2,
size_t N >
2343 struct MultTrait< CompressedVector<T1,true>, HybridVector<T2,N,false> >
2345 using Type = MultTrait_<T1,T2>;
2348 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2349 struct MultTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2351 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2354 template<
typename T1,
size_t N,
typename T2 >
2355 struct MultTrait< HybridVector<T1,N,false>, CompressedVector<T2,true> >
2357 using Type = CompressedMatrix< MultTrait_<T1,T2>,
false >;
2360 template<
typename T1,
size_t N,
typename T2 >
2361 struct MultTrait< HybridVector<T1,N,true>, CompressedVector<T2,false> >
2363 using Type = MultTrait_<T1,T2>;
2366 template<
typename T1,
bool TF,
typename T2 >
2367 struct MultTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2369 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2372 template<
typename T1,
typename T2 >
2373 struct MultTrait< CompressedVector<T1,false>, DynamicVector<T2,true> >
2375 using Type = CompressedMatrix< MultTrait_<T1,T2>,
true >;
2378 template<
typename T1,
typename T2 >
2379 struct MultTrait< CompressedVector<T1,true>, DynamicVector<T2,false> >
2381 using Type = MultTrait_<T1,T2>;
2384 template<
typename T1,
bool TF,
typename T2 >
2385 struct MultTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2387 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2390 template<
typename T1,
typename T2 >
2391 struct MultTrait< DynamicVector<T1,false>, CompressedVector<T2,true> >
2393 using Type = CompressedMatrix< MultTrait_<T1,T2>,
false >;
2396 template<
typename T1,
typename T2 >
2397 struct MultTrait< DynamicVector<T1,true>, CompressedVector<T2,false> >
2399 using Type = MultTrait_<T1,T2>;
2402 template<
typename T1,
bool TF,
typename T2,
bool AF,
bool PF >
2403 struct MultTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2405 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2408 template<
typename T1,
typename T2,
bool AF,
bool PF >
2409 struct MultTrait< CompressedVector<T1,false>, CustomVector<T2,AF,PF,true> >
2411 using Type = CompressedMatrix< MultTrait_<T1,T2>,
true >;
2414 template<
typename T1,
typename T2,
bool AF,
bool PF >
2415 struct MultTrait< CompressedVector<T1,true>, CustomVector<T2,AF,PF,false> >
2417 using Type = MultTrait_<T1,T2>;
2420 template<
typename T1,
bool AF,
bool PF,
bool TF,
typename T2 >
2421 struct MultTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2423 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2426 template<
typename T1,
bool AF,
bool PF,
typename T2 >
2427 struct MultTrait< CustomVector<T1,AF,PF,false>, CompressedVector<T2,true> >
2429 using Type = CompressedMatrix< MultTrait_<T1,T2>,
false >;
2432 template<
typename T1,
bool AF,
bool PF,
typename T2 >
2433 struct MultTrait< CustomVector<T1,AF,PF,true>, CompressedVector<T2,false> >
2435 using Type = MultTrait_<T1,T2>;
2438 template<
typename T1,
bool TF,
typename T2 >
2439 struct MultTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2441 using Type = CompressedVector< MultTrait_<T1,T2>, TF >;
2444 template<
typename T1,
typename T2 >
2445 struct MultTrait< CompressedVector<T1,false>, CompressedVector<T2,true> >
2447 using Type = CompressedMatrix< MultTrait_<T1,T2>,
false >;
2450 template<
typename T1,
typename T2 >
2451 struct MultTrait< CompressedVector<T1,true>, CompressedVector<T2,false> >
2453 using Type = MultTrait_<T1,T2>;
2469 template<
typename T1,
bool TF,
typename T2 >
2470 struct CrossTrait< CompressedVector<T1,TF>, StaticVector<T2,3UL,TF> >
2473 using T = MultTrait_<T1,T2>;
2476 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2479 template<
typename T1,
bool TF,
typename T2 >
2480 struct CrossTrait< StaticVector<T1,3UL,TF>, CompressedVector<T2,TF> >
2483 using T = MultTrait_<T1,T2>;
2486 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2489 template<
typename T1,
bool TF,
typename T2,
size_t N >
2490 struct CrossTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2493 using T = MultTrait_<T1,T2>;
2496 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2499 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2500 struct CrossTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2503 using T = MultTrait_<T1,T2>;
2506 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2509 template<
typename T1,
bool TF,
typename T2 >
2510 struct CrossTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2513 using T = MultTrait_<T1,T2>;
2516 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2519 template<
typename T1,
bool TF,
typename T2 >
2520 struct CrossTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2523 using T = MultTrait_<T1,T2>;
2526 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2529 template<
typename T1,
bool TF,
typename T2 >
2530 struct CrossTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2533 using T = MultTrait_<T1,T2>;
2536 using Type = StaticVector< SubTrait_<T,T>, 3UL, TF >;
2552 template<
typename T1,
bool TF,
typename T2 >
2553 struct DivTrait< CompressedVector<T1,TF>, T2,
EnableIf_< IsNumeric<T2> > >
2555 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2558 template<
typename T1,
bool TF,
typename T2,
size_t N >
2559 struct DivTrait< CompressedVector<T1,TF>, StaticVector<T2,N,TF> >
2561 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2564 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2565 struct DivTrait< StaticVector<T1,N,TF>, CompressedVector<T2,TF> >
2567 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2570 template<
typename T1,
bool TF,
typename T2,
size_t N >
2571 struct DivTrait< CompressedVector<T1,TF>, HybridVector<T2,N,TF> >
2573 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2576 template<
typename T1,
size_t N,
bool TF,
typename T2 >
2577 struct DivTrait< HybridVector<T1,N,TF>, CompressedVector<T2,TF> >
2579 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2582 template<
typename T1,
bool TF,
typename T2 >
2583 struct DivTrait< CompressedVector<T1,TF>, DynamicVector<T2,TF> >
2585 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2588 template<
typename T1,
bool TF,
typename T2 >
2589 struct DivTrait< DynamicVector<T1,TF>, CompressedVector<T2,TF> >
2591 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2594 template<
typename T1,
bool TF,
typename T2,
bool AF,
bool PF >
2595 struct DivTrait< CompressedVector<T1,TF>, CustomVector<T2,AF,PF,TF> >
2597 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2600 template<
typename T1,
bool AF,
bool PF,
bool TF,
typename T2 >
2601 struct DivTrait< CustomVector<T1,AF,PF,TF>, CompressedVector<T2,TF> >
2603 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2606 template<
typename T1,
bool TF,
typename T2 >
2607 struct DivTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2609 using Type = CompressedVector< DivTrait_<T1,T2>, TF >;
2625 template<
typename T1,
bool TF,
typename T2 >
2626 struct MathTrait< CompressedVector<T1,TF>, CompressedVector<T2,TF> >
2628 using HighType = CompressedVector< typename MathTrait<T1,T2>::HighType, TF >;
2629 using LowType = CompressedVector< typename MathTrait<T1,T2>::LowType , TF >;
2645 template<
typename T1,
bool TF >
2646 struct SubvectorTrait< CompressedVector<T1,TF> >
2648 using Type = CompressedVector<T1,TF>;
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#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
Header file for auxiliary alias declarations.
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Header file for mathematical functions.
#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 subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
Header file for the SparseVector base class.
void assign(const DenseVector< VT, TF > &rhs)
Default implementation of the assignment of a dense vector.
Definition: CompressedVector.h:1771
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: CompressedVector.h:1607
Header file for the serial shim.
ValueIndexPair< Type > ElementBase
Base class for the compressed vector element.
Definition: CompressedVector.h:192
CompressedVector< ET, TF > Other
The type of the other CompressedVector.
Definition: CompressedVector.h:235
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
CompressedVector< Type,!TF > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedVector.h:220
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
Access proxy for sparse, N-dimensional vectors.The VectorAccessProxy provides safe access to the elem...
Definition: VectorAccessProxy.h:100
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
VectorAccessProxy< This > Reference
Reference to a non-constant vector value.
Definition: CompressedVector.h:224
const Type & ConstReference
Reference to a constant vector value.
Definition: CompressedVector.h:225
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Algorithm.h:71
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1669
Header file for the DenseVector base class.
void addAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: CompressedVector.h:1840
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
void clear()
Clearing the compressed vector.
Definition: CompressedVector.h:1193
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
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for memory allocation and deallocation functionality.
size_t size_
The current size/dimension of the compressed vector.
Definition: CompressedVector.h:375
const CompressedVector & CompositeType
Data type for composite expression templates.
Definition: CompressedVector.h:223
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: CompressedVector.h:1750
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
Reference operator[](size_t index) noexcept
Subscript operator for the direct access to the compressed vector elements.
Definition: CompressedVector.h:589
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
size_t extendCapacity() const noexcept
Calculating a new vector capacity.
Definition: CompressedVector.h:1473
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2807
EnableIf_< IsBuiltin< T >, T * > allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:150
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the ValueIndexPair class.
Rebind mechanism to obtain a CompressedVector with different data/element type.
Definition: CompressedVector.h:234
CompressedVector() noexcept
The default constructor for CompressedVector.
Definition: CompressedVector.h:423
Iterator set(size_t index, const Type &value)
Setting an element of the compressed vector.
Definition: CompressedVector.h:1215
void subAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: CompressedVector.h:1895
void append(size_t index, const Type &value, bool check=false)
Appending an element to the compressed vector.
Definition: CompressedVector.h:1674
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.This value specifies the default tran...
Definition: TransposeFlag.h:56
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
Iterator insert(size_t index, const Type &value)
Inserting an element into the compressed vector.
Definition: CompressedVector.h:1245
#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
Header file for the IsSMPAssignable type trait.
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2809
Iterator begin_
Pointer to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:377
#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
#define BLAZE_CONSTRAINT_MUST_HAVE_SAME_SIZE(T1, T2)
Constraint on the size of two data types.In case the types T1 and T2 don't have the same size...
Definition: SameSize.h:60
Header file for the subvector trait.
Constraint on the data type.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedVector.h:222
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_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:60
Constraint on the data type.
Header file for the exception macros of the math module.
size_t size() const noexcept
Returns the current size/dimension of the compressed vector.
Definition: CompressedVector.h:1132
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:75
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:119
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
Constraint on the data type.
Headerfile for generic algorithms.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
size_t capacity_
The maximum capacity of the compressed vector.
Definition: CompressedVector.h:376
This ResultType
Result type for expression template evaluations.
Definition: CompressedVector.h:219
void erase(size_t index)
Erasing an element from the compressed vector.
Definition: CompressedVector.h:1311
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: CompressedVector.h:1559
Iterator find(size_t index)
Searches for a specific vector element.
Definition: CompressedVector.h:1512
Header file for the IsNumeric type trait.
void reset()
Reset to the default initial values.
Definition: CompressedVector.h:1177
void resize(size_t n, bool preserve=true)
Changing the size of the compressed vector.
Definition: CompressedVector.h:1384
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:160
CompressedVector< Type, TF > This
Type of this CompressedVector instance.
Definition: CompressedVector.h:217
Reference at(size_t index)
Checked access to the compressed vector elements.
Definition: CompressedVector.h:636
#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 VectorAccessProxy class.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedVector.h:227
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
size_t capacity() const noexcept
Returns the maximum capacity of the compressed vector.
Definition: CompressedVector.h:1146
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedVector.h:226
Constraint on the data type.
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2808
#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
void multAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the multiplication assignment of a dense vector.
Definition: CompressedVector.h:1950
ConstIterator cend() const noexcept
Returns an iterator just past the last non-zero element of the compressed vector. ...
Definition: CompressedVector.h:752
void divAssign(const DenseVector< VT, TF > &rhs)
Default implementation of the division assignment of a dense vector.
Definition: CompressedVector.h:1977
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: CompressedVector.h:1731
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
size_t nonZeros() const
Returns the number of non-zero elements in the compressed vector.
Definition: CompressedVector.h:1163
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the mathematical trait.
void swap(CompressedVector &sv) noexcept
Swapping the contents of two compressed vectors.
Definition: CompressedVector.h:1453
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#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
Iterator end() noexcept
Returns an iterator just past the last non-zero element of the compressed vector. ...
Definition: CompressedVector.h:722
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:70
Constraint on the size of two data types.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
Header file for the default transpose flag for all vectors of the Blaze library.
~CompressedVector()
The destructor for CompressedVector.
Definition: CompressedVector.h:560
CompressedVector & operator=(const CompressedVector &rhs)
Copy assignment operator for CompressedVector.
Definition: CompressedVector.h:779
SparseVector< This, TF > BaseType
Base type of this CompressedVector instance.
Definition: CompressedVector.h:218
typename SubTrait< T1, T2 >::Type SubTrait_
Auxiliary alias declaration for the SubTrait class template.The SubTrait_ alias declaration provides ...
Definition: SubTrait.h:245
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:2811
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
Iterator end_
Pointer one past the last non-zero element of the compressed vector.
Definition: CompressedVector.h:378
ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:708
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: CompressedVector.h:1711
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
Iterator begin() noexcept
Returns an iterator to the first non-zero element of the compressed vector.
Definition: CompressedVector.h:678
Type ElementType
Type of the compressed vector elements.
Definition: CompressedVector.h:221
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedVector.h:380
Header file for the IsResizable type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
#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
Efficient implementation of an arbitrary sized sparse vector.The CompressedVector class is the repres...
Definition: CompressedVector.h:188
void reserve(size_t n)
Setting the minimum capacity of the compressed vector.
Definition: CompressedVector.h:1409