22 #ifndef _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
23 #define _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
181 template<
typename Type
196 using ElementBase::operator=;
206 struct FindIndex :
public std::binary_function<Element,size_t,bool>
208 inline bool operator()(
const Element& element,
size_t index )
const {
209 return element.index() < index;
211 inline bool operator()(
size_t index,
const Element& element )
const {
212 return index < element.index();
214 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
215 return element1.index() < element2.index();
242 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
280 template<
typename Other >
282 operator*=( Other rhs );
284 template<
typename Other >
286 operator/=( Other rhs );
293 inline size_t rows()
const;
296 inline size_t capacity(
size_t i )
const;
298 inline size_t nonZeros(
size_t i )
const;
300 inline void reset(
size_t i );
303 inline void erase (
size_t i,
size_t j );
307 void resize (
size_t m,
size_t n,
bool preserve=
true );
308 inline void reserve(
size_t nonzeros );
309 void reserve(
size_t i,
size_t nonzeros );
314 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
322 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
330 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
331 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
385 template<
typename Type,
bool SO >
400 template<
typename Type
422 template<
typename Type
429 , end_ ( begin_+(m+1UL) )
431 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
446 template<
typename Type
453 , end_ ( begin_+(m+1UL) )
455 begin_[0UL] =
new Element[nonzeros];
456 for(
size_t i=1UL; i<(2UL*
m_+1UL); ++i )
472 template<
typename Type
478 , begin_( new
Iterator[2UL*m_+2UL] )
479 , end_ ( begin_+(m_+1UL) )
481 BLAZE_USER_ASSERT( nonzeros.size() == m,
"Size of capacity vector and number of rows don't match" );
483 size_t newCapacity( 0UL );
484 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
487 begin_[0UL] =
end_[0UL] =
new Element[newCapacity];
488 for(
size_t i=0UL; i<
m_; ++i ) {
500 template<
typename Type
506 , begin_ ( new
Iterator[2UL*m_+2UL] )
507 , end_ ( begin_+(m_+1UL) )
509 const size_t nonzeros( sm.
nonZeros() );
511 begin_[0UL] =
new Element[nonzeros];
512 for(
size_t i=0UL; i<
m_; ++i )
513 begin_[i+1UL] =
end_[i] = std::copy( sm.
begin(i), sm.
end(i), begin_[i] );
514 end_[
m_] = begin_[0UL]+nonzeros;
524 template<
typename Type
526 template<
typename MT
529 : m_ ( (~dm).
rows() )
532 , begin_ ( new
Iterator[2UL*m_+2UL] )
533 , end_ ( begin_+(m_+1UL) )
537 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
550 template<
typename Type
552 template<
typename MT
555 : m_ ( (~sm).
rows() )
558 , begin_ ( new
Iterator[2UL*m_+2UL] )
559 , end_ ( begin_+(m_+1UL) )
563 const size_t nonzeros( (~sm).
nonZeros() );
565 begin_[0UL] =
new Element[nonzeros];
566 for(
size_t i=0UL; i<
m_; ++i )
586 template<
typename Type
590 delete [] begin_[0UL];
611 template<
typename Type
631 template<
typename Type
639 const ConstIterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
641 if( pos == end_[i] || pos->index_ != j )
660 template<
typename Type
682 template<
typename Type
704 template<
typename Type
726 template<
typename Type
748 template<
typename Type
770 template<
typename Type
798 template<
typename Type
803 if( &rhs ==
this )
return *
this;
805 const size_t nonzeros( rhs.
nonZeros() );
807 if( rhs.
m_ > capacity_ || nonzeros > capacity() )
812 newBegin[0UL] =
new Element[nonzeros];
813 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
814 newBegin[i+1UL] = newEnd[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], newBegin[i] );
816 newEnd[rhs.
m_] = newBegin[0UL]+nonzeros;
820 delete [] newBegin[0UL];
825 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
826 begin_[i+1UL] = end_[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], begin_[i] );
847 template<
typename Type
849 template<
typename MT
856 if( (~rhs).canAlias(
this ) ) {
879 template<
typename Type
881 template<
typename MT
888 if( (~rhs).canAlias(
this ) ||
889 (~rhs).
rows() > capacity_ ||
890 (~rhs).nonZeros() > capacity() ) {
915 template<
typename Type
917 template<
typename MT
924 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
925 throw std::invalid_argument(
"Matrix sizes do not match" );
943 template<
typename Type
945 template<
typename MT
951 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
952 throw std::invalid_argument(
"Matrix sizes do not match" );
970 template<
typename Type
972 template<
typename MT
977 if( (~rhs).
rows() != n_ )
978 throw std::invalid_argument(
"Matrix sizes do not match" );
995 template<
typename Type
997 template<
typename Other >
1001 for(
size_t i=0UL; i<m_; ++i ) {
1003 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1004 elem->value_ *= rhs;
1019 template<
typename Type
1021 template<
typename Other >
1033 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1034 for(
size_t i=0UL; i<m_; ++i ) {
1036 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1037 elem->value_ *= tmp;
1041 for(
size_t i=0UL; i<m_; ++i ) {
1043 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1044 elem->value_ /= rhs;
1066 template<
typename Type
1080 template<
typename Type
1094 template<
typename Type
1098 return end_[m_] - begin_[0UL];
1114 template<
typename Type
1119 return begin_[i+1UL] - begin_[i];
1129 template<
typename Type
1133 size_t nonzeros( 0UL );
1135 for(
size_t i=0UL; i<m_; ++i )
1136 nonzeros += nonZeros( i );
1154 template<
typename Type
1159 return end_[i] - begin_[i];
1169 template<
typename Type
1173 for(
size_t i=0UL; i<m_; ++i )
1174 end_[i] = begin_[i];
1190 template<
typename Type
1195 end_[i] = begin_[i];
1207 template<
typename Type
1211 end_[0UL] = end_[m_];
1231 template<
typename Type
1239 const Iterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
1241 if( pos != end_[i] && pos->index_ == j )
1242 throw std::invalid_argument(
"Bad access index" );
1244 if( begin_[i+1UL] - end_[i] != 0 ) {
1245 std::copy_backward( pos, end_[i], end_[i]+1 );
1246 pos->value_ = value;
1252 else if( end_[m_] - begin_[m_] != 0 ) {
1253 std::copy_backward( pos, end_[m_-1UL], end_[m_-1UL]+1 );
1255 pos->value_ = value;
1258 for(
size_t k=i+1UL; k<m_+1UL; ++k ) {
1266 size_t newCapacity( extendCapacity() );
1269 Iterator* newEnd = newBegin+capacity_+1UL;
1271 newBegin[0UL] =
new Element[newCapacity];
1273 for(
size_t k=0UL; k<i; ++k ) {
1274 const size_t nonzeros( end_[k] - begin_[k] );
1275 const size_t total( begin_[k+1UL] - begin_[k] );
1276 newEnd [k] = newBegin[k] + nonzeros;
1277 newBegin[k+1UL] = newBegin[k] + total;
1279 newEnd [i] = newBegin[i] + ( end_[i] - begin_[i] ) + 1;
1280 newBegin[i+1UL] = newBegin[i] + ( begin_[i+1] - begin_[i] ) + 1;
1281 for(
size_t k=i+1UL; k<m_; ++k ) {
1282 const size_t nonzeros( end_[k] - begin_[k] );
1283 const size_t total( begin_[k+1UL] - begin_[k] );
1284 newEnd [k] = newBegin[k] + nonzeros;
1285 newBegin[k+1UL] = newBegin[k] + total;
1288 newEnd[m_] = newEnd[capacity_] = newBegin[0UL]+newCapacity;
1290 Iterator tmp = std::copy( begin_[0UL], pos, newBegin[0UL] );
1291 tmp->value_ = value;
1293 std::copy( pos, end_[m_-1UL], tmp+1UL );
1297 delete [] newBegin[0UL];
1315 template<
typename Type
1322 const Iterator pos( find( i, j ) );
1323 if( pos != end_[i] )
1324 end_[i] = std::copy( pos+1, end_[i], pos );
1338 template<
typename Type
1344 BLAZE_USER_ASSERT( pos >= begin_[i] && pos <= end_[i],
"Invalid compressed matrix iterator" );
1346 if( pos != end_[i] )
1347 end_[i] = std::copy( pos+1, end_[i], pos );
1368 template<
typename Type
1373 return const_cast<Iterator>(
const_cast<const This&
>( *this ).
find( i, j ) );
1392 template<
typename Type
1397 const Iterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
1398 if( pos != end_[i] && pos->index_ == j )
1400 else return end_[i];
1419 template<
typename Type
1425 if( m == m_ && n == n_ )
return;
1430 Iterator* newEnd ( newBegin+m+1UL );
1432 newBegin[0UL] = begin_[0UL];
1435 for(
size_t i=0UL; i<m_; ++i ) {
1436 newEnd [i] = end_ [i];
1437 newBegin[i+1UL] = begin_[i+1UL];
1439 for(
size_t i=m_; i<m; ++i ) {
1440 newBegin[i+1UL] = newEnd[i] = begin_[m_];
1444 for(
size_t i=0UL; i<m; ++i ) {
1445 newBegin[i+1UL] = newEnd[i] = begin_[0UL];
1449 newEnd[m] = end_[m_];
1462 for(
size_t i=0UL; i<m_; ++i )
1463 end_[i] = begin_[i];
1466 for(
size_t i=m_; i<m; ++i )
1467 begin_[i+1UL] = end_[i] = begin_[m_];
1472 for(
size_t i=0UL; i<m; ++i )
1473 end_[i] = std::lower_bound( begin_[i], end_[i], n, FindIndex() );
1476 for(
size_t i=0UL; i<m; ++i )
1477 end_[i] = begin_[i];
1499 template<
typename Type
1503 if( nonzeros > capacity() )
1504 reserveElements( nonzeros );
1523 template<
typename Type
1529 const size_t current( capacity(i) );
1531 if( current >= nonzeros )
return;
1533 const ptrdiff_t additional( nonzeros - current );
1535 if( end_[m_] - begin_[m_] < additional )
1537 const size_t newCapacity( begin_[m_] - begin_[0UL] + additional );
1541 Iterator* newEnd ( newBegin+m_+1UL );
1543 newBegin[0UL] =
new Element[newCapacity];
1544 newEnd [m_ ] = newBegin[0UL]+newCapacity;
1546 for(
size_t k=0UL; k<i; ++k ) {
1547 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
1548 newBegin[k+1UL] = newBegin[k] + capacity(k);
1550 newEnd [i ] = std::copy( begin_[i], end_[i], newBegin[i] );
1551 newBegin[i+1UL] = newBegin[i] + nonzeros;
1552 for(
size_t k=i+1UL; k<m_; ++k ) {
1553 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
1554 newBegin[k+1UL] = newBegin[k] + capacity(k);
1560 delete [] newBegin[0UL];
1566 begin_[m_] += additional;
1567 for(
size_t j=m_-1UL; j>i; --j ) {
1568 begin_[j] = std::copy_backward( begin_[j], end_[j], end_[j]+additional );
1569 end_ [j] += additional;
1581 template<
typename Type
1609 template<
typename Type
1613 if( m_ != n_ )
return false;
1615 for(
size_t i=0UL; i<
rows(); ++i ) {
1616 for(
ConstIterator element=begin_[i]; element!=end_[i]; ++element )
1617 if( element->index_ != i && !
isDefault( element->value_ ) )
1631 template<
typename Type
1635 if( m_ != n_ )
return false;
1637 for(
size_t i=0UL; i<
rows(); ++i ) {
1638 for(
ConstIterator element=begin_[i]; element!=end_[i]; ++element )
1640 const size_t index( element->index_ );
1645 const Iterator pos( std::lower_bound( begin_[index], end_[index], i, FindIndex() ) );
1646 if( pos == end_[index] || pos->index_ != i || !
equal( pos->value_, element->value_ ) )
1662 template<
typename Type
1664 template<
typename Other >
1667 for(
size_t i=0UL; i<m_; ++i )
1668 for(
Iterator element=begin_[i]; element!=end_[i]; ++element )
1669 element->value_ *= scalar;
1682 template<
typename Type
1684 template<
typename Other >
1689 for(
size_t i=0UL; i<size; ++i ) {
1690 Iterator pos = std::lower_bound( begin_[i], end_[i], i, FindIndex() );
1691 if( pos != end_[i] && pos->index_ == i )
1692 pos->value_ *= scalar;
1707 template<
typename Type
1728 template<
typename Type
1732 size_t nonzeros( 2UL*capacity()+1UL );
1749 template<
typename Type
1754 Iterator* newEnd = newBegin+capacity_+1UL;
1756 newBegin[0UL] =
new Element[nonzeros];
1758 for(
size_t k=0UL; k<m_; ++k ) {
1760 newEnd [k] = std::copy( begin_[k], end_[k], newBegin[k] );
1761 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
1764 newEnd[m_] = newBegin[0UL]+nonzeros;
1767 delete [] newBegin[0UL];
1822 template<
typename Type
1829 BLAZE_USER_ASSERT( begin_[i] == end_[i] || j > ( end_[i]-1UL )->index_,
"Index is not strictly increasing" );
1831 end_[i]->value_ = value;
1833 if( !check || !
isDefault( end_[i]->value_ ) ) {
1834 end_[i]->index_ = j;
1854 template<
typename Type
1860 begin_[i+1UL] = end_[i];
1862 end_[i+1UL] = end_[i];
1885 template<
typename Type
1887 template<
typename Other >
1890 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1905 template<
typename Type
1907 template<
typename Other >
1910 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1926 template<
typename Type
1928 template<
typename MT
1932 size_t nonzeros( 0UL );
1934 for(
size_t i=1UL; i<=m_; ++i )
1935 begin_[i] = end_[i] = end_[m_];
1937 for(
size_t i=0UL; i<m_; ++i )
1939 begin_[i] = end_[i] = begin_[0UL]+nonzeros;
1941 for(
size_t j=0UL; j<n_; ++j )
1943 if( nonzeros == capacity() ) {
1944 reserveElements( extendCapacity() );
1945 for(
size_t k=i+1UL; k<=m_; ++k )
1946 begin_[k] = end_[k] = end_[m_];
1949 end_[i]->value_ = (~rhs)(i,j);
1952 end_[i]->index_ = j;
1959 begin_[m_] = begin_[0UL]+nonzeros;
1975 template<
typename Type
1977 template<
typename MT >
1980 for(
size_t i=0UL; i<(~rhs).
rows(); ++i ) {
1981 begin_[i+1UL] = end_[i] = std::copy( (~rhs).begin(i), (~rhs).end(i), begin_[i] );
1998 template<
typename Type
2000 template<
typename MT >
2003 typedef typename MT::ConstIterator RhsIterator;
2006 std::vector<size_t> rowLengths( m_, 0UL );
2007 for(
size_t j=0UL; j<n_; ++j ) {
2008 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2009 ++rowLengths[element->index()];
2013 for(
size_t i=0UL; i<m_; ++i ) {
2014 begin_[i+1UL] = end_[i+1UL] = begin_[i] + rowLengths[i];
2018 for(
size_t j=0UL; j<n_; ++j ) {
2019 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2020 append( element->index(), j, element->value() );
2037 template<
typename Type
2039 template<
typename MT
2063 template<
typename Type
2065 template<
typename MT
2089 template<
typename Type
2091 template<
typename MT
2115 template<
typename Type
2117 template<
typename MT
2150 template<
typename Type >
2164 using ElementBase::operator=;
2174 struct FindIndex :
public std::binary_function<Element,size_t,bool>
2176 inline bool operator()(
const Element& element,
size_t index )
const {
2177 return element.index() < index;
2179 inline bool operator()(
size_t index,
const Element& element )
const {
2180 return index < element.index();
2182 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
2183 return element1.index() < element2.index();
2191 typedef CompressedMatrix<Type,true>
This;
2198 typedef MatrixAccessProxy<This>
Reference;
2210 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
2212 template<
typename MT,
bool SO >
inline CompressedMatrix(
const DenseMatrix<MT,SO>& dm );
2213 template<
typename MT,
bool SO >
inline CompressedMatrix(
const SparseMatrix<MT,SO>& sm );
2244 template<
typename MT,
bool SO >
inline CompressedMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2245 template<
typename MT,
bool SO >
inline CompressedMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2246 template<
typename MT,
bool SO >
inline CompressedMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2248 template<
typename Other >
2250 operator*=( Other rhs );
2252 template<
typename Other >
2254 operator/=( Other rhs );
2261 inline size_t rows()
const;
2262 inline size_t columns()
const;
2264 inline size_t capacity(
size_t j )
const;
2266 inline size_t nonZeros(
size_t j )
const;
2267 inline void reset();
2268 inline void reset(
size_t j );
2269 inline void clear();
2271 inline void erase (
size_t i,
size_t j );
2275 void resize (
size_t m,
size_t n,
bool preserve=
true );
2276 inline void reserve(
size_t nonzeros );
2277 void reserve(
size_t j,
size_t nonzeros );
2282 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
2290 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
2298 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2299 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2300 template<
typename MT,
bool SO >
inline void assign (
const DenseMatrix<MT,SO>& rhs );
2301 template<
typename MT >
inline void assign (
const SparseMatrix<MT,true>& rhs );
2302 template<
typename MT >
inline void assign (
const SparseMatrix<MT,false>& rhs );
2303 template<
typename MT,
bool SO >
inline void addAssign(
const DenseMatrix<MT,SO>& rhs );
2304 template<
typename MT,
bool SO >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
2305 template<
typename MT,
bool SO >
inline void subAssign(
const DenseMatrix<MT,SO>& rhs );
2306 template<
typename MT,
bool SO >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
2328 static const Type
zero_;
2354 template<
typename Type >
2355 const Type CompressedMatrix<Type,true>::zero_ = Type();
2370 template<
typename Type >
2375 , begin_( new Iterator[2UL] )
2376 , end_ ( begin_+1UL )
2393 template<
typename Type >
2398 , begin_( new Iterator[2UL*n+2UL] )
2399 , end_ ( begin_+(n+1UL) )
2401 for(
size_t j=0UL; j<2UL*
n_+2UL; ++j )
2418 template<
typename Type >
2423 , begin_( new Iterator[2UL*n+2UL] )
2424 , end_ ( begin_+(n+1UL) )
2426 begin_[0UL] =
new Element[nonzeros];
2427 for(
size_t j=1UL; j<(2UL*
n_+1UL); ++j )
2445 template<
typename Type >
2450 , begin_( new Iterator[2UL*n_+2UL] )
2451 , end_ ( begin_+(n_+1UL) )
2453 BLAZE_USER_ASSERT( nonzeros.size() == n,
"Size of capacity vector and number of columns don't match" );
2455 size_t newCapacity( 0UL );
2456 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
2459 begin_[0UL] =
end_[0UL] =
new Element[newCapacity];
2460 for(
size_t j=0UL; j<
n_; ++j ) {
2474 template<
typename Type >
2478 , capacity_( sm.n_ )
2479 , begin_ ( new Iterator[2UL*n_+2UL] )
2480 , end_ ( begin_+(n_+1UL) )
2482 const size_t nonzeros( sm.nonZeros() );
2484 begin_[0UL] =
new Element[nonzeros];
2485 for(
size_t j=0UL; j<
n_; ++j )
2486 begin_[j+1UL] =
end_[j] = std::copy( sm.begin(j), sm.end(j), begin_[j] );
2487 end_[
n_] = begin_[0UL]+nonzeros;
2499 template<
typename Type >
2500 template<
typename MT
2503 : m_ ( (~dm).
rows() )
2506 , begin_ ( new Iterator[2UL*n_+2UL] )
2507 , end_ ( begin_+(n_+1UL) )
2511 for(
size_t j=0UL; j<2UL*n_+2UL; ++j )
2526 template<
typename Type >
2527 template<
typename MT
2530 : m_ ( (~sm).
rows() )
2533 , begin_ ( new Iterator[2UL*n_+2UL] )
2534 , end_ ( begin_+(n_+1UL) )
2538 const size_t nonzeros( (~sm).
nonZeros() );
2540 begin_[0UL] =
new Element[nonzeros];
2541 for(
size_t j=0UL; j<
n_; ++j )
2542 begin_[j+1UL] =
end_[j] = begin_[0UL];
2543 end_[
n_] = begin_[0UL]+nonzeros;
2563 template<
typename Type >
2566 delete [] begin_[0UL];
2589 template<
typename Type >
2590 inline typename CompressedMatrix<Type,true>::Reference
2596 return Reference( *
this, i, j );
2610 template<
typename Type >
2611 inline typename CompressedMatrix<Type,true>::ConstReference
2617 const ConstIterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
2619 if( pos == end_[j] || pos->index_ != i )
2635 template<
typename Type >
2636 inline typename CompressedMatrix<Type,true>::Iterator
2653 template<
typename Type >
2654 inline typename CompressedMatrix<Type,true>::ConstIterator
2671 template<
typename Type >
2672 inline typename CompressedMatrix<Type,true>::ConstIterator
2689 template<
typename Type >
2690 inline typename CompressedMatrix<Type,true>::Iterator
2707 template<
typename Type >
2708 inline typename CompressedMatrix<Type,true>::ConstIterator
2725 template<
typename Type >
2726 inline typename CompressedMatrix<Type,true>::ConstIterator
2754 template<
typename Type >
2755 inline CompressedMatrix<Type,true>&
2758 if( &rhs ==
this )
return *
this;
2760 const size_t nonzeros( rhs.nonZeros() );
2762 if( rhs.n_ > capacity_ || nonzeros > capacity() )
2764 Iterator* newBegin(
new Iterator[2UL*rhs.n_+2UL] );
2765 Iterator* newEnd ( newBegin+(rhs.n_+1UL) );
2767 newBegin[0UL] =
new Element[nonzeros];
2768 for(
size_t j=0UL; j<rhs.n_; ++j ) {
2769 newBegin[j+1UL] = newEnd[j] = std::copy( rhs.begin_[j], rhs.end_[j], newBegin[j] );
2771 newEnd[rhs.n_] = newBegin[0UL]+nonzeros;
2775 delete [] newBegin[0UL];
2780 for(
size_t j=0UL; j<rhs.n_; ++j ) {
2781 begin_[j+1UL] = end_[j] = std::copy( rhs.begin_[j], rhs.end_[j], begin_[j] );
2804 template<
typename Type >
2805 template<
typename MT
2807 inline CompressedMatrix<Type,true>&
2812 if( (~rhs).canAlias(
this ) ) {
2813 CompressedMatrix tmp( rhs );
2837 template<
typename Type >
2838 template<
typename MT
2840 inline CompressedMatrix<Type,true>&
2845 if( (~rhs).canAlias(
this ) ||
2846 (~rhs).
columns() > capacity_ ||
2847 (~rhs).nonZeros() > capacity() ) {
2848 CompressedMatrix tmp( rhs );
2874 template<
typename Type >
2875 template<
typename MT
2877 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
2881 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
2882 throw std::invalid_argument(
"Matrix sizes do not match" );
2902 template<
typename Type >
2903 template<
typename MT
2905 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
2909 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
2910 throw std::invalid_argument(
"Matrix sizes do not match" );
2930 template<
typename Type >
2931 template<
typename MT
2933 inline CompressedMatrix<Type,true>&
2934 CompressedMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
2936 if( (~rhs).
rows() != n_ )
2937 throw std::invalid_argument(
"Matrix sizes do not match" );
2939 CompressedMatrix tmp( *
this * (~rhs) );
2956 template<
typename Type >
2957 template<
typename Other >
2958 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
2959 CompressedMatrix<Type,true>::operator*=( Other rhs )
2961 for(
size_t j=0UL; j<n_; ++j ) {
2962 const Iterator endElem( end(j) );
2963 for( Iterator elem=begin(j); elem<endElem; ++elem )
2964 elem->value_ *= rhs;
2981 template<
typename Type >
2982 template<
typename Other >
2983 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
2984 CompressedMatrix<Type,true>::operator/=( Other rhs )
2988 typedef typename DivTrait<Type,Other>::Type DT;
2989 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2993 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2994 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2995 for(
size_t j=0UL; j<n_; ++j ) {
2996 const Iterator endElem( end(j) );
2997 for( Iterator elem=begin(j); elem<endElem; ++elem )
2998 elem->value_ *= tmp;
3002 for(
size_t j=0UL; j<n_; ++j ) {
3003 const Iterator endElem( end(j) );
3004 for( Iterator elem=begin(j); elem<endElem; ++elem )
3005 elem->value_ /= rhs;
3029 template<
typename Type >
3044 template<
typename Type >
3059 template<
typename Type >
3062 return end_[n_] - begin_[0UL];
3075 template<
typename Type >
3079 return begin_[j+1UL] - begin_[j];
3091 template<
typename Type >
3094 size_t nonzeros( 0UL );
3096 for(
size_t j=0UL; j<n_; ++j )
3097 nonzeros += nonZeros( j );
3112 template<
typename Type >
3116 return end_[j] - begin_[j];
3128 template<
typename Type >
3131 for(
size_t j=0UL; j<n_; ++j )
3132 end_[j] = begin_[j];
3148 template<
typename Type >
3152 end_[j] = begin_[j];
3166 template<
typename Type >
3169 end_[0UL] = end_[n_];
3191 template<
typename Type >
3192 typename CompressedMatrix<Type,true>::Iterator
3198 const Iterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
3200 if( pos != end_[j] && pos->index_ == i )
3201 throw std::invalid_argument(
"Bad access index" );
3203 if( begin_[j+1UL] - end_[j] != 0 ) {
3204 std::copy_backward( pos, end_[j], end_[j]+1 );
3205 pos->value_ = value;
3211 else if( end_[n_] - begin_[n_] != 0 ) {
3212 std::copy_backward( pos, end_[n_-1UL], end_[n_-1]+1 );
3214 pos->value_ = value;
3217 for(
size_t k=j+1UL; k<n_+1UL; ++k ) {
3225 size_t newCapacity( extendCapacity() );
3227 Iterator* newBegin =
new Iterator[2UL*capacity_+2UL];
3228 Iterator* newEnd = newBegin+capacity_+1UL;
3230 newBegin[0UL] =
new Element[newCapacity];
3232 for(
size_t k=0UL; k<j; ++k ) {
3233 const size_t nonzeros( end_[k] - begin_[k] );
3234 const size_t total( begin_[k+1UL] - begin_[k] );
3235 newEnd [k] = newBegin[k] + nonzeros;
3236 newBegin[k+1UL] = newBegin[k] + total;
3238 newEnd [j] = newBegin[j] + ( end_[j] - begin_[j] ) + 1;
3239 newBegin[j+1UL] = newBegin[j] + ( begin_[j+1UL] - begin_[j] ) + 1;
3240 for(
size_t k=j+1UL; k<n_; ++k ) {
3241 const size_t nonzeros( end_[k] - begin_[k] );
3242 const size_t total( begin_[k+1UL] - begin_[k] );
3243 newEnd [k] = newBegin[k] + nonzeros;
3244 newBegin[k+1UL] = newBegin[k] + total;
3247 newEnd[n_] = newEnd[capacity_] = newBegin[0UL]+newCapacity;
3249 Iterator tmp = std::copy( begin_[0UL], pos, newBegin[0UL] );
3250 tmp->value_ = value;
3252 std::copy( pos, end_[n_-1UL], tmp+1UL );
3256 delete [] newBegin[0UL];
3275 template<
typename Type >
3281 const Iterator pos( find( i, j ) );
3282 if( pos != end_[j] )
3283 end_[j] = std::copy( pos+1, end_[j], pos );
3297 template<
typename Type >
3298 inline typename CompressedMatrix<Type,true>::Iterator
3302 BLAZE_USER_ASSERT( pos >= begin_[j] && pos <= end_[j],
"Invalid compressed matrix iterator" );
3304 if( pos != end_[j] )
3305 end_[j] = std::copy( pos+1, end_[j], pos );
3327 template<
typename Type >
3328 inline typename CompressedMatrix<Type,true>::Iterator
3331 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).find( i, j ) );
3352 template<
typename Type >
3353 inline typename CompressedMatrix<Type,true>::ConstIterator
3356 const Iterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
3357 if( pos != end_[j] && pos->index_ == i )
3359 else return end_[j];
3380 template<
typename Type >
3385 if( m == m_ && n == n_ )
return;
3389 Iterator* newBegin(
new Iterator[2UL*n+2UL] );
3390 Iterator* newEnd ( newBegin+n+1UL );
3392 newBegin[0UL] = begin_[0UL];
3395 for(
size_t j=0UL; j<n_; ++j ) {
3396 newEnd [j] = end_ [j];
3397 newBegin[j+1UL] = begin_[j+1UL];
3399 for(
size_t j=n_; j<n; ++j ) {
3400 newBegin[j+1UL] = newEnd[j] = begin_[n_];
3404 for(
size_t j=0UL; j<n; ++j ) {
3405 newBegin[j+1UL] = newEnd[j] = begin_[0UL];
3409 newEnd[n] = end_[n_];
3422 for(
size_t j=0UL; j<n_; ++j )
3423 end_[j] = begin_[j];
3426 for(
size_t j=n_; j<n; ++j )
3427 begin_[j+1UL] = end_[j] = begin_[n_];
3432 for(
size_t j=0UL; j<n; ++j )
3433 end_[j] = std::lower_bound( begin_[j], end_[j], m, FindIndex() );
3436 for(
size_t j=0UL; j<n; ++j )
3437 end_[j] = begin_[j];
3461 template<
typename Type >
3464 if( nonzeros > capacity() )
3465 reserveElements( nonzeros );
3483 template<
typename Type >
3488 const size_t current( capacity(j) );
3490 if( current >= nonzeros )
return;
3492 const ptrdiff_t additional( nonzeros - current );
3494 if( end_[n_] - begin_[n_] < additional )
3496 const size_t newCapacity( begin_[n_] - begin_[0UL] + additional );
3499 Iterator* newBegin(
new Iterator[2UL*n_+2UL] );
3500 Iterator* newEnd ( newBegin+n_+1UL );
3502 newBegin[0UL] =
new Element[newCapacity];
3503 newEnd [n_ ] = newBegin[0UL]+newCapacity;
3505 for(
size_t k=0UL; k<j; ++k ) {
3506 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
3507 newBegin[k+1UL] = newBegin[k] + capacity(k);
3509 newEnd [j ] = std::copy( begin_[j], end_[j], newBegin[j] );
3510 newBegin[j+1UL] = newBegin[j] + nonzeros;
3511 for(
size_t k=j+1UL; k<n_; ++k ) {
3512 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
3513 newBegin[k+1UL] = newBegin[k] + capacity(k);
3519 delete [] newBegin[0UL];
3525 begin_[n_] += additional;
3526 for(
size_t k=n_-1UL; k>j; --k ) {
3527 begin_[k] = std::copy_backward( begin_[k], end_[k], end_[k]+additional );
3528 end_ [k] += additional;
3542 template<
typename Type >
3545 CompressedMatrix tmp(
trans( *
this ) );
3571 template<
typename Type >
3574 if( m_ != n_ )
return false;
3576 for(
size_t j=0UL; j<
columns(); ++j ) {
3577 for( ConstIterator element=begin_[j]; element!=end_[j]; ++element )
3578 if( element->index_ != j && !
isDefault( element->value_ ) )
3594 template<
typename Type >
3597 if( m_ != n_ )
return false;
3599 for(
size_t j=0UL; j<
rows(); ++j ) {
3600 for( ConstIterator element=begin_[j]; element!=end_[j]; ++element )
3602 const size_t index( element->index_ );
3607 const Iterator pos( std::lower_bound( begin_[index], end_[index], j, FindIndex() ) );
3608 if( pos == end_[index] || pos->index_ != j || !
equal( pos->value_, element->value_ ) )
3626 template<
typename Type >
3627 template<
typename Other >
3628 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scale( Other scalar )
3630 for(
size_t j=0UL; j<n_; ++j )
3631 for( Iterator element=begin_[j]; element!=end_[j]; ++element )
3632 element->value_ *= scalar;
3647 template<
typename Type >
3648 template<
typename Other >
3649 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scaleDiagonal( Other scalar )
3653 for(
size_t j=0UL; j<size; ++j ) {
3654 Iterator pos = std::lower_bound( begin_[j], end_[j], j, FindIndex() );
3655 if( pos != end_[j] && pos->index_ == j )
3656 pos->value_ *= scalar;
3673 template<
typename Type >
3695 template<
typename Type >
3698 size_t nonzeros( 2UL*capacity()+1UL );
3717 template<
typename Type >
3720 Iterator* newBegin =
new Iterator[2UL*capacity_+2UL];
3721 Iterator* newEnd = newBegin+capacity_+1UL;
3723 newBegin[0UL] =
new Element[nonzeros];
3725 for(
size_t k=0UL; k<n_; ++k ) {
3727 newEnd [k] = std::copy( begin_[k], end_[k], newBegin[k] );
3728 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
3731 newEnd[n_] = newBegin[0UL]+nonzeros;
3734 delete [] newBegin[0UL];
3791 template<
typename Type >
3797 BLAZE_USER_ASSERT( begin_[j] == end_[j] || i > ( end_[j]-1UL )->index_,
"Index is not strictly increasing" );
3799 end_[j]->value_ = value;
3801 if( !check || !
isDefault( end_[j]->value_ ) ) {
3802 end_[j]->index_ = i;
3824 template<
typename Type >
3829 begin_[j+1UL] = end_[j];
3831 end_[j+1UL] = end_[j];
3856 template<
typename Type >
3857 template<
typename Other >
3860 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3877 template<
typename Type >
3878 template<
typename Other >
3881 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3899 template<
typename Type >
3900 template<
typename MT
3904 size_t nonzeros( 0UL );
3906 for(
size_t j=1UL; j<=n_; ++j )
3907 begin_[j] = end_[j] = end_[n_];
3909 for(
size_t j=0UL; j<n_; ++j )
3911 begin_[j] = end_[j] = begin_[0UL]+nonzeros;
3913 for(
size_t i=0UL; i<m_; ++i )
3915 if( nonzeros == capacity() ) {
3916 reserveElements( extendCapacity() );
3917 for(
size_t k=j+1UL; k<=n_; ++k )
3918 begin_[k] = end_[k] = end_[n_];
3921 end_[j]->value_ = (~rhs)(i,j);
3924 end_[j]->index_ = i;
3931 begin_[n_] = begin_[0UL]+nonzeros;
3949 template<
typename Type >
3950 template<
typename MT >
3953 for(
size_t j=0UL; j<(~rhs).
columns(); ++j ) {
3954 begin_[j+1UL] = end_[j] = std::copy( (~rhs).begin(j), (~rhs).end(j), begin_[j] );
3973 template<
typename Type >
3974 template<
typename MT >
3977 typedef typename MT::ConstIterator RhsIterator;
3980 std::vector<size_t> columnLengths( n_, 0UL );
3981 for(
size_t i=0UL; i<m_; ++i ) {
3982 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3983 ++columnLengths[element->index()];
3987 for(
size_t j=0UL; j<n_; ++j ) {
3988 begin_[j+1UL] = end_[j+1UL] = begin_[j] + columnLengths[j];
3992 for(
size_t i=0UL; i<m_; ++i ) {
3993 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3994 append( i, element->index(), element->value() );
4013 template<
typename Type >
4014 template<
typename MT
4021 CompressedMatrix tmp( *
this + (~rhs) );
4040 template<
typename Type >
4041 template<
typename MT
4048 CompressedMatrix tmp( *
this + (~rhs) );
4067 template<
typename Type >
4068 template<
typename MT
4075 CompressedMatrix tmp( *
this - (~rhs) );
4094 template<
typename Type >
4095 template<
typename MT
4102 CompressedMatrix tmp( *
this - (~rhs) );
4124 template<
typename Type,
bool SO >
4125 inline bool isnan(
const CompressedMatrix<Type,SO>& m );
4127 template<
typename Type,
bool SO >
4128 inline void reset( CompressedMatrix<Type,SO>& m );
4130 template<
typename Type,
bool SO >
4131 inline void clear( CompressedMatrix<Type,SO>& m );
4133 template<
typename Type,
bool SO >
4134 inline bool isDefault(
const CompressedMatrix<Type,SO>& m );
4136 template<
typename Type,
bool SO >
4137 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b ) ;
4149 template<
typename Type
4155 for(
size_t i=0UL; i<m.
rows(); ++i ) {
4156 for( ConstIterator element=m.
begin(i); element!=m.
end(i); ++element )
4157 if(
isnan( *element ) )
return true;
4171 template<
typename Type
4187 template<
typename Type
4214 template<
typename Type
4221 for(
size_t i=0UL; i<m.
rows(); ++i ) {
4222 for( ConstIterator element=m.
begin(i); element!=m.
end(i); ++element )
4223 if( !
isDefault( element->value() ) )
return false;
4227 for(
size_t j=0UL; j<m.
columns(); ++j ) {
4228 for( ConstIterator element=m.
begin(j); element!=m.
end(j); ++element )
4229 if( !
isDefault( element->value() ) )
return false;
4247 template<
typename Type
4266 template<
typename T,
bool SO >
4267 struct IsResizable< CompressedMatrix<T,SO> > :
public TrueType
4273 template<
typename T,
bool SO >
4274 struct IsResizable< const CompressedMatrix<T,SO> > :
public TrueType
4280 template<
typename T,
bool SO >
4281 struct IsResizable< volatile CompressedMatrix<T,SO> > :
public TrueType
4287 template<
typename T,
bool SO >
4288 struct IsResizable< const volatile CompressedMatrix<T,SO> > :
public TrueType
4307 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4308 struct AddTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4310 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4313 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4314 struct AddTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4316 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4319 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4320 struct AddTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
4322 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4325 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4326 struct AddTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4328 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4331 template<
typename T1,
bool SO,
typename T2 >
4332 struct AddTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4334 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4337 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4338 struct AddTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4340 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4343 template<
typename T1,
bool SO,
typename T2 >
4344 struct AddTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4346 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4349 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4350 struct AddTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4352 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4355 template<
typename T1,
bool SO,
typename T2 >
4356 struct AddTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4358 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4361 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4362 struct AddTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4364 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4380 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4381 struct SubTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4383 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4386 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4387 struct SubTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4389 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4392 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4393 struct SubTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
4395 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4398 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4399 struct SubTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4401 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4404 template<
typename T1,
bool SO,
typename T2 >
4405 struct SubTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4407 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4410 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4411 struct SubTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4413 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4416 template<
typename T1,
bool SO,
typename T2 >
4417 struct SubTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4419 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4422 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4423 struct SubTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4425 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4428 template<
typename T1,
bool SO,
typename T2 >
4429 struct SubTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4431 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4434 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4435 struct SubTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4437 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4453 template<
typename T1,
bool SO,
typename T2 >
4454 struct MultTrait< CompressedMatrix<T1,SO>, T2 >
4456 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4460 template<
typename T1,
typename T2,
bool SO >
4461 struct MultTrait< T1, CompressedMatrix<T2,SO> >
4463 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4467 template<
typename T1,
bool SO,
typename T2,
size_t N >
4468 struct MultTrait< CompressedMatrix<T1,SO>, StaticVector<T2,N,false> >
4470 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4473 template<
typename T1,
size_t N,
typename T2,
bool SO >
4474 struct MultTrait< StaticVector<T1,N,true>, CompressedMatrix<T2,SO> >
4476 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4479 template<
typename T1,
bool SO,
typename T2 >
4480 struct MultTrait< CompressedMatrix<T1,SO>, DynamicVector<T2,false> >
4482 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4485 template<
typename T1,
typename T2,
bool SO >
4486 struct MultTrait< DynamicVector<T1,true>, CompressedMatrix<T2,SO> >
4488 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4491 template<
typename T1,
bool SO,
typename T2 >
4492 struct MultTrait< CompressedMatrix<T1,SO>, CompressedVector<T2,false> >
4494 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
false > Type;
4497 template<
typename T1,
typename T2,
bool SO >
4498 struct MultTrait< CompressedVector<T1,true>, CompressedMatrix<T2,SO> >
4500 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
true > Type;
4503 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4504 struct MultTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4506 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4509 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4510 struct MultTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4512 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4515 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4516 struct MultTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4518 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4521 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4522 struct MultTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4524 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4527 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4528 struct MultTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4530 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4546 template<
typename T1,
bool SO,
typename T2 >
4547 struct DivTrait< CompressedMatrix<T1,SO>, T2 >
4549 typedef CompressedMatrix< typename DivTrait<T1,T2>::Type, SO > Type;
4566 template<
typename T1,
bool SO,
typename T2 >
4567 struct MathTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4569 typedef CompressedMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
4570 typedef CompressedMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
4586 template<
typename T1,
bool SO >
4587 struct RowTrait< CompressedMatrix<T1,SO> >
4589 typedef CompressedVector<T1,true> Type;
4605 template<
typename T1,
bool SO >
4606 struct ColumnTrait< CompressedMatrix<T1,SO> >
4608 typedef CompressedVector<T1,false> Type;