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>
56 #include <blaze/math/Functions.h>
58 #include <blaze/math/shims/Reset.h>
70 #include <blaze/util/Assert.h>
71 #include <blaze/util/DisableIf.h>
72 #include <blaze/util/EnableIf.h>
74 #include <blaze/util/mpl/If.h>
75 #include <blaze/util/mpl/Or.h>
76 #include <blaze/util/Null.h>
77 #include <blaze/util/SelectType.h>
78 #include <blaze/util/Types.h>
82 #include <blaze/util/Unused.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS DEFINITION
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
351 template< typename MT // Type of the sparse matrix
352  , bool SO = IsColumnMajorMatrix<MT>::value // Storage order
353  , bool SF = IsSymmetric<MT>::value > // Symmetry flag
354 class SparseColumn : public SparseVector< SparseColumn<MT,SO,SF>, false >
355  , private Column
356 {
357  private:
358  //**Type definitions****************************************************************************
360  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
361  //**********************************************************************************************
362 
363  //**********************************************************************************************
365 
371  enum { useConst = IsConst<MT>::value };
372  //**********************************************************************************************
373 
374  public:
375  //**Type definitions****************************************************************************
379  typedef typename MT::ElementType ElementType;
380  typedef typename MT::ReturnType ReturnType;
381  typedef const SparseColumn& CompositeType;
382 
385 
388 
391 
394  //**********************************************************************************************
395 
396  //**Compilation flags***************************************************************************
398  enum { smpAssignable = 0 };
399  //**********************************************************************************************
400 
401  //**Constructors********************************************************************************
404  explicit inline SparseColumn( MT& matrix, size_t index );
405  // No explicitly declared copy constructor.
407  //**********************************************************************************************
408 
409  //**Destructor**********************************************************************************
410  // No explicitly declared destructor.
411  //**********************************************************************************************
412 
413  //**Data access functions***********************************************************************
416  inline Reference operator[]( size_t index );
417  inline ConstReference operator[]( size_t index ) const;
418  inline Iterator begin ();
419  inline ConstIterator begin () const;
420  inline ConstIterator cbegin() const;
421  inline Iterator end ();
422  inline ConstIterator end () const;
423  inline ConstIterator cend () const;
425  //**********************************************************************************************
426 
427  //**Assignment operators************************************************************************
430  inline SparseColumn& operator= ( const SparseColumn& rhs );
431  template< typename VT > inline SparseColumn& operator= ( const DenseVector <VT,false>& rhs );
432  template< typename VT > inline SparseColumn& operator= ( const SparseVector<VT,false>& rhs );
433  template< typename VT > inline SparseColumn& operator+=( const Vector<VT,false>& rhs );
434  template< typename VT > inline SparseColumn& operator-=( const Vector<VT,false>& rhs );
435  template< typename VT > inline SparseColumn& operator*=( const Vector<VT,false>& rhs );
436 
437  template< typename Other >
438  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
439  operator*=( Other rhs );
440 
441  template< typename Other >
442  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
443  operator/=( Other rhs );
445  //**********************************************************************************************
446 
447  //**Utility functions***************************************************************************
450  inline size_t size() const;
451  inline size_t capacity() const;
452  inline size_t nonZeros() const;
453  inline void reset();
454  inline Iterator set ( size_t index, const ElementType& value );
455  inline Iterator insert ( size_t index, const ElementType& value );
456  inline void erase ( size_t index );
457  inline Iterator erase ( Iterator pos );
458  inline Iterator erase ( Iterator first, Iterator last );
459  inline void reserve( size_t n );
460  template< typename Other > inline SparseColumn& scale ( const Other& scalar );
462  //**********************************************************************************************
463 
464  //**Lookup functions****************************************************************************
467  inline Iterator find ( size_t index );
468  inline ConstIterator find ( size_t index ) const;
469  inline Iterator lowerBound( size_t index );
470  inline ConstIterator lowerBound( size_t index ) const;
471  inline Iterator upperBound( size_t index );
472  inline ConstIterator upperBound( size_t index ) const;
474  //**********************************************************************************************
475 
476  //**Low-level utility functions*****************************************************************
479  inline void append( size_t index, const ElementType& value, bool check=false );
481  //**********************************************************************************************
482 
483  //**Expression template evaluation functions****************************************************
486  template< typename Other > inline bool canAlias ( const Other* alias ) const;
487  template< typename Other > inline bool isAliased( const Other* alias ) const;
488 
489  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
490  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
491  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
492  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
493  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
494  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
496  //**********************************************************************************************
497 
498  private:
499  //**Utility functions***************************************************************************
502  inline size_t extendCapacity() const;
504  //**********************************************************************************************
505 
506  //**Member variables****************************************************************************
510  const size_t col_;
511 
512  //**********************************************************************************************
513 
514  //**Friend declarations*************************************************************************
516  template< typename MT2, bool SO2, bool SF2 >
517  friend bool isSame( const SparseColumn<MT2,SO2,SF2>& a, const SparseColumn<MT2,SO2,SF2>& b );
519  //**********************************************************************************************
520 
521  //**Compile time checks*************************************************************************
528  //**********************************************************************************************
529 };
530 //*************************************************************************************************
531 
532 
533 
534 
535 //=================================================================================================
536 //
537 // CONSTRUCTOR
538 //
539 //=================================================================================================
540 
541 //*************************************************************************************************
548 template< typename MT // Type of the sparse matrix
549  , bool SO // Storage order
550  , bool SF > // Symmetry flag
551 inline SparseColumn<MT,SO,SF>::SparseColumn( MT& matrix, size_t index )
552  : matrix_( matrix ) // The sparse matrix containing the column
553  , col_ ( index ) // The index of the column in the matrix
554 {
555  if( matrix_.columns() <= index )
556  throw std::invalid_argument( "Invalid column access index" );
557 }
558 //*************************************************************************************************
559 
560 
561 
562 
563 //=================================================================================================
564 //
565 // DATA ACCESS FUNCTIONS
566 //
567 //=================================================================================================
568 
569 //*************************************************************************************************
575 template< typename MT // Type of the sparse matrix
576  , bool SO // Storage order
577  , bool SF > // Symmetry flag
578 inline typename SparseColumn<MT,SO,SF>::Reference
580 {
581  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
582  return matrix_(index,col_);
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
593 template< typename MT // Type of the sparse matrix
594  , bool SO // Storage order
595  , bool SF > // Symmetry flag
598 {
599  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
600  return const_cast<const MT&>( matrix_ )(index,col_);
601 }
602 //*************************************************************************************************
603 
604 
605 //*************************************************************************************************
612 template< typename MT // Type of the sparse matrix
613  , bool SO // Storage order
614  , bool SF > // Symmetry flag
616 {
617  return matrix_.begin( col_ );
618 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
629 template< typename MT // Type of the sparse matrix
630  , bool SO // Storage order
631  , bool SF > // Symmetry flag
633 {
634  return matrix_.cbegin( col_ );
635 }
636 //*************************************************************************************************
637 
638 
639 //*************************************************************************************************
646 template< typename MT // Type of the sparse matrix
647  , bool SO // Storage order
648  , bool SF > // Symmetry flag
650 {
651  return matrix_.cbegin( col_ );
652 }
653 //*************************************************************************************************
654 
655 
656 //*************************************************************************************************
663 template< typename MT // Type of the sparse matrix
664  , bool SO // Storage order
665  , bool SF > // Symmetry flag
667 {
668  return matrix_.end( col_ );
669 }
670 //*************************************************************************************************
671 
672 
673 //*************************************************************************************************
680 template< typename MT // Type of the sparse matrix
681  , bool SO // Storage order
682  , bool SF > // Symmetry flag
684 {
685  return matrix_.cend( col_ );
686 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
697 template< typename MT // Type of the sparse matrix
698  , bool SO // Storage order
699  , bool SF > // Symmetry flag
701 {
702  return matrix_.cend( col_ );
703 }
704 //*************************************************************************************************
705 
706 
707 
708 
709 //=================================================================================================
710 //
711 // ASSIGNMENT OPERATORS
712 //
713 //=================================================================================================
714 
715 //*************************************************************************************************
725 template< typename MT // Type of the sparse matrix
726  , bool SO // Storage order
727  , bool SF > // Symmetry flag
729 {
730  using blaze::assign;
731 
735 
736  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
737  return *this;
738 
739  if( size() != rhs.size() )
740  throw std::invalid_argument( "Column sizes do not match" );
741 
742  if( rhs.canAlias( &matrix_ ) ) {
743  const ResultType tmp( rhs );
744  matrix_.reset ( col_ );
745  matrix_.reserve( col_, tmp.nonZeros() );
746  assign( *this, tmp );
747  }
748  else {
749  matrix_.reset ( col_ );
750  matrix_.reserve( col_, rhs.nonZeros() );
751  assign( *this, rhs );
752  }
753 
754  return *this;
755 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
769 template< typename MT // Type of the sparse matrix
770  , bool SO // Storage order
771  , bool SF > // Symmetry flag
772 template< typename VT > // Type of the right-hand side dense vector
774 {
775  using blaze::assign;
776 
780 
781  if( size() != (~rhs).size() )
782  throw std::invalid_argument( "Vector sizes do not match" );
783 
784  if( (~rhs).canAlias( &matrix_ ) ) {
785  const typename VT::ResultType tmp( ~rhs );
786  matrix_.reset( col_ );
787  assign( *this, tmp );
788  }
789  else {
790  matrix_.reset( col_ );
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  , bool SF > // Symmetry flag
812 template< typename VT > // Type of the right-hand side sparse vector
814 {
815  using blaze::assign;
816 
817  if( size() != (~rhs).size() )
818  throw std::invalid_argument( "Vector sizes do not match" );
819 
823 
824  if( (~rhs).canAlias( &matrix_ ) ) {
825  const typename VT::ResultType tmp( ~rhs );
826  matrix_.reset ( col_ );
827  matrix_.reserve( col_, tmp.nonZeros() );
828  assign( *this, tmp );
829  }
830  else {
831  matrix_.reset ( col_ );
832  matrix_.reserve( col_, (~rhs).nonZeros() );
833  assign( *this, ~rhs );
834  }
835 
836  return *this;
837 }
838 //*************************************************************************************************
839 
840 
841 //*************************************************************************************************
851 template< typename MT // Type of the sparse matrix
852  , bool SO // Storage order
853  , bool SF > // Symmetry flag
854 template< typename VT > // Type of the right-hand side vector
856 {
857  using blaze::addAssign;
858 
859  if( size() != (~rhs).size() )
860  throw std::invalid_argument( "Vector sizes do not match" );
861 
862  addAssign( *this, ~rhs );
863 
864  return *this;
865 }
866 //*************************************************************************************************
867 
868 
869 //*************************************************************************************************
879 template< typename MT // Type of the sparse matrix
880  , bool SO // Storage order
881  , bool SF > // Symmetry flag
882 template< typename VT > // Type of the right-hand side vector
884 {
885  using blaze::subAssign;
886 
887  if( size() != (~rhs).size() )
888  throw std::invalid_argument( "Vector sizes do not match" );
889 
890  subAssign( *this, ~rhs );
891 
892  return *this;
893 }
894 //*************************************************************************************************
895 
896 
897 //*************************************************************************************************
908 template< typename MT // Type of the sparse matrix
909  , bool SO // Storage order
910  , bool SF > // Symmetry flag
911 template< typename VT > // Type of the right-hand side vector
913 {
914  if( size() != (~rhs).size() )
915  throw std::invalid_argument( "Vector sizes do not match" );
916 
917  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
918 
921 
922  const MultType tmp( *this * (~rhs) );
923  matrix_.reset( col_ );
924  assign( tmp );
925 
926  return *this;
927 }
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
942 template< typename MT // Type of the sparse matrix
943  , bool SO // Storage order
944  , bool SF > // Symmetry flag
945 template< typename Other > // Data type of the right-hand side scalar
946 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,SO,SF> >::Type&
948 {
949  for( Iterator element=begin(); element!=end(); ++element )
950  element->value() *= rhs;
951  return *this;
952 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
968 template< typename MT // Type of the sparse matrix
969  , bool SO // Storage order
970  , bool SF > // Symmetry flag
971 template< typename Other > // Data type of the right-hand side scalar
972 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,SO,SF> >::Type&
974 {
975  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
976 
977  typedef typename DivTrait<ElementType,Other>::Type DT;
978  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
979 
980  // Depending on the two involved data types, an integer division is applied or a
981  // floating point division is selected.
983  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
984  for( Iterator element=begin(); element!=end(); ++element )
985  element->value() *= tmp;
986  }
987  else {
988  for( Iterator element=begin(); element!=end(); ++element )
989  element->value() /= rhs;
990  }
991 
992  return *this;
993 }
994 //*************************************************************************************************
995 
996 
997 
998 
999 //=================================================================================================
1000 //
1001 // UTILITY FUNCTIONS
1002 //
1003 //=================================================================================================
1004 
1005 //*************************************************************************************************
1010 template< typename MT // Type of the sparse matrix
1011  , bool SO // Storage order
1012  , bool SF > // Symmetry flag
1013 inline size_t SparseColumn<MT,SO,SF>::size() const
1014 {
1015  return matrix_.rows();
1016 }
1017 //*************************************************************************************************
1018 
1019 
1020 //*************************************************************************************************
1025 template< typename MT // Type of the sparse matrix
1026  , bool SO // Storage order
1027  , bool SF > // Symmetry flag
1029 {
1030  return matrix_.capacity( col_ );
1031 }
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1043 template< typename MT // Type of the sparse matrix
1044  , bool SO // Storage order
1045  , bool SF > // Symmetry flag
1047 {
1048  return matrix_.nonZeros( col_ );
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1058 template< typename MT // Type of the sparse matrix
1059  , bool SO // Storage order
1060  , bool SF > // Symmetry flag
1062 {
1063  matrix_.reset( col_ );
1064 }
1065 //*************************************************************************************************
1066 
1067 
1068 //*************************************************************************************************
1079 template< typename MT // Type of the sparse matrix
1080  , bool SO // Storage order
1081  , bool SF > // Symmetry flag
1082 inline typename SparseColumn<MT,SO,SF>::Iterator
1083  SparseColumn<MT,SO,SF>::set( size_t index, const ElementType& value )
1084 {
1085  return matrix_.set( index, col_, value );
1086 }
1087 //*************************************************************************************************
1088 
1089 
1090 //*************************************************************************************************
1102 template< typename MT // Type of the sparse matrix
1103  , bool SO // Storage order
1104  , bool SF > // Symmetry flag
1105 inline typename SparseColumn<MT,SO,SF>::Iterator
1106  SparseColumn<MT,SO,SF>::insert( size_t index, const ElementType& value )
1107 {
1108  return matrix_.insert( index, col_, value );
1109 }
1110 //*************************************************************************************************
1111 
1112 
1113 //*************************************************************************************************
1121 template< typename MT // Type of the sparse matrix
1122  , bool SO // Storage order
1123  , bool SF > // Symmetry flag
1124 inline void SparseColumn<MT,SO,SF>::erase( size_t index )
1125 {
1126  matrix_.erase( index, col_ );
1127 }
1128 //*************************************************************************************************
1129 
1130 
1131 //*************************************************************************************************
1139 template< typename MT // Type of the sparse matrix
1140  , bool SO // Storage order
1141  , bool SF > // Symmetry flag
1143 {
1144  return matrix_.erase( col_, pos );
1145 }
1146 //*************************************************************************************************
1147 
1148 
1149 //*************************************************************************************************
1158 template< typename MT // Type of the sparse matrix
1159  , bool SO // Storage order
1160  , bool SF > // Symmetry flag
1161 inline typename SparseColumn<MT,SO,SF>::Iterator
1163 {
1164  return matrix_.erase( col_, first, last );
1165 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1178 template< typename MT // Type of the sparse matrix
1179  , bool SO // Storage order
1180  , bool SF > // Symmetry flag
1182 {
1183  matrix_.reserve( col_, n );
1184 }
1185 //*************************************************************************************************
1186 
1187 
1188 //*************************************************************************************************
1194 template< typename MT // Type of the sparse matrix
1195  , bool SO // Storage order
1196  , bool SF > // Symmetry flag
1197 template< typename Other > // Data type of the scalar value
1199 {
1200  for( Iterator element=begin(); element!=end(); ++element )
1201  element->value() *= scalar;
1202  return *this;
1203 }
1204 //*************************************************************************************************
1205 
1206 
1207 //*************************************************************************************************
1215 template< typename MT // Type of the sparse matrix
1216  , bool SO // Storage order
1217  , bool SF > // Symmetry flag
1219 {
1220  using blaze::max;
1221  using blaze::min;
1222 
1223  size_t nonzeros( 2UL*capacity()+1UL );
1224  nonzeros = max( nonzeros, 7UL );
1225  nonzeros = min( nonzeros, size() );
1226 
1227  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1228 
1229  return nonzeros;
1230 }
1231 //*************************************************************************************************
1232 
1233 
1234 
1235 
1236 //=================================================================================================
1237 //
1238 // LOOKUP FUNCTIONS
1239 //
1240 //=================================================================================================
1241 
1242 //*************************************************************************************************
1255 template< typename MT // Type of the sparse matrix
1256  , bool SO // Storage order
1257  , bool SF > // Symmetry flag
1259 {
1260  return matrix_.find( index, col_ );
1261 }
1262 //*************************************************************************************************
1263 
1264 
1265 //*************************************************************************************************
1278 template< typename MT // Type of the sparse matrix
1279  , bool SO // Storage order
1280  , bool SF > // Symmetry flag
1282  SparseColumn<MT,SO,SF>::find( size_t index ) const
1283 {
1284  return matrix_.find( index, col_ );
1285 }
1286 //*************************************************************************************************
1287 
1288 
1289 //*************************************************************************************************
1301 template< typename MT // Type of the sparse matrix
1302  , bool SO // Storage order
1303  , bool SF > // Symmetry flag
1305 {
1306  return matrix_.lowerBound( index, col_ );
1307 }
1308 //*************************************************************************************************
1309 
1310 
1311 //*************************************************************************************************
1323 template< typename MT // Type of the sparse matrix
1324  , bool SO // Storage order
1325  , bool SF > // Symmetry flag
1328 {
1329  return matrix_.lowerBound( index, col_ );
1330 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1346 template< typename MT // Type of the sparse matrix
1347  , bool SO // Storage order
1348  , bool SF > // Symmetry flag
1350 {
1351  return matrix_.upperBound( index, col_ );
1352 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1368 template< typename MT // Type of the sparse matrix
1369  , bool SO // Storage order
1370  , bool SF > // Symmetry flag
1373 {
1374  return matrix_.upperBound( index, col_ );
1375 }
1376 //*************************************************************************************************
1377 
1378 
1379 
1380 
1381 //=================================================================================================
1382 //
1383 // LOW-LEVEL UTILITY FUNCTIONS
1384 //
1385 //=================================================================================================
1386 
1387 //*************************************************************************************************
1411 template< typename MT // Type of the sparse matrix
1412  , bool SO // Storage order
1413  , bool SF > // Symmetry flag
1414 inline void SparseColumn<MT,SO,SF>::append( size_t index, const ElementType& value, bool check )
1415 {
1416  matrix_.append( index, col_, value, check );
1417 }
1418 //*************************************************************************************************
1419 
1420 
1421 
1422 
1423 //=================================================================================================
1424 //
1425 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1426 //
1427 //=================================================================================================
1428 
1429 //*************************************************************************************************
1439 template< typename MT // Type of the sparse matrix
1440  , bool SO // Storage order
1441  , bool SF > // Symmetry flag
1442 template< typename Other > // Data type of the foreign expression
1443 inline bool SparseColumn<MT,SO,SF>::canAlias( const Other* alias ) const
1444 {
1445  return matrix_.isAliased( alias );
1446 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1460 template< typename MT // Type of the sparse matrix
1461  , bool SO // Storage order
1462  , bool SF > // Symmetry flag
1463 template< typename Other > // Data type of the foreign expression
1464 inline bool SparseColumn<MT,SO,SF>::isAliased( const Other* alias ) const
1465 {
1466  return matrix_.isAliased( alias );
1467 }
1468 //*************************************************************************************************
1469 
1470 
1471 //*************************************************************************************************
1482 template< typename MT // Type of the sparse matrix
1483  , bool SO // Storage order
1484  , bool SF > // Symmetry flag
1485 template< typename VT > // Type of the right-hand side dense vector
1487 {
1488  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1489  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1490 
1491  for( size_t i=0UL; i<size(); ++i )
1492  {
1493  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
1494  matrix_.reserve( col_, extendCapacity() );
1495 
1496  matrix_.append( i, col_, (~rhs)[i], true );
1497  }
1498 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1513 template< typename MT // Type of the sparse matrix
1514  , bool SO // Storage order
1515  , bool SF > // Symmetry flag
1516 template< typename VT > // Type of the right-hand side sparse vector
1518 {
1519  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1520  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1521 
1522  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1523  matrix_.append( element->index(), col_, element->value() );
1524  }
1525 }
1526 //*************************************************************************************************
1527 
1528 
1529 //*************************************************************************************************
1540 template< typename MT // Type of the sparse matrix
1541  , bool SO // Storage order
1542  , bool SF > // Symmetry flag
1543 template< typename VT > // Type of the right-hand side dense vector
1545 {
1546  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1547 
1551 
1552  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1553 
1554  const AddType tmp( serial( *this + (~rhs) ) );
1555  matrix_.reset( col_ );
1556  assign( tmp );
1557 }
1558 //*************************************************************************************************
1559 
1560 
1561 //*************************************************************************************************
1572 template< typename MT // Type of the sparse matrix
1573  , bool SO // Storage order
1574  , bool SF > // Symmetry flag
1575 template< typename VT > // Type of the right-hand side sparse vector
1577 {
1578  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1579 
1583 
1584  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1585 
1586  const AddType tmp( serial( *this + (~rhs) ) );
1587  matrix_.reset ( col_ );
1588  matrix_.reserve( col_, tmp.nonZeros() );
1589  assign( tmp );
1590 }
1591 //*************************************************************************************************
1592 
1593 
1594 //*************************************************************************************************
1605 template< typename MT // Type of the sparse matrix
1606  , bool SO // Storage order
1607  , bool SF > // Symmetry flag
1608 template< typename VT > // Type of the right-hand side dense vector
1610 {
1611  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1612 
1616 
1617  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1618 
1619  const SubType tmp( serial( *this - (~rhs) ) );
1620  matrix_.reset( col_ );
1621  assign( tmp );
1622 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1637 template< typename MT // Type of the sparse matrix
1638  , bool SO // Storage order
1639  , bool SF > // Symmetry flag
1640 template< typename VT > // Type of the right-hand side sparse vector
1642 {
1643  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1644 
1648 
1649  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1650 
1651  const SubType tmp( serial( *this - (~rhs) ) );
1652  matrix_.reset ( col_ );
1653  matrix_.reserve( col_, tmp.nonZeros() );
1654  assign( tmp );
1655 }
1656 //*************************************************************************************************
1657 
1658 
1659 
1660 
1661 
1662 
1663 
1664 
1665 //=================================================================================================
1666 //
1667 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL ROW-MAJOR MATRICES
1668 //
1669 //=================================================================================================
1670 
1671 //*************************************************************************************************
1679 template< typename MT > // Type of the sparse matrix
1680 class SparseColumn<MT,false,false> : public SparseVector< SparseColumn<MT,false,false>, false >
1681  , private Column
1682 {
1683  private:
1684  //**Type definitions****************************************************************************
1686  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1687  //**********************************************************************************************
1688 
1689  //**********************************************************************************************
1691 
1697  enum { useConst = IsConst<MT>::value };
1698  //**********************************************************************************************
1699 
1700  public:
1701  //**Type definitions****************************************************************************
1702  typedef SparseColumn<MT,false,false> This;
1703  typedef typename ColumnTrait<MT>::Type ResultType;
1704  typedef typename ResultType::TransposeType TransposeType;
1705  typedef typename MT::ElementType ElementType;
1706  typedef typename MT::ReturnType ReturnType;
1707  typedef const ResultType CompositeType;
1708 
1710  typedef typename MT::ConstReference ConstReference;
1711 
1713  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1714  //**********************************************************************************************
1715 
1716  //**ColumnElement class definition**************************************************************
1719  template< typename MatrixType // Type of the sparse matrix
1720  , typename IteratorType > // Type of the sparse matrix iterator
1721  class ColumnElement : private SparseElement
1722  {
1723  private:
1724  //*******************************************************************************************
1726 
1731  enum { returnConst = IsConst<MatrixType>::value };
1732  //*******************************************************************************************
1733 
1734  //**Type definitions*************************************************************************
1736  typedef typename std::iterator_traits<IteratorType>::value_type SET;
1737 
1738  typedef typename SET::Reference RT;
1739  typedef typename SET::ConstReference CRT;
1740  //*******************************************************************************************
1741 
1742  public:
1743  //**Type definitions*************************************************************************
1744  typedef typename SET::ValueType ValueType;
1745  typedef size_t IndexType;
1746  typedef typename SelectType<returnConst,CRT,RT>::Type Reference;
1747  typedef CRT ConstReference;
1748  //*******************************************************************************************
1749 
1750  //**Constructor******************************************************************************
1756  inline ColumnElement( IteratorType pos, size_t row )
1757  : pos_( pos ) // Iterator to the current position within the sparse column
1758  , row_( row ) // Index of the according row
1759  {}
1760  //*******************************************************************************************
1761 
1762  //**Assignment operator**********************************************************************
1768  template< typename T > inline ColumnElement& operator=( const T& v ) {
1769  *pos_ = v;
1770  return *this;
1771  }
1772  //*******************************************************************************************
1773 
1774  //**Addition assignment operator*************************************************************
1780  template< typename T > inline ColumnElement& operator+=( const T& v ) {
1781  *pos_ += v;
1782  return *this;
1783  }
1784  //*******************************************************************************************
1785 
1786  //**Subtraction assignment operator**********************************************************
1792  template< typename T > inline ColumnElement& operator-=( const T& v ) {
1793  *pos_ -= v;
1794  return *this;
1795  }
1796  //*******************************************************************************************
1797 
1798  //**Multiplication assignment operator*******************************************************
1804  template< typename T > inline ColumnElement& operator*=( const T& v ) {
1805  *pos_ *= v;
1806  return *this;
1807  }
1808  //*******************************************************************************************
1809 
1810  //**Division assignment operator*************************************************************
1816  template< typename T > inline ColumnElement& operator/=( const T& v ) {
1817  *pos_ /= v;
1818  return *this;
1819  }
1820  //*******************************************************************************************
1821 
1822  //**Element access operator******************************************************************
1827  inline const ColumnElement* operator->() const {
1828  return this;
1829  }
1830  //*******************************************************************************************
1831 
1832  //**Value function***************************************************************************
1837  inline Reference value() const {
1838  return pos_->value();
1839  }
1840  //*******************************************************************************************
1841 
1842  //**Index function***************************************************************************
1847  inline IndexType index() const {
1848  return row_;
1849  }
1850  //*******************************************************************************************
1851 
1852  private:
1853  //**Member variables*************************************************************************
1854  IteratorType pos_;
1855  size_t row_;
1856  //*******************************************************************************************
1857  };
1858  //**********************************************************************************************
1859 
1860  //**ColumnIterator class definition*************************************************************
1863  template< typename MatrixType // Type of the sparse matrix
1864  , typename IteratorType > // Type of the sparse matrix iterator
1865  class ColumnIterator
1866  {
1867  public:
1868  //**Type definitions*************************************************************************
1869  typedef std::forward_iterator_tag IteratorCategory;
1870  typedef ColumnElement<MatrixType,IteratorType> ValueType;
1871  typedef ValueType PointerType;
1872  typedef ValueType ReferenceType;
1873  typedef ptrdiff_t DifferenceType;
1874 
1875  // STL iterator requirements
1876  typedef IteratorCategory iterator_category;
1877  typedef ValueType value_type;
1878  typedef PointerType pointer;
1879  typedef ReferenceType reference;
1880  typedef DifferenceType difference_type;
1881  //*******************************************************************************************
1882 
1883  //**Constructor******************************************************************************
1886  inline ColumnIterator()
1887  : matrix_( NULL ) // The sparse matrix containing the column.
1888  , row_ ( 0UL ) // The current row index.
1889  , column_( 0UL ) // The current column index.
1890  , pos_ () // Iterator to the current sparse element.
1891  {}
1892  //*******************************************************************************************
1893 
1894  //**Constructor******************************************************************************
1901  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column )
1902  : matrix_( &matrix ) // The sparse matrix containing the column.
1903  , row_ ( row ) // The current row index.
1904  , column_( column ) // The current column index.
1905  , pos_ () // Iterator to the current sparse element.
1906  {
1907  for( ; row_<matrix_->rows(); ++row_ ) {
1908  pos_ = matrix_->find( row_, column_ );
1909  if( pos_ != matrix_->end( row_ ) ) break;
1910  }
1911  }
1912  //*******************************************************************************************
1913 
1914  //**Constructor******************************************************************************
1922  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
1923  : matrix_( &matrix ) // The sparse matrix containing the column.
1924  , row_ ( row ) // The current row index.
1925  , column_( column ) // The current column index.
1926  , pos_ ( pos ) // Iterator to the current sparse element.
1927  {
1928  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
1929  }
1930  //*******************************************************************************************
1931 
1932  //**Constructor******************************************************************************
1937  template< typename MatrixType2, typename IteratorType2 >
1938  inline ColumnIterator( const ColumnIterator<MatrixType2,IteratorType2>& it )
1939  : matrix_( it.matrix_ ) // The sparse matrix containing the column.
1940  , row_ ( it.row_ ) // The current row index.
1941  , column_( it.column_ ) // The current column index.
1942  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
1943  {}
1944  //*******************************************************************************************
1945 
1946  //**Prefix increment operator****************************************************************
1951  inline ColumnIterator& operator++() {
1952  ++row_;
1953  for( ; row_<matrix_->rows(); ++row_ ) {
1954  pos_ = matrix_->find( row_, column_ );
1955  if( pos_ != matrix_->end( row_ ) ) break;
1956  }
1957 
1958  return *this;
1959  }
1960  //*******************************************************************************************
1961 
1962  //**Postfix increment operator***************************************************************
1967  inline const ColumnIterator operator++( int ) {
1968  const ColumnIterator tmp( *this );
1969  ++(*this);
1970  return tmp;
1971  }
1972  //*******************************************************************************************
1973 
1974  //**Element access operator******************************************************************
1979  inline ReferenceType operator*() const {
1980  return ReferenceType( pos_, row_ );
1981  }
1982  //*******************************************************************************************
1983 
1984  //**Element access operator******************************************************************
1989  inline PointerType operator->() const {
1990  return PointerType( pos_, row_ );
1991  }
1992  //*******************************************************************************************
1993 
1994  //**Equality operator************************************************************************
2000  template< typename MatrixType2, typename IteratorType2 >
2001  inline bool operator==( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2002  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2003  }
2004  //*******************************************************************************************
2005 
2006  //**Inequality operator**********************************************************************
2012  template< typename MatrixType2, typename IteratorType2 >
2013  inline bool operator!=( const ColumnIterator<MatrixType2,IteratorType2>& rhs ) const {
2014  return !( *this == rhs );
2015  }
2016  //*******************************************************************************************
2017 
2018  //**Subtraction operator*********************************************************************
2024  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
2025  size_t counter( 0UL );
2026  for( size_t i=rhs.row_; i<row_; ++i ) {
2027  if( matrix_->find( i, column_ ) != matrix_->end( i ) )
2028  ++counter;
2029  }
2030  return counter;
2031  }
2032  //*******************************************************************************************
2033 
2034  private:
2035  //**Member variables*************************************************************************
2036  MatrixType* matrix_;
2037  size_t row_;
2038  size_t column_;
2039  IteratorType pos_;
2040  //*******************************************************************************************
2041 
2042  //**Friend declarations**********************************************************************
2043  template< typename MatrixType2, typename IteratorType2 > friend class ColumnIterator;
2044  template< typename MT2, bool SO2, bool SF2 > friend class SparseColumn;
2045  //*******************************************************************************************
2046  };
2047  //**********************************************************************************************
2048 
2049  //**Type definitions****************************************************************************
2051  typedef ColumnIterator<const MT,typename MT::ConstIterator> ConstIterator;
2052 
2054  typedef typename SelectType< useConst, ConstIterator, ColumnIterator<MT,typename MT::Iterator> >::Type Iterator;
2055  //**********************************************************************************************
2056 
2057  //**Compilation flags***************************************************************************
2059  enum { smpAssignable = 0 };
2060  //**********************************************************************************************
2061 
2062  //**Constructors********************************************************************************
2065  explicit inline SparseColumn( MT& matrix, size_t index );
2066  // No explicitly declared copy constructor.
2068  //**********************************************************************************************
2069 
2070  //**Destructor**********************************************************************************
2071  // No explicitly declared destructor.
2072  //**********************************************************************************************
2073 
2074  //**Data access functions***********************************************************************
2077  inline Reference operator[]( size_t index );
2078  inline ConstReference operator[]( size_t index ) const;
2079  inline Iterator begin ();
2080  inline ConstIterator begin () const;
2081  inline ConstIterator cbegin() const;
2082  inline Iterator end ();
2083  inline ConstIterator end () const;
2084  inline ConstIterator cend () const;
2086  //**********************************************************************************************
2087 
2088  //**Assignment operators************************************************************************
2091  inline SparseColumn& operator= ( const SparseColumn& rhs );
2092  template< typename VT > inline SparseColumn& operator= ( const Vector<VT,false>& rhs );
2093  template< typename VT > inline SparseColumn& operator+=( const Vector<VT,false>& rhs );
2094  template< typename VT > inline SparseColumn& operator-=( const Vector<VT,false>& rhs );
2095  template< typename VT > inline SparseColumn& operator*=( const Vector<VT,false>& rhs );
2096 
2097  template< typename Other >
2098  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
2099  operator*=( Other rhs );
2100 
2101  template< typename Other >
2102  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
2103  operator/=( Other rhs );
2105  //**********************************************************************************************
2106 
2107  //**Utility functions***************************************************************************
2110  inline size_t size() const;
2111  inline size_t capacity() const;
2112  inline size_t nonZeros() const;
2113  inline void reset();
2114  inline Iterator set ( size_t index, const ElementType& value );
2115  inline Iterator insert ( size_t index, const ElementType& value );
2116  inline void erase ( size_t index );
2117  inline Iterator erase ( Iterator pos );
2118  inline Iterator erase ( Iterator first, Iterator last );
2119  inline void reserve( size_t n );
2120  template< typename Other > inline SparseColumn& scale ( const Other& scalar );
2122  //**********************************************************************************************
2123 
2124  //**Lookup functions****************************************************************************
2127  inline Iterator find ( size_t index );
2128  inline ConstIterator find ( size_t index ) const;
2129  inline Iterator lowerBound( size_t index );
2130  inline ConstIterator lowerBound( size_t index ) const;
2131  inline Iterator upperBound( size_t index );
2132  inline ConstIterator upperBound( size_t index ) const;
2134  //**********************************************************************************************
2135 
2136  //**Low-level utility functions*****************************************************************
2139  inline void append( size_t index, const ElementType& value, bool check=false );
2141  //**********************************************************************************************
2142 
2143  //**Expression template evaluation functions****************************************************
2146  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2147  template< typename Other > inline bool isAliased( const Other* alias ) const;
2148 
2149  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
2150  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
2151  template< typename VT > inline void addAssign( const Vector<VT,false>& rhs );
2152  template< typename VT > inline void subAssign( const Vector<VT,false>& rhs );
2154  //**********************************************************************************************
2155 
2156  private:
2157  //**Member variables****************************************************************************
2160  Operand matrix_;
2161  const size_t col_;
2162 
2163  //**********************************************************************************************
2164 
2165  //**Friend declarations*************************************************************************
2166  template< typename MT2, bool SO2, bool SF2 >
2167  friend bool isSame( const SparseColumn<MT2,SO2,SF2>& a, const SparseColumn<MT2,SO2,SF2>& b );
2168  //**********************************************************************************************
2169 
2170  //**Compile time checks*************************************************************************
2176  //**********************************************************************************************
2177 };
2179 //*************************************************************************************************
2180 
2181 
2182 
2183 
2184 //=================================================================================================
2185 //
2186 // CONSTRUCTOR
2187 //
2188 //=================================================================================================
2189 
2190 //*************************************************************************************************
2198 template< typename MT > // Type of the sparse matrix
2199 inline SparseColumn<MT,false,false>::SparseColumn( MT& matrix, size_t index )
2200  : matrix_( matrix ) // The sparse matrix containing the column
2201  , col_ ( index ) // The index of the column in the matrix
2202 {
2203  if( matrix_.columns() <= index )
2204  throw std::invalid_argument( "Invalid column access index" );
2205 }
2207 //*************************************************************************************************
2208 
2209 
2210 
2211 
2212 //=================================================================================================
2213 //
2214 // DATA ACCESS FUNCTIONS
2215 //
2216 //=================================================================================================
2217 
2218 //*************************************************************************************************
2225 template< typename MT > // Type of the sparse matrix
2228 {
2229  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2230  return matrix_(index,col_);
2231 }
2233 //*************************************************************************************************
2234 
2235 
2236 //*************************************************************************************************
2243 template< typename MT > // Type of the sparse matrix
2245  SparseColumn<MT,false,false>::operator[]( size_t index ) const
2246 {
2247  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
2248  return const_cast<const MT&>( matrix_ )(index,col_);
2249 }
2251 //*************************************************************************************************
2252 
2253 
2254 //*************************************************************************************************
2262 template< typename MT > // Type of the sparse matrix
2264 {
2265  return Iterator( matrix_, 0UL, col_ );
2266 }
2268 //*************************************************************************************************
2269 
2270 
2271 //*************************************************************************************************
2279 template< typename MT > // Type of the sparse matrix
2282 {
2283  return ConstIterator( matrix_, 0UL, col_ );
2284 }
2286 //*************************************************************************************************
2287 
2288 
2289 //*************************************************************************************************
2297 template< typename MT > // Type of the sparse matrix
2300 {
2301  return ConstIterator( matrix_, 0UL, col_ );
2302 }
2304 //*************************************************************************************************
2305 
2306 
2307 //*************************************************************************************************
2315 template< typename MT > // Type of the sparse matrix
2317 {
2318  return Iterator( matrix_, size(), col_ );
2319 }
2321 //*************************************************************************************************
2322 
2323 
2324 //*************************************************************************************************
2332 template< typename MT > // Type of the sparse matrix
2335 {
2336  return ConstIterator( matrix_, size(), col_ );
2337 }
2339 //*************************************************************************************************
2340 
2341 
2342 //*************************************************************************************************
2350 template< typename MT > // Type of the sparse matrix
2353 {
2354  return ConstIterator( matrix_, size(), col_ );
2355 }
2357 //*************************************************************************************************
2358 
2359 
2360 
2361 
2362 //=================================================================================================
2363 //
2364 // ASSIGNMENT OPERATORS
2365 //
2366 //=================================================================================================
2367 
2368 //*************************************************************************************************
2379 template< typename MT > // Type of the sparse matrix
2380 inline SparseColumn<MT,false,false>&
2381  SparseColumn<MT,false,false>::operator=( const SparseColumn& rhs )
2382 {
2383  using blaze::assign;
2384 
2388 
2389  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
2390  return *this;
2391 
2392  if( size() != rhs.size() )
2393  throw std::invalid_argument( "Column sizes do not match" );
2394 
2395  if( rhs.canAlias( &matrix_ ) ) {
2396  const ResultType tmp( rhs );
2397  assign( *this, tmp );
2398  }
2399  else {
2400  assign( *this, rhs );
2401  }
2402 
2403  return *this;
2404 }
2406 //*************************************************************************************************
2407 
2408 
2409 //*************************************************************************************************
2420 template< typename MT > // Type of the sparse matrix
2421 template< typename VT > // Type of the right-hand side vector
2422 inline SparseColumn<MT,false,false>&
2423  SparseColumn<MT,false,false>::operator=( const Vector<VT,false>& rhs )
2424 {
2425  using blaze::assign;
2426 
2427  if( size() != (~rhs).size() )
2428  throw std::invalid_argument( "Vector sizes do not match" );
2429 
2430  const typename VT::CompositeType tmp( ~rhs );
2431  assign( *this, tmp );
2432 
2433  return *this;
2434 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2450 template< typename MT > // Type of the sparse matrix
2451 template< typename VT > // Type of the right-hand side vector
2452 inline SparseColumn<MT,false,false>&
2453  SparseColumn<MT,false,false>::operator+=( const Vector<VT,false>& rhs )
2454 {
2455  using blaze::addAssign;
2456 
2457  if( size() != (~rhs).size() )
2458  throw std::invalid_argument( "Vector sizes do not match" );
2459 
2460  addAssign( *this, ~rhs );
2461 
2462  return *this;
2463 }
2465 //*************************************************************************************************
2466 
2467 
2468 //*************************************************************************************************
2479 template< typename MT > // Type of the sparse matrix
2480 template< typename VT > // Type of the right-hand side vector
2481 inline SparseColumn<MT,false,false>&
2482  SparseColumn<MT,false,false>::operator-=( const Vector<VT,false>& rhs )
2483 {
2484  using blaze::subAssign;
2485 
2486  if( size() != (~rhs).size() )
2487  throw std::invalid_argument( "Vector sizes do not match" );
2488 
2489  subAssign( *this, ~rhs );
2490 
2491  return *this;
2492 }
2494 //*************************************************************************************************
2495 
2496 
2497 //*************************************************************************************************
2509 template< typename MT > // Type of the sparse matrix
2510 template< typename VT > // Type of the right-hand side vector
2511 inline SparseColumn<MT,false,false>&
2512  SparseColumn<MT,false,false>::operator*=( const Vector<VT,false>& rhs )
2513 {
2514  if( size() != (~rhs).size() )
2515  throw std::invalid_argument( "Vector sizes do not match" );
2516 
2517  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
2518 
2521 
2522  const MultType tmp( *this * (~rhs) );
2523  assign( tmp );
2524 
2525  return *this;
2526 }
2528 //*************************************************************************************************
2529 
2530 
2531 //*************************************************************************************************
2543 template< typename MT > // Type of the sparse matrix
2544 template< typename Other > // Data type of the right-hand side scalar
2545 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
2546  SparseColumn<MT,false,false>::operator*=( Other rhs )
2547 {
2548  for( Iterator element=begin(); element!=end(); ++element )
2549  element->value() *= rhs;
2550  return *this;
2551 }
2553 //*************************************************************************************************
2554 
2555 
2556 //*************************************************************************************************
2569 template< typename MT > // Type of the sparse matrix
2570 template< typename Other > // Data type of the right-hand side scalar
2571 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,false> >::Type&
2572  SparseColumn<MT,false,false>::operator/=( Other rhs )
2573 {
2574  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2575 
2576  typedef typename DivTrait<ElementType,Other>::Type DT;
2577  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2578 
2579  // Depending on the two involved data types, an integer division is applied or a
2580  // floating point division is selected.
2581  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2582  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2583  for( Iterator element=begin(); element!=end(); ++element )
2584  element->value() *= tmp;
2585  }
2586  else {
2587  for( Iterator element=begin(); element!=end(); ++element )
2588  element->value() /= rhs;
2589  }
2590 
2591  return *this;
2592 }
2594 //*************************************************************************************************
2595 
2596 
2597 
2598 
2599 //=================================================================================================
2600 //
2601 // UTILITY FUNCTIONS
2602 //
2603 //=================================================================================================
2604 
2605 //*************************************************************************************************
2611 template< typename MT > // Type of the sparse matrix
2612 inline size_t SparseColumn<MT,false,false>::size() const
2613 {
2614  return matrix_.rows();
2615 }
2617 //*************************************************************************************************
2618 
2619 
2620 //*************************************************************************************************
2626 template< typename MT > // Type of the sparse matrix
2627 inline size_t SparseColumn<MT,false,false>::capacity() const
2628 {
2629  return matrix_.rows();
2630 }
2632 //*************************************************************************************************
2633 
2634 
2635 //*************************************************************************************************
2644 template< typename MT > // Type of the sparse matrix
2645 inline size_t SparseColumn<MT,false,false>::nonZeros() const
2646 {
2647  size_t counter( 0UL );
2648  for( ConstIterator element=begin(); element!=end(); ++element ) {
2649  ++counter;
2650  }
2651  return counter;
2652 }
2654 //*************************************************************************************************
2655 
2656 
2657 //*************************************************************************************************
2663 template< typename MT > // Type of the sparse matrix
2665 {
2666  for( size_t i=0UL; i<size(); ++i ) {
2667  matrix_.erase( i, col_ );
2668  }
2669 }
2671 //*************************************************************************************************
2672 
2673 
2674 //*************************************************************************************************
2686 template< typename MT > // Type of the sparse matrix
2688  SparseColumn<MT,false,false>::set( size_t index, const ElementType& value )
2689 {
2690  return Iterator( matrix_, index, col_, matrix_.set( index, col_, value ) );
2691 }
2693 //*************************************************************************************************
2694 
2695 
2696 //*************************************************************************************************
2709 template< typename MT > // Type of the sparse matrix
2711  SparseColumn<MT,false,false>::insert( size_t index, const ElementType& value )
2712 {
2713  return Iterator( matrix_, index, col_, matrix_.insert( index, col_, value ) );
2714 }
2716 //*************************************************************************************************
2717 
2718 
2719 //*************************************************************************************************
2728 template< typename MT > // Type of the sparse matrix
2729 inline void SparseColumn<MT,false,false>::erase( size_t index )
2730 {
2731  matrix_.erase( index, col_ );
2732 }
2734 //*************************************************************************************************
2735 
2736 
2737 //*************************************************************************************************
2746 template< typename MT > // Type of the sparse matrix
2749 {
2750  const size_t row( pos.row_ );
2751 
2752  if( row == size() )
2753  return pos;
2754 
2755  matrix_.erase( row, pos.pos_ );
2756  return Iterator( matrix_, row+1UL, col_ );
2757 }
2759 //*************************************************************************************************
2760 
2761 
2762 //*************************************************************************************************
2772 template< typename MT > // Type of the sparse matrix
2775 {
2776  for( ; first!=last; ++first ) {
2777  matrix_.erase( first.row_, first.pos_ );
2778  }
2779  return last;
2780 }
2782 //*************************************************************************************************
2783 
2784 
2785 //*************************************************************************************************
2795 template< typename MT > // Type of the sparse matrix
2797 {
2798  UNUSED_PARAMETER( n );
2799  return;
2800 }
2802 //*************************************************************************************************
2803 
2804 
2805 //*************************************************************************************************
2812 template< typename MT > // Type of the sparse matrix
2813 template< typename Other > // Data type of the scalar value
2814 inline SparseColumn<MT,false,false>& SparseColumn<MT,false,false>::scale( const Other& scalar )
2815 {
2816  for( Iterator element=begin(); element!=end(); ++element )
2817  element->value() *= scalar;
2818  return *this;
2819 }
2821 //*************************************************************************************************
2822 
2823 
2824 
2825 
2826 //=================================================================================================
2827 //
2828 // LOOKUP FUNCTIONS
2829 //
2830 //=================================================================================================
2831 
2832 //*************************************************************************************************
2846 template< typename MT > // Type of the sparse matrix
2848  SparseColumn<MT,false,false>::find( size_t index )
2849 {
2850  const typename MT::Iterator pos( matrix_.find( index, col_ ) );
2851 
2852  if( pos != matrix_.end( index ) )
2853  return Iterator( matrix_, index, col_, pos );
2854  else
2855  return end();
2856 }
2858 //*************************************************************************************************
2859 
2860 
2861 //*************************************************************************************************
2875 template< typename MT > // Type of the sparse matrix
2877  SparseColumn<MT,false,false>::find( size_t index ) const
2878 {
2879  const typename MT::ConstIterator pos( matrix_.find( index, col_ ) );
2880 
2881  if( pos != matrix_.end( index ) )
2882  return ConstIterator( matrix_, index, col_, pos );
2883  else
2884  return end();
2885 }
2887 //*************************************************************************************************
2888 
2889 
2890 //*************************************************************************************************
2903 template< typename MT > // Type of the sparse matrix
2906 {
2907  for( size_t i=index; i<size(); ++i )
2908  {
2909  const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2910 
2911  if( pos != matrix_.end( i ) )
2912  return Iterator( matrix_, i, col_, pos );
2913  }
2914 
2915  return end();
2916 }
2918 //*************************************************************************************************
2919 
2920 
2921 //*************************************************************************************************
2934 template< typename MT > // Type of the sparse matrix
2936  SparseColumn<MT,false,false>::lowerBound( size_t index ) const
2937 {
2938  for( size_t i=index; i<size(); ++i )
2939  {
2940  const typename MT::ConstIterator pos( matrix_.find( i, col_ ) );
2941 
2942  if( pos != matrix_.end( i ) )
2943  return ConstIterator( matrix_, i, col_, pos );
2944  }
2945 
2946  return end();
2947 }
2949 //*************************************************************************************************
2950 
2951 
2952 //*************************************************************************************************
2965 template< typename MT > // Type of the sparse matrix
2968 {
2969  for( size_t i=index+1UL; i<size(); ++i )
2970  {
2971  const typename MT::Iterator pos( matrix_.find( i, col_ ) );
2972 
2973  if( pos != matrix_.end( i ) )
2974  return Iterator( matrix_, i, col_, pos );
2975  }
2976 
2977  return end();
2978 }
2980 //*************************************************************************************************
2981 
2982 
2983 //*************************************************************************************************
2996 template< typename MT > // Type of the sparse matrix
2998  SparseColumn<MT,false,false>::upperBound( size_t index ) const
2999 {
3000  for( size_t i=index+1UL; i<size(); ++i )
3001  {
3002  const typename MT::ConstIterator pos( matrix_.find( i, col_ ) );
3003 
3004  if( pos != matrix_.end( i ) )
3005  return ConstIterator( matrix_, i, col_, pos );
3006  }
3007 
3008  return end();
3009 }
3011 //*************************************************************************************************
3012 
3013 
3014 
3015 
3016 //=================================================================================================
3017 //
3018 // LOW-LEVEL UTILITY FUNCTIONS
3019 //
3020 //=================================================================================================
3021 
3022 //*************************************************************************************************
3047 template< typename MT > // Type of the sparse matrix
3048 inline void SparseColumn<MT,false,false>::append( size_t index, const ElementType& value, bool check )
3049 {
3050  if( !check || !isDefault( value ) )
3051  matrix_.insert( index, col_, value );
3052 }
3054 //*************************************************************************************************
3055 
3056 
3057 
3058 
3059 //=================================================================================================
3060 //
3061 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3062 //
3063 //=================================================================================================
3064 
3065 //*************************************************************************************************
3076 template< typename MT > // Type of the sparse matrix
3077 template< typename Other > // Data type of the foreign expression
3078 inline bool SparseColumn<MT,false,false>::canAlias( const Other* alias ) const
3079 {
3080  return matrix_.isAliased( alias );
3081 }
3083 //*************************************************************************************************
3084 
3085 
3086 //*************************************************************************************************
3093 template< typename MT > // Type of the sparse matrix
3094 template< typename Other > // Data type of the foreign expression
3095 inline bool SparseColumn<MT,false,false>::isAliased( const Other* alias ) const
3096 {
3097  return matrix_.isAliased( alias );
3098 }
3100 //*************************************************************************************************
3101 
3102 
3103 //*************************************************************************************************
3115 template< typename MT > // Type of the sparse matrix
3116 template< typename VT > // Type of the right-hand side dense vector
3117 inline void SparseColumn<MT,false,false>::assign( const DenseVector<VT,false>& rhs )
3118 {
3119  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3120 
3121  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
3122  matrix_(i,col_) = (~rhs)[i];
3123  }
3124 }
3126 //*************************************************************************************************
3127 
3128 
3129 //*************************************************************************************************
3141 template< typename MT > // Type of the sparse matrix
3142 template< typename VT > // Type of the right-hand side sparse vector
3143 inline void SparseColumn<MT,false,false>::assign( const SparseVector<VT,false>& rhs )
3144 {
3145  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3146 
3147  size_t i( 0UL );
3148 
3149  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
3150  for( ; i<element->index(); ++i )
3151  matrix_.erase( i, col_ );
3152  matrix_(i++,col_) = element->value();
3153  }
3154  for( ; i<size(); ++i ) {
3155  matrix_.erase( i, col_ );
3156  }
3157 }
3159 //*************************************************************************************************
3160 
3161 
3162 //*************************************************************************************************
3174 template< typename MT > // Type of the sparse matrix
3175 template< typename VT > // Type of the right-hand side vector
3176 inline void SparseColumn<MT,false,false>::addAssign( const Vector<VT,false>& rhs )
3177 {
3178  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3179 
3182 
3183  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3184 
3185  const AddType tmp( serial( *this + (~rhs) ) );
3186  assign( tmp );
3187 }
3189 //*************************************************************************************************
3190 
3191 
3192 //*************************************************************************************************
3204 template< typename MT > // Type of the sparse matrix
3205 template< typename VT > // Type of the right-hand side vector
3206 inline void SparseColumn<MT,false,false>::subAssign( const Vector<VT,false>& rhs )
3207 {
3208  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3209 
3212 
3213  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3214 
3215  const SubType tmp( serial( *this - (~rhs) ) );
3216  assign( tmp );
3217 }
3219 //*************************************************************************************************
3220 
3221 
3222 
3223 
3224 
3225 
3226 
3227 
3228 //=================================================================================================
3229 //
3230 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC ROW-MAJOR MATRICES
3231 //
3232 //=================================================================================================
3233 
3234 //*************************************************************************************************
3242 template< typename MT > // Type of the sparse matrix
3243 class SparseColumn<MT,false,true> : public SparseVector< SparseColumn<MT,false,true>, false >
3244  , private Column
3245 {
3246  private:
3247  //**Type definitions****************************************************************************
3249  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
3250  //**********************************************************************************************
3251 
3252  //**********************************************************************************************
3254 
3260  enum { useConst = IsConst<MT>::value };
3261  //**********************************************************************************************
3262 
3263  public:
3264  //**Type definitions****************************************************************************
3265  typedef SparseColumn<MT,false,true> This;
3266  typedef typename ColumnTrait<MT>::Type ResultType;
3267  typedef typename ResultType::TransposeType TransposeType;
3268  typedef typename MT::ElementType ElementType;
3269  typedef typename MT::ReturnType ReturnType;
3270  typedef const SparseColumn& CompositeType;
3271 
3273  typedef typename MT::ConstReference ConstReference;
3274 
3276  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
3277 
3279  typedef typename MT::ConstIterator ConstIterator;
3280 
3282  typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator;
3283  //**********************************************************************************************
3284 
3285  //**Compilation flags***************************************************************************
3287  enum { smpAssignable = 0 };
3288  //**********************************************************************************************
3289 
3290  //**Constructors********************************************************************************
3293  explicit inline SparseColumn( MT& matrix, size_t index );
3294  // No explicitly declared copy constructor.
3296  //**********************************************************************************************
3297 
3298  //**Destructor**********************************************************************************
3299  // No explicitly declared destructor.
3300  //**********************************************************************************************
3301 
3302  //**Data access functions***********************************************************************
3305  inline Reference operator[]( size_t index );
3306  inline ConstReference operator[]( size_t index ) const;
3307  inline Iterator begin ();
3308  inline ConstIterator begin () const;
3309  inline ConstIterator cbegin() const;
3310  inline Iterator end ();
3311  inline ConstIterator end () const;
3312  inline ConstIterator cend () const;
3314  //**********************************************************************************************
3315 
3316  //**Assignment operators************************************************************************
3319  inline SparseColumn& operator= ( const SparseColumn& rhs );
3320  template< typename VT > inline SparseColumn& operator= ( const DenseVector <VT,false>& rhs );
3321  template< typename VT > inline SparseColumn& operator= ( const SparseVector<VT,false>& rhs );
3322  template< typename VT > inline SparseColumn& operator+=( const Vector<VT,false>& rhs );
3323  template< typename VT > inline SparseColumn& operator-=( const Vector<VT,false>& rhs );
3324  template< typename VT > inline SparseColumn& operator*=( const Vector<VT,false>& rhs );
3325 
3326  template< typename Other >
3327  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
3328  operator*=( Other rhs );
3329 
3330  template< typename Other >
3331  inline typename EnableIf< IsNumeric<Other>, SparseColumn >::Type&
3332  operator/=( Other rhs );
3334  //**********************************************************************************************
3335 
3336  //**Utility functions***************************************************************************
3339  inline size_t size() const;
3340  inline size_t capacity() const;
3341  inline size_t nonZeros() const;
3342  inline void reset();
3343  inline Iterator set ( size_t index, const ElementType& value );
3344  inline Iterator insert ( size_t index, const ElementType& value );
3345  inline void erase ( size_t index );
3346  inline Iterator erase ( Iterator pos );
3347  inline Iterator erase ( Iterator first, Iterator last );
3348  inline void reserve( size_t n );
3349  template< typename Other > inline SparseColumn& scale ( const Other& scalar );
3351  //**********************************************************************************************
3352 
3353  //**Lookup functions****************************************************************************
3356  inline Iterator find ( size_t index );
3357  inline ConstIterator find ( size_t index ) const;
3358  inline Iterator lowerBound( size_t index );
3359  inline ConstIterator lowerBound( size_t index ) const;
3360  inline Iterator upperBound( size_t index );
3361  inline ConstIterator upperBound( size_t index ) const;
3363  //**********************************************************************************************
3364 
3365  //**Low-level utility functions*****************************************************************
3368  inline void append( size_t index, const ElementType& value, bool check=false );
3370  //**********************************************************************************************
3371 
3372  //**Expression template evaluation functions****************************************************
3375  template< typename Other > inline bool canAlias ( const Other* alias ) const;
3376  template< typename Other > inline bool isAliased( const Other* alias ) const;
3377 
3378  template< typename VT > inline void assign ( const DenseVector <VT,false>& rhs );
3379  template< typename VT > inline void assign ( const SparseVector<VT,false>& rhs );
3380  template< typename VT > inline void addAssign( const DenseVector <VT,false>& rhs );
3381  template< typename VT > inline void addAssign( const SparseVector<VT,false>& rhs );
3382  template< typename VT > inline void subAssign( const DenseVector <VT,false>& rhs );
3383  template< typename VT > inline void subAssign( const SparseVector<VT,false>& rhs );
3385  //**********************************************************************************************
3386 
3387  private:
3388  //**Utility functions***************************************************************************
3391  inline size_t extendCapacity() const;
3393  //**********************************************************************************************
3394 
3395  //**Member variables****************************************************************************
3398  Operand matrix_;
3399  const size_t col_;
3400 
3401  //**********************************************************************************************
3402 
3403  //**Friend declarations*************************************************************************
3404  template< typename MT2, bool SO2, bool SF2 >
3405  friend bool isSame( const SparseColumn<MT2,SO2,SF2>& a, const SparseColumn<MT2,SO2,SF2>& b );
3406  //**********************************************************************************************
3407 
3408  //**Compile time checks*************************************************************************
3414  //**********************************************************************************************
3415 };
3417 //*************************************************************************************************
3418 
3419 
3420 
3421 
3422 //=================================================================================================
3423 //
3424 // CONSTRUCTOR
3425 //
3426 //=================================================================================================
3427 
3428 //*************************************************************************************************
3436 template< typename MT > // Type of the sparse matrix
3437 inline SparseColumn<MT,false,true>::SparseColumn( MT& matrix, size_t index )
3438  : matrix_( matrix ) // The sparse matrix containing the column
3439  , col_ ( index ) // The index of the column in the matrix
3440 {
3441  if( matrix_.columns() <= index )
3442  throw std::invalid_argument( "Invalid column access index" );
3443 }
3445 //*************************************************************************************************
3446 
3447 
3448 
3449 
3450 //=================================================================================================
3451 //
3452 // DATA ACCESS FUNCTIONS
3453 //
3454 //=================================================================================================
3455 
3456 //*************************************************************************************************
3463 template< typename MT > // Type of the sparse matrix
3466 {
3467  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
3468  return matrix_(col_,index);
3469 }
3471 //*************************************************************************************************
3472 
3473 
3474 //*************************************************************************************************
3481 template< typename MT > // Type of the sparse matrix
3483  SparseColumn<MT,false,true>::operator[]( size_t index ) const
3484 {
3485  BLAZE_USER_ASSERT( index < size(), "Invalid column access index" );
3486  return const_cast<const MT&>( matrix_ )(col_,index);
3487 }
3489 //*************************************************************************************************
3490 
3491 
3492 //*************************************************************************************************
3500 template< typename MT > // Type of the sparse matrix
3502 {
3503  return matrix_.begin( col_ );
3504 }
3506 //*************************************************************************************************
3507 
3508 
3509 //*************************************************************************************************
3517 template< typename MT > // Type of the sparse matrix
3520 {
3521  return matrix_.cbegin( col_ );
3522 }
3524 //*************************************************************************************************
3525 
3526 
3527 //*************************************************************************************************
3535 template< typename MT > // Type of the sparse matrix
3538 {
3539  return matrix_.cbegin( col_ );
3540 }
3542 //*************************************************************************************************
3543 
3544 
3545 //*************************************************************************************************
3553 template< typename MT > // Type of the sparse matrix
3555 {
3556  return matrix_.end( col_ );
3557 }
3559 //*************************************************************************************************
3560 
3561 
3562 //*************************************************************************************************
3570 template< typename MT > // Type of the sparse matrix
3573 {
3574  return matrix_.cend( col_ );
3575 }
3577 //*************************************************************************************************
3578 
3579 
3580 //*************************************************************************************************
3588 template< typename MT > // Type of the sparse matrix
3591 {
3592  return matrix_.cend( col_ );
3593 }
3595 //*************************************************************************************************
3596 
3597 
3598 
3599 
3600 //=================================================================================================
3601 //
3602 // ASSIGNMENT OPERATORS
3603 //
3604 //=================================================================================================
3605 
3606 //*************************************************************************************************
3617 template< typename MT > // Type of the sparse matrix
3618 inline SparseColumn<MT,false,true>& SparseColumn<MT,false,true>::operator=( const SparseColumn& rhs )
3619 {
3620  using blaze::assign;
3621 
3625 
3626  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && col_ == rhs.col_ ) )
3627  return *this;
3628 
3629  if( size() != rhs.size() )
3630  throw std::invalid_argument( "Column sizes do not match" );
3631 
3632  if( rhs.canAlias( &matrix_ ) ) {
3633  const ResultType tmp( rhs );
3634  matrix_.reset ( col_ );
3635  matrix_.reserve( col_, tmp.nonZeros() );
3636  assign( *this, tmp );
3637  }
3638  else {
3639  matrix_.reset ( col_ );
3640  matrix_.reserve( col_, rhs.nonZeros() );
3641  assign( *this, rhs );
3642  }
3643 
3644  return *this;
3645 }
3647 //*************************************************************************************************
3648 
3649 
3650 //*************************************************************************************************
3661 template< typename MT > // Type of the sparse matrix
3662 template< typename VT > // Type of the right-hand side dense vector
3663 inline SparseColumn<MT,false,true>&
3664  SparseColumn<MT,false,true>::operator=( const DenseVector<VT,false>& rhs )
3665 {
3666  using blaze::assign;
3667 
3671 
3672  if( size() != (~rhs).size() )
3673  throw std::invalid_argument( "Vector sizes do not match" );
3674 
3675  if( (~rhs).canAlias( &matrix_ ) ) {
3676  const typename VT::ResultType tmp( ~rhs );
3677  matrix_.reset( col_ );
3678  assign( *this, tmp );
3679  }
3680  else {
3681  matrix_.reset( col_ );
3682  assign( *this, ~rhs );
3683  }
3684 
3685  return *this;
3686 }
3688 //*************************************************************************************************
3689 
3690 
3691 //*************************************************************************************************
3702 template< typename MT > // Type of the sparse matrix
3703 template< typename VT > // Type of the right-hand side sparse vector
3704 inline SparseColumn<MT,false,true>&
3705  SparseColumn<MT,false,true>::operator=( const SparseVector<VT,false>& rhs )
3706 {
3707  using blaze::assign;
3708 
3709  if( size() != (~rhs).size() )
3710  throw std::invalid_argument( "Vector sizes do not match" );
3711 
3715 
3716  if( (~rhs).canAlias( &matrix_ ) ) {
3717  const typename VT::ResultType tmp( ~rhs );
3718  matrix_.reset ( col_ );
3719  matrix_.reserve( col_, tmp.nonZeros() );
3720  assign( *this, tmp );
3721  }
3722  else {
3723  matrix_.reset ( col_ );
3724  matrix_.reserve( col_, (~rhs).nonZeros() );
3725  assign( *this, ~rhs );
3726  }
3727 
3728  return *this;
3729 }
3731 //*************************************************************************************************
3732 
3733 
3734 //*************************************************************************************************
3745 template< typename MT > // Type of the sparse matrix
3746 template< typename VT > // Type of the right-hand side vector
3747 inline SparseColumn<MT,false,true>&
3748  SparseColumn<MT,false,true>::operator+=( const Vector<VT,false>& rhs )
3749 {
3750  using blaze::addAssign;
3751 
3752  if( size() != (~rhs).size() )
3753  throw std::invalid_argument( "Vector sizes do not match" );
3754 
3755  addAssign( *this, ~rhs );
3756 
3757  return *this;
3758 }
3760 //*************************************************************************************************
3761 
3762 
3763 //*************************************************************************************************
3774 template< typename MT > // Type of the sparse matrix
3775 template< typename VT > // Type of the right-hand side vector
3776 inline SparseColumn<MT,false,true>&
3777  SparseColumn<MT,false,true>::operator-=( const Vector<VT,false>& rhs )
3778 {
3779  using blaze::subAssign;
3780 
3781  if( size() != (~rhs).size() )
3782  throw std::invalid_argument( "Vector sizes do not match" );
3783 
3784  subAssign( *this, ~rhs );
3785 
3786  return *this;
3787 }
3789 //*************************************************************************************************
3790 
3791 
3792 //*************************************************************************************************
3804 template< typename MT > // Type of the sparse matrix
3805 template< typename VT > // Type of the right-hand side vector
3806 inline SparseColumn<MT,false,true>&
3807  SparseColumn<MT,false,true>::operator*=( const Vector<VT,false>& rhs )
3808 {
3809  if( size() != (~rhs).size() )
3810  throw std::invalid_argument( "Vector sizes do not match" );
3811 
3812  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
3813 
3816 
3817  const MultType tmp( *this * (~rhs) );
3818  matrix_.reset( col_ );
3819  assign( tmp );
3820 
3821  return *this;
3822 }
3824 //*************************************************************************************************
3825 
3826 
3827 //*************************************************************************************************
3839 template< typename MT > // Type of the sparse matrix
3840 template< typename Other > // Data type of the right-hand side scalar
3841 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
3842  SparseColumn<MT,false,true>::operator*=( Other rhs )
3843 {
3844  for( Iterator element=begin(); element!=end(); ++element )
3845  element->value() *= rhs;
3846  return *this;
3847 }
3849 //*************************************************************************************************
3850 
3851 
3852 //*************************************************************************************************
3865 template< typename MT > // Type of the sparse matrix
3866 template< typename Other > // Data type of the right-hand side scalar
3867 inline typename EnableIf< IsNumeric<Other>, SparseColumn<MT,false,true> >::Type&
3868  SparseColumn<MT,false,true>::operator/=( Other rhs )
3869 {
3870  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3871 
3872  typedef typename DivTrait<ElementType,Other>::Type DT;
3873  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
3874 
3875  // Depending on the two involved data types, an integer division is applied or a
3876  // floating point division is selected.
3877  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
3878  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
3879  for( Iterator element=begin(); element!=end(); ++element )
3880  element->value() *= tmp;
3881  }
3882  else {
3883  for( Iterator element=begin(); element!=end(); ++element )
3884  element->value() /= rhs;
3885  }
3886 
3887  return *this;
3888 }
3890 //*************************************************************************************************
3891 
3892 
3893 
3894 
3895 //=================================================================================================
3896 //
3897 // UTILITY FUNCTIONS
3898 //
3899 //=================================================================================================
3900 
3901 //*************************************************************************************************
3907 template< typename MT > // Type of the sparse matrix
3908 inline size_t SparseColumn<MT,false,true>::size() const
3909 {
3910  return matrix_.rows();
3911 }
3913 //*************************************************************************************************
3914 
3915 
3916 //*************************************************************************************************
3922 template< typename MT > // Type of the sparse matrix
3923 inline size_t SparseColumn<MT,false,true>::capacity() const
3924 {
3925  return matrix_.capacity( col_ );
3926 }
3928 //*************************************************************************************************
3929 
3930 
3931 //*************************************************************************************************
3940 template< typename MT > // Type of the sparse matrix
3941 inline size_t SparseColumn<MT,false,true>::nonZeros() const
3942 {
3943  return matrix_.nonZeros( col_ );
3944 }
3946 //*************************************************************************************************
3947 
3948 
3949 //*************************************************************************************************
3955 template< typename MT > // Type of the sparse matrix
3957 {
3958  matrix_.reset( col_ );
3959 }
3961 //*************************************************************************************************
3962 
3963 
3964 //*************************************************************************************************
3976 template< typename MT > // Type of the sparse matrix
3978  SparseColumn<MT,false,true>::set( size_t index, const ElementType& value )
3979 {
3980  return matrix_.set( col_, index, value );
3981 }
3983 //*************************************************************************************************
3984 
3985 
3986 //*************************************************************************************************
3999 template< typename MT > // Type of the sparse matrix
4001  SparseColumn<MT,false,true>::insert( size_t index, const ElementType& value )
4002 {
4003  return matrix_.insert( col_, index, value );
4004 }
4006 //*************************************************************************************************
4007 
4008 
4009 //*************************************************************************************************
4018 template< typename MT > // Type of the sparse matrix
4019 inline void SparseColumn<MT,false,true>::erase( size_t index )
4020 {
4021  matrix_.erase( col_, index );
4022 }
4024 //*************************************************************************************************
4025 
4026 
4027 //*************************************************************************************************
4036 template< typename MT > // Type of the sparse matrix
4039 {
4040  return matrix_.erase( col_, pos );
4041 }
4043 //*************************************************************************************************
4044 
4045 
4046 //*************************************************************************************************
4056 template< typename MT > // Type of the sparse matrix
4059 {
4060  return matrix_.erase( col_, first, last );
4061 }
4063 //*************************************************************************************************
4064 
4065 
4066 //*************************************************************************************************
4076 template< typename MT > // Type of the sparse matrix
4077 void SparseColumn<MT,false,true>::reserve( size_t n )
4078 {
4079  matrix_.reserve( col_, n );
4080 }
4082 //*************************************************************************************************
4083 
4084 
4085 //*************************************************************************************************
4092 template< typename MT > // Type of the sparse matrix
4093 template< typename Other > // Data type of the scalar value
4094 inline SparseColumn<MT,false,true>& SparseColumn<MT,false,true>::scale( const Other& scalar )
4095 {
4096  for( Iterator element=begin(); element!=end(); ++element )
4097  element->value() *= scalar;
4098  return *this;
4099 }
4101 //*************************************************************************************************
4102 
4103 
4104 //*************************************************************************************************
4113 template< typename MT > // Type of the sparse matrix
4114 inline size_t SparseColumn<MT,false,true>::extendCapacity() const
4115 {
4116  using blaze::max;
4117  using blaze::min;
4118 
4119  size_t nonzeros( 2UL*capacity()+1UL );
4120  nonzeros = max( nonzeros, 7UL );
4121  nonzeros = min( nonzeros, size() );
4122 
4123  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
4124 
4125  return nonzeros;
4126 }
4128 //*************************************************************************************************
4129 
4130 
4131 
4132 
4133 //=================================================================================================
4134 //
4135 // LOOKUP FUNCTIONS
4136 //
4137 //=================================================================================================
4138 
4139 //*************************************************************************************************
4153 template< typename MT > // Type of the sparse matrix
4155  SparseColumn<MT,false,true>::find( size_t index )
4156 {
4157  return matrix_.find( col_, index );
4158 }
4160 //*************************************************************************************************
4161 
4162 
4163 //*************************************************************************************************
4177 template< typename MT > // Type of the sparse matrix
4179  SparseColumn<MT,false,true>::find( size_t index ) const
4180 {
4181  return matrix_.find( col_, index );
4182 }
4184 //*************************************************************************************************
4185 
4186 
4187 //*************************************************************************************************
4200 template< typename MT > // Type of the sparse matrix
4203 {
4204  return matrix_.lowerBound( col_, index );
4205 }
4207 //*************************************************************************************************
4208 
4209 
4210 //*************************************************************************************************
4223 template< typename MT > // Type of the sparse matrix
4225  SparseColumn<MT,false,true>::lowerBound( size_t index ) const
4226 {
4227  return matrix_.lowerBound( col_, index );
4228 }
4230 //*************************************************************************************************
4231 
4232 
4233 //*************************************************************************************************
4246 template< typename MT > // Type of the sparse matrix
4249 {
4250  return matrix_.upperBound( col_, index );
4251 }
4253 //*************************************************************************************************
4254 
4255 
4256 //*************************************************************************************************
4269 template< typename MT > // Type of the sparse matrix
4271  SparseColumn<MT,false,true>::upperBound( size_t index ) const
4272 {
4273  return matrix_.upperBound( col_, index );
4274 }
4276 //*************************************************************************************************
4277 
4278 
4279 
4280 
4281 //=================================================================================================
4282 //
4283 // LOW-LEVEL UTILITY FUNCTIONS
4284 //
4285 //=================================================================================================
4286 
4287 //*************************************************************************************************
4312 template< typename MT > // Type of the sparse matrix
4313 inline void SparseColumn<MT,false,true>::append( size_t index, const ElementType& value, bool check )
4314 {
4315  matrix_.append( col_, index, value, check );
4316 }
4318 //*************************************************************************************************
4319 
4320 
4321 
4322 
4323 //=================================================================================================
4324 //
4325 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4326 //
4327 //=================================================================================================
4328 
4329 //*************************************************************************************************
4340 template< typename MT > // Type of the sparse matrix
4341 template< typename Other > // Data type of the foreign expression
4342 inline bool SparseColumn<MT,false,true>::canAlias( const Other* alias ) const
4343 {
4344  return matrix_.isAliased( alias );
4345 }
4347 //*************************************************************************************************
4348 
4349 
4350 //*************************************************************************************************
4361 template< typename MT > // Type of the sparse matrix
4362 template< typename Other > // Data type of the foreign expression
4363 inline bool SparseColumn<MT,false,true>::isAliased( const Other* alias ) const
4364 {
4365  return matrix_.isAliased( alias );
4366 }
4368 //*************************************************************************************************
4369 
4370 
4371 //*************************************************************************************************
4383 template< typename MT > // Type of the sparse matrix
4384 template< typename VT > // Type of the right-hand side dense vector
4385 inline void SparseColumn<MT,false,true>::assign( const DenseVector<VT,false>& rhs )
4386 {
4387  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4388  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4389 
4390  for( size_t i=0UL; i<size(); ++i )
4391  {
4392  if( matrix_.nonZeros( col_ ) == matrix_.capacity( col_ ) )
4393  matrix_.reserve( col_, extendCapacity() );
4394 
4395  matrix_.append( col_, i, (~rhs)[i], true );
4396  }
4397 }
4399 //*************************************************************************************************
4400 
4401 
4402 //*************************************************************************************************
4414 template< typename MT > // Type of the sparse matrix
4415 template< typename VT > // Type of the right-hand side sparse vector
4416 inline void SparseColumn<MT,false,true>::assign( const SparseVector<VT,false>& rhs )
4417 {
4418  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4419  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
4420 
4421  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
4422  matrix_.append( col_, element->index(), element->value() );
4423  }
4424 }
4426 //*************************************************************************************************
4427 
4428 
4429 //*************************************************************************************************
4441 template< typename MT > // Type of the sparse matrix
4442 template< typename VT > // Type of the right-hand side dense vector
4443 inline void SparseColumn<MT,false,true>::addAssign( const DenseVector<VT,false>& rhs )
4444 {
4445  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4446 
4450 
4451  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4452 
4453  const AddType tmp( serial( *this + (~rhs) ) );
4454  matrix_.reset( col_ );
4455  assign( tmp );
4456 }
4458 //*************************************************************************************************
4459 
4460 
4461 //*************************************************************************************************
4473 template< typename MT > // Type of the sparse matrix
4474 template< typename VT > // Type of the right-hand side sparse vector
4475 inline void SparseColumn<MT,false,true>::addAssign( const SparseVector<VT,false>& rhs )
4476 {
4477  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
4478 
4482 
4483  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4484 
4485  const AddType tmp( serial( *this + (~rhs) ) );
4486  matrix_.reset ( col_ );
4487  matrix_.reserve( col_, tmp.nonZeros() );
4488  assign( tmp );
4489 }
4491 //*************************************************************************************************
4492 
4493 
4494 //*************************************************************************************************
4506 template< typename MT > // Type of the sparse matrix
4507 template< typename VT > // Type of the right-hand side dense vector
4508 inline void SparseColumn<MT,false,true>::subAssign( const DenseVector<VT,false>& rhs )
4509 {
4510  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4511 
4515 
4516  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4517 
4518  const SubType tmp( serial( *this - (~rhs) ) );
4519  matrix_.reset( col_ );
4520  assign( tmp );
4521 }
4523 //*************************************************************************************************
4524 
4525 
4526 //*************************************************************************************************
4538 template< typename MT > // Type of the sparse matrix
4539 template< typename VT > // Type of the right-hand side sparse vector
4540 inline void SparseColumn<MT,false,true>::subAssign( const SparseVector<VT,false>& rhs )
4541 {
4542  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
4543 
4547 
4548  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
4549 
4550  const SubType tmp( serial( *this - (~rhs) ) );
4551  matrix_.reset ( col_ );
4552  matrix_.reserve( col_, tmp.nonZeros() );
4553  assign( tmp );
4554 }
4556 //*************************************************************************************************
4557 
4558 
4559 
4560 
4561 
4562 
4563 
4564 
4565 //=================================================================================================
4566 //
4567 // SPARSECOLUMN OPERATORS
4568 //
4569 //=================================================================================================
4570 
4571 //*************************************************************************************************
4574 template< typename MT, bool SO, bool SF >
4575 inline void reset( SparseColumn<MT,SO,SF>& column );
4576 
4577 template< typename MT, bool SO, bool SF >
4578 inline void clear( SparseColumn<MT,SO,SF>& column );
4579 
4580 template< typename MT, bool SO, bool SF >
4581 inline bool isDefault( const SparseColumn<MT,SO,SF>& column );
4582 
4583 template< typename MT, bool SO, bool SF >
4584 inline bool isSame( const SparseColumn<MT,SO,SF>& a, const SparseColumn<MT,SO,SF>& b );
4586 //*************************************************************************************************
4587 
4588 
4589 //*************************************************************************************************
4596 template< typename MT // Type of the sparse matrix
4597  , bool SO // Storage order
4598  , bool SF > // Symmetry flag
4599 inline void reset( SparseColumn<MT,SO,SF>& column )
4600 {
4601  column.reset();
4602 }
4603 //*************************************************************************************************
4604 
4605 
4606 //*************************************************************************************************
4615 template< typename MT // Type of the sparse matrix
4616  , bool SO // Storage order
4617  , bool SF > // Symmetry flag
4618 inline void clear( SparseColumn<MT,SO,SF>& column )
4619 {
4620  column.reset();
4621 }
4622 //*************************************************************************************************
4623 
4624 
4625 //*************************************************************************************************
4643 template< typename MT // Type of the sparse matrix
4644  , bool SO // Storage order
4645  , bool SF > // Symmetry flag
4646 inline bool isDefault( const SparseColumn<MT,SO,SF>& column )
4647 {
4649 
4650  const ConstIterator end( column.end() );
4651  for( ConstIterator element=column.begin(); element!=end; ++element )
4652  if( !isDefault( element->value() ) ) return false;
4653  return true;
4654 }
4655 //*************************************************************************************************
4656 
4657 
4658 //*************************************************************************************************
4670 template< typename MT // Type of the sparse matrix
4671  , bool SO // Storage order
4672  , bool SF > // Symmetry flag
4673 inline bool isSame( const SparseColumn<MT,SO,SF>& a, const SparseColumn<MT,SO,SF>& b )
4674 {
4675  return ( isSame( a.matrix_, b.matrix_ ) && ( a.col_ == b.col_ ) );
4676 }
4677 //*************************************************************************************************
4678 
4679 
4680 
4681 
4682 //=================================================================================================
4683 //
4684 // SUBVECTORTRAIT SPECIALIZATIONS
4685 //
4686 //=================================================================================================
4687 
4688 //*************************************************************************************************
4690 template< typename MT, bool SO, bool SF >
4691 struct SubvectorTrait< SparseColumn<MT,SO,SF> >
4692 {
4694 };
4696 //*************************************************************************************************
4697 
4698 } // namespace blaze
4699 
4700 #endif
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseColumn.h:1349
Constraint on the data type.
bool canAlias(const Other *alias) const
Returns whether the sparse column can alias with the given address alias.
Definition: SparseColumn.h:1443
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
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.
ConstIterator cbegin() const
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:649
#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
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:4838
Header file for the subtraction trait.
MT::ElementType ElementType
Type of the column elements.
Definition: SparseColumn.h:379
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse column.
Definition: SparseColumn.h:1106
Iterator find(size_t index)
Searches for a specific column element.
Definition: SparseColumn.h:1258
Header file for the SparseVector base class.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
void subAssign(const DenseVector< VT, false > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseColumn.h:1609
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
Base template for the ColumnTrait class.
Definition: ColumnTrait.h:115
#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
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
#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
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SparseColumn.h:390
void reserve(size_t n)
Setting the minimum capacity of the sparse column.
Definition: SparseColumn.h:1181
size_t capacity() const
Returns the maximum capacity of the sparse column.
Definition: SparseColumn.h:1028
Header file for the IsColumnMajorMatrix type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: SparseColumn.h:393
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:695
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:386
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:95
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:78
#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
Operand matrix_
The sparse matrix containing the column.
Definition: SparseColumn.h:509
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse column.
Definition: SparseColumn.h:1414
Header file for the column base class.
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:700
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.
Header file for the IsSymmetric type trait.
SparseColumn< MT, SO, SF > This
Type of this SparseColumn instance.
Definition: SparseColumn.h:376
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
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseColumn.h:1304
const size_t col_
The index of the column in the matrix.
Definition: SparseColumn.h:510
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the Or class template.
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
BLAZE_ALWAYS_INLINE 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:635
Iterator set(size_t index, const ElementType &value)
Setting an element of the sparse column.
Definition: SparseColumn.h:1083
Base class for all columns.The Column class serves as a tag for all columns (i.e. dense and sparse co...
Definition: Column.h:64
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Header file for the subvector trait.
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.
Header file for the SparseElement base class.
Constraint on the data type.
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant column value.
Definition: SparseColumn.h:387
void reset()
Reset to the default initial values.
Definition: SparseColumn.h:1061
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseColumn.h:378
void erase(size_t index)
Erasing an element from the sparse column.
Definition: SparseColumn.h:1124
Constraints on the storage order of matrix types.
Constraint on the data type.
void assign(const DenseVector< VT, false > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseColumn.h:1486
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
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:2476
size_t nonZeros() const
Returns the number of non-zero elements in the column.
Definition: SparseColumn.h:1046
Constraint on the data type.
Header file for the SelectType class template.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
Header file for the EnableIf class template.
Header file for the serial shim.
bool isAliased(const Other *alias) const
Returns whether the sparse column is aliased with the given address alias.
Definition: SparseColumn.h:1464
Header file for the IsNumeric type trait.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
#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:2477
Header file for the IsConst type trait.
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:142
Base template for the MultTrait class.
Definition: MultTrait.h:142
MT::ConstReference ConstReference
Reference to a constant column value.
Definition: SparseColumn.h:384
Header file for the addition trait.
BLAZE_ALWAYS_INLINE 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:742
Header file for the division trait.
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.
SparseColumn & operator=(const SparseColumn &rhs)
Copy assignment operator for SparseColumn.
Definition: SparseColumn.h:728
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Header file for the column trait.
Header file for the isDefault shim.
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
const SparseColumn & CompositeType
Data type for composite expression templates.
Definition: SparseColumn.h:381
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
#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
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
Base template for the DivTrait class.
Definition: DivTrait.h:142
#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
void addAssign(const DenseVector< VT, false > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseColumn.h:1544
Iterator end()
Returns an iterator just past the last element of the column.
Definition: SparseColumn.h:666
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:151
Iterator begin()
Returns an iterator to the first element of the column.
Definition: SparseColumn.h:615
Reference operator[](size_t index)
Subscript operator for the direct access to the column elements.
Definition: SparseColumn.h:579
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:256
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseColumn.h:380
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
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:2473
ColumnTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseColumn.h:377
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.
size_t extendCapacity() const
Calculating a new sparse column capacity.
Definition: SparseColumn.h:1218
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Base template for the SubTrait class.
Definition: SubTrait.h:142
#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
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseColumn.h:360
#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.
BLAZE_ALWAYS_INLINE 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:849
size_t size() const
Returns the current size/dimension of the sparse column.
Definition: SparseColumn.h:1013
SparseColumn(MT &matrix, size_t index)
The constructor for SparseColumn.
Definition: SparseColumn.h:551
Header file for a safe C++ NULL pointer implementation.