22 #ifndef _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
23 #define _BLAZE_MATH_SPARSE_COMPRESSEDMATRIX_H_
182 template<
typename Type
197 using ElementBase::operator=;
207 struct FindIndex :
public std::binary_function<Element,size_t,bool>
209 inline bool operator()(
const Element& element,
size_t index )
const {
210 return element.index() < index;
212 inline bool operator()(
size_t index,
const Element& element )
const {
213 return index < element.index();
215 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
216 return element1.index() < element2.index();
243 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
281 template<
typename Other >
283 operator*=( Other rhs );
285 template<
typename Other >
287 operator/=( Other rhs );
294 inline size_t rows()
const;
297 inline size_t capacity(
size_t i )
const;
299 inline size_t nonZeros(
size_t i )
const;
301 inline void reset(
size_t i );
304 inline void erase (
size_t i,
size_t j );
308 void resize (
size_t m,
size_t n,
bool preserve=
true );
309 inline void reserve(
size_t nonzeros );
310 void reserve(
size_t i,
size_t nonzeros );
315 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
323 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
331 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
332 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
386 template<
typename Type,
bool SO >
401 template<
typename Type
423 template<
typename Type
430 , end_ ( begin_+(m+1UL) )
432 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
447 template<
typename Type
454 , end_ ( begin_+(m+1UL) )
456 begin_[0UL] =
new Element[nonzeros];
457 for(
size_t i=1UL; i<(2UL*
m_+1UL); ++i )
473 template<
typename Type
479 , begin_( new
Iterator[2UL*m_+2UL] )
480 , end_ ( begin_+(m_+1UL) )
482 BLAZE_USER_ASSERT( nonzeros.size() == m,
"Size of capacity vector and number of rows don't match" );
484 size_t newCapacity( 0UL );
485 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
488 begin_[0UL] =
end_[0UL] =
new Element[newCapacity];
489 for(
size_t i=0UL; i<
m_; ++i ) {
501 template<
typename Type
507 , begin_ ( new
Iterator[2UL*m_+2UL] )
508 , end_ ( begin_+(m_+1UL) )
510 const size_t nonzeros( sm.
nonZeros() );
512 begin_[0UL] =
new Element[nonzeros];
513 for(
size_t i=0UL; i<
m_; ++i )
514 begin_[i+1UL] =
end_[i] = std::copy( sm.
begin(i), sm.
end(i), begin_[i] );
515 end_[
m_] = begin_[0UL]+nonzeros;
525 template<
typename Type
527 template<
typename MT
530 : m_ ( (~dm).
rows() )
533 , begin_ ( new
Iterator[2UL*m_+2UL] )
534 , end_ ( begin_+(m_+1UL) )
538 for(
size_t i=0UL; i<2UL*
m_+2UL; ++i )
551 template<
typename Type
553 template<
typename MT
556 : m_ ( (~sm).
rows() )
559 , begin_ ( new
Iterator[2UL*m_+2UL] )
560 , end_ ( begin_+(m_+1UL) )
564 const size_t nonzeros( (~sm).
nonZeros() );
566 begin_[0UL] =
new Element[nonzeros];
567 for(
size_t i=0UL; i<
m_; ++i )
587 template<
typename Type
591 delete [] begin_[0UL];
612 template<
typename Type
632 template<
typename Type
640 const ConstIterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
642 if( pos == end_[i] || pos->index_ != j )
661 template<
typename Type
683 template<
typename Type
705 template<
typename Type
727 template<
typename Type
749 template<
typename Type
771 template<
typename Type
799 template<
typename Type
804 if( &rhs ==
this )
return *
this;
806 const size_t nonzeros( rhs.
nonZeros() );
808 if( rhs.
m_ > capacity_ || nonzeros > capacity() )
813 newBegin[0UL] =
new Element[nonzeros];
814 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
815 newBegin[i+1UL] = newEnd[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], newBegin[i] );
817 newEnd[rhs.
m_] = newBegin[0UL]+nonzeros;
821 delete [] newBegin[0UL];
826 for(
size_t i=0UL; i<rhs.
m_; ++i ) {
827 begin_[i+1UL] = end_[i] = std::copy( rhs.
begin_[i], rhs.
end_[i], begin_[i] );
848 template<
typename Type
850 template<
typename MT
857 if( (~rhs).canAlias(
this ) ) {
880 template<
typename Type
882 template<
typename MT
889 if( (~rhs).canAlias(
this ) ||
890 (~rhs).
rows() > capacity_ ||
891 (~rhs).nonZeros() > capacity() ) {
916 template<
typename Type
918 template<
typename MT
925 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
926 throw std::invalid_argument(
"Matrix sizes do not match" );
944 template<
typename Type
946 template<
typename MT
952 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
953 throw std::invalid_argument(
"Matrix sizes do not match" );
971 template<
typename Type
973 template<
typename MT
978 if( (~rhs).
rows() != n_ )
979 throw std::invalid_argument(
"Matrix sizes do not match" );
996 template<
typename Type
998 template<
typename Other >
1002 for(
size_t i=0UL; i<m_; ++i ) {
1004 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1005 elem->value_ *= rhs;
1020 template<
typename Type
1022 template<
typename Other >
1034 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1035 for(
size_t i=0UL; i<m_; ++i ) {
1037 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1038 elem->value_ *= tmp;
1042 for(
size_t i=0UL; i<m_; ++i ) {
1044 for(
Iterator elem=begin(i); elem<endElem; ++elem )
1045 elem->value_ /= rhs;
1067 template<
typename Type
1081 template<
typename Type
1095 template<
typename Type
1099 return end_[m_] - begin_[0UL];
1115 template<
typename Type
1120 return begin_[i+1UL] - begin_[i];
1130 template<
typename Type
1134 size_t nonzeros( 0UL );
1136 for(
size_t i=0UL; i<m_; ++i )
1137 nonzeros += nonZeros( i );
1155 template<
typename Type
1160 return end_[i] - begin_[i];
1170 template<
typename Type
1174 for(
size_t i=0UL; i<m_; ++i )
1175 end_[i] = begin_[i];
1191 template<
typename Type
1196 end_[i] = begin_[i];
1208 template<
typename Type
1212 end_[0UL] = end_[m_];
1232 template<
typename Type
1240 const Iterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
1242 if( pos != end_[i] && pos->index_ == j )
1243 throw std::invalid_argument(
"Bad access index" );
1245 if( begin_[i+1UL] - end_[i] != 0 ) {
1246 std::copy_backward( pos, end_[i], end_[i]+1 );
1247 pos->value_ = value;
1253 else if( end_[m_] - begin_[m_] != 0 ) {
1254 std::copy_backward( pos, end_[m_-1UL], end_[m_-1UL]+1 );
1256 pos->value_ = value;
1259 for(
size_t k=i+1UL; k<m_+1UL; ++k ) {
1267 size_t newCapacity( extendCapacity() );
1270 Iterator* newEnd = newBegin+capacity_+1UL;
1272 newBegin[0UL] =
new Element[newCapacity];
1274 for(
size_t k=0UL; k<i; ++k ) {
1275 const size_t nonzeros( end_[k] - begin_[k] );
1276 const size_t total( begin_[k+1UL] - begin_[k] );
1277 newEnd [k] = newBegin[k] + nonzeros;
1278 newBegin[k+1UL] = newBegin[k] + total;
1280 newEnd [i] = newBegin[i] + ( end_[i] - begin_[i] ) + 1;
1281 newBegin[i+1UL] = newBegin[i] + ( begin_[i+1] - begin_[i] ) + 1;
1282 for(
size_t k=i+1UL; k<m_; ++k ) {
1283 const size_t nonzeros( end_[k] - begin_[k] );
1284 const size_t total( begin_[k+1UL] - begin_[k] );
1285 newEnd [k] = newBegin[k] + nonzeros;
1286 newBegin[k+1UL] = newBegin[k] + total;
1289 newEnd[m_] = newEnd[capacity_] = newBegin[0UL]+newCapacity;
1291 Iterator tmp = std::copy( begin_[0UL], pos, newBegin[0UL] );
1292 tmp->value_ = value;
1294 std::copy( pos, end_[m_-1UL], tmp+1UL );
1298 delete [] newBegin[0UL];
1316 template<
typename Type
1323 const Iterator pos( find( i, j ) );
1324 if( pos != end_[i] )
1325 end_[i] = std::copy( pos+1, end_[i], pos );
1339 template<
typename Type
1345 BLAZE_USER_ASSERT( pos >= begin_[i] && pos <= end_[i],
"Invalid compressed matrix iterator" );
1347 if( pos != end_[i] )
1348 end_[i] = std::copy( pos+1, end_[i], pos );
1369 template<
typename Type
1374 return const_cast<Iterator>(
const_cast<const This&
>( *this ).
find( i, j ) );
1393 template<
typename Type
1398 const Iterator pos( std::lower_bound( begin_[i], end_[i], j, FindIndex() ) );
1399 if( pos != end_[i] && pos->index_ == j )
1401 else return end_[i];
1419 template<
typename Type
1423 if( m == m_ && n == n_ )
return;
1430 newBegin[0UL] = begin_[0UL];
1433 for(
size_t i=0UL; i<m_; ++i ) {
1434 newEnd [i] = end_ [i];
1435 newBegin[i+1UL] = begin_[i+1UL];
1437 for(
size_t i=m_; i<m; ++i ) {
1438 newBegin[i+1UL] = newEnd[i] = begin_[m_];
1442 for(
size_t i=0UL; i<m; ++i ) {
1443 newBegin[i+1UL] = newEnd[i] = begin_[0UL];
1447 newEnd[m] = end_[m_];
1460 for(
size_t i=0UL; i<m_; ++i )
1461 end_[i] = begin_[i];
1464 for(
size_t i=m_; i<m; ++i )
1465 begin_[i+1UL] = end_[i] = begin_[m_];
1470 for(
size_t i=0UL; i<m; ++i )
1471 end_[i] = std::lower_bound( begin_[i], end_[i], n, FindIndex() );
1474 for(
size_t i=0UL; i<m; ++i )
1475 end_[i] = begin_[i];
1497 template<
typename Type
1501 if( nonzeros > capacity() )
1502 reserveElements( nonzeros );
1521 template<
typename Type
1527 const size_t current( capacity(i) );
1529 if( current >= nonzeros )
return;
1531 const ptrdiff_t additional( nonzeros - current );
1533 if( end_[m_] - begin_[m_] < additional )
1535 const size_t newCapacity( begin_[m_] - begin_[0UL] + additional );
1539 Iterator* newEnd ( newBegin+m_+1UL );
1541 newBegin[0UL] =
new Element[newCapacity];
1542 newEnd [m_ ] = newBegin[0UL]+newCapacity;
1544 for(
size_t k=0UL; k<i; ++k ) {
1545 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
1546 newBegin[k+1UL] = newBegin[k] + capacity(k);
1548 newEnd [i ] = std::copy( begin_[i], end_[i], newBegin[i] );
1549 newBegin[i+1UL] = newBegin[i] + nonzeros;
1550 for(
size_t k=i+1UL; k<m_; ++k ) {
1551 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
1552 newBegin[k+1UL] = newBegin[k] + capacity(k);
1558 delete [] newBegin[0UL];
1564 begin_[m_] += additional;
1565 for(
size_t j=m_-1UL; j>i; --j ) {
1566 begin_[j] = std::copy_backward( begin_[j], end_[j], end_[j]+additional );
1567 end_ [j] += additional;
1579 template<
typename Type
1607 template<
typename Type
1611 if( m_ != n_ )
return false;
1613 for(
size_t i=0UL; i<
rows(); ++i ) {
1614 for(
ConstIterator element=begin_[i]; element!=end_[i]; ++element )
1615 if( element->index_ != i && !
isDefault( element->value_ ) )
1629 template<
typename Type
1633 if( m_ != n_ )
return false;
1635 for(
size_t i=0UL; i<
rows(); ++i ) {
1636 for(
ConstIterator element=begin_[i]; element!=end_[i]; ++element )
1638 const size_t index( element->index_ );
1643 const Iterator pos( std::lower_bound( begin_[index], end_[index], i, FindIndex() ) );
1644 if( pos == end_[index] || pos->index_ != i || !
equal( pos->value_, element->value_ ) )
1660 template<
typename Type
1662 template<
typename Other >
1665 for(
size_t i=0UL; i<m_; ++i )
1666 for(
Iterator element=begin_[i]; element!=end_[i]; ++element )
1667 element->value_ *= scalar;
1680 template<
typename Type
1682 template<
typename Other >
1687 for(
size_t i=0UL; i<size; ++i ) {
1688 Iterator pos = std::lower_bound( begin_[i], end_[i], i, FindIndex() );
1689 if( pos != end_[i] && pos->index_ == i )
1690 pos->value_ *= scalar;
1705 template<
typename Type
1726 template<
typename Type
1730 size_t nonzeros( 2UL*capacity()+1UL );
1747 template<
typename Type
1752 Iterator* newEnd = newBegin+m_+1UL;
1754 newBegin[0UL] =
new Element[nonzeros];
1756 for(
size_t k=0UL; k<m_; ++k ) {
1758 newEnd [k] = std::copy( begin_[k], end_[k], newBegin[k] );
1759 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
1762 newEnd[m_] = newBegin[0UL]+nonzeros;
1765 delete [] newBegin[0UL];
1820 template<
typename Type
1827 BLAZE_USER_ASSERT( begin_[i] == end_[i] || j > ( end_[i]-1UL )->index_,
"Index is not strictly increasing" );
1829 end_[i]->value_ = value;
1831 if( !check || !
isDefault( end_[i]->value_ ) ) {
1832 end_[i]->index_ = j;
1852 template<
typename Type
1858 begin_[i+1UL] = end_[i];
1860 end_[i+1UL] = end_[i];
1883 template<
typename Type
1885 template<
typename Other >
1888 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1903 template<
typename Type
1905 template<
typename Other >
1908 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1924 template<
typename Type
1926 template<
typename MT
1930 size_t nonzeros( 0UL );
1932 for(
size_t i=1UL; i<=m_; ++i )
1933 begin_[i] = end_[i] = end_[m_];
1935 for(
size_t i=0UL; i<m_; ++i )
1937 begin_[i] = end_[i] = begin_[0UL]+nonzeros;
1939 for(
size_t j=0UL; j<n_; ++j )
1941 if( nonzeros == capacity() ) {
1942 reserveElements( extendCapacity() );
1943 for(
size_t k=i+1UL; k<=m_; ++k )
1944 begin_[k] = end_[k] = end_[m_];
1947 end_[i]->value_ = (~rhs)(i,j);
1950 end_[i]->index_ = j;
1957 begin_[m_] = begin_[0UL]+nonzeros;
1973 template<
typename Type
1975 template<
typename MT >
1978 for(
size_t i=0UL; i<(~rhs).
rows(); ++i ) {
1979 begin_[i+1UL] = end_[i] = std::copy( (~rhs).begin(i), (~rhs).end(i), begin_[i] );
1996 template<
typename Type
1998 template<
typename MT >
2001 typedef typename MT::ConstIterator RhsIterator;
2004 std::vector<size_t> rowLengths( m_, 0UL );
2005 for(
size_t j=0UL; j<n_; ++j ) {
2006 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2007 ++rowLengths[element->index()];
2011 for(
size_t i=0UL; i<m_; ++i ) {
2012 begin_[i+1UL] = end_[i+1UL] = begin_[i] + rowLengths[i];
2016 for(
size_t j=0UL; j<n_; ++j ) {
2017 for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2018 append( element->index(), j, element->value() );
2035 template<
typename Type
2037 template<
typename MT
2061 template<
typename Type
2063 template<
typename MT
2087 template<
typename Type
2089 template<
typename MT
2113 template<
typename Type
2115 template<
typename MT
2148 template<
typename Type >
2162 using ElementBase::operator=;
2172 struct FindIndex :
public std::binary_function<Element,size_t,bool>
2174 inline bool operator()(
const Element& element,
size_t index )
const {
2175 return element.index() < index;
2177 inline bool operator()(
size_t index,
const Element& element )
const {
2178 return index < element.index();
2180 inline bool operator()(
const Element& element1,
const Element& element2 )
const {
2181 return element1.index() < element2.index();
2189 typedef CompressedMatrix<Type,true>
This;
2196 typedef MatrixAccessProxy<This>
Reference;
2208 explicit CompressedMatrix(
size_t m,
size_t n,
const std::vector<size_t>& nonzeros );
2210 template<
typename MT,
bool SO >
inline CompressedMatrix(
const DenseMatrix<MT,SO>& dm );
2211 template<
typename MT,
bool SO >
inline CompressedMatrix(
const SparseMatrix<MT,SO>& sm );
2242 template<
typename MT,
bool SO >
inline CompressedMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2243 template<
typename MT,
bool SO >
inline CompressedMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2244 template<
typename MT,
bool SO >
inline CompressedMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2246 template<
typename Other >
2248 operator*=( Other rhs );
2250 template<
typename Other >
2252 operator/=( Other rhs );
2259 inline size_t rows()
const;
2260 inline size_t columns()
const;
2262 inline size_t capacity(
size_t j )
const;
2264 inline size_t nonZeros(
size_t j )
const;
2265 inline void reset();
2266 inline void reset(
size_t j );
2267 inline void clear();
2269 inline void erase (
size_t i,
size_t j );
2273 void resize (
size_t m,
size_t n,
bool preserve=
true );
2274 inline void reserve(
size_t nonzeros );
2275 void reserve(
size_t j,
size_t nonzeros );
2280 template<
typename Other >
inline CompressedMatrix& scaleDiagonal( Other scalar );
2288 inline void append (
size_t i,
size_t j,
const Type& value,
bool check=
false );
2296 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2297 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2298 template<
typename MT,
bool SO >
inline void assign (
const DenseMatrix<MT,SO>& rhs );
2299 template<
typename MT >
inline void assign (
const SparseMatrix<MT,true>& rhs );
2300 template<
typename MT >
inline void assign (
const SparseMatrix<MT,false>& rhs );
2301 template<
typename MT,
bool SO >
inline void addAssign(
const DenseMatrix<MT,SO>& rhs );
2302 template<
typename MT,
bool SO >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
2303 template<
typename MT,
bool SO >
inline void subAssign(
const DenseMatrix<MT,SO>& rhs );
2304 template<
typename MT,
bool SO >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
2326 static const Type
zero_;
2352 template<
typename Type >
2353 const Type CompressedMatrix<Type,true>::zero_ = Type();
2368 template<
typename Type >
2373 , begin_( new Iterator[2UL] )
2374 , end_ ( begin_+1UL )
2391 template<
typename Type >
2396 , begin_( new Iterator[2UL*n+2UL] )
2397 , end_ ( begin_+(n+1UL) )
2399 for(
size_t j=0UL; j<2UL*
n_+2UL; ++j )
2416 template<
typename Type >
2421 , begin_( new Iterator[2UL*n+2UL] )
2422 , end_ ( begin_+(n+1UL) )
2424 begin_[0UL] =
new Element[nonzeros];
2425 for(
size_t j=1UL; j<(2UL*
n_+1UL); ++j )
2443 template<
typename Type >
2448 , begin_( new Iterator[2UL*n_+2UL] )
2449 , end_ ( begin_+(n_+1UL) )
2451 BLAZE_USER_ASSERT( nonzeros.size() == n,
"Size of capacity vector and number of columns don't match" );
2453 size_t newCapacity( 0UL );
2454 for( std::vector<size_t>::const_iterator it=nonzeros.begin(); it!=nonzeros.end(); ++it )
2457 begin_[0UL] =
end_[0UL] =
new Element[newCapacity];
2458 for(
size_t j=0UL; j<
n_; ++j ) {
2472 template<
typename Type >
2476 , capacity_( sm.n_ )
2477 , begin_ ( new Iterator[2UL*n_+2UL] )
2478 , end_ ( begin_+(n_+1UL) )
2480 const size_t nonzeros( sm.nonZeros() );
2482 begin_[0UL] =
new Element[nonzeros];
2483 for(
size_t j=0UL; j<
n_; ++j )
2484 begin_[j+1UL] =
end_[j] = std::copy( sm.begin(j), sm.end(j), begin_[j] );
2485 end_[
n_] = begin_[0UL]+nonzeros;
2497 template<
typename Type >
2498 template<
typename MT
2501 : m_ ( (~dm).
rows() )
2504 , begin_ ( new Iterator[2UL*n_+2UL] )
2505 , end_ ( begin_+(n_+1UL) )
2509 for(
size_t j=0UL; j<2UL*n_+2UL; ++j )
2524 template<
typename Type >
2525 template<
typename MT
2528 : m_ ( (~sm).
rows() )
2531 , begin_ ( new Iterator[2UL*n_+2UL] )
2532 , end_ ( begin_+(n_+1UL) )
2536 const size_t nonzeros( (~sm).
nonZeros() );
2538 begin_[0UL] =
new Element[nonzeros];
2539 for(
size_t j=0UL; j<
n_; ++j )
2540 begin_[j+1UL] =
end_[j] = begin_[0UL];
2541 end_[
n_] = begin_[0UL]+nonzeros;
2561 template<
typename Type >
2564 delete [] begin_[0UL];
2587 template<
typename Type >
2588 inline typename CompressedMatrix<Type,true>::Reference
2594 return Reference( *
this, i, j );
2608 template<
typename Type >
2609 inline typename CompressedMatrix<Type,true>::ConstReference
2615 const ConstIterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
2617 if( pos == end_[j] || pos->index_ != i )
2633 template<
typename Type >
2634 inline typename CompressedMatrix<Type,true>::Iterator
2651 template<
typename Type >
2652 inline typename CompressedMatrix<Type,true>::ConstIterator
2669 template<
typename Type >
2670 inline typename CompressedMatrix<Type,true>::ConstIterator
2687 template<
typename Type >
2688 inline typename CompressedMatrix<Type,true>::Iterator
2705 template<
typename Type >
2706 inline typename CompressedMatrix<Type,true>::ConstIterator
2723 template<
typename Type >
2724 inline typename CompressedMatrix<Type,true>::ConstIterator
2752 template<
typename Type >
2753 inline CompressedMatrix<Type,true>&
2756 if( &rhs ==
this )
return *
this;
2758 const size_t nonzeros( rhs.nonZeros() );
2760 if( rhs.n_ > capacity_ || nonzeros > capacity() )
2762 Iterator* newBegin(
new Iterator[2UL*rhs.n_+2UL] );
2763 Iterator* newEnd ( newBegin+(rhs.n_+1UL) );
2765 newBegin[0UL] =
new Element[nonzeros];
2766 for(
size_t j=0UL; j<rhs.n_; ++j ) {
2767 newBegin[j+1UL] = newEnd[j] = std::copy( rhs.begin_[j], rhs.end_[j], newBegin[j] );
2769 newEnd[rhs.n_] = newBegin[0UL]+nonzeros;
2773 delete [] newBegin[0UL];
2778 for(
size_t j=0UL; j<rhs.n_; ++j ) {
2779 begin_[j+1UL] = end_[j] = std::copy( rhs.begin_[j], rhs.end_[j], begin_[j] );
2802 template<
typename Type >
2803 template<
typename MT
2805 inline CompressedMatrix<Type,true>&
2810 if( (~rhs).canAlias(
this ) ) {
2811 CompressedMatrix tmp( rhs );
2835 template<
typename Type >
2836 template<
typename MT
2838 inline CompressedMatrix<Type,true>&
2843 if( (~rhs).canAlias(
this ) ||
2844 (~rhs).
columns() > capacity_ ||
2845 (~rhs).nonZeros() > capacity() ) {
2846 CompressedMatrix tmp( rhs );
2872 template<
typename Type >
2873 template<
typename MT
2875 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
2879 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
2880 throw std::invalid_argument(
"Matrix sizes do not match" );
2900 template<
typename Type >
2901 template<
typename MT
2903 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
2907 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
2908 throw std::invalid_argument(
"Matrix sizes do not match" );
2928 template<
typename Type >
2929 template<
typename MT
2931 inline CompressedMatrix<Type,true>&
2932 CompressedMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
2934 if( (~rhs).
rows() != n_ )
2935 throw std::invalid_argument(
"Matrix sizes do not match" );
2937 CompressedMatrix tmp( *
this * (~rhs) );
2954 template<
typename Type >
2955 template<
typename Other >
2956 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
2957 CompressedMatrix<Type,true>::operator*=( Other rhs )
2959 for(
size_t j=0UL; j<n_; ++j ) {
2960 const Iterator endElem( end(j) );
2961 for( Iterator elem=begin(j); elem<endElem; ++elem )
2962 elem->value_ *= rhs;
2979 template<
typename Type >
2980 template<
typename Other >
2981 inline typename EnableIf< IsNumeric<Other>, CompressedMatrix<Type,true> >::Type&
2982 CompressedMatrix<Type,true>::operator/=( Other rhs )
2986 typedef typename DivTrait<Type,Other>::Type DT;
2987 typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2991 if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2992 const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2993 for(
size_t j=0UL; j<n_; ++j ) {
2994 const Iterator endElem( end(j) );
2995 for( Iterator elem=begin(j); elem<endElem; ++elem )
2996 elem->value_ *= tmp;
3000 for(
size_t j=0UL; j<n_; ++j ) {
3001 const Iterator endElem( end(j) );
3002 for( Iterator elem=begin(j); elem<endElem; ++elem )
3003 elem->value_ /= rhs;
3027 template<
typename Type >
3042 template<
typename Type >
3057 template<
typename Type >
3060 return end_[n_] - begin_[0UL];
3073 template<
typename Type >
3077 return begin_[j+1UL] - begin_[j];
3089 template<
typename Type >
3092 size_t nonzeros( 0UL );
3094 for(
size_t j=0UL; j<n_; ++j )
3095 nonzeros += nonZeros( j );
3110 template<
typename Type >
3114 return end_[j] - begin_[j];
3126 template<
typename Type >
3129 for(
size_t j=0UL; j<n_; ++j )
3130 end_[j] = begin_[j];
3146 template<
typename Type >
3150 end_[j] = begin_[j];
3164 template<
typename Type >
3167 end_[0UL] = end_[n_];
3189 template<
typename Type >
3190 typename CompressedMatrix<Type,true>::Iterator
3196 const Iterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
3198 if( pos != end_[j] && pos->index_ == i )
3199 throw std::invalid_argument(
"Bad access index" );
3201 if( begin_[j+1UL] - end_[j] != 0 ) {
3202 std::copy_backward( pos, end_[j], end_[j]+1 );
3203 pos->value_ = value;
3209 else if( end_[n_] - begin_[n_] != 0 ) {
3210 std::copy_backward( pos, end_[n_-1UL], end_[n_-1]+1 );
3212 pos->value_ = value;
3215 for(
size_t k=j+1UL; k<n_+1UL; ++k ) {
3223 size_t newCapacity( extendCapacity() );
3225 Iterator* newBegin =
new Iterator[2UL*capacity_+2UL];
3226 Iterator* newEnd = newBegin+capacity_+1UL;
3228 newBegin[0UL] =
new Element[newCapacity];
3230 for(
size_t k=0UL; k<j; ++k ) {
3231 const size_t nonzeros( end_[k] - begin_[k] );
3232 const size_t total( begin_[k+1UL] - begin_[k] );
3233 newEnd [k] = newBegin[k] + nonzeros;
3234 newBegin[k+1UL] = newBegin[k] + total;
3236 newEnd [j] = newBegin[j] + ( end_[j] - begin_[j] ) + 1;
3237 newBegin[j+1UL] = newBegin[j] + ( begin_[j+1UL] - begin_[j] ) + 1;
3238 for(
size_t k=j+1UL; k<n_; ++k ) {
3239 const size_t nonzeros( end_[k] - begin_[k] );
3240 const size_t total( begin_[k+1UL] - begin_[k] );
3241 newEnd [k] = newBegin[k] + nonzeros;
3242 newBegin[k+1UL] = newBegin[k] + total;
3245 newEnd[n_] = newEnd[capacity_] = newBegin[0UL]+newCapacity;
3247 Iterator tmp = std::copy( begin_[0UL], pos, newBegin[0UL] );
3248 tmp->value_ = value;
3250 std::copy( pos, end_[n_-1UL], tmp+1UL );
3254 delete [] newBegin[0UL];
3273 template<
typename Type >
3279 const Iterator pos( find( i, j ) );
3280 if( pos != end_[j] )
3281 end_[j] = std::copy( pos+1, end_[j], pos );
3295 template<
typename Type >
3296 inline typename CompressedMatrix<Type,true>::Iterator
3300 BLAZE_USER_ASSERT( pos >= begin_[j] && pos <= end_[j],
"Invalid compressed matrix iterator" );
3302 if( pos != end_[j] )
3303 end_[j] = std::copy( pos+1, end_[j], pos );
3325 template<
typename Type >
3326 inline typename CompressedMatrix<Type,true>::Iterator
3329 return const_cast<Iterator
>(
const_cast<const This&
>( *this ).find( i, j ) );
3350 template<
typename Type >
3351 inline typename CompressedMatrix<Type,true>::ConstIterator
3354 const Iterator pos( std::lower_bound( begin_[j], end_[j], i, FindIndex() ) );
3355 if( pos != end_[j] && pos->index_ == i )
3357 else return end_[j];
3377 template<
typename Type >
3380 if( m == m_ && n == n_ )
return;
3384 Iterator* newBegin(
new Iterator[2UL*n+2UL] );
3385 Iterator* newEnd ( newBegin+n+1 );
3387 newBegin[0UL] = begin_[0UL];
3390 for(
size_t j=0UL; j<n_; ++j ) {
3391 newEnd [j] = end_ [j];
3392 newBegin[j+1UL] = begin_[j+1UL];
3394 for(
size_t j=n_; j<n; ++j ) {
3395 newBegin[j+1UL] = newEnd[j] = begin_[n_];
3399 for(
size_t j=0UL; j<n; ++j ) {
3400 newBegin[j+1UL] = newEnd[j] = begin_[0UL];
3404 newEnd[n] = end_[n_];
3417 for(
size_t j=0UL; j<n_; ++j )
3418 end_[j] = begin_[j];
3421 for(
size_t j=n_; j<n; ++j )
3422 begin_[j+1UL] = end_[j] = begin_[n_];
3427 for(
size_t j=0UL; j<n; ++j )
3428 end_[j] = std::lower_bound( begin_[j], end_[j], m, FindIndex() );
3431 for(
size_t j=0UL; j<n; ++j )
3432 end_[j] = begin_[j];
3456 template<
typename Type >
3459 if( nonzeros > capacity() )
3460 reserveElements( nonzeros );
3478 template<
typename Type >
3483 const size_t current( capacity(j) );
3485 if( current >= nonzeros )
return;
3487 const ptrdiff_t additional( nonzeros - current );
3489 if( end_[n_] - begin_[n_] < additional )
3491 const size_t newCapacity( begin_[n_] - begin_[0UL] + additional );
3494 Iterator* newBegin(
new Iterator[2UL*n_+2UL] );
3495 Iterator* newEnd ( newBegin+n_+1UL );
3497 newBegin[0UL] =
new Element[newCapacity];
3498 newEnd [n_ ] = newBegin[0UL]+newCapacity;
3500 for(
size_t k=0UL; k<j; ++k ) {
3501 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
3502 newBegin[k+1UL] = newBegin[k] + capacity(k);
3504 newEnd [j ] = std::copy( begin_[j], end_[j], newBegin[j] );
3505 newBegin[j+1UL] = newBegin[j] + nonzeros;
3506 for(
size_t k=j+1UL; k<n_; ++k ) {
3507 newEnd [k ] = std::copy( begin_[k], end_[k], newBegin[k] );
3508 newBegin[k+1UL] = newBegin[k] + capacity(k);
3514 delete [] newBegin[0UL];
3520 begin_[n_] += additional;
3521 for(
size_t k=n_-1UL; k>j; --k ) {
3522 begin_[k] = std::copy_backward( begin_[k], end_[k], end_[k]+additional );
3523 end_ [k] += additional;
3537 template<
typename Type >
3540 CompressedMatrix tmp(
trans( *
this ) );
3566 template<
typename Type >
3569 if( m_ != n_ )
return false;
3571 for(
size_t j=0UL; j<
columns(); ++j ) {
3572 for( ConstIterator element=begin_[j]; element!=end_[j]; ++element )
3573 if( element->index_ != j && !
isDefault( element->value_ ) )
3589 template<
typename Type >
3592 if( m_ != n_ )
return false;
3594 for(
size_t j=0UL; j<
rows(); ++j ) {
3595 for( ConstIterator element=begin_[j]; element!=end_[j]; ++element )
3597 const size_t index( element->index_ );
3602 const Iterator pos( std::lower_bound( begin_[index], end_[index], j, FindIndex() ) );
3603 if( pos == end_[index] || pos->index_ != j || !
equal( pos->value_, element->value_ ) )
3621 template<
typename Type >
3622 template<
typename Other >
3623 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scale( Other scalar )
3625 for(
size_t j=0UL; j<n_; ++j )
3626 for( Iterator element=begin_[j]; element!=end_[j]; ++element )
3627 element->value_ *= scalar;
3642 template<
typename Type >
3643 template<
typename Other >
3644 inline CompressedMatrix<Type,true>& CompressedMatrix<Type,true>::scaleDiagonal( Other scalar )
3648 for(
size_t j=0UL; j<size; ++j ) {
3649 Iterator pos = std::lower_bound( begin_[j], end_[j], j, FindIndex() );
3650 if( pos != end_[j] && pos->index_ == j )
3651 pos->value_ *= scalar;
3668 template<
typename Type >
3690 template<
typename Type >
3693 size_t nonzeros( 2UL*capacity()+1UL );
3712 template<
typename Type >
3715 Iterator* newBegin =
new Iterator[2UL*n_+2UL];
3716 Iterator* newEnd = newBegin+n_+1UL;
3718 newBegin[0UL] =
new Element[nonzeros];
3720 for(
size_t k=0UL; k<n_; ++k ) {
3722 newEnd [k] = std::copy( begin_[k], end_[k], newBegin[k] );
3723 newBegin[k+1UL] = newBegin[k] + ( begin_[k+1UL] - begin_[k] );
3726 newEnd[n_] = newBegin[0UL]+nonzeros;
3729 delete [] newBegin[0UL];
3786 template<
typename Type >
3792 BLAZE_USER_ASSERT( begin_[j] == end_[j] || i > ( end_[j]-1UL )->index_,
"Index is not strictly increasing" );
3794 end_[j]->value_ = value;
3796 if( !check || !
isDefault( end_[j]->value_ ) ) {
3797 end_[j]->index_ = i;
3819 template<
typename Type >
3824 begin_[j+1UL] = end_[j];
3826 end_[j+1UL] = end_[j];
3851 template<
typename Type >
3852 template<
typename Other >
3855 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3872 template<
typename Type >
3873 template<
typename Other >
3876 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3894 template<
typename Type >
3895 template<
typename MT
3899 size_t nonzeros( 0UL );
3901 for(
size_t j=1UL; j<=n_; ++j )
3902 begin_[j] = end_[j] = end_[n_];
3904 for(
size_t j=0UL; j<n_; ++j )
3906 begin_[j] = end_[j] = begin_[0UL]+nonzeros;
3908 for(
size_t i=0UL; i<m_; ++i )
3910 if( nonzeros == capacity() ) {
3911 reserveElements( extendCapacity() );
3912 for(
size_t k=j+1UL; k<=n_; ++k )
3913 begin_[k] = end_[k] = end_[n_];
3916 end_[j]->value_ = (~rhs)(i,j);
3919 end_[j]->index_ = i;
3926 begin_[n_] = begin_[0UL]+nonzeros;
3944 template<
typename Type >
3945 template<
typename MT >
3948 for(
size_t j=0UL; j<(~rhs).
columns(); ++j ) {
3949 begin_[j+1UL] = end_[j] = std::copy( (~rhs).begin(j), (~rhs).end(j), begin_[j] );
3968 template<
typename Type >
3969 template<
typename MT >
3972 typedef typename MT::ConstIterator RhsIterator;
3975 std::vector<size_t> columnLengths( n_, 0UL );
3976 for(
size_t i=0UL; i<m_; ++i ) {
3977 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3978 ++columnLengths[element->index()];
3982 for(
size_t j=0UL; j<n_; ++j ) {
3983 begin_[j+1UL] = end_[j+1UL] = begin_[j] + columnLengths[j];
3987 for(
size_t i=0UL; i<m_; ++i ) {
3988 for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3989 append( i, element->index(), element->value() );
4008 template<
typename Type >
4009 template<
typename MT
4016 CompressedMatrix tmp( *
this + (~rhs) );
4035 template<
typename Type >
4036 template<
typename MT
4043 CompressedMatrix tmp( *
this + (~rhs) );
4062 template<
typename Type >
4063 template<
typename MT
4070 CompressedMatrix tmp( *
this - (~rhs) );
4089 template<
typename Type >
4090 template<
typename MT
4097 CompressedMatrix tmp( *
this - (~rhs) );
4119 template<
typename Type,
bool SO >
4120 inline bool isnan(
const CompressedMatrix<Type,SO>& m );
4122 template<
typename Type,
bool SO >
4123 inline void reset( CompressedMatrix<Type,SO>& m );
4125 template<
typename Type,
bool SO >
4126 inline void clear( CompressedMatrix<Type,SO>& m );
4128 template<
typename Type,
bool SO >
4129 inline bool isDefault(
const CompressedMatrix<Type,SO>& m );
4131 template<
typename Type,
bool SO >
4132 inline const CompressedMatrix<Type,SO>
inv(
const CompressedMatrix<Type,SO>& m );
4134 template<
typename Type,
bool SO >
4135 inline void swap( CompressedMatrix<Type,SO>& a, CompressedMatrix<Type,SO>& b ) ;
4147 template<
typename Type
4153 for(
size_t i=0UL; i<m.
rows(); ++i ) {
4154 for( ConstIterator element=m.
begin(i); element!=m.
end(i); ++element )
4155 if(
isnan( *element ) )
return true;
4169 template<
typename Type
4185 template<
typename Type
4212 template<
typename Type
4219 for(
size_t i=0UL; i<m.
rows(); ++i ) {
4220 for( ConstIterator element=m.
begin(i); element!=m.
end(i); ++element )
4221 if( !
isDefault( element->value() ) )
return false;
4225 for(
size_t j=0UL; j<m.
columns(); ++j ) {
4226 for( ConstIterator element=m.
begin(j); element!=m.
end(j); ++element )
4227 if( !
isDefault( element->value() ) )
return false;
4245 template<
typename Type
4264 template<
typename Type
4283 template<
typename T,
bool SO >
4284 struct IsResizable< CompressedMatrix<T,SO> > :
public TrueType
4290 template<
typename T,
bool SO >
4291 struct IsResizable< const CompressedMatrix<T,SO> > :
public TrueType
4297 template<
typename T,
bool SO >
4298 struct IsResizable< volatile CompressedMatrix<T,SO> > :
public TrueType
4304 template<
typename T,
bool SO >
4305 struct IsResizable< const volatile CompressedMatrix<T,SO> > :
public TrueType
4324 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4325 struct AddTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4327 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4330 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4331 struct AddTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4333 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4336 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4337 struct AddTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
4339 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4342 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4343 struct AddTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4345 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4348 template<
typename T1,
bool SO,
typename T2 >
4349 struct AddTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4351 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4354 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4355 struct AddTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4357 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4360 template<
typename T1,
bool SO,
typename T2 >
4361 struct AddTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4363 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4366 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4367 struct AddTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4369 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4372 template<
typename T1,
bool SO,
typename T2 >
4373 struct AddTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4375 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4378 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4379 struct AddTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4381 typedef CompressedMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4397 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4398 struct SubTrait< CompressedMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4400 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4403 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4404 struct SubTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4406 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4409 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4410 struct SubTrait< StaticMatrix<T1,M,N,SO>, CompressedMatrix<T2,SO> >
4412 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4415 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4416 struct SubTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4418 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4421 template<
typename T1,
bool SO,
typename T2 >
4422 struct SubTrait< CompressedMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4424 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4427 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4428 struct SubTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4430 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4433 template<
typename T1,
bool SO,
typename T2 >
4434 struct SubTrait< DynamicMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4436 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4439 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4440 struct SubTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4442 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4445 template<
typename T1,
bool SO,
typename T2 >
4446 struct SubTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4448 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4451 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4452 struct SubTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4454 typedef CompressedMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4470 template<
typename T1,
bool SO,
typename T2 >
4471 struct MultTrait< CompressedMatrix<T1,SO>, T2 >
4473 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4477 template<
typename T1,
typename T2,
bool SO >
4478 struct MultTrait< T1, CompressedMatrix<T2,SO> >
4480 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4484 template<
typename T1,
bool SO,
typename T2,
size_t N >
4485 struct MultTrait< CompressedMatrix<T1,SO>, StaticVector<T2,N,false> >
4487 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4490 template<
typename T1,
size_t N,
typename T2,
bool SO >
4491 struct MultTrait< StaticVector<T1,N,true>, CompressedMatrix<T2,SO> >
4493 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4496 template<
typename T1,
bool SO,
typename T2 >
4497 struct MultTrait< CompressedMatrix<T1,SO>, DynamicVector<T2,false> >
4499 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4502 template<
typename T1,
typename T2,
bool SO >
4503 struct MultTrait< DynamicVector<T1,true>, CompressedMatrix<T2,SO> >
4505 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4508 template<
typename T1,
bool SO,
typename T2 >
4509 struct MultTrait< CompressedMatrix<T1,SO>, CompressedVector<T2,false> >
4511 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
false > Type;
4514 template<
typename T1,
typename T2,
bool SO >
4515 struct MultTrait< CompressedVector<T1,true>, CompressedMatrix<T2,SO> >
4517 typedef CompressedVector< typename MultTrait<T1,T2>::Type,
true > Type;
4520 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4521 struct MultTrait< CompressedMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4523 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4526 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4527 struct MultTrait< StaticMatrix<T1,M,N,SO1>, CompressedMatrix<T2,SO2> >
4529 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4532 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4533 struct MultTrait< CompressedMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4535 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4538 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4539 struct MultTrait< DynamicMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4541 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4544 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4545 struct MultTrait< CompressedMatrix<T1,SO1>, CompressedMatrix<T2,SO2> >
4547 typedef CompressedMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4563 template<
typename T1,
bool SO,
typename T2 >
4564 struct DivTrait< CompressedMatrix<T1,SO>, T2 >
4566 typedef CompressedMatrix< typename DivTrait<T1,T2>::Type, SO > Type;
4583 template<
typename T1,
bool SO,
typename T2 >
4584 struct MathTrait< CompressedMatrix<T1,SO>, CompressedMatrix<T2,SO> >
4586 typedef CompressedMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
4587 typedef CompressedMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
4603 template<
typename T1,
bool SO >
4604 struct RowTrait< CompressedMatrix<T1,SO> >
4606 typedef CompressedVector<T1,true> Type;
4622 template<
typename T1,
bool SO >
4623 struct ColumnTrait< CompressedMatrix<T1,SO> >
4625 typedef CompressedVector<T1,false> Type;