All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseColumn.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
36 #define _BLAZE_MATH_VIEWS_SPARSECOLUMN_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
55 #include <blaze/math/Functions.h>
57 #include <blaze/math/shims/Reset.h>
66 #include <blaze/util/Assert.h>
67 #include <blaze/util/DisableIf.h>
68 #include <blaze/util/EnableIf.h>
70 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/mpl/Or.h>
72 #include <blaze/util/SelectType.h>
73 #include <blaze/util/Types.h>
77 #include <blaze/util/Unused.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS DEFINITION
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
338 template< typename MT // Type of the sparse matrix
339  , bool SO = IsColumnMajorMatrix<MT>::value > // Storage order
340 class SparseColumn : public SparseVector< SparseColumn<MT,SO>, false >
341  , private View
342 {
343  private:
344  //**Type definitions****************************************************************************
346  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
347  //**********************************************************************************************
348 
349  //**********************************************************************************************
351 
357  enum { useConst = IsConst<MT>::value };
358  //**********************************************************************************************
359 
360  public:
361  //**Type definitions****************************************************************************
365  typedef typename MT::ElementType ElementType;
366  typedef typename MT::ReturnType ReturnType;
367  typedef const SparseColumn& CompositeType;
368 
371 
374 
377 
380  //**********************************************************************************************
381 
382  //**Constructors********************************************************************************
385  explicit inline SparseColumn( MT& matrix, size_t index );
386  // No explicitly declared copy constructor.
388  //**********************************************************************************************
389 
390  //**Destructor**********************************************************************************
391  // No explicitly declared destructor.
392  //**********************************************************************************************
393 
394  //**Data access functions***********************************************************************
397  inline Reference operator[]( size_t index );
398  inline ConstReference operator[]( size_t index ) const;
399  inline Iterator begin ();
400  inline ConstIterator begin () const;
401  inline ConstIterator cbegin() const;
402  inline Iterator end ();
403  inline ConstIterator end () const;
404  inline ConstIterator cend () const;
406  //**********************************************************************************************
407 
408  //**Assignment operators************************************************************************
411  inline SparseColumn& operator= ( const SparseColumn& rhs );
412  template< typename VT > inline SparseColumn& operator= ( const DenseVector <VT,false>& rhs );
413  template< typename VT > inline SparseColumn& operator= ( const SparseVector<VT,false>& rhs );
414  template< typename VT > inline SparseColumn& operator+=( const Vector<VT,false>& rhs );
415  template< typename VT > inline SparseColumn& operator-=( const Vector<VT,false>& rhs );
416  template< typename VT > inline SparseColumn& operator*=( const Vector<VT,false>& rhs );
417 
418  template< typename Other >
419  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
420  operator*=( Other rhs );
421 
422  template< typename Other >
423  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
424  operator/=( Other rhs );
426  //**********************************************************************************************
427 
428  //**Utility functions***************************************************************************
431  inline size_t size() const;
432  inline size_t capacity() const;
433  inline size_t nonZeros() const;
434  inline void reset();
435  inline Iterator insert ( size_t index, const ElementType& value );
436  inline void erase ( size_t index );
437  inline Iterator erase ( Iterator pos );
438  inline Iterator erase ( Iterator first, Iterator last );
439  inline void reserve( size_t n );
440  template< typename Other > inline SparseColumn& scale ( Other scalar );
442  //**********************************************************************************************
443 
444  //**Lookup functions****************************************************************************
447  inline Iterator find ( size_t index );
448  inline ConstIterator find ( size_t index ) const;
449  inline Iterator lowerBound( size_t index );
450  inline ConstIterator lowerBound( size_t index ) const;
451  inline Iterator upperBound( size_t index );
452  inline ConstIterator upperBound( size_t index ) const;
454  //**********************************************************************************************
455 
456  //**Low-level utility functions*****************************************************************
459  inline void append( size_t index, const ElementType& value, bool check=false );
461  //**********************************************************************************************
462 
463  //**Expression template evaluation functions****************************************************
466  template< typename Other > inline bool canAlias ( const Other* alias ) const;
467  template< typename Other > inline bool isAliased( const Other* alias ) const;
468  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
469  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
470  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
471  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
472  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
473  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
475  //**********************************************************************************************
476 
477  private:
478  //**Utility functions***************************************************************************
481  inline size_t extendCapacity() const;
483  //**********************************************************************************************
484 
485  //**Member variables****************************************************************************
489  const size_t col_;
490 
491  //**********************************************************************************************
492 
493  //**Compile time checks*************************************************************************
500  //**********************************************************************************************
501 };
502 //*************************************************************************************************
503 
504 
505 
506 
507 //=================================================================================================
508 //
509 // CONSTRUCTOR
510 //
511 //=================================================================================================
512 
513 //*************************************************************************************************
520 template< typename MT // Type of the sparse matrix
521  , bool SO > // Storage order
522 inline SparseColumn<MT,SO>::SparseColumn( MT& matrix, size_t index )
523  : matrix_( matrix ) // The sparse matrix containing the column
524  , col_ ( index ) // The index of the column in the matrix
525 {
526  if( matrix_.columns() <= index )
527  throw std::invalid_argument( "Invalid column access index" );
528 }
529 //*************************************************************************************************
530 
531 
532 
533 
534 //=================================================================================================
535 //
536 // DATA ACCESS FUNCTIONS
537 //
538 //=================================================================================================
539 
540 //*************************************************************************************************
546 template< typename MT // Type of the sparse matrix
547  , bool SO > // Storage order
549 {
550  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
551  return matrix_(index,col_);
552 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
562 template< typename MT // Type of the sparse matrix
563  , bool SO > // Storage order
565 {
566  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
567  return const_cast<const MT&>( matrix_ )(index,col_);
568 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
579 template< typename MT // Type of the sparse matrix
580  , bool SO > // Storage order
582 {
583  return matrix_.begin( col_ );
584 }
585 //*************************************************************************************************
586 
587 
588 //*************************************************************************************************
595 template< typename MT // Type of the sparse matrix
596  , bool SO > // Storage order
598 {
599  return matrix_.cbegin( col_ );
600 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
611 template< typename MT // Type of the sparse matrix
612  , bool SO > // Storage order
614 {
615  return matrix_.cbegin( col_ );
616 }
617 //*************************************************************************************************
618 
619 
620 //*************************************************************************************************
627 template< typename MT // Type of the sparse matrix
628  , bool SO > // Storage order
630 {
631  return matrix_.end( col_ );
632 }
633 //*************************************************************************************************
634 
635 
636 //*************************************************************************************************
643 template< typename MT // Type of the sparse matrix
644  , bool SO > // Storage order
646 {
647  return matrix_.cend( col_ );
648 }
649 //*************************************************************************************************
650 
651 
652 //*************************************************************************************************
659 template< typename MT // Type of the sparse matrix
660  , bool SO > // Storage order
662 {
663  return matrix_.cend( col_ );
664 }
665 //*************************************************************************************************
666 
667 
668 
669 
670 //=================================================================================================
671 //
672 // ASSIGNMENT OPERATORS
673 //
674 //=================================================================================================
675 
676 //*************************************************************************************************
686 template< typename MT // Type of the sparse matrix
687  , bool SO > // Storage order
689 {
690  using blaze::assign;
691 
695 
696  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
697  return *this;
698 
699  if( size() != rhs.size() )
700  throw std::invalid_argument( "Column sizes do not match" );
701 
702  if( rhs.canAlias( &matrix_ ) ) {
703  const ResultType tmp( rhs );
704  matrix_.reset ( col_ );
705  matrix_.reserve( col_, tmp.nonZeros() );
706  assign( *this, tmp );
707  }
708  else {
709  matrix_.reset ( col_ );
710  matrix_.reserve( col_, rhs.nonZeros() );
711  assign( *this, rhs );
712  }
713 
714  return *this;
715 }
716 //*************************************************************************************************
717 
718 
719 //*************************************************************************************************
729 template< typename MT // Type of the sparse matrix
730  , bool SO > // Storage order
731 template< typename VT > // Type of the right-hand side dense vector
733 {
734  using blaze::assign;
735 
739 
740  if( size() != (~rhs).size() )
741  throw std::invalid_argument( "Vector sizes do not match" );
742 
743  if( (~rhs).canAlias( &matrix_ ) ) {
744  const typename VT::ResultType tmp( ~rhs );
745  matrix_.reset( col_ );
746  assign( *this, tmp );
747  }
748  else {
749  matrix_.reset( col_ );
750  assign( *this, ~rhs );
751  }
752 
753  return *this;
754 }
755 //*************************************************************************************************
756 
757 
758 //*************************************************************************************************
768 template< typename MT // Type of the sparse matrix
769  , bool SO > // Storage order
770 template< typename VT > // Type of the right-hand side sparse vector
772 {
773  using blaze::assign;
774 
775  if( size() != (~rhs).size() )
776  throw std::invalid_argument( "Vector sizes do not match" );
777 
781 
782  if( (~rhs).canAlias( &matrix_ ) ) {
783  const typename VT::ResultType tmp( ~rhs );
784  matrix_.reset ( col_ );
785  matrix_.reserve( col_, tmp.nonZeros() );
786  assign( *this, tmp );
787  }
788  else {
789  matrix_.reset ( col_ );
790  matrix_.reserve( col_, (~rhs).nonZeros() );
791  assign( *this, ~rhs );
792  }
793 
794  return *this;
795 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
809 template< typename MT // Type of the sparse matrix
810  , bool SO > // Storage order
811 template< typename VT > // Type of the right-hand side vector
813 {
814  using blaze::addAssign;
815 
816  if( size() != (~rhs).size() )
817  throw std::invalid_argument( "Vector sizes do not match" );
818 
819  addAssign( *this, ~rhs );
820 
821  return *this;
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
836 template< typename MT // Type of the sparse matrix
837  , bool SO > // Storage order
838 template< typename VT > // Type of the right-hand side vector
840 {
841  using blaze::subAssign;
842 
843  if( size() != (~rhs).size() )
844  throw std::invalid_argument( "Vector sizes do not match" );
845 
846  subAssign( *this, ~rhs );
847 
848  return *this;
849 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
864 template< typename MT // Type of the sparse matrix
865  , bool SO > // Storage order
866 template< typename VT > // Type of the right-hand side vector
868 {
869  if( size() != (~rhs).size() )
870  throw std::invalid_argument( "Vector sizes do not match" );
871 
872  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
873 
876 
877  const MultType tmp( *this * (~rhs) );
878  matrix_.reset( col_ );
879  assign( tmp );
880 
881  return *this;
882 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
897 template< typename MT // Type of the sparse matrix
898  , bool SO > // Storage order
899 template< typename Other > // Data type of the right-hand side scalar
900 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,SO> >::Type&
902 {
903  for( Iterator element=begin(); element!=end(); ++element )
904  element->value() *= rhs;
905  return *this;
906 }
907 //*************************************************************************************************
908 
909 
910 //*************************************************************************************************
922 template< typename MT // Type of the sparse matrix
923  , bool SO > // Storage order
924 template< typename Other > // Data type of the right-hand side scalar
925 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,SO> >::Type&
927 {
928  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
929 
930  typedef typename DivTrait<ElementType,Other>::Type DT;
931  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
932 
933  // Depending on the two involved data types, an integer division is applied or a
934  // floating point division is selected.
936  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
937  for( Iterator element=begin(); element!=end(); ++element )
938  element->value() *= tmp;
939  }
940  else {
941  for( Iterator element=begin(); element!=end(); ++element )
942  element->value() /= rhs;
943  }
944 
945  return *this;
946 }
947 //*************************************************************************************************
948 
949 
950 
951 
952 //=================================================================================================
953 //
954 // UTILITY FUNCTIONS
955 //
956 //=================================================================================================
957 
958 //*************************************************************************************************
963 template< typename MT // Type of the sparse matrix
964  , bool SO > // Storage order
965 inline size_t SparseColumn<MT,SO>::size() const
966 {
967  return matrix_.rows();
968 }
969 //*************************************************************************************************
970 
971 
972 //*************************************************************************************************
977 template< typename MT // Type of the sparse matrix
978  , bool SO > // Storage order
979 inline size_t SparseColumn<MT,SO>::capacity() const
980 {
981  return matrix_.capacity( col_ );
982 }
983 //*************************************************************************************************
984 
985 
986 //*************************************************************************************************
994 template< typename MT // Type of the sparse matrix
995  , bool SO > // Storage order
996 inline size_t SparseColumn<MT,SO>::nonZeros() const
997 {
998  return matrix_.nonZeros( col_ );
999 }
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1008 template< typename MT // Type of the sparse matrix
1009  , bool SO > // Storage order
1011 {
1012  matrix_.reset( col_ );
1013 }
1014 //*************************************************************************************************
1015 
1016 
1017 //*************************************************************************************************
1029 template< typename MT // Type of the sparse matrix
1030  , bool SO > // Storage order
1031 inline typename SparseColumn<MT,SO>::Iterator
1032  SparseColumn<MT,SO>::insert( size_t index, const ElementType& value )
1033 {
1034  return matrix_.insert( index, col_, value );
1035 }
1036 //*************************************************************************************************
1037 
1038 
1039 //*************************************************************************************************
1047 template< typename MT // Type of the sparse matrix
1048  , bool SO > // Storage order
1049 inline void SparseColumn<MT,SO>::erase( size_t index )
1050 {
1051  matrix_.erase( index, col_ );
1052 }
1053 //*************************************************************************************************
1054 
1055 
1056 //*************************************************************************************************
1064 template< typename MT // Type of the sparse matrix
1065  , bool SO > // Storage order
1067 {
1068  return matrix_.erase( col_, pos );
1069 }
1070 //*************************************************************************************************
1071 
1072 
1073 //*************************************************************************************************
1082 template< typename MT // Type of the sparse matrix
1083  , bool SO > // Storage order
1085 {
1086  return matrix_.erase( col_, first, last );
1087 }
1088 //*************************************************************************************************
1089 
1090 
1091 //*************************************************************************************************
1100 template< typename MT // Type of the sparse matrix
1101  , bool SO > // Storage order
1103 {
1104  matrix_.reserve( col_, n );
1105 }
1106 //*************************************************************************************************
1107 
1108 
1109 //*************************************************************************************************
1115 template< typename MT // Type of the sparse matrix
1116  , bool SO > // Storage order
1117 template< typename Other > // Data type of the scalar value
1119 {
1120  for( Iterator element=begin(); element!=end(); ++element )
1121  element->value() *= scalar;
1122  return *this;
1123 }
1124 //*************************************************************************************************
1125 
1126 
1127 //*************************************************************************************************
1135 template< typename MT // Type of the sparse matrix
1136  , bool SO > // Storage order
1138 {
1139  using blaze::max;
1140  using blaze::min;
1141 
1142  size_t nonzeros( 2UL*capacity()+1UL );
1143  nonzeros = max( nonzeros, 7UL );
1144  nonzeros = min( nonzeros, size() );
1145 
1146  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1147 
1148  return nonzeros;
1149 }
1150 //*************************************************************************************************
1151 
1152 
1153 
1154 
1155 //=================================================================================================
1156 //
1157 // LOOKUP FUNCTIONS
1158 //
1159 //=================================================================================================
1160 
1161 //*************************************************************************************************
1174 template< typename MT // Type of the sparse matrix
1175  , bool SO > // Storage order
1177 {
1178  return matrix_.find( index, col_ );
1179 }
1180 //*************************************************************************************************
1181 
1182 
1183 //*************************************************************************************************
1196 template< typename MT // Type of the sparse matrix
1197  , bool SO > // Storage order
1199 {
1200  return matrix_.find( index, col_ );
1201 }
1202 //*************************************************************************************************
1203 
1204 
1205 //*************************************************************************************************
1217 template< typename MT // Type of the sparse matrix
1218  , bool SO > // Storage order
1220 {
1221  return matrix_.lowerBound( index, col_ );
1222 }
1223 //*************************************************************************************************
1224 
1225 
1226 //*************************************************************************************************
1238 template< typename MT // Type of the sparse matrix
1239  , bool SO > // Storage order
1241 {
1242  return matrix_.lowerBound( index, col_ );
1243 }
1244 //*************************************************************************************************
1245 
1246 
1247 //*************************************************************************************************
1259 template< typename MT // Type of the sparse matrix
1260  , bool SO > // Storage order
1262 {
1263  return matrix_.upperBound( index, col_ );
1264 }
1265 //*************************************************************************************************
1266 
1267 
1268 //*************************************************************************************************
1280 template< typename MT // Type of the sparse matrix
1281  , bool SO > // Storage order
1283 {
1284  return matrix_.upperBound( index, col_ );
1285 }
1286 //*************************************************************************************************
1287 
1288 
1289 
1290 
1291 //=================================================================================================
1292 //
1293 // LOW-LEVEL UTILITY FUNCTIONS
1294 //
1295 //=================================================================================================
1296 
1297 //*************************************************************************************************
1321 template< typename MT // Type of the sparse matrix
1322  , bool SO > // Storage order
1323 inline void SparseColumn<MT,SO>::append( size_t index, const ElementType& value, bool check )
1324 {
1325  matrix_.append( index, col_, value, check );
1326 }
1327 //*************************************************************************************************
1328 
1329 
1330 
1331 
1332 //=================================================================================================
1333 //
1334 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1335 //
1336 //=================================================================================================
1337 
1338 //*************************************************************************************************
1348 template< typename MT // Type of the sparse matrix
1349  , bool SO > // Storage order
1350 template< typename Other > // Data type of the foreign expression
1351 inline bool SparseColumn<MT,SO>::canAlias( const Other* alias ) const
1352 {
1353  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1354 }
1355 //*************************************************************************************************
1356 
1357 
1358 //*************************************************************************************************
1368 template< typename MT // Type of the sparse matrix
1369  , bool SO > // Storage order
1370 template< typename Other > // Data type of the foreign expression
1371 inline bool SparseColumn<MT,SO>::isAliased( const Other* alias ) const
1372 {
1373  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1374 }
1375 //*************************************************************************************************
1376 
1377 
1378 //*************************************************************************************************
1389 template< typename MT // Type of the sparse matrix
1390  , bool SO > // Storage order
1391 template< typename VT > // Type of the right-hand side dense vector
1393 {
1394  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1395  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1396 
1397  for( size_t i=0UL; i<size(); ++i )
1398  {
1399  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
1400  matrix_.reserve( col_, extendCapacity() );
1401 
1402  matrix_.append( i, col_, (~rhs)[i], true );
1403  }
1404 }
1405 //*************************************************************************************************
1406 
1407 
1408 //*************************************************************************************************
1419 template< typename MT // Type of the sparse matrix
1420  , bool SO > // Storage order
1421 template< typename VT > // Type of the right-hand side sparse vector
1423 {
1424  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1425  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1426 
1427  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1428  matrix_.append( element->index(), col_, element->value() );
1429  }
1430 }
1431 //*************************************************************************************************
1432 
1433 
1434 //*************************************************************************************************
1445 template< typename MT // Type of the sparse matrix
1446  , bool SO > // Storage order
1447 template< typename VT > // Type of the right-hand side dense vector
1449 {
1450  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1451 
1455 
1456  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1457 
1458  const AddType tmp( *this + (~rhs) );
1459  matrix_.reset( col_ );
1460  assign( tmp );
1461 }
1462 //*************************************************************************************************
1463 
1464 
1465 //*************************************************************************************************
1476 template< typename MT // Type of the sparse matrix
1477  , bool SO > // Storage order
1478 template< typename VT > // Type of the right-hand side sparse vector
1480 {
1481  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1482 
1486 
1487  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1488 
1489  const AddType tmp( *this + (~rhs) );
1490  matrix_.reset ( col_ );
1491  matrix_.reserve( col_, tmp.nonZeros() );
1492  assign( tmp );
1493 }
1494 //*************************************************************************************************
1495 
1496 
1497 //*************************************************************************************************
1508 template< typename MT // Type of the sparse matrix
1509  , bool SO > // Storage order
1510 template< typename VT > // Type of the right-hand side dense vector
1512 {
1513  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1514 
1518 
1519  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1520 
1521  const SubType tmp( *this - (~rhs) );
1522  matrix_.reset( col_ );
1523  assign( tmp );
1524 }
1525 //*************************************************************************************************
1526 
1527 
1528 //*************************************************************************************************
1539 template< typename MT // Type of the sparse matrix
1540  , bool SO > // Storage order
1541 template< typename VT > // Type of the right-hand side sparse vector
1543 {
1544  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1545 
1549 
1550  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1551 
1552  const SubType tmp( *this - (~rhs) );
1553  matrix_.reset ( col_ );
1554  matrix_.reserve( col_, tmp.nonZeros() );
1555  assign( tmp );
1556 }
1557 //*************************************************************************************************
1558 
1559 
1560 
1561 
1562 
1563 
1564 
1565 
1566 //=================================================================================================
1567 //
1568 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR MATRICES
1569 //
1570 //=================================================================================================
1571 
1572 //*************************************************************************************************
1580 template< typename MT > // Type of the sparse matrix
1581 class SparseColumn<MT,false> : public SparseVector< SparseColumn<MT,false>, false >
1582  , private View
1583 {
1584  private:
1585  //**Type definitions****************************************************************************
1587  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1588  //**********************************************************************************************
1589 
1590  //**********************************************************************************************
1592 
1598  enum { useConst = IsConst<MT>::value };
1599  //**********************************************************************************************
1600 
1601  public:
1602  //**Type definitions****************************************************************************
1603  typedef SparseColumn<MT,false> This;
1604  typedef typename ColumnTrait<MT>::Type ResultType;
1605  typedef typename ResultType::TransposeType TransposeType;
1606  typedef typename MT::ElementType ElementType;
1607  typedef typename MT::ReturnType ReturnType;
1608  typedef const ResultType CompositeType;
1609 
1611  typedef typename MT::ConstReference ConstReference;
1612 
1614  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1615  //**********************************************************************************************
1616 
1617  //**ColumnElement class definition**************************************************************
1620  template< typename MatrixType // Type of the sparse matrix
1621  , typename IteratorType > // Type of the sparse matrix iterator
1622  class ColumnElement
1623  {
1624  private:
1625  //*******************************************************************************************
1627 
1632  enum { returnConst = IsConst<MatrixType>::value };
1633  //*******************************************************************************************
1634 
1635  public:
1636  //**Type definitions*************************************************************************
1637  typedef typename SelectType< returnConst, const ElementType&, ElementType& >::Type ReferenceType;
1638  //*******************************************************************************************
1639 
1640  //**Constructor******************************************************************************
1646  inline ColumnElement( IteratorType pos, size_t row )
1647  : pos_( pos ) // Iterator to the current position within the sparse column
1648  , row_( row ) // Index of the according row
1649  {}
1650  //*******************************************************************************************
1651 
1652  //**Assignment operator**********************************************************************
1658  template< typename T > inline ColumnElement& operator=( const T& v ) {
1659  *pos_ = v;
1660  return *this;
1661  }
1662  //*******************************************************************************************
1663 
1664  //**Addition assignment operator*************************************************************
1670  template< typename T > inline ColumnElement& operator+=( const T& v ) {
1671  *pos_ += v;
1672  return *this;
1673  }
1674  //*******************************************************************************************
1675 
1676  //**Subtraction assignment operator**********************************************************
1682  template< typename T > inline ColumnElement& operator-=( const T& v ) {
1683  *pos_ -= v;
1684  return *this;
1685  }
1686  //*******************************************************************************************
1687 
1688  //**Multiplication assignment operator*******************************************************
1694  template< typename T > inline ColumnElement& operator*=( const T& v ) {
1695  *pos_ *= v;
1696  return *this;
1697  }
1698  //*******************************************************************************************
1699 
1700  //**Division assignment operator*************************************************************
1706  template< typename T > inline ColumnElement& operator/=( const T& v ) {
1707  *pos_ /= v;
1708  return *this;
1709  }
1710  //*******************************************************************************************
1711 
1712  //**Element access operator******************************************************************
1717  inline const ColumnElement* operator->() const {
1718  return this;
1719  }
1720  //*******************************************************************************************
1721 
1722  //**Value function***************************************************************************
1727  inline ReferenceType value() const {
1728  return pos_->value();
1729  }
1730  //*******************************************************************************************
1731 
1732  //**Index function***************************************************************************
1737  inline size_t index() const {
1738  return row_;
1739  }
1740  //*******************************************************************************************
1741 
1742  private:
1743  //**Member variables*************************************************************************
1744  IteratorType pos_;
1745  size_t row_;
1746  //*******************************************************************************************
1747  };
1748  //**********************************************************************************************
1749 
1750  //**ColumnIterator class definition*************************************************************
1753  template< typename MatrixType // Type of the sparse matrix
1754  , typename IteratorType > // Type of the sparse matrix iterator
1755  class ColumnIterator
1756  {
1757  public:
1758  //**Type definitions*************************************************************************
1759  typedef std::forward_iterator_tag IteratorCategory;
1760  typedef ColumnElement<MatrixType,IteratorType> ValueType;
1761  typedef ValueType PointerType;
1762  typedef ValueType ReferenceType;
1763  typedef ptrdiff_t DifferenceType;
1764 
1765  // STL iterator requirements
1766  typedef IteratorCategory iterator_category;
1767  typedef ValueType value_type;
1768  typedef PointerType pointer;
1769  typedef ReferenceType reference;
1770  typedef DifferenceType difference_type;
1771  //*******************************************************************************************
1772 
1773  //**Constructor******************************************************************************
1780  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column )
1781  : matrix_( matrix ) // The sparse matrix containing the column.
1782  , row_ ( row ) // The current row index.
1783  , column_( column ) // The current column index.
1784  , pos_ () // Iterator to the current sparse element.
1785  {
1786  for( ; row_<matrix_.rows(); ++row_ ) {
1787  pos_ = matrix_.find( row_, column_ );
1788  if( pos_ != matrix_.end( row_ ) ) break;
1789  }
1790  }
1791  //*******************************************************************************************
1792 
1793  //**Constructor******************************************************************************
1801  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
1802  : matrix_( matrix ) // The sparse matrix containing the column.
1803  , row_ ( row ) // The current row index.
1804  , column_( column ) // The current column index.
1805  , pos_ ( pos ) // Iterator to the current sparse element.
1806  {
1807  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
1808  }
1809  //*******************************************************************************************
1810 
1811  //**Constructor******************************************************************************
1816  template< typename MatrixType2, typename IteratorType2 >
1817  inline ColumnIterator( const ColumnIterator<MatrixType2,IteratorType2>& it )
1818  : matrix_( it.matrix_ ) // The sparse matrix containing the column.
1819  , row_ ( it.row_ ) // The current row index.
1820  , column_( it.column_ ) // The current column index.
1821  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
1822  {}
1823  //*******************************************************************************************
1824 
1825  //**Prefix increment operator****************************************************************
1830  inline ColumnIterator& operator++() {
1831  ++row_;
1832  for( ; row_<matrix_.rows(); ++row_ ) {
1833  pos_ = matrix_.find( row_, column_ );
1834  if( pos_ != matrix_.end( row_ ) ) break;
1835  }
1836 
1837  return *this;
1838  }
1839  //*******************************************************************************************
1840 
1841  //**Postfix increment operator***************************************************************
1846  inline const ColumnIterator operator++( int ) {
1847  const ColumnIterator tmp( *this );
1848  ++(*this);
1849  return tmp;
1850  }
1851  //*******************************************************************************************
1852 
1853  //**Element access operator******************************************************************
1858  inline ReferenceType operator*() const {
1859  return ReferenceType( pos_, row_ );
1860  }
1861  //*******************************************************************************************
1862 
1863  //**Element access operator******************************************************************
1868  inline PointerType operator->() const {
1869  return PointerType( pos_, row_ );
1870  }
1871  //*******************************************************************************************
1872 
1873  //**Equality operator************************************************************************
1879  template< typename MatrixType2, typename IteratorType2 >
1880  inline bool operator==( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
1881  return ( &matrix_ == &rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1882  }
1883  //*******************************************************************************************
1884 
1885  //**Inequality operator**********************************************************************
1891  template< typename MatrixType2, typename IteratorType2 >
1892  inline bool operator!=( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
1893  return !( *this == rhs );
1894  }
1895  //*******************************************************************************************
1896 
1897  //**Subtraction operator*********************************************************************
1903  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
1904  size_t counter( 0UL );
1905  for( size_t i=rhs.row_; i<row_; ++i ) {
1906  if( matrix_.find( i, column_ ) != matrix_.end( i ) )
1907  ++counter;
1908  }
1909  return counter;
1910  }
1911  //*******************************************************************************************
1912 
1913  private:
1914  //**Member variables*************************************************************************
1915  MatrixType& matrix_;
1916  size_t row_;
1917  size_t column_;
1918  IteratorType pos_;
1919  //*******************************************************************************************
1920 
1921  //**Friend declarations**********************************************************************
1923  template< typename MatrixType2, typename IteratorType2 > friend class ColumnIterator;
1924  template< typename MT2, bool SO2 > friend class SparseColumn;
1926  //*******************************************************************************************
1927  };
1928  //**********************************************************************************************
1929 
1930  //**Type definitions****************************************************************************
1932  typedef ColumnIterator<const MT,typename MT::ConstIterator> ConstIterator;
1933 
1935  typedef typename SelectType< useConst, ConstIterator, ColumnIterator<MT,typename MT::Iterator> >::Type Iterator;
1936  //**********************************************************************************************
1937 
1938  //**Constructors********************************************************************************
1941  explicit inline SparseColumn( MT& matrix, size_t index );
1942  // No explicitly declared copy constructor.
1944  //**********************************************************************************************
1945 
1946  //**Destructor**********************************************************************************
1947  // No explicitly declared destructor.
1948  //**********************************************************************************************
1949 
1950  //**Data access functions***********************************************************************
1953  inline Reference operator[]( size_t index );
1954  inline ConstReference operator[]( size_t index ) const;
1955  inline Iterator begin ();
1956  inline ConstIterator begin () const;
1957  inline ConstIterator cbegin() const;
1958  inline Iterator end ();
1959  inline ConstIterator end () const;
1960  inline ConstIterator cend () const;
1962  //**********************************************************************************************
1963 
1964  //**Assignment operators************************************************************************
1967  inline SparseColumn& operator= ( const SparseColumn& rhs );
1968  template< typename VT > inline SparseColumn& operator= ( const Vector<VT,false>& rhs );
1969  template< typename VT > inline SparseColumn& operator+=( const Vector<VT,false>& rhs );
1970  template< typename VT > inline SparseColumn& operator-=( const Vector<VT,false>& rhs );
1971  template< typename VT > inline SparseColumn& operator*=( const Vector<VT,false>& rhs );
1972 
1973  template< typename Other >
1974  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
1975  operator*=( Other rhs );
1976 
1977  template< typename Other >
1978  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
1979  operator/=( Other rhs );
1981  //**********************************************************************************************
1982 
1983  //**Utility functions***************************************************************************
1986  inline size_t size() const;
1987  inline size_t capacity() const;
1988  inline size_t nonZeros() const;
1989  inline void reset();
1990  inline Iterator insert ( size_t index, const ElementType& value );
1991  inline void erase ( size_t index );
1992  inline Iterator erase ( Iterator pos );
1993  inline Iterator erase ( Iterator first, Iterator last );
1994  inline void reserve( size_t n );
1995  template< typename Other > inline SparseColumn& scale ( Other scalar );
1997  //**********************************************************************************************
1998 
1999  //**Lookup functions****************************************************************************
2002  inline Iterator find ( size_t index );
2003  inline ConstIterator find ( size_t index ) const;
2004  inline Iterator lowerBound( size_t index );
2005  inline ConstIterator lowerBound( size_t index ) const;
2006  inline Iterator upperBound( size_t index );
2007  inline ConstIterator upperBound( size_t index ) const;
2009  //**********************************************************************************************
2010 
2011  //**Low-level utility functions*****************************************************************
2014  inline void append( size_t index, const ElementType& value, bool check=false );
2016  //**********************************************************************************************
2017 
2018  //**Expression template evaluation functions****************************************************
2021  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2022  template< typename Other > inline bool isAliased( const Other* alias ) const;
2023  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
2024  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
2025  template< typename VT > inline void addAssign( const Vector<VT,false>& rhs );
2026  template< typename VT > inline void subAssign( const Vector<VT,false>& rhs );
2028  //**********************************************************************************************
2029 
2030  private:
2031  //**Member variables****************************************************************************
2035  const size_t col_;
2036 
2037  //**********************************************************************************************
2038 
2039  //**Compile time checks*************************************************************************
2046  //**********************************************************************************************
2047 };
2049 //*************************************************************************************************
2050 
2051 
2052 
2053 
2054 //=================================================================================================
2055 //
2056 // CONSTRUCTOR
2057 //
2058 //=================================================================================================
2059 
2060 //*************************************************************************************************
2068 template< typename MT > // Type of the sparse matrix
2069 inline SparseColumn<MT,false>::SparseColumn( MT& matrix, size_t index )
2070  : matrix_( matrix ) // The sparse matrix containing the column
2071  , col_ ( index ) // The index of the column in the matrix
2072 {
2073  if( matrix_.columns() <= index )
2074  throw std::invalid_argument( "Invalid column access index" );
2075 }
2077 //*************************************************************************************************
2078 
2079 
2080 
2081 
2082 //=================================================================================================
2083 //
2084 // DATA ACCESS FUNCTIONS
2085 //
2086 //=================================================================================================
2087 
2088 //*************************************************************************************************
2095 template< typename MT > // Type of the sparse matrix
2096 inline typename SparseColumn<MT,false>::Reference SparseColumn<MT,false>::operator[]( size_t index )
2097 {
2098  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2099  return matrix_(index,col_);
2100 }
2102 //*************************************************************************************************
2103 
2104 
2105 //*************************************************************************************************
2112 template< typename MT > // Type of the sparse matrix
2113 inline typename SparseColumn<MT,false>::ConstReference SparseColumn<MT,false>::operator[]( size_t index ) const
2114 {
2115  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2116  return const_cast<const MT&>( matrix_ )(index,col_);
2117 }
2119 //*************************************************************************************************
2120 
2121 
2122 //*************************************************************************************************
2130 template< typename MT > // Type of the sparse matrix
2131 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::begin()
2132 {
2133  return Iterator( matrix_, 0UL, col_ );
2134 }
2136 //*************************************************************************************************
2137 
2138 
2139 //*************************************************************************************************
2147 template< typename MT > // Type of the sparse matrix
2148 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::begin() const
2149 {
2150  return ConstIterator( matrix_, 0UL, col_ );
2151 }
2153 //*************************************************************************************************
2154 
2155 
2156 //*************************************************************************************************
2164 template< typename MT > // Type of the sparse matrix
2165 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::cbegin() const
2166 {
2167  return ConstIterator( matrix_, 0UL, col_ );
2168 }
2170 //*************************************************************************************************
2171 
2172 
2173 //*************************************************************************************************
2181 template< typename MT > // Type of the sparse matrix
2182 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::end()
2183 {
2184  return Iterator( matrix_, size(), col_ );
2185 }
2187 //*************************************************************************************************
2188 
2189 
2190 //*************************************************************************************************
2198 template< typename MT > // Type of the sparse matrix
2199 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::end() const
2200 {
2201  return ConstIterator( matrix_, size(), col_ );
2202 }
2204 //*************************************************************************************************
2205 
2206 
2207 //*************************************************************************************************
2215 template< typename MT > // Type of the sparse matrix
2216 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::cend() const
2217 {
2218  return ConstIterator( matrix_, size(), col_ );
2219 }
2221 //*************************************************************************************************
2222 
2223 
2224 
2225 
2226 //=================================================================================================
2227 //
2228 // ASSIGNMENT OPERATORS
2229 //
2230 //=================================================================================================
2231 
2232 //*************************************************************************************************
2243 template< typename MT > // Type of the sparse matrix
2244 inline SparseColumn<MT,false>& SparseColumn<MT,false>::operator=( const SparseColumn& rhs )
2245 {
2246  using blaze::assign;
2247 
2251 
2252  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
2253  return *this;
2254 
2255  if( size() != rhs.size() )
2256  throw std::invalid_argument( "Column sizes do not match" );
2257 
2258  if( rhs.canAlias( &matrix_ ) ) {
2259  const ResultType tmp( rhs );
2260  assign( *this, tmp );
2261  }
2262  else {
2263  assign( *this, rhs );
2264  }
2265 
2266  return *this;
2267 }
2269 //*************************************************************************************************
2270 
2271 
2272 //*************************************************************************************************
2283 template< typename MT > // Type of the sparse matrix
2284 template< typename VT > // Type of the right-hand side vector
2285 inline SparseColumn<MT,false>& SparseColumn<MT,false>::operator=( const Vector<VT,false>& rhs )
2286 {
2287  using blaze::assign;
2288 
2289  if( size() != (~rhs).size() )
2290  throw std::invalid_argument( "Vector sizes do not match" );
2291 
2292  const typename VT::CompositeType tmp( ~rhs );
2293  assign( *this, tmp );
2294 
2295  return *this;
2296 }
2298 //*************************************************************************************************
2299 
2300 
2301 //*************************************************************************************************
2312 template< typename MT > // Type of the sparse matrix
2313 template< typename VT > // Type of the right-hand side vector
2314 inline SparseColumn<MT,false>& SparseColumn<MT,false>::operator+=( const Vector<VT,false>& rhs )
2315 {
2316  using blaze::addAssign;
2317 
2318  if( size() != (~rhs).size() )
2319  throw std::invalid_argument( "Vector sizes do not match" );
2320 
2321  addAssign( *this, ~rhs );
2322 
2323  return *this;
2324 }
2326 //*************************************************************************************************
2327 
2328 
2329 //*************************************************************************************************
2340 template< typename MT > // Type of the sparse matrix
2341 template< typename VT > // Type of the right-hand side vector
2342 inline SparseColumn<MT,false>& SparseColumn<MT,false>::operator-=( const Vector<VT,false>& rhs )
2343 {
2344  using blaze::subAssign;
2345 
2346  if( size() != (~rhs).size() )
2347  throw std::invalid_argument( "Vector sizes do not match" );
2348 
2349  subAssign( *this, ~rhs );
2350 
2351  return *this;
2352 }
2354 //*************************************************************************************************
2355 
2356 
2357 //*************************************************************************************************
2369 template< typename MT > // Type of the sparse matrix
2370 template< typename VT > // Type of the right-hand side vector
2371 inline SparseColumn<MT,false>& SparseColumn<MT,false>::operator*=( const Vector<VT,false>& rhs )
2372 {
2373  if( size() != (~rhs).size() )
2374  throw std::invalid_argument( "Vector sizes do not match" );
2375 
2376  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
2377 
2380 
2381  const MultType tmp( *this * (~rhs) );
2382  assign( tmp );
2383 
2384  return *this;
2385 }
2387 //*************************************************************************************************
2388 
2389 
2390 //*************************************************************************************************
2402 template< typename MT > // Type of the sparse matrix
2403 template< typename Other > // Data type of the right-hand side scalar
2404 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false> >::Type&
2405  SparseColumn<MT,false>::operator*=( Other rhs )
2406 {
2407  for( Iterator element=begin(); element!=end(); ++element )
2408  element->value() *= rhs;
2409  return *this;
2410 }
2412 //*************************************************************************************************
2413 
2414 
2415 //*************************************************************************************************
2428 template< typename MT > // Type of the sparse matrix
2429 template< typename Other > // Data type of the right-hand side scalar
2430 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false> >::Type&
2431  SparseColumn<MT,false>::operator/=( Other rhs )
2432 {
2433  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2434 
2435  typedef typename DivTrait<ElementType,Other>::Type DT;
2436  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2437 
2438  // Depending on the two involved data types, an integer division is applied or a
2439  // floating point division is selected.
2440  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2441  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2442  for( Iterator element=begin(); element!=end(); ++element )
2443  element->value() *= tmp;
2444  }
2445  else {
2446  for( Iterator element=begin(); element!=end(); ++element )
2447  element->value() /= rhs;
2448  }
2449 
2450  return *this;
2451 }
2453 //*************************************************************************************************
2454 
2455 
2456 
2457 
2458 //=================================================================================================
2459 //
2460 // UTILITY FUNCTIONS
2461 //
2462 //=================================================================================================
2463 
2464 //*************************************************************************************************
2470 template< typename MT > // Type of the sparse matrix
2471 inline size_t SparseColumn<MT,false>::size() const
2472 {
2473  return matrix_.rows();
2474 }
2476 //*************************************************************************************************
2477 
2478 
2479 //*************************************************************************************************
2485 template< typename MT > // Type of the sparse matrix
2486 inline size_t SparseColumn<MT,false>::capacity() const
2487 {
2488  return matrix_.rows();
2489 }
2491 //*************************************************************************************************
2492 
2493 
2494 //*************************************************************************************************
2503 template< typename MT > // Type of the sparse matrix
2504 inline size_t SparseColumn<MT,false>::nonZeros() const
2505 {
2506  size_t counter( 0UL );
2507  for( ConstIterator element=begin(); element!=end(); ++element ) {
2508  ++counter;
2509  }
2510  return counter;
2511 }
2513 //*************************************************************************************************
2514 
2515 
2516 //*************************************************************************************************
2522 template< typename MT > // Type of the sparse matrix
2523 inline void SparseColumn<MT,false>::reset()
2524 {
2525  for( size_t i=0UL; i<size(); ++i ) {
2526  matrix_.erase( i, col_ );
2527  }
2528 }
2530 //*************************************************************************************************
2531 
2532 
2533 //*************************************************************************************************
2546 template< typename MT > // Type of the sparse matrix
2547 inline typename SparseColumn<MT,false>::Iterator
2548  SparseColumn<MT,false>::insert( size_t index, const ElementType& value )
2549 {
2550  return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
2551 }
2553 //*************************************************************************************************
2554 
2555 
2556 //*************************************************************************************************
2565 template< typename MT > // Type of the sparse matrix
2566 inline void SparseColumn<MT,false>::erase( size_t index )
2567 {
2568  matrix_.erase( index, col_ );
2569 }
2571 //*************************************************************************************************
2572 
2573 
2574 //*************************************************************************************************
2583 template< typename MT > // Type of the sparse matrix
2584 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::erase( Iterator pos )
2585 {
2586  const size_t row( pos.row_ );
2587 
2588  if( row == size() )
2589  return pos;
2590 
2591  matrix_.erase( row, pos.pos_ );
2592  return Iterator( matrix_, row+1UL, col_ );
2593 }
2595 //*************************************************************************************************
2596 
2597 
2598 //*************************************************************************************************
2608 template< typename MT > // Type of the sparse matrix
2609 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::erase( Iterator first, Iterator last )
2610 {
2611  for( ; first!=last; ++first ) {
2612  matrix_.erase( first.row_, first.pos_ );
2613  }
2614  return last;
2615 }
2617 //*************************************************************************************************
2618 
2619 
2620 //*************************************************************************************************
2630 template< typename MT > // Type of the sparse matrix
2631 void SparseColumn<MT,false>::reserve( size_t n )
2632 {
2633  UNUSED_PARAMETER( n );
2634  return;
2635 }
2637 //*************************************************************************************************
2638 
2639 
2640 //*************************************************************************************************
2647 template< typename MT > // Type of the sparse matrix
2648 template< typename Other > // Data type of the scalar value
2649 inline SparseColumn<MT,false>& SparseColumn<MT,false>::scale( Other scalar )
2650 {
2651  for( Iterator element=begin(); element!=end(); ++element )
2652  element->value() *= scalar;
2653  return *this;
2654 }
2656 //*************************************************************************************************
2657 
2658 
2659 
2660 
2661 //=================================================================================================
2662 //
2663 // LOOKUP FUNCTIONS
2664 //
2665 //=================================================================================================
2666 
2667 //*************************************************************************************************
2681 template< typename MT > // Type of the sparse matrix
2682 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::find( size_t index )
2683 {
2684  const typename MT::Iterator pos( matrix_.find( index, col_ ) );
2685 
2686  if( pos != matrix_.end( index ) )
2687  return Iterator( matrix_, index, col_, pos );
2688  else
2689  return end();
2690 }
2692 //*************************************************************************************************
2693 
2694 
2695 //*************************************************************************************************
2709 template< typename MT > // Type of the sparse matrix
2710 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::find( size_t index ) const
2711 {
2712  const typename MT::ConstIterator pos( matrix_.find( index, col_ ) );
2713 
2714  if( pos != matrix_.end( index ) )
2715  return ConstIterator( matrix_, index, col_, pos );
2716  else
2717  return end();
2718 }
2720 //*************************************************************************************************
2721 
2722 
2723 //*************************************************************************************************
2736 template< typename MT > // Type of the sparse matrix
2737 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::lowerBound( size_t index )
2738 {
2739  for( size_t i=index; i<size(); ++i )
2740  {
2741  const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2742 
2743  if( pos != matrix_.end( i ) )
2744  return Iterator( matrix_, i, col_, pos );
2745  }
2746 
2747  return end();
2748 }
2750 //*************************************************************************************************
2751 
2752 
2753 //*************************************************************************************************
2766 template< typename MT > // Type of the sparse matrix
2767 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::lowerBound( size_t index ) const
2768 {
2769  for( size_t i=index; i<size(); ++i )
2770  {
2771  const typename MT::ConstIterator pos( matrix_.find( i, col_ ) );
2772 
2773  if( pos != matrix_.end( i ) )
2774  return ConstIterator( matrix_, i, col_, pos );
2775  }
2776 
2777  return end();
2778 }
2780 //*************************************************************************************************
2781 
2782 
2783 //*************************************************************************************************
2796 template< typename MT > // Type of the sparse matrix
2797 inline typename SparseColumn<MT,false>::Iterator SparseColumn<MT,false>::upperBound( size_t index )
2798 {
2799  for( size_t i=index+1UL; i<size(); ++i )
2800  {
2801  const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2802 
2803  if( pos != matrix_.end( i ) )
2804  return Iterator( matrix_, i, col_, pos );
2805  }
2806 
2807  return end();
2808 }
2810 //*************************************************************************************************
2811 
2812 
2813 //*************************************************************************************************
2826 template< typename MT > // Type of the sparse matrix
2827 inline typename SparseColumn<MT,false>::ConstIterator SparseColumn<MT,false>::upperBound( size_t index ) const
2828 {
2829  for( size_t i=index+1UL; i<size(); ++i )
2830  {
2831  const typename MT::ConstIterator pos( matrix_.find( i, col_ ) );
2832 
2833  if( pos != matrix_.end( i ) )
2834  return ConstIterator( matrix_, i, col_, pos );
2835  }
2836 
2837  return end();
2838 }
2840 //*************************************************************************************************
2841 
2842 
2843 
2844 
2845 //=================================================================================================
2846 //
2847 // LOW-LEVEL UTILITY FUNCTIONS
2848 //
2849 //=================================================================================================
2850 
2851 //*************************************************************************************************
2876 template< typename MT > // Type of the sparse matrix
2877 inline void SparseColumn<MT,false>::append( size_t index, const ElementType& value, bool check )
2878 {
2879  if( !check || !isDefault( value ) )
2880  matrix_.insert( index, col_, value );
2881 }
2883 //*************************************************************************************************
2884 
2885 
2886 
2887 
2888 //=================================================================================================
2889 //
2890 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2891 //
2892 //=================================================================================================
2893 
2894 //*************************************************************************************************
2905 template< typename MT > // Type of the sparse matrix
2906 template< typename Other > // Data type of the foreign expression
2907 inline bool SparseColumn<MT,false>::canAlias( const Other* alias ) const
2908 {
2909  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2910 }
2912 //*************************************************************************************************
2913 
2914 
2915 //*************************************************************************************************
2922 template< typename MT > // Type of the sparse matrix
2923 template< typename Other > // Data type of the foreign expression
2924 inline bool SparseColumn<MT,false>::isAliased( const Other* alias ) const
2925 {
2926  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2927 }
2929 //*************************************************************************************************
2930 
2931 
2932 //*************************************************************************************************
2944 template< typename MT > // Type of the sparse matrix
2945 template< typename VT > // Type of the right-hand side dense vector
2946 inline void SparseColumn<MT,false>::assign( const DenseVector<VT,false>& rhs )
2947 {
2948  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2949 
2950  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
2951  matrix_(i,col_) = (~rhs)[i];
2952  }
2953 }
2955 //*************************************************************************************************
2956 
2957 
2958 //*************************************************************************************************
2970 template< typename MT > // Type of the sparse matrix
2971 template< typename VT > // Type of the right-hand side sparse vector
2972 inline void SparseColumn<MT,false>::assign( const SparseVector<VT,false>& rhs )
2973 {
2974  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2975 
2976  size_t i( 0UL );
2977 
2978  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
2979  for( ; i<element->index(); ++i )
2980  matrix_.erase( i, col_ );
2981  matrix_(i++,col_) = element->value();
2982  }
2983  for( ; i<size(); ++i ) {
2984  matrix_.erase( i, col_ );
2985  }
2986 }
2988 //*************************************************************************************************
2989 
2990 
2991 //*************************************************************************************************
3003 template< typename MT > // Type of the sparse matrix
3004 template< typename VT > // Type of the right-hand side vector
3005 inline void SparseColumn<MT,false>::addAssign( const Vector<VT,false>& rhs )
3006 {
3007  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3008 
3011 
3012  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3013 
3014  const AddType tmp( *this + (~rhs) );
3015  assign( tmp );
3016 }
3018 //*************************************************************************************************
3019 
3020 
3021 //*************************************************************************************************
3033 template< typename MT > // Type of the sparse matrix
3034 template< typename VT > // Type of the right-hand side vector
3035 inline void SparseColumn<MT,false>::subAssign( const Vector<VT,false>& rhs )
3036 {
3037  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3038 
3041 
3042  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3043 
3044  const SubType tmp( *this - (~rhs) );
3045  assign( tmp );
3046 }
3048 //*************************************************************************************************
3049 
3050 
3051 
3052 
3053 
3054 
3055 
3056 
3057 //=================================================================================================
3058 //
3059 // SPARSECOLUMN OPERATORS
3060 //
3061 //=================================================================================================
3062 
3063 //*************************************************************************************************
3066 template< typename MT, bool SO >
3067 inline void reset( SparseColumn<MT,SO>& column );
3068 
3069 template< typename MT, bool SO >
3070 inline void clear( SparseColumn<MT,SO>& column );
3071 
3072 template< typename MT, bool SO >
3073 inline bool isDefault( const SparseColumn<MT,SO>& column );
3075 //*************************************************************************************************
3076 
3077 
3078 //*************************************************************************************************
3085 template< typename MT // Type of the sparse matrix
3086  , bool SO > // Storage order
3087 inline void reset( SparseColumn<MT,SO>& column )
3088 {
3089  column.reset();
3090 }
3091 //*************************************************************************************************
3092 
3093 
3094 //*************************************************************************************************
3103 template< typename MT // Type of the sparse matrix
3104  , bool SO > // Storage order
3105 inline void clear( SparseColumn<MT,SO>& column )
3106 {
3107  column.reset();
3108 }
3109 //*************************************************************************************************
3110 
3111 
3112 //*************************************************************************************************
3130 template< typename MT // Type of the sparse matrix
3131  , bool SO > // Storage order
3132 inline bool isDefault( const SparseColumn<MT,SO>& column )
3133 {
3135 
3136  const ConstIterator end( column.end() );
3137  for( ConstIterator element=column.begin(); element!=end; ++element )
3138  if( !isDefault( element->value() ) ) return false;
3139  return true;
3140 }
3141 //*************************************************************************************************
3142 
3143 
3144 
3145 
3146 //=================================================================================================
3147 //
3148 // GLOBAL OPERATORS
3149 //
3150 //=================================================================================================
3151 
3152 //*************************************************************************************************
3173 template< typename MT // Type of the sparse matrix
3174  , bool SO > // Storage order
3175 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseColumn<MT> >::Type
3176  column( SparseMatrix<MT,SO>& sm, size_t index )
3177 {
3179 
3180  return SparseColumn<MT>( ~sm, index );
3181 }
3182 //*************************************************************************************************
3183 
3184 
3185 //*************************************************************************************************
3206 template< typename MT // Type of the sparse matrix
3207  , bool SO > // Storage order
3208 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseColumn<const MT> >::Type
3209  column( const SparseMatrix<MT,SO>& sm, size_t index )
3210 {
3212 
3213  return SparseColumn<const MT>( ~sm, index );
3214 }
3215 //*************************************************************************************************
3216 
3217 
3218 
3219 
3220 //=================================================================================================
3221 //
3222 // SUBVECTORTRAIT SPECIALIZATIONS
3223 //
3224 //=================================================================================================
3225 
3226 //*************************************************************************************************
3228 template< typename MT, bool SO >
3229 struct SubvectorTrait< SparseColumn<MT,SO> >
3230 {
3231  typedef typename SubvectorTrait< typename SparseColumn<MT,SO>::ResultType >::Type Type;
3232 };
3234 //*************************************************************************************************
3235 
3236 } // namespace blaze
3237 
3238 #endif
Constraint on the data type.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseColumn< MT > >::Type column(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific column of the given dense matrix.
Definition: DenseColumn.h:3026
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Header file for mathematical functions.
void subAssign(const DenseVector< VT, false > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseColumn.h:1511
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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
Operand matrix_
The sparse matrix containing the column.
Definition: SparseColumn.h:488
Header file for the UNUSED_PARAMETER function template.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:3703
Header file for the subtraction trait.
Iterator end()
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:629
Header file for the SparseVector base class.
Header file for the View base class.
ConstIterator cend() const
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:661
Base template for the ColumnTrait class.
Definition: ColumnTrait.h:114
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: TransposeFlag.h:159
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
const size_t col_
The index of the column in the matrix.
Definition: DenseColumn.h:2070
Header file for the IsColumnMajorMatrix type trait.
void assign(const DenseVector< VT, false > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseColumn.h:1392
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
Iterator find(size_t index)
Searches for a specific column element.
Definition: SparseColumn.h:1176
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseColumn.h:364
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:2793
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
Constraint on the data type.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SparseColumn.h:376
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: SparseColumn.h:379
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the multiplication trait.
MT::ElementType ElementType
Type of the column elements.
Definition: SparseColumn.h:365
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Header file for the Or class template.
Iterator begin()
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:581
void addAssign(const DenseVector< VT, false > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseColumn.h:1448
size_t size() const
Returns the current size/dimension of the sparse column.
Definition: SparseColumn.h:965
MT::ConstReference ConstReference
Reference to a constant column value.
Definition: SparseColumn.h:370
Header file for the subvector trait.
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseColumn.h:1219
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:79
Constraint on the data type.
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseColumn.h:1261
Constraint on the data type.
Operand matrix_
The dense matrix containing the column.
Definition: DenseColumn.h:2069
size_t nonZeros() const
Returns the number of non-zero elements in the column.
Definition: SparseColumn.h:996
Constraints on the storage order of matrix types.
Constraint on the data type.
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:94
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
Constraint on the data type.
Header file for the SelectType class template.
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:2794
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
Header file for the EnableIf class template.
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the IsNumeric type trait.
const size_t col_
The index of the column in the matrix.
Definition: SparseColumn.h:489
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Header file for the IsConst type trait.
void erase(size_t index)
Erasing an element from the sparse column.
Definition: SparseColumn.h:1049
SparseColumn< MT, SO > This
Type of this SparseColumn instance.
Definition: SparseColumn.h:362
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:141
Base template for the MultTrait class.
Definition: MultTrait.h:141
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseColumn.h:346
Header file for the addition trait.
ColumnTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseColumn.h:363
Header file for the division trait.
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
void reserve(size_t n)
Setting the minimum capacity of the sparse column.
Definition: SparseColumn.h:1102
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Header file for the reset shim.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseRow< MT > >::Type row(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific row of the given dense matrix.
Definition: DenseRow.h:3025
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
const VT::ElementType max(const SparseVector< VT, TF > &sv)
Returns the largest element of the sparse vector.
Definition: SparseVector.h:405
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
Header file for the column trait.
Header file for the isDefault shim.
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse column.
Definition: SparseColumn.h:1032
size_t capacity() const
Returns the maximum capacity of the sparse column.
Definition: SparseColumn.h:979
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
ConstIterator cbegin() const
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:613
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
const SparseColumn & CompositeType
Data type for composite expression templates.
Definition: SparseColumn.h:367
Base template for the DivTrait class.
Definition: DivTrait.h:141
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseColumn.h:366
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:79
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
Base class for all views.The View class serves as a tag for all views (subvectors, submatrices, rows, columns, ...). All classes that represent a view and that are used within the expression template environment of the Blaze library have to derive from this class in order to qualify as a view. Only in case a class is derived from the View base class, the IsView type trait recognizes the class as valid view.
Definition: View.h:64
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:247
SparseColumn(MT &matrix, size_t index)
The constructor for SparseColumn.
Definition: SparseColumn.h:522
SparseColumn & operator=(const SparseColumn &rhs)
Copy assignment operator for SparseColumn.
Definition: SparseColumn.h:688
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
void reset()
Reset to the default initial values.
Definition: SparseColumn.h:1010
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
Reference operator[](size_t index)
Subscript operator for the direct access to the column elements.
Definition: SparseColumn.h:548
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant column value.
Definition: SparseColumn.h:373
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2376
Base template for the SubTrait class.
Definition: SubTrait.h:141
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
bool canAlias(const Other *alias) const
Returns whether the sparse column can alias with the given address alias.
Definition: SparseColumn.h:1351
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse column.
Definition: SparseColumn.h:1323
bool isAliased(const Other *alias) const
Returns whether the sparse column is aliased with the given address alias.
Definition: SparseColumn.h:1371
size_t extendCapacity() const
Calculating a new sparse column capacity.
Definition: SparseColumn.h:1137
#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
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:2792
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
Reference to a specific column of a sparse matrix.The SparseColumn template represents a reference to...
Definition: Forward.h:51
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.