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 );
238 struct FindIndex :
public std::binary_function<Element,size_t,bool>
240 inline bool operator()(
const Element& element,
size_t index )
const {
241 return element.index() < index;
243 inline bool operator()(
size_t index,
const Element& element )
const {
244 return index < element.index();
246 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
247 return element1.index() < element2.index();
271 template<
typename ET >
291 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
308 inline Reference
operator()(
size_t i,
size_t j );
309 inline ConstReference
operator()(
size_t i,
size_t j )
const;
310 inline Reference
at(
size_t i,
size_t j );
311 inline ConstReference
at(
size_t i,
size_t j )
const;
312 inline Iterator
begin (
size_t i );
313 inline ConstIterator
begin (
size_t i )
const;
314 inline ConstIterator
cbegin(
size_t i )
const;
315 inline Iterator
end (
size_t i );
316 inline ConstIterator
end (
size_t i )
const;
317 inline ConstIterator
cend (
size_t i )
const;
331 template<
typename Other >
333 operator*=( Other rhs );
335 template<
typename Other >
337 operator/=( Other rhs );
344 inline size_t rows()
const;
347 inline size_t capacity(
size_t i )
const;
349 inline size_t nonZeros(
size_t i )
const;
351 inline void reset(
size_t i );
353 inline Iterator
set (
size_t i,
size_t j,
const Type& value );
354 inline Iterator
insert (
size_t i,
size_t j,
const Type& value );
355 inline void erase (
size_t i,
size_t j );
356 inline Iterator
erase (
size_t i, Iterator pos );
357 inline Iterator
erase (
size_t i, Iterator first, Iterator last );
358 void resize (
size_t m,
size_t n,
bool preserve=
true );
359 inline void reserve(
size_t nonzeros );
360 void reserve(
size_t i,
size_t nonzeros );
362 inline void trim (
size_t i );
365 template<
typename Other >
inline CompressedMatrix& scale(
const Other& scalar );
366 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
374 inline Iterator
find (
size_t i,
size_t j );
375 inline ConstIterator
find (
size_t i,
size_t j )
const;
376 inline Iterator
lowerBound(
size_t i,
size_t j );
377 inline ConstIterator
lowerBound(
size_t i,
size_t j )
const;
378 inline Iterator
upperBound(
size_t i,
size_t j );
379 inline ConstIterator
upperBound(
size_t i,
size_t j )
const;
386 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
394 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
395 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
413 Iterator
insert( Iterator pos,
size_t i,
size_t j,
const Type& value );
453 template<
typename Type,
bool SO >
468 template<
typename Type
490 template<
typename Type
499 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
514 template<
typename Type
523 begin_[0UL] = allocate<Element>( nonzeros );
524 for(
size_t i=1UL; i<(2UL*
m_+1UL); ++i )
542 template<
typename Type
551 BLAZE_USER_ASSERT( nonzeros.size() == m,
"Size of capacity vector and number of rows don't match" );
553 size_t newCapacity( 0UL );
554 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
557 begin_[0UL] =
end_[0UL] = allocate<Element>( newCapacity );
558 for(
size_t i=0UL; i<
m_; ++i ) {
570 template<
typename Type
579 const size_t nonzeros( sm.
nonZeros() );
581 begin_[0UL] = allocate<Element>( nonzeros );
582 for(
size_t i=0UL; i<
m_; ++i )
583 begin_[i+1UL] =
end_[i] = std::copy( sm.
begin(i), sm.
end(i), begin_[i] );
584 end_[
m_] = begin_[0UL]+nonzeros;
594 template<
typename Type
596 template<
typename MT
607 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
620 template<
typename Type
622 template<
typename MT
633 const size_t nonzeros( (~sm).
nonZeros() );
635 begin_[0UL] = allocate<Element>( nonzeros );
636 for(
size_t i=0UL; i<
m_; ++i )
656 template<
typename Type
684 template<
typename Type
707 template<
typename Type
717 if( pos ==
end_[i] || pos->index_ != j )
736 template<
typename Type
763 template<
typename Type
790 template<
typename Type
812 template<
typename Type
834 template<
typename Type
856 template<
typename Type
878 template<
typename Type
900 template<
typename Type
928 template<
typename Type
933 if( &rhs ==
this )
return *
this;
935 const size_t nonzeros( rhs.
nonZeros() );
942 newBegin[0UL] = allocate<Element>( nonzeros );
943 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
944 newBegin[i+1UL] = newEnd[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], newBegin[i] );
946 newEnd[rhs.
m_] = newBegin[0UL]+nonzeros;
955 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
977 template<
typename Type
979 template<
typename MT
986 if( (~rhs).canAlias(
this ) ) {
992 assign( *
this, ~rhs );
1009 template<
typename Type
1011 template<
typename MT
1016 using blaze::assign;
1018 if( (~rhs).canAlias(
this ) ||
1027 assign( *
this, ~rhs );
1045 template<
typename Type
1047 template<
typename MT
1052 using blaze::addAssign;
1058 addAssign( *
this, ~rhs );
1074 template<
typename Type
1076 template<
typename MT
1080 using blaze::subAssign;
1086 subAssign( *
this, ~rhs );
1102 template<
typename Type
1104 template<
typename MT
1109 if( (~rhs).
rows() !=
n_ ) {
1128 template<
typename Type
1130 template<
typename Other >
1134 for(
size_t i=0UL; i<
m_; ++i ) {
1137 element->value_ *= rhs;
1151 template<
typename Type
1153 template<
typename Other >
1165 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1166 for(
size_t i=0UL; i<
m_; ++i ) {
1169 element->value_ *= tmp;
1173 for(
size_t i=0UL; i<
m_; ++i ) {
1176 element->value_ /= rhs;
1198 template<
typename Type
1212 template<
typename Type
1226 template<
typename Type
1246 template<
typename Type
1261 template<
typename Type
1265 size_t nonzeros( 0UL );
1267 for(
size_t i=0UL; i<
m_; ++i )
1286 template<
typename Type
1301 template<
typename Type
1305 for(
size_t i=0UL; i<
m_; ++i )
1322 template<
typename Type
1339 template<
typename Type
1362 template<
typename Type
1370 const Iterator pos( lowerBound( i, j ) );
1372 if( pos !=
end_[i] && pos->index_ == j ) {
1373 pos->value() = value;
1376 else return insert( pos, i, j, value );
1394 template<
typename Type
1402 const Iterator pos( lowerBound( i, j ) );
1404 if( pos !=
end_[i] && pos->index_ == j ) {
1408 return insert( pos, i, j, value );
1423 template<
typename Type
1429 std::copy_backward( pos,
end_[i],
end_[i]+1 );
1430 pos->value_ = value;
1437 std::copy_backward( pos,
end_[
m_-1UL],
end_[
m_-1UL]+1 );
1439 pos->value_ = value;
1442 for(
size_t k=i+1UL; k<
m_+1UL; ++k ) {
1450 size_t newCapacity( extendCapacity() );
1455 newBegin[0UL] = allocate<Element>( newCapacity );
1457 for(
size_t k=0UL; k<i; ++k ) {
1458 const size_t nonzeros(
end_[k] -
begin_[k] );
1460 newEnd [k] = newBegin[k] + nonzeros;
1461 newBegin[k+1UL] = newBegin[k] + total;
1463 newEnd [i] = newBegin[i] + (
end_[i] -
begin_[i] ) + 1;
1464 newBegin[i+1UL] = newBegin[i] + (
begin_[i+1] -
begin_[i] ) + 1;
1465 for(
size_t k=i+1UL; k<
m_; ++k ) {
1466 const size_t nonzeros(
end_[k] -
begin_[k] );
1468 newEnd [k] = newBegin[k] + nonzeros;
1469 newBegin[k+1UL] = newBegin[k] + total;
1472 newEnd[
m_] = newEnd[
capacity_] = newBegin[0UL]+newCapacity;
1475 tmp->value_ = value;
1477 std::copy( pos,
end_[m_-1UL], tmp+1UL );
1499 template<
typename Type
1506 const Iterator pos( find( i, j ) );
1507 if( pos !=
end_[i] )
1508 end_[i] = std::copy( pos+1,
end_[i], pos );
1524 template<
typename Type
1532 if( pos !=
end_[i] )
1533 end_[i] = std::copy( pos+1,
end_[i], pos );
1552 template<
typename Type
1563 end_[i] = std::copy( last,
end_[i], first );
1585 template<
typename Type
1592 if( m ==
m_ && n ==
n_ )
return;
1597 Iterator* newEnd ( newBegin+m+1UL );
1599 newBegin[0UL] =
begin_[0UL];
1602 for(
size_t i=0UL; i<
m_; ++i ) {
1603 newEnd [i] =
end_ [i];
1604 newBegin[i+1UL] =
begin_[i+1UL];
1606 for(
size_t i=m_; i<m; ++i ) {
1607 newBegin[i+1UL] = newEnd[i] =
begin_[
m_];
1611 for(
size_t i=0UL; i<m; ++i ) {
1612 newBegin[i+1UL] = newEnd[i] =
begin_[0UL];
1629 for(
size_t i=0UL; i<
m_; ++i )
1633 for(
size_t i=
m_; i<m; ++i )
1639 for(
size_t i=0UL; i<m; ++i )
1640 end_[i] = lowerBound( i, n );
1643 for(
size_t i=0UL; i<m; ++i )
1669 template<
typename Type
1674 reserveElements( nonzeros );
1693 template<
typename Type
1702 const size_t current(
capacity(i) );
1704 if( current >= nonzeros )
return;
1706 const ptrdiff_t additional( nonzeros - current );
1710 const size_t newCapacity(
begin_[
m_] -
begin_[0UL] + additional );
1716 newBegin[0UL] = allocate<Element>( newCapacity );
1717 newEnd [
m_ ] = newBegin[0UL]+newCapacity;
1719 for(
size_t k=0UL; k<i; ++k ) {
1720 newEnd [k ] = std::copy(
begin_[k],
end_[k], newBegin[k] );
1721 newBegin[k+1UL] = newBegin[k] +
capacity(k);
1723 newEnd [i ] = std::copy(
begin_[i],
end_[i], newBegin[i] );
1724 newBegin[i+1UL] = newBegin[i] + nonzeros;
1725 for(
size_t k=i+1UL; k<
m_; ++k ) {
1726 newEnd [k ] = std::copy(
begin_[k],
end_[k], newBegin[k] );
1727 newBegin[k+1UL] = newBegin[k] +
capacity(k);
1741 for(
size_t j=
m_-1UL; j>i; --j ) {
1743 end_ [j] += additional;
1763 template<
typename Type
1767 for(
size_t i=0UL; i<
m_; ++i )
1784 template<
typename Type
1790 if( i < (
m_ - 1UL ) )
1802 template<
typename Type
1818 template<
typename Type
1835 template<
typename Type
1837 template<
typename Other >
1840 for(
size_t i=0UL; i<
m_; ++i )
1842 element->value_ *= scalar;
1855 template<
typename Type
1857 template<
typename Other >
1862 for(
size_t i=0UL; i<
size; ++i ) {
1864 if( pos !=
end_[i] && pos->index_ == i )
1865 pos->value_ *= scalar;
1880 template<
typename Type
1901 template<
typename Type
1905 size_t nonzeros( 2UL*
capacity()+1UL );
1921 template<
typename Type
1928 newBegin[0UL] = allocate<Element>( nonzeros );
1930 for(
size_t k=0UL; k<
m_; ++k ) {
1932 newEnd [k] = std::copy(
begin_[k],
end_[k], newBegin[k] );
1933 newBegin[k+1UL] = newBegin[k] + (
begin_[k+1UL] -
begin_[k] );
1936 newEnd[
m_] = newBegin[0UL]+nonzeros;
1969 template<
typename Type
1974 return const_cast<Iterator>(
const_cast<const This&
>( *this ).
find( i, j ) );
1994 template<
typename Type
2000 if( pos !=
end_[i] && pos->index_ == j )
2002 else return end_[i];
2022 template<
typename Type
2047 template<
typename Type
2053 return std::lower_bound(
begin_[i],
end_[i], j, FindIndex() );
2073 template<
typename Type
2098 template<
typename Type
2104 return std::upper_bound(
begin_[i],
end_[i], j, FindIndex() );
2161 template<
typename Type
2170 end_[i]->value_ = value;
2173 end_[i]->index_ = j;
2193 template<
typename Type
2224 template<
typename Type
2226 template<
typename Other >
2229 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
2244 template<
typename Type
2246 template<
typename Other >
2249 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
2264 template<
typename Type
2284 template<
typename Type
2286 template<
typename MT
2293 size_t nonzeros( 0UL );
2295 for(
size_t i=1UL; i<=
m_; ++i )
2298 for(
size_t i=0UL; i<
m_; ++i )
2309 for(
size_t j=jbegin; j<jend; ++j )
2312 reserveElements( extendCapacity() );
2313 for(
size_t k=i+1UL; k<=
m_; ++k )
2317 end_[i]->value_ = (~rhs)(i,j);
2320 end_[i]->index_ = j;
2343 template<
typename Type
2345 template<
typename MT >
2353 if(
m_ == 0UL ||
begin_[0] == NULL )
2356 for(
size_t i=0UL; i<
m_; ++i ) {
2374 template<
typename Type
2376 template<
typename MT >
2389 std::vector<size_t> rowLengths(
m_, 0UL );
2390 for(
size_t j=0UL; j<
n_; ++j ) {
2391 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2392 ++rowLengths[element->index()];
2396 for(
size_t i=0UL; i<
m_; ++i ) {
2401 for(
size_t j=0UL; j<
n_; ++j ) {
2402 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2403 append( element->index(), j, element->value() );
2420 template<
typename Type
2422 template<
typename MT
2446 template<
typename Type
2448 template<
typename MT
2472 template<
typename Type
2474 template<
typename MT
2498 template<
typename Type
2500 template<
typename MT
2533 template<
typename Type >
2545 struct Element :
public ElementBase
2549 template<
typename Other >
2550 inline Element&
operator=(
const Other& rhs )
2552 ElementBase::operator=( rhs );
2565 struct FindIndex :
public std::binary_function<Element,size_t,bool>
2567 inline bool operator()(
const Element& element,
size_t index )
const {
2568 return element.index() < index;
2570 inline bool operator()(
size_t index,
const Element& element )
const {
2571 return index < element.index();
2573 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
2574 return element1.index() < element2.index();
2598 template<
typename ET >
2618 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
2620 template<
typename MT,
bool SO >
inline CompressedMatrix(
const DenseMatrix<MT,SO>& dm );
2621 template<
typename MT,
bool SO >
inline CompressedMatrix(
const SparseMatrix<MT,SO>& sm );
2635 inline Reference
operator()(
size_t i,
size_t j );
2636 inline ConstReference
operator()(
size_t i,
size_t j )
const;
2637 inline Reference
at(
size_t i,
size_t j );
2638 inline ConstReference
at(
size_t i,
size_t j )
const;
2639 inline Iterator
begin (
size_t i );
2640 inline ConstIterator
begin (
size_t i )
const;
2641 inline ConstIterator
cbegin(
size_t i )
const;
2642 inline Iterator
end (
size_t i );
2643 inline ConstIterator
end (
size_t i )
const;
2644 inline ConstIterator
cend (
size_t i )
const;
2654 template<
typename MT,
bool SO >
inline CompressedMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2655 template<
typename MT,
bool SO >
inline CompressedMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2656 template<
typename MT,
bool SO >
inline CompressedMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2658 template<
typename Other >
2660 operator*=( Other rhs );
2662 template<
typename Other >
2664 operator/=( Other rhs );
2671 inline size_t rows()
const;
2672 inline size_t columns()
const;
2674 inline size_t capacity(
size_t j )
const;
2676 inline size_t nonZeros(
size_t j )
const;
2677 inline void reset();
2678 inline void reset(
size_t j );
2679 inline void clear();
2680 inline Iterator
set (
size_t i,
size_t j,
const Type& value );
2681 inline Iterator
insert (
size_t i,
size_t j,
const Type& value );
2682 inline void erase (
size_t i,
size_t j );
2683 inline Iterator
erase (
size_t j, Iterator pos );
2684 inline Iterator
erase (
size_t j, Iterator first, Iterator last );
2685 void resize (
size_t m,
size_t n,
bool preserve=
true );
2686 inline void reserve(
size_t nonzeros );
2687 void reserve(
size_t j,
size_t nonzeros );
2688 inline void trim ();
2689 inline void trim (
size_t j );
2692 template<
typename Other >
inline CompressedMatrix& scale(
const Other& scalar );
2693 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
2701 inline Iterator
find (
size_t i,
size_t j );
2702 inline ConstIterator
find (
size_t i,
size_t j )
const;
2703 inline Iterator
lowerBound(
size_t i,
size_t j );
2704 inline ConstIterator
lowerBound(
size_t i,
size_t j )
const;
2705 inline Iterator
upperBound(
size_t i,
size_t j );
2706 inline ConstIterator
upperBound(
size_t i,
size_t j )
const;
2713 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
2721 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2722 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2726 template<
typename MT,
bool SO >
inline void assign (
const DenseMatrix<MT,SO>& rhs );
2727 template<
typename MT >
inline void assign (
const SparseMatrix<MT,true>& rhs );
2728 template<
typename MT >
inline void assign (
const SparseMatrix<MT,false>& rhs );
2729 template<
typename MT,
bool SO >
inline void addAssign(
const DenseMatrix<MT,SO>& rhs );
2730 template<
typename MT,
bool SO >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
2731 template<
typename MT,
bool SO >
inline void subAssign(
const DenseMatrix<MT,SO>& rhs );
2732 template<
typename MT,
bool SO >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
2740 Iterator
insert( Iterator pos,
size_t i,
size_t j,
const Type& value );
2781 template<
typename Type >
2797 template<
typename Type >
2820 template<
typename Type >
2821 inline CompressedMatrix<Type,true>::CompressedMatrix(
size_t m,
size_t n )
2828 for(
size_t j=0UL; j<2UL*
n_+2UL; ++j )
2845 template<
typename Type >
2846 inline CompressedMatrix<Type,true>::CompressedMatrix(
size_t m,
size_t n,
size_t nonzeros )
2853 begin_[0UL] = allocate<Element>( nonzeros );
2854 for(
size_t j=1UL; j<(2UL*
n_+1UL); ++j )
2873 template<
typename Type >
2874 CompressedMatrix<Type,true>::CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros )
2881 BLAZE_USER_ASSERT( nonzeros.size() == n,
"Size of capacity vector and number of columns don't match" );
2883 size_t newCapacity( 0UL );
2884 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
2887 begin_[0UL] =
end_[0UL] = allocate<Element>( newCapacity );
2888 for(
size_t j=0UL; j<
n_; ++j ) {
2902 template<
typename Type >
2903 inline CompressedMatrix<Type,true>::CompressedMatrix(
const CompressedMatrix& sm )
2910 const size_t nonzeros( sm.nonZeros() );
2912 begin_[0UL] = allocate<Element>( nonzeros );
2913 for(
size_t j=0UL; j<
n_; ++j )
2914 begin_[j+1UL] =
end_[j] = std::copy( sm.begin(j), sm.end(j), begin_[j] );
2915 end_[
n_] = begin_[0UL]+nonzeros;
2927 template<
typename Type >
2928 template<
typename MT
2930 inline CompressedMatrix<Type,true>::CompressedMatrix(
const DenseMatrix<MT,SO>& dm )
2934 , begin_ ( new
Iterator[2UL*n_+2UL] )
2935 ,
end_ ( begin_+(n_+1UL) )
2937 using blaze::assign;
2939 for(
size_t j=0UL; j<2UL*n_+2UL; ++j )
2942 assign( *
this, ~dm );
2954 template<
typename Type >
2955 template<
typename MT
2957 inline CompressedMatrix<Type,true>::CompressedMatrix(
const SparseMatrix<MT,SO>& sm )
2961 , begin_ ( new
Iterator[2UL*n_+2UL] )
2962 ,
end_ ( begin_+(n_+1UL) )
2964 using blaze::assign;
2966 const size_t nonzeros( (~sm).
nonZeros() );
2968 begin_[0UL] = allocate<Element>( nonzeros );
2969 for(
size_t j=0UL; j<
n_; ++j )
2970 begin_[j+1UL] =
end_[j] = begin_[0UL];
2971 end_[
n_] = begin_[0UL]+nonzeros;
2973 assign( *
this, ~sm );
2991 template<
typename Type >
2992 inline CompressedMatrix<Type,true>::~CompressedMatrix()
3017 template<
typename Type >
3019 CompressedMatrix<Type,true>::operator()(
size_t i,
size_t j )
3038 template<
typename Type >
3040 CompressedMatrix<Type,true>::operator()(
size_t i,
size_t j )
const
3047 if( pos ==
end_[j] || pos->index_ != i )
3068 template<
typename Type >
3070 CompressedMatrix<Type,true>::at(
size_t i,
size_t j )
3078 return (*
this)(i,j);
3096 template<
typename Type >
3098 CompressedMatrix<Type,true>::at(
size_t i,
size_t j )
const
3106 return (*
this)(i,j);
3119 template<
typename Type >
3121 CompressedMatrix<Type,true>::begin(
size_t j )
3137 template<
typename Type >
3139 CompressedMatrix<Type,true>::begin(
size_t j )
const
3155 template<
typename Type >
3157 CompressedMatrix<Type,true>::cbegin(
size_t j )
const
3173 template<
typename Type >
3175 CompressedMatrix<Type,true>::end(
size_t j )
3191 template<
typename Type >
3193 CompressedMatrix<Type,true>::end(
size_t j )
const
3209 template<
typename Type >
3211 CompressedMatrix<Type,true>::cend(
size_t j )
const
3238 template<
typename Type >
3239 inline CompressedMatrix<Type,true>&
3240 CompressedMatrix<Type,true>::operator=(
const CompressedMatrix& rhs )
3242 if( &rhs ==
this )
return *
this;
3244 const size_t nonzeros( rhs.nonZeros() );
3249 Iterator* newEnd ( newBegin+(rhs.n_+1UL) );
3251 newBegin[0UL] = allocate<Element>( nonzeros );
3252 for(
size_t j=0UL; j<rhs.n_; ++j ) {
3253 newBegin[j+1UL] = newEnd[j] = std::copy( rhs.begin_[j], rhs.end_[j], newBegin[j] );
3255 newEnd[rhs.n_] = newBegin[0UL]+nonzeros;
3264 for(
size_t j=0UL; j<rhs.n_; ++j ) {
3265 begin_[j+1UL] =
end_[j] = std::copy( rhs.begin_[j], rhs.end_[j], begin_[j] );
3288 template<
typename Type >
3289 template<
typename MT
3291 inline CompressedMatrix<Type,true>&
3292 CompressedMatrix<Type,true>::operator=(
const DenseMatrix<MT,SO>& rhs )
3294 using blaze::assign;
3296 if( (~rhs).canAlias(
this ) ) {
3297 CompressedMatrix tmp( ~rhs );
3302 assign( *
this, ~rhs );
3321 template<
typename Type >
3322 template<
typename MT
3324 inline CompressedMatrix<Type,true>&
3325 CompressedMatrix<Type,true>::operator=(
const SparseMatrix<MT,SO>& rhs )
3327 using blaze::assign;
3329 if( (~rhs).canAlias(
this ) ||
3332 CompressedMatrix tmp( ~rhs );
3338 assign( *
this, ~rhs );
3358 template<
typename Type >
3359 template<
typename MT
3361 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3363 using blaze::addAssign;
3369 addAssign( *
this, ~rhs );
3387 template<
typename Type >
3388 template<
typename MT
3390 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3392 using blaze::subAssign;
3398 subAssign( *
this, ~rhs );
3416 template<
typename Type >
3417 template<
typename MT
3419 inline CompressedMatrix<Type,true>&
3420 CompressedMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3422 if( (~rhs).
rows() != n_ ) {
3426 CompressedMatrix tmp( *
this * (~rhs) );
3443 template<
typename Type >
3444 template<
typename Other >
3445 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
3446 CompressedMatrix<Type,true>::operator*=( Other rhs )
3448 for(
size_t j=0UL; j<
n_; ++j ) {
3451 element->value_ *= rhs;
3467 template<
typename Type >
3468 template<
typename Other >
3469 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
3470 CompressedMatrix<Type,true>::operator/=( Other rhs )
3474 typedef typename DivTrait<Type,Other>::Type DT;
3475 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3479 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3480 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3481 for(
size_t j=0UL; j<
n_; ++j ) {
3484 element->value_ *= tmp;
3488 for(
size_t j=0UL; j<
n_; ++j ) {
3491 element->value_ /= rhs;
3515 template<
typename Type >
3516 inline size_t CompressedMatrix<Type,true>::rows()
const
3530 template<
typename Type >
3531 inline size_t CompressedMatrix<Type,true>::columns()
const
3545 template<
typename Type >
3546 inline size_t CompressedMatrix<Type,true>::capacity()
const
3548 return end_[
n_] - begin_[0UL];
3561 template<
typename Type >
3562 inline size_t CompressedMatrix<Type,true>::capacity(
size_t j )
const
3565 return begin_[j+1UL] - begin_[j];
3577 template<
typename Type >
3578 inline size_t CompressedMatrix<Type,true>::nonZeros()
const
3580 size_t nonzeros( 0UL );
3582 for(
size_t j=0UL; j<
n_; ++j )
3598 template<
typename Type >
3599 inline size_t CompressedMatrix<Type,true>::nonZeros(
size_t j )
const
3602 return end_[j] - begin_[j];
3614 template<
typename Type >
3617 for(
size_t j=0UL; j<
n_; ++j )
3618 end_[j] = begin_[j];
3634 template<
typename Type >
3638 end_[j] = begin_[j];
3652 template<
typename Type >
3676 template<
typename Type >
3678 CompressedMatrix<Type,true>::set(
size_t i,
size_t j,
const Type& value )
3683 const Iterator pos( lowerBound( i, j ) );
3685 if( pos !=
end_[j] && pos->index_ == i ) {
3686 pos->value() = value;
3689 else return insert( pos, i, j, value );
3709 template<
typename Type >
3711 CompressedMatrix<Type,true>::insert(
size_t i,
size_t j,
const Type& value )
3716 const Iterator pos( lowerBound( i, j ) );
3718 if( pos !=
end_[j] && pos->index_ == i ) {
3722 return insert( pos, i, j, value );
3739 template<
typename Type >
3741 CompressedMatrix<Type,true>::insert(
Iterator pos,
size_t i,
size_t j,
const Type& value )
3743 if( begin_[j+1UL] -
end_[j] != 0 ) {
3744 std::copy_backward( pos,
end_[j],
end_[j]+1 );
3745 pos->value_ = value;
3751 else if(
end_[n_] - begin_[n_] != 0 ) {
3752 std::copy_backward( pos,
end_[n_-1UL],
end_[n_-1]+1 );
3754 pos->value_ = value;
3757 for(
size_t k=j+1UL; k<n_+1UL; ++k ) {
3765 size_t newCapacity( extendCapacity() );
3770 newBegin[0UL] = allocate<Element>( newCapacity );
3772 for(
size_t k=0UL; k<j; ++k ) {
3773 const size_t nonzeros(
end_[k] - begin_[k] );
3774 const size_t total( begin_[k+1UL] - begin_[k] );
3775 newEnd [k] = newBegin[k] + nonzeros;
3776 newBegin[k+1UL] = newBegin[k] + total;
3778 newEnd [j] = newBegin[j] + (
end_[j] - begin_[j] ) + 1;
3779 newBegin[j+1UL] = newBegin[j] + ( begin_[j+1UL] - begin_[j] ) + 1;
3780 for(
size_t k=j+1UL; k<
n_; ++k ) {
3781 const size_t nonzeros(
end_[k] - begin_[k] );
3782 const size_t total( begin_[k+1UL] - begin_[k] );
3783 newEnd [k] = newBegin[k] + nonzeros;
3784 newBegin[k+1UL] = newBegin[k] + total;
3787 newEnd[
n_] = newEnd[
capacity_] = newBegin[0UL]+newCapacity;
3789 Iterator tmp = std::copy( begin_[0UL], pos, newBegin[0UL] );
3790 tmp->value_ = value;
3792 std::copy( pos,
end_[n_-1UL], tmp+1UL );
3816 template<
typename Type >
3817 inline void CompressedMatrix<Type,true>::erase(
size_t i,
size_t j )
3822 const Iterator pos( find( i, j ) );
3823 if( pos !=
end_[j] )
3824 end_[j] = std::copy( pos+1,
end_[j], pos );
3840 template<
typename Type >
3842 CompressedMatrix<Type,true>::erase(
size_t j,
Iterator pos )
3847 if( pos !=
end_[j] )
3848 end_[j] = std::copy( pos+1,
end_[j], pos );
3867 template<
typename Type >
3869 CompressedMatrix<Type,true>::erase(
size_t j,
Iterator first,
Iterator last )
3877 end_[j] = std::copy( last,
end_[j], first );
3901 template<
typename Type >
3902 void CompressedMatrix<Type,true>::resize(
size_t m,
size_t n,
bool preserve )
3907 if( m ==
m_ && n == n_ )
return;
3912 Iterator* newEnd ( newBegin+n+1UL );
3914 newBegin[0UL] = begin_[0UL];
3917 for(
size_t j=0UL; j<
n_; ++j ) {
3918 newEnd [j] =
end_ [j];
3919 newBegin[j+1UL] = begin_[j+1UL];
3921 for(
size_t j=n_; j<n; ++j ) {
3922 newBegin[j+1UL] = newEnd[j] = begin_[
n_];
3926 for(
size_t j=0UL; j<n; ++j ) {
3927 newBegin[j+1UL] = newEnd[j] = begin_[0UL];
3944 for(
size_t j=0UL; j<
n_; ++j )
3945 end_[j] = begin_[j];
3948 for(
size_t j=n_; j<n; ++j )
3949 begin_[j+1UL] =
end_[j] = begin_[n_];
3954 for(
size_t j=0UL; j<n; ++j )
3955 end_[j] = lowerBound( m, j );
3958 for(
size_t j=0UL; j<n; ++j )
3959 end_[j] = begin_[j];
3986 template<
typename Type >
3987 inline void CompressedMatrix<Type,true>::reserve(
size_t nonzeros )
3990 reserveElements( nonzeros );
4008 template<
typename Type >
4009 void CompressedMatrix<Type,true>::reserve(
size_t j,
size_t nonzeros )
4016 const size_t current(
capacity(j) );
4018 if( current >= nonzeros )
return;
4020 const ptrdiff_t additional( nonzeros - current );
4022 if(
end_[n_] - begin_[n_] < additional )
4024 const size_t newCapacity( begin_[n_] - begin_[0UL] + additional );
4028 Iterator* newEnd ( newBegin+n_+1UL );
4030 newBegin[0UL] = allocate<Element>( newCapacity );
4031 newEnd [
n_ ] = newBegin[0UL]+newCapacity;
4033 for(
size_t k=0UL; k<j; ++k ) {
4034 newEnd [k ] = std::copy( begin_[k],
end_[k], newBegin[k] );
4035 newBegin[k+1UL] = newBegin[k] +
capacity(k);
4037 newEnd [j ] = std::copy( begin_[j],
end_[j], newBegin[j] );
4038 newBegin[j+1UL] = newBegin[j] + nonzeros;
4039 for(
size_t k=j+1UL; k<
n_; ++k ) {
4040 newEnd [k ] = std::copy( begin_[k],
end_[k], newBegin[k] );
4041 newBegin[k+1UL] = newBegin[k] +
capacity(k);
4054 begin_[
n_] += additional;
4055 for(
size_t k=n_-1UL; k>j; --k ) {
4056 begin_[k] = std::copy_backward( begin_[k],
end_[k],
end_[k]+additional );
4057 end_ [k] += additional;
4078 template<
typename Type >
4079 void CompressedMatrix<Type,true>::trim()
4081 for(
size_t j=0UL; j<
n_; ++j )
4099 template<
typename Type >
4100 void CompressedMatrix<Type,true>::trim(
size_t j )
4104 if( j < ( n_ - 1UL ) )
4105 end_[j+1] = std::copy( begin_[j+1],
end_[j+1],
end_[j] );
4106 begin_[j+1] =
end_[j];
4118 template<
typename Type >
4119 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::transpose()
4121 CompressedMatrix tmp(
trans( *
this ) );
4135 template<
typename Type >
4136 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::ctranspose()
4138 CompressedMatrix tmp(
ctrans( *
this ) );
4153 template<
typename Type >
4154 template<
typename Other >
4155 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scale(
const Other& scalar )
4157 for(
size_t j=0UL; j<
n_; ++j )
4158 for(
Iterator element=begin_[j]; element!=
end_[j]; ++element )
4159 element->value_ *= scalar;
4174 template<
typename Type >
4175 template<
typename Other >
4176 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scaleDiagonal( Other scalar )
4180 for(
size_t j=0UL; j<
size; ++j ) {
4182 if( pos !=
end_[j] && pos->index_ == j )
4183 pos->value_ *= scalar;
4200 template<
typename Type >
4222 template<
typename Type >
4223 inline size_t CompressedMatrix<Type,true>::extendCapacity()
const
4225 size_t nonzeros( 2UL*
capacity()+1UL );
4243 template<
typename Type >
4244 void CompressedMatrix<Type,true>::reserveElements(
size_t nonzeros )
4249 newBegin[0UL] = allocate<Element>( nonzeros );
4251 for(
size_t k=0UL; k<
n_; ++k ) {
4253 newEnd [k] = std::copy( begin_[k],
end_[k], newBegin[k] );
4254 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
4257 newEnd[
n_] = newBegin[0UL]+nonzeros;
4291 template<
typename Type >
4293 CompressedMatrix<Type,true>::find(
size_t i,
size_t j )
4295 return const_cast<Iterator>(
const_cast<const This&
>( *this ).find( i, j ) );
4316 template<
typename Type >
4318 CompressedMatrix<Type,true>::find(
size_t i,
size_t j )
const
4321 if( pos !=
end_[j] && pos->index_ == i )
4323 else return end_[j];
4343 template<
typename Type >
4345 CompressedMatrix<Type,true>::lowerBound(
size_t i,
size_t j )
4347 return const_cast<Iterator>(
const_cast<const This&
>( *this ).lowerBound( i, j ) );
4367 template<
typename Type >
4369 CompressedMatrix<Type,true>::lowerBound(
size_t i,
size_t j )
const
4372 return std::lower_bound( begin_[j],
end_[j], i, FindIndex() );
4392 template<
typename Type >
4394 CompressedMatrix<Type,true>::upperBound(
size_t i,
size_t j )
4396 return const_cast<Iterator>(
const_cast<const This&
>( *this ).upperBound( i, j ) );
4416 template<
typename Type >
4418 CompressedMatrix<Type,true>::upperBound(
size_t i,
size_t j )
const
4421 return std::upper_bound( begin_[j],
end_[j], i, FindIndex() );
4477 template<
typename Type >
4478 inline void CompressedMatrix<Type,true>::append(
size_t i,
size_t j,
const Type& value,
bool check )
4485 end_[j]->value_ = value;
4488 end_[j]->index_ = i;
4510 template<
typename Type >
4511 inline void CompressedMatrix<Type,true>::finalize(
size_t j )
4515 begin_[j+1UL] =
end_[j];
4542 template<
typename Type >
4543 template<
typename Other >
4544 inline bool CompressedMatrix<Type,true>::canAlias(
const Other* alias )
const
4546 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4563 template<
typename Type >
4564 template<
typename Other >
4565 inline bool CompressedMatrix<Type,true>::isAliased(
const Other* alias )
const
4567 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4584 template<
typename Type >
4585 inline bool CompressedMatrix<Type,true>::canSMPAssign()
const
4605 template<
typename Type >
4606 template<
typename MT
4608 inline void CompressedMatrix<Type,true>::assign(
const DenseMatrix<MT,SO>& rhs )
4613 size_t nonzeros( 0UL );
4615 for(
size_t j=1UL; j<=
n_; ++j )
4618 for(
size_t j=0UL; j<
n_; ++j )
4620 begin_[j] =
end_[j] = begin_[0UL]+nonzeros;
4622 const size_t ibegin( ( IsLower<MT>::value )
4623 ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4625 const size_t iend ( ( IsUpper<MT>::value )
4626 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4629 for(
size_t i=ibegin; i<iend; ++i )
4632 reserveElements( extendCapacity() );
4633 for(
size_t k=j+1UL; k<=
n_; ++k )
4637 end_[j]->value_ = (~rhs)(i,j);
4640 end_[j]->index_ = i;
4647 begin_[
n_] = begin_[0UL]+nonzeros;
4665 template<
typename Type >
4666 template<
typename MT >
4667 inline void CompressedMatrix<Type,true>::assign(
const SparseMatrix<MT,true>& rhs )
4674 if( n_ == 0UL || begin_[0] == NULL )
4677 for(
size_t j=0UL; j<
n_; ++j ) {
4678 begin_[j+1UL] =
end_[j] = std::copy( (~rhs).
begin(j), (~rhs).
end(j), begin_[j] );
4697 template<
typename Type >
4698 template<
typename MT >
4699 inline void CompressedMatrix<Type,true>::assign(
const SparseMatrix<MT,false>& rhs )
4711 std::vector<size_t> columnLengths( n_, 0UL );
4712 for(
size_t i=0UL; i<
m_; ++i ) {
4713 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4714 ++columnLengths[element->index()];
4718 for(
size_t j=0UL; j<
n_; ++j ) {
4719 begin_[j+1UL] =
end_[j+1UL] = begin_[j] + columnLengths[j];
4723 for(
size_t i=0UL; i<
m_; ++i ) {
4724 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4725 append( i, element->index(), element->value() );
4744 template<
typename Type >
4745 template<
typename MT
4747 inline void CompressedMatrix<Type,true>::addAssign(
const DenseMatrix<MT,SO>& rhs )
4752 CompressedMatrix tmp(
serial( *
this + (~rhs) ) );
4771 template<
typename Type >
4772 template<
typename MT
4774 inline void CompressedMatrix<Type,true>::addAssign(
const SparseMatrix<MT,SO>& rhs )
4779 CompressedMatrix tmp(
serial( *
this + (~rhs) ) );
4798 template<
typename Type >
4799 template<
typename MT
4801 inline void CompressedMatrix<Type,true>::subAssign(
const DenseMatrix<MT,SO>& rhs )
4806 CompressedMatrix tmp(
serial( *
this - (~rhs) ) );
4825 template<
typename Type >
4826 template<
typename MT
4828 inline void CompressedMatrix<Type,true>::subAssign(
const SparseMatrix<MT,SO>& rhs )
4833 CompressedMatrix tmp(
serial( *
this - (~rhs) ) );
4855 template<
typename Type,
bool SO >
4856 inline void reset( CompressedMatrix<Type,SO>& m );
4858 template<
typename Type,
bool SO >
4859 inline void reset( CompressedMatrix<Type,SO>& m,
size_t i );
4861 template<
typename Type,
bool SO >
4862 inline void clear( CompressedMatrix<Type,SO>& m );
4864 template<
typename Type,
bool SO >
4865 inline bool isDefault(
const CompressedMatrix<Type,SO>& m );
4867 template<
typename Type,
bool SO >
4868 inline bool isIntact(
const CompressedMatrix<Type,SO>& m );
4870 template<
typename Type,
bool SO >
4871 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b ) ;
4873 template<
typename Type,
bool SO >
4874 inline void move( CompressedMatrix<Type,SO>& dst, CompressedMatrix<Type,SO>& src ) ;
4886 template<
typename Type
4888 inline void reset( CompressedMatrix<Type,SO>& m )
4908 template<
typename Type
4910 inline void reset( CompressedMatrix<Type,SO>& m,
size_t i )
4924 template<
typename Type
4926 inline void clear( CompressedMatrix<Type,SO>& m )
4951 template<
typename Type
4955 return ( m.rows() == 0UL && m.columns() == 0UL );
4978 template<
typename Type
4980 inline bool isIntact(
const CompressedMatrix<Type,SO>& m )
4982 return ( m.nonZeros() <= m.capacity() );
4996 template<
typename Type
4998 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b )
5014 template<
typename Type
5016 inline void move( CompressedMatrix<Type,SO>& dst, CompressedMatrix<Type,SO>& src )
5033 template<
typename T,
bool SO >
5034 struct IsResizable< CompressedMatrix<T,SO> > :
public TrueType
5053 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5054 struct AddTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5056 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5059 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5060 struct AddTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5062 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO2 > Type;
5065 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5066 struct AddTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5068 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5071 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5072 struct AddTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5074 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO1 > Type;
5077 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5078 struct AddTrait< CompressedMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5080 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5083 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5084 struct AddTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5086 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO2 > Type;
5089 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5090 struct AddTrait< HybridMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5092 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5095 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5096 struct AddTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5098 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO1 > Type;
5101 template<
typename T1,
bool SO,
typename T2 >
5102 struct AddTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5104 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5107 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5108 struct AddTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5110 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO2 > Type;
5113 template<
typename T1,
bool SO,
typename T2 >
5114 struct AddTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5116 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5119 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5120 struct AddTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5122 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO1 > Type;
5125 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5126 struct AddTrait< CompressedMatrix<T1,SO>, CustomMatrix<T2,AF,PF,SO> >
5128 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5131 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5132 struct AddTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5134 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO2 > Type;
5137 template<
typename T1,
bool AF,
bool PF,
bool SO,
typename T2 >
5138 struct AddTrait< CustomMatrix<T1,AF,PF,SO>, CompressedMatrix<T2,SO> >
5140 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5143 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5144 struct AddTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5146 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO1 > Type;
5149 template<
typename T1,
bool SO,
typename T2 >
5150 struct AddTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5152 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5155 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5156 struct AddTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5158 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type,
false > Type;
5174 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5175 struct SubTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5177 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5180 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5181 struct SubTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5183 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO2 > Type;
5186 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5187 struct SubTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5189 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5192 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5193 struct SubTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5195 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO1 > Type;
5198 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
5199 struct SubTrait< CompressedMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5201 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5204 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5205 struct SubTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5207 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO2 > Type;
5210 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5211 struct SubTrait< HybridMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
5213 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5216 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5217 struct SubTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5219 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO1 > Type;
5222 template<
typename T1,
bool SO,
typename T2 >
5223 struct SubTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5225 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO > Type;
5228 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5229 struct SubTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5231 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO2 > Type;
5234 template<
typename T1,
bool SO,
typename T2 >
5235 struct SubTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5237 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO > Type;
5240 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5241 struct SubTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5243 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO1 > Type;
5246 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5247 struct SubTrait< CompressedMatrix<T1,SO>, CustomMatrix<T2,AF,PF,SO> >
5249 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO > Type;
5252 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5253 struct SubTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5255 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO2 > Type;
5258 template<
typename T1,
bool AF,
bool PF,
bool SO,
typename T2 >
5259 struct SubTrait< CustomMatrix<T1,AF,PF,SO>, CompressedMatrix<T2,SO> >
5261 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO > Type;
5264 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5265 struct SubTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5267 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO1 > Type;
5270 template<
typename T1,
bool SO,
typename T2 >
5271 struct SubTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5273 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
5276 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5277 struct SubTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5279 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
5295 template<
typename T1,
bool SO,
typename T2 >
5296 struct MultTrait< CompressedMatrix<T1,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
5298 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5301 template<
typename T1,
typename T2,
bool SO >
5302 struct MultTrait< T1, CompressedMatrix<T2,SO>, typename EnableIf< IsNumeric<T1> >::Type >
5304 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5307 template<
typename T1,
bool SO,
typename T2,
size_t N >
5308 struct MultTrait< CompressedMatrix<T1,SO>, StaticVector<T2,N,false> >
5310 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
5313 template<
typename T1,
size_t N,
typename T2,
bool SO >
5314 struct MultTrait< StaticVector<T1,N,true>, CompressedMatrix<T2,SO> >
5316 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5319 template<
typename T1,
bool SO,
typename T2,
size_t N >
5320 struct MultTrait< CompressedMatrix<T1,SO>, HybridVector<T2,N,false> >
5322 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
5325 template<
typename T1,
size_t N,
typename T2,
bool SO >
5326 struct MultTrait< HybridVector<T1,N,true>, CompressedMatrix<T2,SO> >
5328 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5331 template<
typename T1,
bool SO,
typename T2 >
5332 struct MultTrait< CompressedMatrix<T1,SO>, DynamicVector<T2,false> >
5334 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
5337 template<
typename T1,
typename T2,
bool SO >
5338 struct MultTrait< DynamicVector<T1,true>, CompressedMatrix<T2,SO> >
5340 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5343 template<
typename T1,
bool SO,
typename T2,
bool AF,
bool PF >
5344 struct MultTrait< CompressedMatrix<T1,SO>, CustomVector<T2,AF,PF,false> >
5346 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
5349 template<
typename T1,
bool AF,
bool PF,
typename T2,
bool SO >
5350 struct MultTrait< CustomVector<T1,AF,PF,true>, CompressedMatrix<T2,SO> >
5352 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5355 template<
typename T1,
bool SO,
typename T2 >
5356 struct MultTrait< CompressedMatrix<T1,SO>, CompressedVector<T2,false> >
5358 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
false > Type;
5361 template<
typename T1,
typename T2,
bool SO >
5362 struct MultTrait< CompressedVector<T1,true>, CompressedMatrix<T2,SO> >
5364 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
true > Type;
5367 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5368 struct MultTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5370 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5373 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5374 struct MultTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5376 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5379 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5380 struct MultTrait< CompressedMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5382 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5385 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5386 struct MultTrait< HybridMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
5388 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5391 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5392 struct MultTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5394 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5397 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5398 struct MultTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5400 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5403 template<
typename T1,
bool SO1,
typename T2,
bool AF,
bool PF,
bool SO2 >
5404 struct MultTrait< CompressedMatrix<T1,SO1>, CustomMatrix<T2,AF,PF,SO2> >
5406 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5409 template<
typename T1,
bool AF,
bool PF,
bool SO1,
typename T2,
bool SO2 >
5410 struct MultTrait< CustomMatrix<T1,AF,PF,SO1>, CompressedMatrix<T2,SO2> >
5412 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5415 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5416 struct MultTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
5418 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5434 template<
typename T1,
bool SO,
typename T2 >
5435 struct DivTrait< CompressedMatrix<T1,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
5437 typedef CompressedMatrix< typename DivTrait<T1,T2>::Type, SO > Type;
5453 template<
typename T1,
bool SO,
typename T2 >
5454 struct MathTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
5456 typedef CompressedMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5457 typedef CompressedMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5473 template<
typename T1,
bool SO >
5474 struct SubmatrixTrait< CompressedMatrix<T1,SO> >
5476 typedef CompressedMatrix<T1,SO> Type;
5492 template<
typename T1,
bool SO >
5493 struct RowTrait< CompressedMatrix<T1,SO> >
5495 typedef CompressedVector<T1,true> Type;
5511 template<
typename T1,
bool SO >
5512 struct ColumnTrait< CompressedMatrix<T1,SO> >
5514 typedef CompressedVector<T1,false> Type;
#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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Pointer difference type of the Blaze library.
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
size_t rows() const
Returns the current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:1200
void reserveElements(size_t nonzeros)
Reserving the specified number of sparse matrix elements.
Definition: CompressedMatrix.h:1923
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Iterator * end_
Pointers one past the last non-zero element of each row.
Definition: CompressedMatrix.h:426
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:262
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
Header file for the subtraction trait.
Header file for basic type definitions.
const Type & ConstReference
Reference to a constant sparse matrix value.
Definition: CompressedMatrix.h:263
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
Header file for the row trait.
CompressedMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: CompressedMatrix.h:1820
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:250
Header file for the IsSparseMatrix type trait.
CompressedMatrix()
The default constructor for CompressedMatrix.
Definition: CompressedMatrix.h:470
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
size_t extendCapacity() const
Calculating a new matrix capacity.
Definition: CompressedMatrix.h:1903
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2749
void clear()
Clearing the sparse matrix.
Definition: CompressedMatrix.h:1341
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:259
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
CompressedMatrix< ET, SO > Other
The type of the other CompressedMatrix.
Definition: CompressedMatrix.h:273
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:257
#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:116
~CompressedMatrix()
The destructor for CompressedMatrix.
Definition: CompressedMatrix.h:658
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
void reset(CompressedMatrix< Type, SO > &m)
Resetting the given compressed matrix.
Definition: CompressedMatrix.h:4888
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:378
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:90
Header file for memory allocation and deallocation functionality.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: CompressedMatrix.h:2247
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:428
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:260
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:117
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
size_t nonZeros() const
Returns the number of non-zero elements in the sparse matrix.
Definition: CompressedMatrix.h:1263
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2751
Header file for the SparseMatrix base class.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:424
void reserve(size_t nonzeros)
Setting the minimum capacity of the sparse matrix.
Definition: CompressedMatrix.h:1671
void reset()
Reset to the default initial values.
Definition: CompressedMatrix.h:1303
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:261
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:4953
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
Iterator set(size_t i, size_t j, const Type &value)
Setting an element of the compressed matrix.
Definition: CompressedMatrix.h:1365
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
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:2592
#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:116
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:1501
Iterator * end_
Pointers one past the last non-zero element of each column.
Definition: CompressedMatrix.h:2753
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:227
#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:78
const CTransExprTrait< MT >::Type ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatConjExpr.h:974
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.
Header file for the default storage order for all vectors of the Blaze library.
Iterator insert(size_t i, size_t j, const Type &value)
Inserting an element into the compressed matrix.
Definition: CompressedMatrix.h:1397
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:187
CompressedMatrix< ET, true > Other
The type of the other CompressedMatrix.
Definition: CompressedMatrix.h:2600
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:94
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:120
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:532
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
void subAssign(const DenseMatrix< MT, SO2 > &rhs)
Default implementation of the subtraction assignment of a dense matrix.
Definition: CompressedMatrix.h:2476
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
Header file for the serial shim.
void swap(CompressedMatrix &sm)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:1882
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:265
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: CompressedMatrix.h:2266
size_t capacity() const
Returns the maximum capacity of the sparse matrix.
Definition: CompressedMatrix.h:1228
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the sparse matrix.
Definition: CompressedMatrix.h:1587
Header file for the IsNumeric type trait.
CompressedMatrix & operator=(const CompressedMatrix &rhs)
Copy assignment operator for CompressedMatrix.
Definition: CompressedMatrix.h:931
#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:116
Reference operator()(size_t i, size_t j)
2D-access to the sparse matrix elements.
Definition: CompressedMatrix.h:687
Header file for run time assertion macros.
Header file for the addition trait.
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: CompressedMatrix.h:859
CompressedMatrix & transpose()
In-place transpose of the matrix.
Definition: CompressedMatrix.h:1804
Header file for the division trait.
void trim()
Removing all excessive capacity from all rows/columns.
Definition: CompressedMatrix.h:1765
Header file for the submatrix trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the column trait.
Header file for the isDefault shim.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
Constraint on the data type.
size_t columns() const
Returns the current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:1214
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:256
Iterator * begin_
Pointers to the first non-zero element of each column.
Definition: CompressedMatrix.h:2752
void assign(const DenseMatrix< MT, SO2 > &rhs)
Default implementation of the assignment of a row-major dense matrix.
Definition: CompressedMatrix.h:2288
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:264
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:2163
void finalize(size_t i)
Finalizing the element insertion of a row/column.
Definition: CompressedMatrix.h:2195
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: CompressedMatrix.h:2227
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Base template for the DivTrait class.
Definition: DivTrait.h:138
CompressedMatrix< Type, SO > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:255
Iterator find(size_t i, size_t j)
Searches for a specific matrix element.
Definition: CompressedMatrix.h:1972
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:425
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2750
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:2424
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:258
Iterator lowerBound(size_t i, size_t j)
Returns an iterator to the first index not less then the given index.
Definition: CompressedMatrix.h:2025
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:2755
Iterator upperBound(size_t i, size_t j)
Returns an iterator to the first index greater then the given index.
Definition: CompressedMatrix.h:2076
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: CompressedMatrix.h:837
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:272
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2599
Header file for the IsUpper type trait.
Header file for exception macros.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:423
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: CompressedMatrix.h:903
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: CompressedMatrix.h:739
Header file for the IsResizable type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:422
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)
Returns an iterator to the first non-zero element of row/column i.
Definition: CompressedMatrix.h:793
Header file for a safe C++ NULL pointer implementation.