35 #ifndef _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
36 #define _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
205 template<
typename Type
218 struct Element :
public ElementBase
222 template<
typename Other >
223 inline Element&
operator=(
const Other& rhs )
225 ElementBase::operator=( rhs );
253 template<
typename ET >
273 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
291 inline Reference operator()(
size_t i,
size_t j ) noexcept;
292 inline ConstReference operator()(
size_t i,
size_t j ) const noexcept;
293 inline Reference
at(
size_t i,
size_t j );
294 inline ConstReference
at(
size_t i,
size_t j ) const;
295 inline Iterator
begin (
size_t i ) noexcept;
296 inline ConstIterator
begin (
size_t i ) const noexcept;
297 inline ConstIterator
cbegin(
size_t i ) const noexcept;
298 inline Iterator
end (
size_t i ) noexcept;
299 inline ConstIterator
end (
size_t i ) const noexcept;
300 inline ConstIterator
cend (
size_t i ) const noexcept;
307 inline CompressedMatrix& operator=( const CompressedMatrix& rhs );
308 inline CompressedMatrix& operator=( CompressedMatrix&& rhs ) noexcept;
310 template< typename MT,
bool SO2 > inline CompressedMatrix& operator= ( const
DenseMatrix<MT,SO2>& rhs );
311 template< typename MT,
bool SO2 > inline CompressedMatrix& operator= ( const
SparseMatrix<MT,SO2>& rhs );
312 template< typename MT,
bool SO2 > inline CompressedMatrix& operator+=( const
Matrix<MT,SO2>& rhs );
313 template< typename MT,
bool SO2 > inline CompressedMatrix& operator-=( const
Matrix<MT,SO2>& rhs );
314 template< typename MT,
bool SO2 > inline CompressedMatrix& operator*=( const
Matrix<MT,SO2>& rhs );
316 template< typename Other >
319 template< typename Other >
327 inline
size_t rows() const noexcept;
328 inline
size_t columns() const noexcept;
329 inline
size_t capacity() const noexcept;
330 inline
size_t capacity(
size_t i ) const noexcept;
332 inline
size_t nonZeros(
size_t i ) const;
334 inline
void reset(
size_t i );
336 inline Iterator
set (
size_t i,
size_t j, const Type& value );
337 inline Iterator
insert (
size_t i,
size_t j, const Type& value );
338 inline
void erase (
size_t i,
size_t j );
339 inline Iterator
erase (
size_t i, Iterator pos );
340 inline Iterator
erase (
size_t i, Iterator first, Iterator last );
341 void resize (
size_t m,
size_t n,
bool preserve=true );
342 inline
void reserve(
size_t nonzeros );
343 void reserve(
size_t i,
size_t nonzeros );
345 inline
void trim (
size_t i );
348 template< typename Other > inline CompressedMatrix& scale( const Other& scalar );
349 template< typename Other > inline CompressedMatrix& scaleDiagonal( Other scalar );
350 inline
void swap( CompressedMatrix& sm ) noexcept;
357 inline Iterator
find (
size_t i,
size_t j );
358 inline ConstIterator
find (
size_t i,
size_t j ) const;
359 inline Iterator
lowerBound(
size_t i,
size_t j );
360 inline ConstIterator
lowerBound(
size_t i,
size_t j ) const;
361 inline Iterator
upperBound(
size_t i,
size_t j );
362 inline ConstIterator
upperBound(
size_t i,
size_t j ) const;
369 inline
void append (
size_t i,
size_t j, const Type& value,
bool check=false );
377 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
378 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
382 template< typename MT,
bool SO2 > inline
void assign ( const
DenseMatrix<MT,SO2>& rhs );
396 Iterator
insert( Iterator pos,
size_t i,
size_t j, const Type& value );
436 template< typename Type,
bool SO >
437 const Type CompressedMatrix<Type,SO>::zero_ = Type();
451 template< typename Type
453 inline CompressedMatrix<Type,SO>::CompressedMatrix()
471 template<
typename Type
477 ,
begin_( new Iterator[2UL*m+2UL] )
480 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
495 template<
typename Type
501 ,
begin_( new Iterator[2UL*m+2UL] )
504 begin_[0UL] = allocate<Element>( nonzeros );
505 for(
size_t i=1UL; i<(2UL*
m_+1UL); ++i )
523 template<
typename Type
529 ,
begin_( new Iterator[2UL*
m_+2UL] )
532 BLAZE_USER_ASSERT( nonzeros.size() == m,
"Size of capacity vector and number of rows don't match" );
534 size_t newCapacity( 0UL );
535 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
538 begin_[0UL] =
end_[0UL] = allocate<Element>( newCapacity );
539 for(
size_t i=0UL; i<
m_; ++i ) {
551 template<
typename Type
557 ,
begin_( new Iterator[2UL*
m_+2UL] )
560 const size_t nonzeros( sm.
nonZeros() );
562 begin_[0UL] = allocate<Element>( nonzeros );
563 for(
size_t i=0UL; i<
m_; ++i )
564 begin_[i+1UL] =
end_[i] = std::copy( sm.
begin(i), sm.
end(i), begin_[i] );
565 end_[
m_] = begin_[0UL]+nonzeros;
575 template<
typename Type
598 template<
typename Type
600 template<
typename MT
606 ,
begin_ ( new Iterator[2UL*
m_+2UL] )
611 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
624 template<
typename Type
626 template<
typename MT
632 ,
begin_ ( new Iterator[2UL*
m_+2UL] )
637 const size_t nonzeros( (~sm).
nonZeros() );
639 begin_[0UL] = allocate<Element>( nonzeros );
640 for(
size_t i=0UL; i<
m_; ++i )
660 template<
typename Type
693 template<
typename Type
716 template<
typename Type
724 const ConstIterator pos( lowerBound( i, j ) );
726 if( pos ==
end_[i] || pos->index_ != j )
747 template<
typename Type
774 template<
typename Type
801 template<
typename Type
823 template<
typename Type
845 template<
typename Type
867 template<
typename Type
889 template<
typename Type
911 template<
typename Type
939 template<
typename Type
944 if( &rhs ==
this )
return *
this;
946 const size_t nonzeros( rhs.
nonZeros() );
950 Iterator* newBegin(
new Iterator[2UL*rhs.
m_+2UL] );
951 Iterator* newEnd ( newBegin+(rhs.
m_+1UL) );
953 newBegin[0UL] = allocate<Element>( nonzeros );
954 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
955 newBegin[i+1UL] = newEnd[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], newBegin[i] );
957 newEnd[rhs.
m_] = newBegin[0UL]+nonzeros;
963 if( newBegin !=
nullptr ) {
969 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
988 template<
typename Type
1006 rhs.capacity_ = 0UL;
1007 rhs.begin_ =
nullptr;
1024 template<
typename Type
1026 template<
typename MT
1031 using blaze::assign;
1033 if( (~rhs).canAlias(
this ) ) {
1039 assign( *
this, ~rhs );
1056 template<
typename Type
1058 template<
typename MT
1063 using blaze::assign;
1065 if( (~rhs).canAlias(
this ) ||
1074 assign( *
this, ~rhs );
1092 template<
typename Type
1094 template<
typename MT
1099 using blaze::addAssign;
1105 addAssign( *
this, ~rhs );
1121 template<
typename Type
1123 template<
typename MT
1127 using blaze::subAssign;
1133 subAssign( *
this, ~rhs );
1149 template<
typename Type
1151 template<
typename MT
1156 if( (~rhs).
rows() !=
n_ ) {
1175 template<
typename Type
1177 template<
typename Other >
1181 for(
size_t i=0UL; i<
m_; ++i ) {
1182 const Iterator last(
end(i) );
1183 for( Iterator element=
begin(i); element!=last; ++element )
1184 element->value_ *= rhs;
1198 template<
typename Type
1200 template<
typename Other >
1212 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1213 for(
size_t i=0UL; i<
m_; ++i ) {
1214 const Iterator last(
end(i) );
1215 for( Iterator element=
begin(i); element!=last; ++element )
1216 element->value_ *= tmp;
1220 for(
size_t i=0UL; i<
m_; ++i ) {
1221 const Iterator last(
end(i) );
1222 for( Iterator element=
begin(i); element!=last; ++element )
1223 element->value_ /= rhs;
1245 template<
typename Type
1259 template<
typename Type
1273 template<
typename Type
1295 template<
typename Type
1310 template<
typename Type
1314 size_t nonzeros( 0UL );
1316 for(
size_t i=0UL; i<
m_; ++i )
1335 template<
typename Type
1350 template<
typename Type
1354 for(
size_t i=0UL; i<
m_; ++i )
1371 template<
typename Type
1388 template<
typename Type
1411 template<
typename Type
1419 const Iterator pos( lowerBound( i, j ) );
1421 if( pos !=
end_[i] && pos->index_ == j ) {
1422 pos->value() = value;
1425 else return insert( pos, i, j, value );
1443 template<
typename Type
1451 const Iterator pos( lowerBound( i, j ) );
1453 if( pos !=
end_[i] && pos->index_ == j ) {
1457 return insert( pos, i, j, value );
1472 template<
typename Type
1478 std::move_backward( pos,
end_[i],
end_[i]+1UL );
1479 pos->value_ = value;
1486 std::move_backward( pos,
end_[
m_-1UL],
end_[
m_-1UL]+1UL );
1488 pos->value_ = value;
1491 for(
size_t k=i+1UL; k<
m_+1UL; ++k ) {
1499 size_t newCapacity( extendCapacity() );
1501 Iterator* newBegin =
new Iterator[2UL*
capacity_+2UL];
1502 Iterator* newEnd = newBegin+
capacity_+1UL;
1504 newBegin[0UL] = allocate<Element>( newCapacity );
1506 for(
size_t k=0UL; k<i; ++k ) {
1507 const size_t nonzeros(
end_[k] -
begin_[k] );
1509 newEnd [k] = newBegin[k] + nonzeros;
1510 newBegin[k+1UL] = newBegin[k] + total;
1512 newEnd [i] = newBegin[i] + (
end_[i] -
begin_[i] ) + 1;
1513 newBegin[i+1UL] = newBegin[i] + (
begin_[i+1] -
begin_[i] ) + 1;
1514 for(
size_t k=i+1UL; k<
m_; ++k ) {
1515 const size_t nonzeros(
end_[k] -
begin_[k] );
1517 newEnd [k] = newBegin[k] + nonzeros;
1518 newBegin[k+1UL] = newBegin[k] + total;
1521 newEnd[
m_] = newEnd[
capacity_] = newBegin[0UL]+newCapacity;
1523 Iterator tmp = std::move(
begin_[0UL], pos, newBegin[0UL] );
1524 tmp->value_ = value;
1526 std::move( pos,
end_[m_-1UL], tmp+1UL );
1548 template<
typename Type
1555 const Iterator pos( find( i, j ) );
1556 if( pos !=
end_[i] )
1557 end_[i] = std::move( pos+1,
end_[i], pos );
1573 template<
typename Type
1581 if( pos !=
end_[i] )
1582 end_[i] = std::move( pos+1,
end_[i], pos );
1601 template<
typename Type
1612 end_[i] = std::move( last,
end_[i], first );
1634 template<
typename Type
1641 if( m ==
m_ && n ==
n_ )
return;
1645 begin_ =
new Iterator[2UL*m+2UL];
1648 for(
size_t i=0UL; i<2UL*m+2UL; ++i ) {
1656 Iterator* newBegin(
new Iterator[2UL*m+2UL] );
1657 Iterator* newEnd ( newBegin+m+1UL );
1659 newBegin[0UL] =
begin_[0UL];
1662 for(
size_t i=0UL; i<
m_; ++i ) {
1663 newEnd [i] =
end_ [i];
1664 newBegin[i+1UL] =
begin_[i+1UL];
1666 for(
size_t i=m_; i<m; ++i ) {
1667 newBegin[i+1UL] = newEnd[i] =
begin_[
m_];
1671 for(
size_t i=0UL; i<m; ++i ) {
1672 newBegin[i+1UL] = newEnd[i] =
begin_[0UL];
1688 for(
size_t i=0UL; i<
m_; ++i )
1692 for(
size_t i=
m_; i<m; ++i ) {
1699 for(
size_t i=0UL; i<m; ++i )
1700 end_[i] = lowerBound( i, n );
1703 for(
size_t i=0UL; i<m; ++i )
1729 template<
typename Type
1734 reserveElements( nonzeros );
1753 template<
typename Type
1762 const size_t current(
capacity(i) );
1764 if( current >= nonzeros )
return;
1766 const ptrdiff_t additional( nonzeros - current );
1770 const size_t newCapacity(
begin_[
m_] -
begin_[0UL] + additional );
1773 Iterator* newBegin(
new Iterator[2UL*
m_+2UL] );
1774 Iterator* newEnd ( newBegin+
m_+1UL );
1776 newBegin[0UL] = allocate<Element>( newCapacity );
1777 newEnd [
m_ ] = newBegin[0UL]+newCapacity;
1779 for(
size_t k=0UL; k<i; ++k ) {
1781 newBegin[k+1UL] = newBegin[k] +
capacity(k);
1784 newBegin[i+1UL] = newBegin[i] + nonzeros;
1785 for(
size_t k=i+1UL; k<
m_; ++k ) {
1787 newBegin[k+1UL] = newBegin[k] +
capacity(k);
1801 for(
size_t j=
m_-1UL; j>i; --j ) {
1803 end_ [j] += additional;
1823 template<
typename Type
1827 for(
size_t i=0UL; i<
m_; ++i )
1844 template<
typename Type
1850 if( i < (
m_ - 1UL ) )
1862 template<
typename Type
1878 template<
typename Type
1895 template<
typename Type
1897 template<
typename Other >
1900 for(
size_t i=0UL; i<
m_; ++i )
1901 for( Iterator element=
begin_[i]; element!=
end_[i]; ++element )
1902 element->value_ *= scalar;
1915 template<
typename Type
1917 template<
typename Other >
1922 for(
size_t i=0UL; i<
size; ++i ) {
1923 Iterator pos = lowerBound( i, i );
1924 if( pos !=
end_[i] && pos->index_ == i )
1925 pos->value_ *= scalar;
1939 template<
typename Type
1960 template<
typename Type
1964 size_t nonzeros( 2UL*
capacity()+1UL );
1980 template<
typename Type
1984 Iterator* newBegin =
new Iterator[2UL*
capacity_+2UL];
1985 Iterator* newEnd = newBegin+
capacity_+1UL;
1987 newBegin[0UL] = allocate<Element>( nonzeros );
1989 for(
size_t k=0UL; k<
m_; ++k ) {
1992 newBegin[k+1UL] = newBegin[k] + (
begin_[k+1UL] -
begin_[k] );
1995 newEnd[
m_] = newBegin[0UL]+nonzeros;
2000 if( newBegin !=
nullptr ) {
2031 template<
typename Type
2036 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).find( i, j ) );
2056 template<
typename Type
2061 const ConstIterator pos( lowerBound( i, j ) );
2062 if( pos !=
end_[i] && pos->index_ == j )
2064 else return end_[i];
2084 template<
typename Type
2089 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).lowerBound( i, j ) );
2109 template<
typename Type
2115 return std::lower_bound(
begin_[i],
end_[i], j,
2116 [](
const Element& element,
size_t index )
2118 return element.index() < index;
2139 template<
typename Type
2144 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).upperBound( i, j ) );
2164 template<
typename Type
2170 return std::upper_bound(
begin_[i],
end_[i], j,
2171 [](
size_t index,
const Element& element )
2173 return index < element.index();
2231 template<
typename Type
2240 end_[i]->value_ = value;
2243 end_[i]->index_ = j;
2263 template<
typename Type
2294 template<
typename Type
2296 template<
typename Other >
2299 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
2314 template<
typename Type
2316 template<
typename Other >
2319 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
2334 template<
typename Type
2354 template<
typename Type
2356 template<
typename MT
2363 if(
m_ == 0UL ||
n_ == 0UL )
2366 size_t nonzeros( 0UL );
2368 for(
size_t i=1UL; i<=
m_; ++i )
2371 for(
size_t i=0UL; i<
m_; ++i )
2382 for(
size_t j=jbegin; j<jend; ++j )
2385 reserveElements( extendCapacity() );
2386 for(
size_t k=i+1UL; k<=
m_; ++k )
2390 end_[i]->value_ = (~rhs)(i,j);
2393 end_[i]->index_ = j;
2416 template<
typename Type
2418 template<
typename MT >
2426 if(
m_ == 0UL ||
begin_[0] ==
nullptr )
2429 for(
size_t i=0UL; i<
m_; ++i ) {
2447 template<
typename Type
2449 template<
typename MT >
2462 std::vector<size_t> rowLengths(
m_, 0UL );
2463 for(
size_t j=0UL; j<
n_; ++j ) {
2464 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2465 ++rowLengths[element->index()];
2469 for(
size_t i=0UL; i<
m_; ++i ) {
2474 for(
size_t j=0UL; j<
n_; ++j ) {
2475 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2476 append( element->index(), j, element->value() );
2493 template<
typename Type
2495 template<
typename MT
2519 template<
typename Type
2521 template<
typename MT
2545 template<
typename Type
2547 template<
typename MT
2571 template<
typename Type
2573 template<
typename MT
2606 template<
typename Type >
2618 struct Element :
public ElementBase
2622 template<
typename Other >
2623 inline Element&
operator=(
const Other& rhs )
2625 ElementBase::operator=( rhs );
2653 template<
typename ET >
2673 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
2676 template< typename MT,
bool SO > inline
CompressedMatrix( const DenseMatrix<MT,SO>& dm );
2677 template< typename MT,
bool SO > inline
CompressedMatrix( const SparseMatrix<MT,SO>& sm );
2691 inline Reference operator()(
size_t i,
size_t j ) noexcept;
2692 inline ConstReference operator()(
size_t i,
size_t j ) const noexcept;
2693 inline Reference
at(
size_t i,
size_t j );
2694 inline ConstReference
at(
size_t i,
size_t j ) const;
2695 inline Iterator
begin (
size_t i ) noexcept;
2696 inline ConstIterator
begin (
size_t i ) const noexcept;
2697 inline ConstIterator
cbegin(
size_t i ) const noexcept;
2698 inline Iterator
end (
size_t i ) noexcept;
2699 inline ConstIterator
end (
size_t i ) const noexcept;
2700 inline ConstIterator
cend (
size_t i ) const noexcept;
2707 inline CompressedMatrix& operator=( const CompressedMatrix& rhs );
2708 inline CompressedMatrix& operator=( CompressedMatrix&& rhs ) noexcept;
2710 template< typename MT,
bool SO > inline CompressedMatrix& operator= ( const DenseMatrix<MT,SO>& rhs );
2711 template< typename MT,
bool SO > inline CompressedMatrix& operator= ( const SparseMatrix<MT,SO>& rhs );
2712 template< typename MT,
bool SO > inline CompressedMatrix& operator+=( const Matrix<MT,SO>& rhs );
2713 template< typename MT,
bool SO > inline CompressedMatrix& operator-=( const Matrix<MT,SO>& rhs );
2714 template< typename MT,
bool SO > inline CompressedMatrix& operator*=( const Matrix<MT,SO>& rhs );
2716 template< typename Other >
2717 inline
EnableIf_< IsNumeric<Other>, CompressedMatrix >& operator*=( Other rhs );
2719 template< typename Other >
2720 inline
EnableIf_< IsNumeric<Other>, CompressedMatrix >& operator/=( Other rhs );
2727 inline
size_t rows() const noexcept;
2728 inline
size_t columns() const noexcept;
2729 inline
size_t capacity() const noexcept;
2730 inline
size_t capacity(
size_t j ) const noexcept;
2732 inline
size_t nonZeros(
size_t j ) const;
2733 inline
void reset();
2734 inline
void reset(
size_t j );
2735 inline
void clear();
2736 inline Iterator
set (
size_t i,
size_t j, const Type& value );
2737 inline Iterator
insert (
size_t i,
size_t j, const Type& value );
2738 inline
void erase (
size_t i,
size_t j );
2739 inline Iterator
erase (
size_t j, Iterator pos );
2740 inline Iterator
erase (
size_t j, Iterator first, Iterator last );
2741 void resize (
size_t m,
size_t n,
bool preserve=true );
2742 inline
void reserve(
size_t nonzeros );
2743 void reserve(
size_t j,
size_t nonzeros );
2744 inline
void trim ();
2745 inline
void trim (
size_t j );
2748 template< typename Other > inline CompressedMatrix& scale( const Other& scalar );
2749 template< typename Other > inline CompressedMatrix& scaleDiagonal( Other scalar );
2750 inline
void swap( CompressedMatrix& sm ) noexcept;
2757 inline Iterator
find (
size_t i,
size_t j );
2758 inline ConstIterator
find (
size_t i,
size_t j ) const;
2759 inline Iterator
lowerBound(
size_t i,
size_t j );
2760 inline ConstIterator
lowerBound(
size_t i,
size_t j ) const;
2761 inline Iterator
upperBound(
size_t i,
size_t j );
2762 inline ConstIterator
upperBound(
size_t i,
size_t j ) const;
2769 inline
void append (
size_t i,
size_t j, const Type& value,
bool check=false );
2777 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
2778 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
2782 template< typename MT,
bool SO > inline
void assign ( const DenseMatrix<MT,SO>& rhs );
2783 template< typename MT > inline
void assign ( const SparseMatrix<MT,true>& rhs );
2784 template< typename MT > inline
void assign ( const SparseMatrix<MT,false>& rhs );
2785 template< typename MT,
bool SO > inline
void addAssign( const DenseMatrix<MT,SO>& rhs );
2786 template< typename MT,
bool SO > inline
void addAssign( const SparseMatrix<MT,SO>& rhs );
2787 template< typename MT,
bool SO > inline
void subAssign( const DenseMatrix<MT,SO>& rhs );
2788 template< typename MT,
bool SO > inline
void subAssign( const SparseMatrix<MT,SO>& rhs );
2796 Iterator
insert( Iterator pos,
size_t i,
size_t j, const Type& value );
2837 template< typename Type >
2838 const Type CompressedMatrix<Type,true>::zero_ = Type();
2853 template< typename Type >
2854 inline CompressedMatrix<Type,true>::CompressedMatrix()
2858 , begin_ (
nullptr )
2874 template<
typename Type >
2879 ,
begin_( new Iterator[2UL*n+2UL] )
2882 for(
size_t j=0UL; j<2UL*
n_+2UL; ++j )
2899 template<
typename Type >
2900 inline CompressedMatrix<Type,true>::CompressedMatrix(
size_t m,
size_t n,
size_t nonzeros )
2904 ,
begin_( new Iterator[2UL*n+2UL] )
2907 begin_[0UL] = allocate<Element>( nonzeros );
2908 for(
size_t j=1UL; j<(2UL*
n_+1UL); ++j )
2927 template<
typename Type >
2928 CompressedMatrix<Type,true>::CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros )
2932 ,
begin_( new Iterator[2UL*
n_+2UL] )
2935 BLAZE_USER_ASSERT( nonzeros.size() == n,
"Size of capacity vector and number of columns don't match" );
2937 size_t newCapacity( 0UL );
2938 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
2941 begin_[0UL] =
end_[0UL] = allocate<Element>( newCapacity );
2942 for(
size_t j=0UL; j<
n_; ++j ) {
2956 template<
typename Type >
2957 inline CompressedMatrix<Type,true>::CompressedMatrix(
const CompressedMatrix& sm )
2961 ,
begin_ ( new Iterator[2UL*
n_+2UL] )
2964 const size_t nonzeros( sm.nonZeros() );
2966 begin_[0UL] = allocate<Element>( nonzeros );
2967 for(
size_t j=0UL; j<
n_; ++j )
2968 begin_[j+1UL] =
end_[j] = std::copy( sm.begin(j), sm.end(j), begin_[j] );
2969 end_[
n_] = begin_[0UL]+nonzeros;
2981 template<
typename Type >
2982 inline CompressedMatrix<Type,true>::CompressedMatrix( CompressedMatrix&& sm ) noexcept
2986 , begin_ ( sm.begin_ )
2992 sm.begin_ =
nullptr;
3005 template<
typename Type >
3006 template<
typename MT
3008 inline CompressedMatrix<Type,true>::CompressedMatrix(
const DenseMatrix<MT,SO>& dm )
3012 , begin_ ( new Iterator[2UL*n_+2UL] )
3013 ,
end_ ( begin_+(n_+1UL) )
3015 using blaze::assign;
3017 for(
size_t j=0UL; j<2UL*n_+2UL; ++j )
3018 begin_[j] =
nullptr;
3020 assign( *
this, ~dm );
3032 template<
typename Type >
3033 template<
typename MT
3035 inline CompressedMatrix<Type,true>::CompressedMatrix(
const SparseMatrix<MT,SO>& sm )
3039 , begin_ ( new Iterator[2UL*n_+2UL] )
3040 ,
end_ ( begin_+(n_+1UL) )
3042 using blaze::assign;
3044 const size_t nonzeros( (~sm).
nonZeros() );
3046 begin_[0UL] = allocate<Element>( nonzeros );
3047 for(
size_t j=0UL; j<
n_; ++j )
3048 begin_[j+1UL] =
end_[j] = begin_[0UL];
3049 end_[
n_] = begin_[0UL]+nonzeros;
3051 assign( *
this, ~sm );
3069 template<
typename Type >
3070 inline CompressedMatrix<Type,true>::~CompressedMatrix()
3072 if( begin_ !=
nullptr ) {
3103 template<
typename Type >
3105 CompressedMatrix<Type,true>::operator()(
size_t i,
size_t j ) noexcept
3127 template<
typename Type >
3129 CompressedMatrix<Type,true>::operator()(
size_t i,
size_t j )
const noexcept
3134 const ConstIterator pos( lowerBound( i, j ) );
3136 if( pos ==
end_[j] || pos->index_ != i )
3159 template<
typename Type >
3161 CompressedMatrix<Type,true>::at(
size_t i,
size_t j )
3169 return (*
this)(i,j);
3187 template<
typename Type >
3189 CompressedMatrix<Type,true>::at(
size_t i,
size_t j )
const
3197 return (*
this)(i,j);
3210 template<
typename Type >
3212 CompressedMatrix<Type,true>::begin(
size_t j ) noexcept
3228 template<
typename Type >
3230 CompressedMatrix<Type,true>::begin(
size_t j )
const noexcept
3246 template<
typename Type >
3248 CompressedMatrix<Type,true>::cbegin(
size_t j )
const noexcept
3264 template<
typename Type >
3266 CompressedMatrix<Type,true>::end(
size_t j ) noexcept
3282 template<
typename Type >
3284 CompressedMatrix<Type,true>::end(
size_t j )
const noexcept
3300 template<
typename Type >
3302 CompressedMatrix<Type,true>::cend(
size_t j )
const noexcept
3329 template<
typename Type >
3330 inline CompressedMatrix<Type,true>&
3331 CompressedMatrix<Type,true>::operator=(
const CompressedMatrix& rhs )
3333 if( &rhs ==
this )
return *
this;
3335 const size_t nonzeros( rhs.nonZeros() );
3339 Iterator* newBegin(
new Iterator[2UL*rhs.n_+2UL] );
3340 Iterator* newEnd ( newBegin+(rhs.n_+1UL) );
3342 newBegin[0UL] = allocate<Element>( nonzeros );
3343 for(
size_t j=0UL; j<rhs.n_; ++j ) {
3344 newBegin[j+1UL] = newEnd[j] = std::copy( rhs.begin_[j], rhs.end_[j], newBegin[j] );
3346 newEnd[rhs.n_] = newBegin[0UL]+nonzeros;
3352 if( newBegin !=
nullptr ) {
3358 for(
size_t j=0UL; j<rhs.n_; ++j ) {
3359 begin_[j+1UL] =
end_[j] = std::copy( rhs.begin_[j], rhs.end_[j], begin_[j] );
3379 template<
typename Type >
3380 inline CompressedMatrix<Type,true>&
3381 CompressedMatrix<Type,true>::operator=( CompressedMatrix&& rhs ) noexcept
3383 if( begin_ !=
nullptr ) {
3391 begin_ = rhs.begin_;
3396 rhs.capacity_ = 0UL;
3397 rhs.begin_ =
nullptr;
3416 template<
typename Type >
3417 template<
typename MT
3419 inline CompressedMatrix<Type,true>&
3420 CompressedMatrix<Type,true>::operator=(
const DenseMatrix<MT,SO>& rhs )
3422 using blaze::assign;
3424 if( (~rhs).canAlias(
this ) ) {
3425 CompressedMatrix tmp( ~rhs );
3430 assign( *
this, ~rhs );
3449 template<
typename Type >
3450 template<
typename MT
3452 inline CompressedMatrix<Type,true>&
3453 CompressedMatrix<Type,true>::operator=(
const SparseMatrix<MT,SO>& rhs )
3455 using blaze::assign;
3457 if( (~rhs).canAlias(
this ) ||
3460 CompressedMatrix tmp( ~rhs );
3466 assign( *
this, ~rhs );
3486 template<
typename Type >
3487 template<
typename MT
3489 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3491 using blaze::addAssign;
3497 addAssign( *
this, ~rhs );
3515 template<
typename Type >
3516 template<
typename MT
3518 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3520 using blaze::subAssign;
3526 subAssign( *
this, ~rhs );
3544 template<
typename Type >
3545 template<
typename MT
3547 inline CompressedMatrix<Type,true>&
3548 CompressedMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3550 if( (~rhs).
rows() != n_ ) {
3554 CompressedMatrix tmp( *
this * (~rhs) );
3571 template<
typename Type >
3572 template<
typename Other >
3573 inline EnableIf_< IsNumeric<Other>, CompressedMatrix<Type,true> >&
3574 CompressedMatrix<Type,true>::operator*=( Other rhs )
3576 for(
size_t j=0UL; j<
n_; ++j ) {
3577 const Iterator last(
end(j) );
3578 for( Iterator element=
begin(j); element!=last; ++element )
3579 element->value_ *= rhs;
3595 template<
typename Type >
3596 template<
typename Other >
3597 inline EnableIf_< IsNumeric<Other>, CompressedMatrix<Type,true> >&
3598 CompressedMatrix<Type,true>::operator/=( Other rhs )
3602 typedef DivTrait_<Type,Other> DT;
3603 typedef If_< IsNumeric<DT>, DT, Other > Tmp;
3607 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3608 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3609 for(
size_t j=0UL; j<
n_; ++j ) {
3610 const Iterator last(
end(j) );
3611 for( Iterator element=
begin(j); element!=last; ++element )
3612 element->value_ *= tmp;
3616 for(
size_t j=0UL; j<
n_; ++j ) {
3617 const Iterator last(
end(j) );
3618 for( Iterator element=
begin(j); element!=last; ++element )
3619 element->value_ /= rhs;
3643 template<
typename Type >
3644 inline size_t CompressedMatrix<Type,true>::rows() const noexcept
3658 template<
typename Type >
3659 inline size_t CompressedMatrix<Type,true>::columns() const noexcept
3673 template<
typename Type >
3674 inline size_t CompressedMatrix<Type,true>::capacity() const noexcept
3676 if( begin_ !=
nullptr )
3677 return end_[
n_] - begin_[0UL];
3691 template<
typename Type >
3692 inline size_t CompressedMatrix<Type,true>::capacity(
size_t j )
const noexcept
3695 return begin_[j+1UL] - begin_[j];
3707 template<
typename Type >
3708 inline size_t CompressedMatrix<Type,true>::nonZeros()
const
3710 size_t nonzeros( 0UL );
3712 for(
size_t j=0UL; j<
n_; ++j )
3728 template<
typename Type >
3729 inline size_t CompressedMatrix<Type,true>::nonZeros(
size_t j )
const
3732 return end_[j] - begin_[j];
3744 template<
typename Type >
3747 for(
size_t j=0UL; j<
n_; ++j )
3748 end_[j] = begin_[j];
3764 template<
typename Type >
3768 end_[j] = begin_[j];
3782 template<
typename Type >
3806 template<
typename Type >
3808 CompressedMatrix<Type,true>::set(
size_t i,
size_t j,
const Type& value )
3813 const Iterator pos( lowerBound( i, j ) );
3815 if( pos !=
end_[j] && pos->index_ == i ) {
3816 pos->value() = value;
3819 else return insert( pos, i, j, value );
3839 template<
typename Type >
3841 CompressedMatrix<Type,true>::insert(
size_t i,
size_t j,
const Type& value )
3846 const Iterator pos( lowerBound( i, j ) );
3848 if( pos !=
end_[j] && pos->index_ == i ) {
3852 return insert( pos, i, j, value );
3869 template<
typename Type >
3871 CompressedMatrix<Type,true>::insert( Iterator pos,
size_t i,
size_t j,
const Type& value )
3873 if( begin_[j+1UL] -
end_[j] != 0 ) {
3874 std::move_backward( pos,
end_[j],
end_[j]+1UL );
3875 pos->value_ = value;
3881 else if(
end_[n_] - begin_[n_] != 0 ) {
3882 std::move_backward( pos,
end_[n_-1UL],
end_[n_-1]+1UL );
3884 pos->value_ = value;
3887 for(
size_t k=j+1UL; k<n_+1UL; ++k ) {
3895 size_t newCapacity( extendCapacity() );
3897 Iterator* newBegin =
new Iterator[2UL*
capacity_+2UL];
3898 Iterator* newEnd = newBegin+
capacity_+1UL;
3900 newBegin[0UL] = allocate<Element>( newCapacity );
3902 for(
size_t k=0UL; k<j; ++k ) {
3903 const size_t nonzeros(
end_[k] - begin_[k] );
3904 const size_t total( begin_[k+1UL] - begin_[k] );
3905 newEnd [k] = newBegin[k] + nonzeros;
3906 newBegin[k+1UL] = newBegin[k] + total;
3908 newEnd [j] = newBegin[j] + (
end_[j] - begin_[j] ) + 1;
3909 newBegin[j+1UL] = newBegin[j] + ( begin_[j+1UL] - begin_[j] ) + 1;
3910 for(
size_t k=j+1UL; k<
n_; ++k ) {
3911 const size_t nonzeros(
end_[k] - begin_[k] );
3912 const size_t total( begin_[k+1UL] - begin_[k] );
3913 newEnd [k] = newBegin[k] + nonzeros;
3914 newBegin[k+1UL] = newBegin[k] + total;
3917 newEnd[
n_] = newEnd[
capacity_] = newBegin[0UL]+newCapacity;
3919 Iterator tmp = std::move( begin_[0UL], pos, newBegin[0UL] );
3920 tmp->value_ = value;
3922 std::move( pos,
end_[n_-1UL], tmp+1UL );
3946 template<
typename Type >
3947 inline void CompressedMatrix<Type,true>::erase(
size_t i,
size_t j )
3952 const Iterator pos( find( i, j ) );
3953 if( pos !=
end_[j] )
3954 end_[j] = std::move( pos+1,
end_[j], pos );
3970 template<
typename Type >
3972 CompressedMatrix<Type,true>::erase(
size_t j, Iterator pos )
3977 if( pos !=
end_[j] )
3978 end_[j] = std::move( pos+1,
end_[j], pos );
3997 template<
typename Type >
3999 CompressedMatrix<Type,true>::erase(
size_t j, Iterator first, Iterator last )
4007 end_[j] = std::move( last,
end_[j], first );
4031 template<
typename Type >
4032 void CompressedMatrix<Type,true>::resize(
size_t m,
size_t n,
bool preserve )
4037 if( m ==
m_ && n == n_ )
return;
4039 if( begin_ ==
nullptr )
4041 begin_ =
new Iterator[2UL*n+2UL];
4042 end_ = begin_+n+1UL;
4044 for(
size_t j=0UL; j<2UL*n+2UL; ++j ) {
4045 begin_[j] =
nullptr;
4052 Iterator* newBegin(
new Iterator[2UL*n+2UL] );
4053 Iterator* newEnd ( newBegin+n+1UL );
4055 newBegin[0UL] = begin_[0UL];
4058 for(
size_t j=0UL; j<
n_; ++j ) {
4059 newEnd [j] =
end_ [j];
4060 newBegin[j+1UL] = begin_[j+1UL];
4062 for(
size_t j=n_; j<n; ++j ) {
4063 newBegin[j+1UL] = newEnd[j] = begin_[
n_];
4067 for(
size_t j=0UL; j<n; ++j ) {
4068 newBegin[j+1UL] = newEnd[j] = begin_[0UL];
4084 for(
size_t j=0UL; j<
n_; ++j )
4085 end_[j] = begin_[j];
4088 for(
size_t j=n_; j<n; ++j ) {
4089 begin_[j+1UL] =
end_[j] = begin_[
n_];
4095 for(
size_t j=0UL; j<n; ++j )
4096 end_[j] = lowerBound( m, j );
4099 for(
size_t j=0UL; j<n; ++j )
4100 end_[j] = begin_[j];
4127 template<
typename Type >
4128 inline void CompressedMatrix<Type,true>::reserve(
size_t nonzeros )
4131 reserveElements( nonzeros );
4149 template<
typename Type >
4150 void CompressedMatrix<Type,true>::reserve(
size_t j,
size_t nonzeros )
4157 const size_t current(
capacity(j) );
4159 if( current >= nonzeros )
return;
4161 const ptrdiff_t additional( nonzeros - current );
4163 if(
end_[n_] - begin_[n_] < additional )
4165 const size_t newCapacity( begin_[n_] - begin_[0UL] + additional );
4168 Iterator* newBegin(
new Iterator[2UL*n_+2UL] );
4169 Iterator* newEnd ( newBegin+n_+1UL );
4171 newBegin[0UL] = allocate<Element>( newCapacity );
4172 newEnd [
n_ ] = newBegin[0UL]+newCapacity;
4174 for(
size_t k=0UL; k<j; ++k ) {
4175 newEnd [k ] =
transfer( begin_[k],
end_[k], newBegin[k] );
4176 newBegin[k+1UL] = newBegin[k] +
capacity(k);
4178 newEnd [j ] =
transfer( begin_[j],
end_[j], newBegin[j] );
4179 newBegin[j+1UL] = newBegin[j] + nonzeros;
4180 for(
size_t k=j+1UL; k<
n_; ++k ) {
4181 newEnd [k ] =
transfer( begin_[k],
end_[k], newBegin[k] );
4182 newBegin[k+1UL] = newBegin[k] +
capacity(k);
4195 begin_[
n_] += additional;
4196 for(
size_t k=n_-1UL; k>j; --k ) {
4197 begin_[k] = std::move_backward( begin_[k],
end_[k],
end_[k]+additional );
4198 end_ [k] += additional;
4219 template<
typename Type >
4220 void CompressedMatrix<Type,true>::trim()
4222 for(
size_t j=0UL; j<
n_; ++j )
4240 template<
typename Type >
4241 void CompressedMatrix<Type,true>::trim(
size_t j )
4245 if( j < ( n_ - 1UL ) )
4246 end_[j+1] = std::move( begin_[j+1],
end_[j+1],
end_[j] );
4247 begin_[j+1] =
end_[j];
4259 template<
typename Type >
4260 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::transpose()
4262 CompressedMatrix tmp(
trans( *
this ) );
4276 template<
typename Type >
4277 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::ctranspose()
4279 CompressedMatrix tmp(
ctrans( *
this ) );
4294 template<
typename Type >
4295 template<
typename Other >
4296 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scale(
const Other& scalar )
4298 for(
size_t j=0UL; j<
n_; ++j )
4299 for( Iterator element=begin_[j]; element!=
end_[j]; ++element )
4300 element->value_ *= scalar;
4315 template<
typename Type >
4316 template<
typename Other >
4317 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scaleDiagonal( Other scalar )
4321 for(
size_t j=0UL; j<
size; ++j ) {
4322 Iterator pos = lowerBound( j, j );
4323 if( pos !=
end_[j] && pos->index_ == j )
4324 pos->value_ *= scalar;
4340 template<
typename Type >
4362 template<
typename Type >
4363 inline size_t CompressedMatrix<Type,true>::extendCapacity() const noexcept
4365 size_t nonzeros( 2UL*
capacity()+1UL );
4383 template<
typename Type >
4384 void CompressedMatrix<Type,true>::reserveElements(
size_t nonzeros )
4386 Iterator* newBegin =
new Iterator[2UL*
capacity_+2UL];
4387 Iterator* newEnd = newBegin+
capacity_+1UL;
4389 newBegin[0UL] = allocate<Element>( nonzeros );
4391 for(
size_t k=0UL; k<
n_; ++k ) {
4393 newEnd [k] =
transfer( begin_[k],
end_[k], newBegin[k] );
4394 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
4397 newEnd[
n_] = newBegin[0UL]+nonzeros;
4402 if( newBegin !=
nullptr ) {
4434 template<
typename Type >
4436 CompressedMatrix<Type,true>::find(
size_t i,
size_t j )
4438 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).find( i, j ) );
4459 template<
typename Type >
4461 CompressedMatrix<Type,true>::find(
size_t i,
size_t j )
const
4463 const ConstIterator pos( lowerBound( i, j ) );
4464 if( pos !=
end_[j] && pos->index_ == i )
4466 else return end_[j];
4486 template<
typename Type >
4488 CompressedMatrix<Type,true>::lowerBound(
size_t i,
size_t j )
4490 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).lowerBound( i, j ) );
4510 template<
typename Type >
4512 CompressedMatrix<Type,true>::lowerBound(
size_t i,
size_t j )
const
4515 return std::lower_bound( begin_[j],
end_[j], i,
4516 [](
const Element& element,
size_t index )
4518 return element.index() < index;
4539 template<
typename Type >
4541 CompressedMatrix<Type,true>::upperBound(
size_t i,
size_t j )
4543 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).upperBound( i, j ) );
4563 template<
typename Type >
4565 CompressedMatrix<Type,true>::upperBound(
size_t i,
size_t j )
const
4568 return std::upper_bound( begin_[j],
end_[j], i,
4569 [](
size_t index,
const Element& element )
4571 return index < element.index();
4628 template<
typename Type >
4629 inline void CompressedMatrix<Type,true>::append(
size_t i,
size_t j,
const Type& value,
bool check )
4636 end_[j]->value_ = value;
4639 end_[j]->index_ = i;
4661 template<
typename Type >
4662 inline void CompressedMatrix<Type,true>::finalize(
size_t j )
4666 begin_[j+1UL] =
end_[j];
4693 template<
typename Type >
4694 template<
typename Other >
4695 inline bool CompressedMatrix<Type,true>::canAlias(
const Other* alias )
const noexcept
4697 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4714 template<
typename Type >
4715 template<
typename Other >
4716 inline bool CompressedMatrix<Type,true>::isAliased(
const Other* alias )
const noexcept
4718 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4735 template<
typename Type >
4736 inline bool CompressedMatrix<Type,true>::canSMPAssign() const noexcept
4756 template<
typename Type >
4757 template<
typename MT
4759 inline void CompressedMatrix<Type,true>::assign(
const DenseMatrix<MT,SO>& rhs )
4764 if(
m_ == 0UL || n_ == 0UL )
4767 size_t nonzeros( 0UL );
4769 for(
size_t j=1UL; j<=
n_; ++j )
4772 for(
size_t j=0UL; j<
n_; ++j )
4774 begin_[j] =
end_[j] = begin_[0UL]+nonzeros;
4776 const size_t ibegin( ( IsLower<MT>::value )
4777 ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4779 const size_t iend ( ( IsUpper<MT>::value )
4780 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4783 for(
size_t i=ibegin; i<iend; ++i )
4786 reserveElements( extendCapacity() );
4787 for(
size_t k=j+1UL; k<=
n_; ++k )
4791 end_[j]->value_ = (~rhs)(i,j);
4794 end_[j]->index_ = i;
4801 begin_[
n_] = begin_[0UL]+nonzeros;
4819 template<
typename Type >
4820 template<
typename MT >
4821 inline void CompressedMatrix<Type,true>::assign(
const SparseMatrix<MT,true>& rhs )
4828 if( n_ == 0UL || begin_[0] ==
nullptr )
4831 for(
size_t j=0UL; j<
n_; ++j ) {
4832 begin_[j+1UL] =
end_[j] = std::copy( (~rhs).
begin(j), (~rhs).
end(j), begin_[j] );
4851 template<
typename Type >
4852 template<
typename MT >
4853 inline void CompressedMatrix<Type,true>::assign(
const SparseMatrix<MT,false>& rhs )
4862 typedef ConstIterator_<MT> RhsIterator;
4865 std::vector<size_t> columnLengths( n_, 0UL );
4866 for(
size_t i=0UL; i<
m_; ++i ) {
4867 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4868 ++columnLengths[element->index()];
4872 for(
size_t j=0UL; j<
n_; ++j ) {
4873 begin_[j+1UL] =
end_[j+1UL] = begin_[j] + columnLengths[j];
4877 for(
size_t i=0UL; i<
m_; ++i ) {
4878 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4879 append( i, element->index(), element->value() );
4898 template<
typename Type >
4899 template<
typename MT
4901 inline void CompressedMatrix<Type,true>::addAssign(
const DenseMatrix<MT,SO>& rhs )
4906 CompressedMatrix tmp(
serial( *
this + (~rhs) ) );
4925 template<
typename Type >
4926 template<
typename MT
4928 inline void CompressedMatrix<Type,true>::addAssign(
const SparseMatrix<MT,SO>& rhs )
4933 CompressedMatrix tmp(
serial( *
this + (~rhs) ) );
4952 template<
typename Type >
4953 template<
typename MT
4955 inline void CompressedMatrix<Type,true>::subAssign(
const DenseMatrix<MT,SO>& rhs )
4960 CompressedMatrix tmp(
serial( *
this - (~rhs) ) );
4979 template<
typename Type >
4980 template<
typename MT
4982 inline void CompressedMatrix<Type,true>::subAssign(
const SparseMatrix<MT,SO>& rhs )
4987 CompressedMatrix tmp(
serial( *
this - (~rhs) ) );
5009 template<
typename Type,
bool SO >
5010 inline void reset( CompressedMatrix<Type,SO>& m );
5012 template<
typename Type,
bool SO >
5013 inline void reset( CompressedMatrix<Type,SO>& m,
size_t i );
5015 template<
typename Type,
bool SO >
5016 inline void clear( CompressedMatrix<Type,SO>& m );
5018 template<
typename Type,
bool SO >
5019 inline bool isDefault(
const CompressedMatrix<Type,SO>& m );
5021 template<
typename Type,
bool SO >
5022 inline bool isIntact(
const CompressedMatrix<Type,SO>& m );
5024 template<
typename Type,
bool SO >
5025 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b ) noexcept;
5037 template<
typename Type
5039 inline void reset( CompressedMatrix<Type,SO>& m )
5059 template<
typename Type
5061 inline void reset( CompressedMatrix<Type,SO>& m,
size_t i )
5075 template<
typename Type
5077 inline void clear( CompressedMatrix<Type,SO>& m )
5102 template<
typename Type
5106 return ( m.rows() == 0UL && m.columns() == 0UL );
5129 template<
typename Type
5131 inline bool isIntact(
const CompressedMatrix<Type,SO>& m )
5133 return ( m.nonZeros() <= m.capacity() );
5146 template<
typename Type
5148 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b ) noexcept
5165 template<
typename T,
bool SO >
5166 struct IsResizable< CompressedMatrix<T,SO> > :
public TrueType
5182 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5183 struct AddTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5185 using Type = StaticMatrix< AddTrait_<T1,T2>, M, N, SO >;
5188 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5189 struct AddTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5191 using Type = StaticMatrix< AddTrait_<T1,T2>, M, N, SO2 >;
5194 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5195 struct AddTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5197 using Type = StaticMatrix< AddTrait_<T1,T2>, M, N, SO >;
5200 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5201 struct AddTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5203 using Type = StaticMatrix< AddTrait_<T1,T2>, M, N, SO1 >;
5206 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5207 struct AddTrait< CompressedMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5209 using Type = HybridMatrix< AddTrait_<T1,T2>, M, N, SO >;
5212 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5213 struct AddTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5215 using Type = HybridMatrix< AddTrait_<T1,T2>, M, N, SO2 >;
5218 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5219 struct AddTrait< HybridMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5221 using Type = HybridMatrix< AddTrait_<T1,T2>, M, N, SO >;
5224 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5225 struct AddTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5227 using Type = HybridMatrix< AddTrait_<T1,T2>, M, N, SO1 >;
5230 template<
typename T1,
bool SO,
typename T2 >
5231 struct AddTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5233 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO >;
5236 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5237 struct AddTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5239 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO2 >;
5242 template<
typename T1,
bool SO,
typename T2 >
5243 struct AddTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5245 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO >;
5248 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5249 struct AddTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5251 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO1 >;
5254 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5255 struct AddTrait< CompressedMatrix<T1,SO>, CustomMatrix<T2,AF,PF,SO> >
5257 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO >;
5260 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5261 struct AddTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5263 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO2 >;
5266 template<
typename T1,
bool AF,
bool PF,
bool SO,
typename T2 >
5267 struct AddTrait< CustomMatrix<T1,AF,PF,SO>, CompressedMatrix<T2,SO> >
5269 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO >;
5272 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5273 struct AddTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5275 using Type = DynamicMatrix< AddTrait_<T1,T2>, SO1 >;
5278 template<
typename T1,
bool SO,
typename T2 >
5279 struct AddTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5281 using Type = CompressedMatrix< AddTrait_<T1,T2>, SO >;
5284 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5285 struct AddTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5287 using Type = CompressedMatrix< AddTrait_<T1,T2>,
false >;
5303 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5304 struct SubTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5306 using Type = StaticMatrix< SubTrait_<T1,T2>, M, N, SO >;
5309 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5310 struct SubTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5312 using Type = StaticMatrix< SubTrait_<T1,T2>, M, N, SO2 >;
5315 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5316 struct SubTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5318 using Type = StaticMatrix< SubTrait_<T1,T2>, M, N, SO >;
5321 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5322 struct SubTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5324 using Type = StaticMatrix< SubTrait_<T1,T2>, M, N, SO1 >;
5327 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5328 struct SubTrait< CompressedMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5330 using Type = HybridMatrix< SubTrait_<T1,T2>, M, N, SO >;
5333 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5334 struct SubTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5336 using Type = HybridMatrix< SubTrait_<T1,T2>, M, N, SO2 >;
5339 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5340 struct SubTrait< HybridMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5342 using Type = HybridMatrix< SubTrait_<T1,T2>, M, N, SO >;
5345 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5346 struct SubTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5348 using Type = HybridMatrix< SubTrait_<T1,T2>, M, N, SO1 >;
5351 template<
typename T1,
bool SO,
typename T2 >
5352 struct SubTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5354 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO >;
5357 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5358 struct SubTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5360 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO2 >;
5363 template<
typename T1,
bool SO,
typename T2 >
5364 struct SubTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5366 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO >;
5369 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5370 struct SubTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5372 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO1 >;
5375 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5376 struct SubTrait< CompressedMatrix<T1,SO>, CustomMatrix<T2,AF,PF,SO> >
5378 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO >;
5381 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5382 struct SubTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5384 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO2 >;
5387 template<
typename T1,
bool AF,
bool PF,
bool SO,
typename T2 >
5388 struct SubTrait< CustomMatrix<T1,AF,PF,SO>, CompressedMatrix<T2,SO> >
5390 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO >;
5393 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5394 struct SubTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5396 using Type = DynamicMatrix< SubTrait_<T1,T2>, SO1 >;
5399 template<
typename T1,
bool SO,
typename T2 >
5400 struct SubTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5402 using Type = CompressedMatrix< SubTrait_<T1,T2> , SO >;
5405 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5406 struct SubTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5408 using Type = CompressedMatrix< SubTrait_<T1,T2> ,
false >;
5424 template<
typename T1,
bool SO,
typename T2 >
5425 struct MultTrait< CompressedMatrix<T1,SO>, T2,
EnableIf_< IsNumeric<T2> > >
5427 using Type = CompressedMatrix< MultTrait_<T1,T2>, SO >;
5430 template<
typename T1,
typename T2,
bool SO >
5431 struct MultTrait< T1, CompressedMatrix<T2,SO>,
EnableIf_< IsNumeric<T1> > >
5433 using Type = CompressedMatrix< MultTrait_<T1,T2>, SO >;
5436 template<
typename T1,
bool SO,
typename T2,
size_t N >
5437 struct MultTrait< CompressedMatrix<T1,SO>, StaticVector<T2,N,false> >
5439 using Type = DynamicVector< MultTrait_<T1,T2>,
false >;
5442 template<
typename T1,
size_t N,
typename T2,
bool SO >
5443 struct MultTrait< StaticVector<T1,N,true>, CompressedMatrix<T2,SO> >
5445 using Type = DynamicVector< MultTrait_<T1,T2>,
true >;
5448 template<
typename T1,
bool SO,
typename T2,
size_t N >
5449 struct MultTrait< CompressedMatrix<T1,SO>, HybridVector<T2,N,false> >
5451 using Type = DynamicVector< MultTrait_<T1,T2>,
false >;
5454 template<
typename T1,
size_t N,
typename T2,
bool SO >
5455 struct MultTrait< HybridVector<T1,N,true>, CompressedMatrix<T2,SO> >
5457 using Type = DynamicVector< MultTrait_<T1,T2>,
true >;
5460 template<
typename T1,
bool SO,
typename T2 >
5461 struct MultTrait< CompressedMatrix<T1,SO>, DynamicVector<T2,false> >
5463 using Type = DynamicVector< MultTrait_<T1,T2>,
false >;
5466 template<
typename T1,
typename T2,
bool SO >
5467 struct MultTrait< DynamicVector<T1,true>, CompressedMatrix<T2,SO> >
5469 using Type = DynamicVector< MultTrait_<T1,T2>,
true >;
5472 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5473 struct MultTrait< CompressedMatrix<T1,SO>, CustomVector<T2,AF,PF,false> >
5475 using Type = DynamicVector< MultTrait_<T1,T2>,
false >;
5478 template<
typename T1,
bool AF,
bool PF,
typename T2,
bool SO >
5479 struct MultTrait< CustomVector<T1,AF,PF,true>, CompressedMatrix<T2,SO> >
5481 using Type = DynamicVector< MultTrait_<T1,T2>,
true >;
5484 template<
typename T1,
bool SO,
typename T2 >
5485 struct MultTrait< CompressedMatrix<T1,SO>, CompressedVector<T2,false> >
5487 using Type = CompressedVector< MultTrait_<T1,T2>,
false >;
5490 template<
typename T1,
typename T2,
bool SO >
5491 struct MultTrait< CompressedVector<T1,true>, CompressedMatrix<T2,SO> >
5493 using Type = CompressedVector< MultTrait_<T1,T2>,
true >;
5496 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5497 struct MultTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5499 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5502 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5503 struct MultTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5505 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5508 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5509 struct MultTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5511 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5514 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5515 struct MultTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5517 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5520 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5521 struct MultTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5523 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5526 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5527 struct MultTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5529 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5532 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5533 struct MultTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5535 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5538 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5539 struct MultTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5541 using Type = DynamicMatrix< MultTrait_<T1,T2>, SO1 >;
5544 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5545 struct MultTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5547 using Type = CompressedMatrix< MultTrait_<T1,T2>, SO1 >;
5563 template<
typename T1,
bool SO,
typename T2 >
5564 struct DivTrait< CompressedMatrix<T1,SO>, T2,
EnableIf_< IsNumeric<T2> > >
5566 using Type = CompressedMatrix< DivTrait_<T1,T2>, SO >;
5582 template<
typename T1,
bool SO,
typename T2 >
5583 struct MathTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5585 using HighType = CompressedMatrix< typename MathTrait<T1,T2>::HighType, SO >;
5586 using LowType = CompressedMatrix< typename MathTrait<T1,T2>::LowType , SO >;
5602 template<
typename T1,
bool SO >
5603 struct SubmatrixTrait< CompressedMatrix<T1,SO> >
5605 using Type = CompressedMatrix<T1,SO>;
5621 template<
typename T1,
bool SO >
5622 struct RowTrait< CompressedMatrix<T1,SO> >
5624 using Type = CompressedVector<T1,true>;
5640 template<
typename T1,
bool SO >
5641 struct ColumnTrait< CompressedMatrix<T1,SO> >
5643 using Type = CompressedVector<T1,false>;
#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
Pointer difference type of the Blaze library.
void reserveElements(size_t nonzeros)
Reserving the specified number of sparse matrix elements.
Definition: CompressedMatrix.h:1982
Header file for auxiliary alias declarations.
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: CompressedMatrix.h:2297
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
Iterator * end_
Pointers one past the last non-zero element of each row.
Definition: CompressedMatrix.h:409
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
MatrixAccessProxy< This > Reference
Reference to a sparse matrix value.
Definition: CompressedMatrix.h:244
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.
const Type & ConstReference
Reference to a constant sparse matrix value.
Definition: CompressedMatrix.h:245
Header file for the row trait.
CompressedMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: CompressedMatrix.h:1880
CompressedMatrix()
The default constructor for CompressedMatrix.
Definition: CompressedMatrix.h:453
Header file for the serial shim.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
const CTransExprTrait_< MT > ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatForEachExpr.h:1195
Iterator end(size_t i) noexcept
Returns an iterator just past the last non-zero element of row/column i.
Definition: CompressedMatrix.h:870
Reference operator()(size_t i, size_t j) noexcept
2D-access to the sparse matrix elements.
Definition: CompressedMatrix.h:696
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
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2805
void clear()
Clearing the sparse matrix.
Definition: CompressedMatrix.h:1390
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:241
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
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
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
CompressedMatrix< ET, SO > Other
The type of the other CompressedMatrix.
Definition: CompressedMatrix.h:255
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:239
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: CompressedMatrix.h:2336
#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
~CompressedMatrix()
The destructor for CompressedMatrix.
Definition: CompressedMatrix.h:662
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
void reset(CompressedMatrix< Type, SO > &m)
Resetting the given compressed matrix.
Definition: CompressedMatrix.h:5039
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
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:100
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
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.
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: CompressedMatrix.h:2317
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:411
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:242
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:109
void swap(CompressedMatrix &sm) noexcept
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:1941
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
size_t extendCapacity() const noexcept
Calculating a new matrix capacity.
Definition: CompressedMatrix.h:1962
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: CompressedMatrix.h:1312
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2807
Header file for the SparseMatrix base class.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:407
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse matrix.
Definition: CompressedMatrix.h:1731
void reset()
Reset to the default initial values.
Definition: CompressedMatrix.h:1352
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:243
Header file for the ValueIndexPair class.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5104
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type 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.
Iterator set(size_t i, size_t j, const Type &value)
Setting an element of the compressed matrix.
Definition: CompressedMatrix.h:1414
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
Header file for the MatrixAccessProxy class.
Header file for all forward declarations of the math module.
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
Header file for the IsSMPAssignable type trait.
void erase(size_t i, size_t j)
Erasing an element from the sparse matrix.
Definition: CompressedMatrix.h:1550
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2809
#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
ValueIndexPair< Type > ElementBase
Base class for the sparse matrix element.
Definition: CompressedMatrix.h:211
Constraint on the data type.
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
Header file for the default storage order for all vectors of the Blaze library.
ConstIterator cend(size_t i) const noexcept
Returns an iterator just past the last non-zero element of row/column i.
Definition: CompressedMatrix.h:914
Iterator insert(size_t i, size_t j, const Type &value)
Inserting an element into the compressed matrix.
Definition: CompressedMatrix.h:1446
Header file for the exception macros of the math module.
CompressedMatrix< ET, true > Other
The type of the other CompressedMatrix.
Definition: CompressedMatrix.h:2655
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
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 void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
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
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Headerfile for generic algorithms.
void subAssign(const DenseMatrix< MT, SO2 > &rhs)
Default implementation of the subtraction assignment of a dense matrix.
Definition: CompressedMatrix.h:2549
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
size_t columns() const noexcept
Returns the current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:1261
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:247
typename DivTrait< T1, T2 >::Type DivTrait_
Auxiliary alias declaration for the DivTrait class template.The DivTrait_ alias declaration provides ...
Definition: DivTrait.h:245
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the sparse matrix.
Definition: CompressedMatrix.h:1636
Header file for the IsNumeric type trait.
CompressedMatrix & operator=(const CompressedMatrix &rhs)
Copy assignment operator for CompressedMatrix.
Definition: CompressedMatrix.h:942
#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
size_t rows() const noexcept
Returns the current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:1247
Header file for run time assertion macros.
Header file for the addition trait.
CompressedMatrix & transpose()
In-place transpose of the matrix.
Definition: CompressedMatrix.h:1864
Header file for the division trait.
void trim()
Removing all excessive capacity from all rows/columns.
Definition: CompressedMatrix.h:1825
Header file for the submatrix 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
#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.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:89
Constraint on the data type.
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:238
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2808
void assign(const DenseMatrix< MT, SO2 > &rhs)
Default implementation of the assignment of a row-major dense matrix.
Definition: CompressedMatrix.h:2358
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:246
size_t capacity() const noexcept
Returns the maximum capacity of the sparse matrix.
Definition: CompressedMatrix.h:1275
void append(size_t i, size_t j, const Type &value, bool check=false)
Appending an element to the specified row/column of the sparse matrix.
Definition: CompressedMatrix.h:2233
EnableIf_< IsBuiltin< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:225
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: CompressedMatrix.h:2265
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
CompressedMatrix< Type, SO > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:236
Iterator find(size_t i, size_t j)
Searches for a specific matrix element.
Definition: CompressedMatrix.h:2034
Header file for the mathematical trait.
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
Iterator * begin_
Pointers to the first non-zero element of each row.
Definition: CompressedMatrix.h:408
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
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2806
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.
void addAssign(const DenseMatrix< MT, SO2 > &rhs)
Default implementation of the addition assignment of a dense matrix.
Definition: CompressedMatrix.h:2497
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:950
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:240
SparseMatrix< This, SO > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:237
Iterator lowerBound(size_t i, size_t j)
Returns an iterator to the first index not less then the given index.
Definition: CompressedMatrix.h:2087
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:2811
Iterator upperBound(size_t i, size_t j)
Returns an iterator to the first index greater then the given index.
Definition: CompressedMatrix.h:2142
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:254
ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: CompressedMatrix.h:848
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2654
Header file for the IsUpper type trait.
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:406
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: CompressedMatrix.h:750
Header file for the IsResizable type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:405
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
Iterator begin(size_t i) noexcept
Returns an iterator to the first non-zero element of row/column i.
Definition: CompressedMatrix.h:804
constexpr bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56