All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseRow.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SPARSEROW_H_
36 #define _BLAZE_MATH_VIEWS_SPARSEROW_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
55 #include <blaze/math/Functions.h>
57 #include <blaze/math/shims/Reset.h>
66 #include <blaze/util/Assert.h>
67 #include <blaze/util/DisableIf.h>
68 #include <blaze/util/EnableIf.h>
70 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/mpl/Or.h>
72 #include <blaze/util/SelectType.h>
73 #include <blaze/util/Types.h>
77 #include <blaze/util/Unused.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS DEFINITION
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
337 template< typename MT // Type of the sparse matrix
338  , bool SO = IsRowMajorMatrix<MT>::value > // Storage order
339 class SparseRow : public SparseVector< SparseRow<MT,SO>, true >
340  , private View
341 {
342  private:
343  //**Type definitions****************************************************************************
345  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
346  //**********************************************************************************************
347 
348  //**********************************************************************************************
350 
356  enum { useConst = IsConst<MT>::value };
357  //**********************************************************************************************
358 
359  public:
360  //**Type definitions****************************************************************************
362  typedef typename RowTrait<MT>::Type ResultType;
364  typedef typename MT::ElementType ElementType;
365  typedef typename MT::ReturnType ReturnType;
366  typedef const SparseRow& CompositeType;
367 
370 
373 
376 
379  //**********************************************************************************************
380 
381  //**Constructors********************************************************************************
384  explicit inline SparseRow( MT& matrix, size_t index );
385  // No explicitly declared copy constructor.
387  //**********************************************************************************************
388 
389  //**Destructor**********************************************************************************
390  // No explicitly declared destructor.
391  //**********************************************************************************************
392 
393  //**Data access functions***********************************************************************
396  inline Reference operator[]( size_t index );
397  inline ConstReference operator[]( size_t index ) const;
398  inline Iterator begin ();
399  inline ConstIterator begin () const;
400  inline ConstIterator cbegin() const;
401  inline Iterator end ();
402  inline ConstIterator end () const;
403  inline ConstIterator cend () const;
405  //**********************************************************************************************
406 
407  //**Assignment operators************************************************************************
410  inline SparseRow& operator= ( const SparseRow& rhs );
411  template< typename VT > inline SparseRow& operator= ( const DenseVector <VT,true>& rhs );
412  template< typename VT > inline SparseRow& operator= ( const SparseVector<VT,true>& rhs );
413  template< typename VT > inline SparseRow& operator+=( const Vector<VT,true>& rhs );
414  template< typename VT > inline SparseRow& operator-=( const Vector<VT,true>& rhs );
415  template< typename VT > inline SparseRow& operator*=( const Vector<VT,true>& rhs );
416 
417  template< typename Other >
418  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
419  operator*=( Other rhs );
420 
421  template< typename Other >
422  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
423  operator/=( Other rhs );
425  //**********************************************************************************************
426 
427  //**Utility functions***************************************************************************
430  inline size_t size() const;
431  inline size_t capacity() const;
432  inline size_t nonZeros() const;
433  inline void reset();
434  inline Iterator insert ( size_t index, const ElementType& value );
435  inline void erase ( size_t index );
436  inline Iterator erase ( Iterator pos );
437  inline Iterator erase ( Iterator first, Iterator last );
438  inline void reserve( size_t n );
439  template< typename Other > inline SparseRow& scale ( Other scalar );
441  //**********************************************************************************************
442 
443  //**Lookup functions****************************************************************************
446  inline Iterator find ( size_t index );
447  inline ConstIterator find ( size_t index ) const;
448  inline Iterator lowerBound( size_t index );
449  inline ConstIterator lowerBound( size_t index ) const;
450  inline Iterator upperBound( size_t index );
451  inline ConstIterator upperBound( size_t index ) const;
453  //**********************************************************************************************
454 
455  //**Low-level utility functions*****************************************************************
458  inline void append( size_t index, const ElementType& value, bool check=false );
460  //**********************************************************************************************
461 
462  //**Expression template evaluation functions****************************************************
465  template< typename Other > inline bool canAlias ( const Other* alias ) const;
466  template< typename Other > inline bool isAliased( const Other* alias ) const;
467  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
468  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
469  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
470  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
471  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
472  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
474  //**********************************************************************************************
475 
476  private:
477  //**Utility functions***************************************************************************
480  inline size_t extendCapacity() const;
482  //**********************************************************************************************
483 
484  //**Member variables****************************************************************************
488  const size_t row_;
489 
490  //**********************************************************************************************
491 
492  //**Compile time checks*************************************************************************
499  //**********************************************************************************************
500 };
501 //*************************************************************************************************
502 
503 
504 
505 
506 //=================================================================================================
507 //
508 // CONSTRUCTOR
509 //
510 //=================================================================================================
511 
512 //*************************************************************************************************
519 template< typename MT // Type of the sparse matrix
520  , bool SO > // Storage order
521 inline SparseRow<MT,SO>::SparseRow( MT& matrix, size_t index )
522  : matrix_( matrix ) // The sparse matrix containing the row
523  , row_ ( index ) // The index of the row in the matrix
524 {
525  if( matrix_.rows() <= index )
526  throw std::invalid_argument( "Invalid row access index" );
527 }
528 //*************************************************************************************************
529 
530 
531 
532 
533 //=================================================================================================
534 //
535 // DATA ACCESS FUNCTIONS
536 //
537 //=================================================================================================
538 
539 //*************************************************************************************************
545 template< typename MT // Type of the sparse matrix
546  , bool SO > // Storage order
548 {
549  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
550  return matrix_(row_,index);
551 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
561 template< typename MT // Type of the sparse matrix
562  , bool SO > // Storage order
564 {
565  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
566  return const_cast<const MT&>( matrix_ )(row_,index);
567 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
578 template< typename MT // Type of the sparse matrix
579  , bool SO > // Storage order
581 {
582  return matrix_.begin( row_ );
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
594 template< typename MT // Type of the sparse matrix
595  , bool SO > // Storage order
597 {
598  return matrix_.cbegin( row_ );
599 }
600 //*************************************************************************************************
601 
602 
603 //*************************************************************************************************
610 template< typename MT // Type of the sparse matrix
611  , bool SO > // Storage order
613 {
614  return matrix_.cbegin( row_ );
615 }
616 //*************************************************************************************************
617 
618 
619 //*************************************************************************************************
626 template< typename MT // Type of the sparse matrix
627  , bool SO > // Storage order
629 {
630  return matrix_.end( row_ );
631 }
632 //*************************************************************************************************
633 
634 
635 //*************************************************************************************************
642 template< typename MT // Type of the sparse matrix
643  , bool SO > // Storage order
645 {
646  return matrix_.cend( row_ );
647 }
648 //*************************************************************************************************
649 
650 
651 //*************************************************************************************************
658 template< typename MT // Type of the sparse matrix
659  , bool SO > // Storage order
661 {
662  return matrix_.cend( row_ );
663 }
664 //*************************************************************************************************
665 
666 
667 
668 
669 //=================================================================================================
670 //
671 // ASSIGNMENT OPERATORS
672 //
673 //=================================================================================================
674 
675 //*************************************************************************************************
685 template< typename MT // Type of the sparse matrix
686  , bool SO > // Storage order
688 {
689  using blaze::assign;
690 
694 
695  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
696  return *this;
697 
698  if( size() != rhs.size() )
699  throw std::invalid_argument( "Row sizes do not match" );
700 
701  if( rhs.canAlias( &matrix_ ) ) {
702  const ResultType tmp( rhs );
703  matrix_.reset ( row_ );
704  matrix_.reserve( row_, tmp.nonZeros() );
705  assign( *this, tmp );
706  }
707  else {
708  matrix_.reset ( row_ );
709  matrix_.reserve( row_, rhs.nonZeros() );
710  assign( *this, rhs );
711  }
712 
713  return *this;
714 }
715 //*************************************************************************************************
716 
717 
718 //*************************************************************************************************
728 template< typename MT // Type of the sparse matrix
729  , bool SO > // Storage order
730 template< typename VT > // Type of the right-hand side dense vector
732 {
733  using blaze::assign;
734 
738 
739  if( size() != (~rhs).size() )
740  throw std::invalid_argument( "Vector sizes do not match" );
741 
742  if( (~rhs).canAlias( &matrix_ ) ) {
743  const typename VT::ResultType tmp( ~rhs );
744  matrix_.reset( row_ );
745  assign( *this, tmp );
746  }
747  else {
748  matrix_.reset( row_ );
749  assign( *this, ~rhs );
750  }
751 
752  return *this;
753 }
754 //*************************************************************************************************
755 
756 
757 //*************************************************************************************************
767 template< typename MT // Type of the sparse matrix
768  , bool SO > // Storage order
769 template< typename VT > // Type of the right-hand side sparse vector
771 {
772  using blaze::assign;
773 
777 
778  if( size() != (~rhs).size() )
779  throw std::invalid_argument( "Vector sizes do not match" );
780 
781  if( (~rhs).canAlias( &matrix_ ) ) {
782  const typename VT::ResultType tmp( ~rhs );
783  matrix_.reset ( row_ );
784  matrix_.reserve( row_, tmp.nonZeros() );
785  assign( *this, tmp );
786  }
787  else {
788  matrix_.reset ( row_ );
789  matrix_.reserve( row_, (~rhs).nonZeros() );
790  assign( *this, ~rhs );
791  }
792 
793  return *this;
794 }
795 //*************************************************************************************************
796 
797 
798 //*************************************************************************************************
808 template< typename MT // Type of the sparse matrix
809  , bool SO > // Storage order
810 template< typename VT > // Type of the right-hand side vector
812 {
813  using blaze::addAssign;
814 
815  if( size() != (~rhs).size() )
816  throw std::invalid_argument( "Vector sizes do not match" );
817 
818  addAssign( *this, ~rhs );
819 
820  return *this;
821 }
822 //*************************************************************************************************
823 
824 
825 //*************************************************************************************************
835 template< typename MT // Type of the sparse matrix
836  , bool SO > // Storage order
837 template< typename VT > // Type of the right-hand side vector
839 {
840  using blaze::subAssign;
841 
842  if( size() != (~rhs).size() )
843  throw std::invalid_argument( "Vector sizes do not match" );
844 
845  subAssign( *this, ~rhs );
846 
847  return *this;
848 }
849 //*************************************************************************************************
850 
851 
852 //*************************************************************************************************
863 template< typename MT // Type of the sparse matrix
864  , bool SO > // Storage order
865 template< typename VT > // Type of the right-hand side vector
867 {
868  if( size() != (~rhs).size() )
869  throw std::invalid_argument( "Vector sizes do not match" );
870 
871  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
872 
875 
876  const MultType tmp( *this * (~rhs) );
877  matrix_.reset( row_ );
878  assign( tmp );
879 
880  return *this;
881 }
882 //*************************************************************************************************
883 
884 
885 //*************************************************************************************************
896 template< typename MT // Type of the sparse matrix
897  , bool SO > // Storage order
898 template< typename Other > // Data type of the right-hand side scalar
899 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,SO> >::Type&
901 {
902  for( Iterator element=begin(); element!=end(); ++element )
903  element->value() *= rhs;
904  return *this;
905 }
906 //*************************************************************************************************
907 
908 
909 //*************************************************************************************************
921 template< typename MT // Type of the sparse matrix
922  , bool SO > // Storage order
923 template< typename Other > // Data type of the right-hand side scalar
924 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,SO> >::Type&
926 {
927  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
928 
929  typedef typename DivTrait<ElementType,Other>::Type DT;
930  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
931 
932  // Depending on the two involved data types, an integer division is applied or a
933  // floating point division is selected.
935  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
936  for( Iterator element=begin(); element!=end(); ++element )
937  element->value() *= tmp;
938  }
939  else {
940  for( Iterator element=begin(); element!=end(); ++element )
941  element->value() /= rhs;
942  }
943 
944  return *this;
945 }
946 //*************************************************************************************************
947 
948 
949 
950 
951 //=================================================================================================
952 //
953 // UTILITY FUNCTIONS
954 //
955 //=================================================================================================
956 
957 //*************************************************************************************************
962 template< typename MT // Type of the sparse matrix
963  , bool SO > // Storage order
964 inline size_t SparseRow<MT,SO>::size() const
965 {
966  return matrix_.columns();
967 }
968 //*************************************************************************************************
969 
970 
971 //*************************************************************************************************
976 template< typename MT // Type of the sparse matrix
977  , bool SO > // Storage order
978 inline size_t SparseRow<MT,SO>::capacity() const
979 {
980  return matrix_.capacity( row_ );
981 }
982 //*************************************************************************************************
983 
984 
985 //*************************************************************************************************
993 template< typename MT // Type of the sparse matrix
994  , bool SO > // Storage order
995 inline size_t SparseRow<MT,SO>::nonZeros() const
996 {
997  return matrix_.nonZeros( row_ );
998 }
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1007 template< typename MT // Type of the sparse matrix
1008  , bool SO > // Storage order
1010 {
1011  matrix_.reset( row_ );
1012 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1028 template< typename MT // Type of the sparse matrix
1029  , bool SO > // Storage order
1030 inline typename SparseRow<MT,SO>::Iterator
1031  SparseRow<MT,SO>::insert( size_t index, const ElementType& value )
1032 {
1033  return matrix_.insert( row_, index, value );
1034 }
1035 //*************************************************************************************************
1036 
1037 
1038 //*************************************************************************************************
1046 template< typename MT // Type of the sparse matrix
1047  , bool SO > // Storage order
1048 inline void SparseRow<MT,SO>::erase( size_t index )
1049 {
1050  matrix_.erase( row_, index );
1051 }
1052 //*************************************************************************************************
1053 
1054 
1055 //*************************************************************************************************
1063 template< typename MT // Type of the sparse matrix
1064  , bool SO > // Storage order
1066 {
1067  return matrix_.erase( row_, pos );
1068 }
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1081 template< typename MT // Type of the sparse matrix
1082  , bool SO > // Storage order
1084 {
1085  return matrix_.erase( row_, first, last );
1086 }
1087 //*************************************************************************************************
1088 
1089 
1090 //*************************************************************************************************
1099 template< typename MT // Type of the sparse matrix
1100  , bool SO > // Storage order
1102 {
1103  matrix_.reserve( row_, n );
1104 }
1105 //*************************************************************************************************
1106 
1107 
1108 //*************************************************************************************************
1114 template< typename MT // Type of the sparse matrix
1115  , bool SO > // Storage order
1116 template< typename Other > // Data type of the scalar value
1118 {
1119  for( Iterator element=begin(); element!=end(); ++element )
1120  element->value() *= scalar;
1121  return *this;
1122 }
1123 //*************************************************************************************************
1124 
1125 
1126 //*************************************************************************************************
1134 template< typename MT // Type of the sparse matrix
1135  , bool SO > // Storage order
1137 {
1138  using blaze::max;
1139  using blaze::min;
1140 
1141  size_t nonzeros( 2UL*capacity()+1UL );
1142  nonzeros = max( nonzeros, 7UL );
1143  nonzeros = min( nonzeros, size() );
1144 
1145  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1146 
1147  return nonzeros;
1148 }
1149 //*************************************************************************************************
1150 
1151 
1152 
1153 
1154 //=================================================================================================
1155 //
1156 // LOOKUP FUNCTIONS
1157 //
1158 //=================================================================================================
1159 
1160 //*************************************************************************************************
1173 template< typename MT // Type of the sparse matrix
1174  , bool SO > // Storage order
1176 {
1177  return matrix_.find( row_, index );
1178 }
1179 //*************************************************************************************************
1180 
1181 
1182 //*************************************************************************************************
1195 template< typename MT // Type of the sparse matrix
1196  , bool SO > // Storage order
1197 inline typename SparseRow<MT,SO>::ConstIterator SparseRow<MT,SO>::find( size_t index ) const
1198 {
1199  return matrix_.find( row_, index );
1200 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1216 template< typename MT // Type of the sparse matrix
1217  , bool SO > // Storage order
1219 {
1220  return matrix_.lowerBound( row_, index );
1221 }
1222 //*************************************************************************************************
1223 
1224 
1225 //*************************************************************************************************
1237 template< typename MT // Type of the sparse matrix
1238  , bool SO > // Storage order
1240 {
1241  return matrix_.lowerBound( row_, index );
1242 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1258 template< typename MT // Type of the sparse matrix
1259  , bool SO > // Storage order
1261 {
1262  return matrix_.upperBound( row_, index );
1263 }
1264 //*************************************************************************************************
1265 
1266 
1267 //*************************************************************************************************
1279 template< typename MT // Type of the sparse matrix
1280  , bool SO > // Storage order
1282 {
1283  return matrix_.upperBound( row_, index );
1284 }
1285 //*************************************************************************************************
1286 
1287 
1288 
1289 
1290 //=================================================================================================
1291 //
1292 // LOW-LEVEL UTILITY FUNCTIONS
1293 //
1294 //=================================================================================================
1295 
1296 //*************************************************************************************************
1320 template< typename MT // Type of the sparse matrix
1321  , bool SO > // Storage order
1322 inline void SparseRow<MT,SO>::append( size_t index, const ElementType& value, bool check )
1323 {
1324  matrix_.append( row_, index, value, check );
1325 }
1326 //*************************************************************************************************
1327 
1328 
1329 
1330 
1331 //=================================================================================================
1332 //
1333 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1334 //
1335 //=================================================================================================
1336 
1337 //*************************************************************************************************
1347 template< typename MT // Type of the sparse matrix
1348  , bool SO > // Storage order
1349 template< typename Other > // Data type of the foreign expression
1350 inline bool SparseRow<MT,SO>::canAlias( const Other* alias ) const
1351 {
1352  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1353 }
1354 //*************************************************************************************************
1355 
1356 
1357 //*************************************************************************************************
1367 template< typename MT // Type of the sparse matrix
1368  , bool SO > // Storage order
1369 template< typename Other > // Data type of the foreign expression
1370 inline bool SparseRow<MT,SO>::isAliased( const Other* alias ) const
1371 {
1372  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1373 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1388 template< typename MT // Type of the sparse matrix
1389  , bool SO > // Storage order
1390 template< typename VT > // Type of the right-hand side dense vector
1392 {
1393  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1394  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1395 
1396  for( size_t j=0UL; j<size(); ++j )
1397  {
1398  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1399  matrix_.reserve( row_, extendCapacity() );
1400 
1401  matrix_.append( row_, j, (~rhs)[j], true );
1402  }
1403 }
1404 //*************************************************************************************************
1405 
1406 
1407 //*************************************************************************************************
1418 template< typename MT // Type of the sparse matrix
1419  , bool SO > // Storage order
1420 template< typename VT > // Type of the right-hand side sparse vector
1422 {
1423  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1424  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1425 
1426  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1427  matrix_.append( row_, element->index(), element->value() );
1428  }
1429 }
1430 //*************************************************************************************************
1431 
1432 
1433 //*************************************************************************************************
1444 template< typename MT // Type of the sparse matrix
1445  , bool SO > // Storage order
1446 template< typename VT > // Type of the right-hand side dense vector
1448 {
1449  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1450 
1454 
1455  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1456 
1457  const AddType tmp( *this + (~rhs) );
1458  matrix_.reset( row_ );
1459  assign( tmp );
1460 }
1461 //*************************************************************************************************
1462 
1463 
1464 //*************************************************************************************************
1475 template< typename MT // Type of the sparse matrix
1476  , bool SO > // Storage order
1477 template< typename VT > // Type of the right-hand side sparse vector
1479 {
1480  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1481 
1485 
1486  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1487 
1488  const AddType tmp( *this + (~rhs) );
1489  matrix_.reset ( row_ );
1490  matrix_.reserve( row_, tmp.nonZeros() );
1491  assign( tmp );
1492 }
1493 //*************************************************************************************************
1494 
1495 
1496 //*************************************************************************************************
1507 template< typename MT // Type of the sparse matrix
1508  , bool SO > // Storage order
1509 template< typename VT > // Type of the right-hand side dense vector
1511 {
1512  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1513 
1517 
1518  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1519 
1520  const SubType tmp( *this - (~rhs) );
1521  matrix_.reset ( row_ );
1522  assign( tmp );
1523 }
1524 //*************************************************************************************************
1525 
1526 
1527 //*************************************************************************************************
1538 template< typename MT // Type of the sparse matrix
1539  , bool SO > // Storage order
1540 template< typename VT > // Type of the right-hand side sparse vector
1542 {
1543  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1544 
1548 
1549  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1550 
1551  const SubType tmp( *this - (~rhs) );
1552  matrix_.reset ( row_ );
1553  matrix_.reserve( row_, tmp.nonZeros() );
1554  assign( tmp );
1555 }
1556 //*************************************************************************************************
1557 
1558 
1559 
1560 
1561 
1562 
1563 
1564 
1565 //=================================================================================================
1566 //
1567 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
1568 //
1569 //=================================================================================================
1570 
1571 //*************************************************************************************************
1579 template< typename MT > // Type of the sparse matrix
1580 class SparseRow<MT,false> : public SparseVector< SparseRow<MT,false>, true >
1581  , private View
1582 {
1583  private:
1584  //**Type definitions****************************************************************************
1586  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1587  //**********************************************************************************************
1588 
1589  //**********************************************************************************************
1591 
1597  enum { useConst = IsConst<MT>::value };
1598  //**********************************************************************************************
1599 
1600  public:
1601  //**Type definitions****************************************************************************
1602  typedef SparseRow<MT,false> This;
1603  typedef typename RowTrait<MT>::Type ResultType;
1604  typedef typename ResultType::TransposeType TransposeType;
1605  typedef typename MT::ElementType ElementType;
1606  typedef typename MT::ReturnType ReturnType;
1607  typedef const ResultType CompositeType;
1608 
1610  typedef typename MT::ConstReference ConstReference;
1611 
1613  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1614  //**********************************************************************************************
1615 
1616  //**RowElement class definition*****************************************************************
1619  template< typename MatrixType // Type of the sparse matrix
1620  , typename IteratorType > // Type of the sparse matrix iterator
1621  class RowElement
1622  {
1623  private:
1624  //*******************************************************************************************
1626 
1631  enum { returnConst = IsConst<MatrixType>::value };
1632  //*******************************************************************************************
1633 
1634  public:
1635  //**Type definitions*************************************************************************
1636  typedef typename SelectType< returnConst, const ElementType&, ElementType& >::Type ReferenceType;
1637  //*******************************************************************************************
1638 
1639  //**Constructor******************************************************************************
1645  inline RowElement( IteratorType pos, size_t column )
1646  : pos_ ( pos ) // Iterator to the current position within the sparse row
1647  , column_( column ) // Index of the according column
1648  {}
1649  //*******************************************************************************************
1650 
1651  //**Assignment operator**********************************************************************
1657  template< typename T > inline RowElement& operator=( const T& v ) {
1658  *pos_ = v;
1659  return *this;
1660  }
1661  //*******************************************************************************************
1662 
1663  //**Addition assignment operator*************************************************************
1669  template< typename T > inline RowElement& operator+=( const T& v ) {
1670  *pos_ += v;
1671  return *this;
1672  }
1673  //*******************************************************************************************
1674 
1675  //**Subtraction assignment operator**********************************************************
1681  template< typename T > inline RowElement& operator-=( const T& v ) {
1682  *pos_ -= v;
1683  return *this;
1684  }
1685  //*******************************************************************************************
1686 
1687  //**Multiplication assignment operator*******************************************************
1693  template< typename T > inline RowElement& operator*=( const T& v ) {
1694  *pos_ *= v;
1695  return *this;
1696  }
1697  //*******************************************************************************************
1698 
1699  //**Division assignment operator*************************************************************
1705  template< typename T > inline RowElement& operator/=( const T& v ) {
1706  *pos_ /= v;
1707  return *this;
1708  }
1709  //*******************************************************************************************
1710 
1711  //**Element access operator******************************************************************
1716  inline const RowElement* operator->() const {
1717  return this;
1718  }
1719  //*******************************************************************************************
1720 
1721  //**Value function***************************************************************************
1726  inline ReferenceType value() const {
1727  return pos_->value();
1728  }
1729  //*******************************************************************************************
1730 
1731  //**Index function***************************************************************************
1736  inline size_t index() const {
1737  return column_;
1738  }
1739  //*******************************************************************************************
1740 
1741  private:
1742  //**Member variables*************************************************************************
1743  IteratorType pos_;
1744  size_t column_;
1745  //*******************************************************************************************
1746  };
1747  //**********************************************************************************************
1748 
1749  //**RowIterator class definition****************************************************************
1752  template< typename MatrixType // Type of the sparse matrix
1753  , typename IteratorType > // Type of the sparse matrix iterator
1754  class RowIterator
1755  {
1756  public:
1757  //**Type definitions*************************************************************************
1758  typedef std::forward_iterator_tag IteratorCategory;
1759  typedef RowElement<MatrixType,IteratorType> ValueType;
1760  typedef ValueType PointerType;
1761  typedef ValueType ReferenceType;
1762  typedef ptrdiff_t DifferenceType;
1763 
1764  // STL iterator requirements
1765  typedef IteratorCategory iterator_category;
1766  typedef ValueType value_type;
1767  typedef PointerType pointer;
1768  typedef ReferenceType reference;
1769  typedef DifferenceType difference_type;
1770  //*******************************************************************************************
1771 
1772  //**Constructor******************************************************************************
1779  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
1780  : matrix_( matrix ) // The sparse matrix containing the row.
1781  , row_ ( row ) // The current row index.
1782  , column_( column ) // The current column index.
1783  , pos_ () // Iterator to the current sparse element.
1784  {
1785  for( ; column_<matrix_.columns(); ++column_ ) {
1786  pos_ = matrix_.find( row_, column_ );
1787  if( pos_ != matrix_.end( column_ ) ) break;
1788  }
1789  }
1790  //*******************************************************************************************
1791 
1792  //**Constructor******************************************************************************
1800  inline RowIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
1801  : matrix_( matrix ) // The sparse matrix containing the row.
1802  , row_ ( row ) // The current row index.
1803  , column_( column ) // The current column index.
1804  , pos_ ( pos ) // Iterator to the current sparse element.
1805  {
1806  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
1807  }
1808  //*******************************************************************************************
1809 
1810  //**Constructor******************************************************************************
1815  template< typename MatrixType2, typename IteratorType2 >
1816  inline RowIterator( const RowIterator<MatrixType2,IteratorType2>& it )
1817  : matrix_( it.matrix_ ) // The sparse matrix containing the row.
1818  , row_ ( it.row_ ) // The current row index.
1819  , column_( it.column_ ) // The current column index.
1820  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
1821  {}
1822  //*******************************************************************************************
1823 
1824  //**Prefix increment operator****************************************************************
1829  inline RowIterator& operator++() {
1830  ++column_;
1831  for( ; column_<matrix_.columns(); ++column_ ) {
1832  pos_ = matrix_.find( row_, column_ );
1833  if( pos_ != matrix_.end( column_ ) ) break;
1834  }
1835 
1836  return *this;
1837  }
1838  //*******************************************************************************************
1839 
1840  //**Postfix increment operator***************************************************************
1845  inline const RowIterator operator++( int ) {
1846  const RowIterator tmp( *this );
1847  ++(*this);
1848  return tmp;
1849  }
1850  //*******************************************************************************************
1851 
1852  //**Element access operator******************************************************************
1857  inline ReferenceType operator*() const {
1858  return ReferenceType( pos_, column_ );
1859  }
1860  //*******************************************************************************************
1861 
1862  //**Element access operator******************************************************************
1867  inline PointerType operator->() const {
1868  return PointerType( pos_, column_ );
1869  }
1870  //*******************************************************************************************
1871 
1872  //**Equality operator************************************************************************
1878  template< typename MatrixType2, typename IteratorType2 >
1879  inline bool operator==( const RowIterator<MatrixType2,IteratorType2>& rhs ) const {
1880  return ( &matrix_ == &rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1881  }
1882  //*******************************************************************************************
1883 
1884  //**Inequality operator**********************************************************************
1890  template< typename MatrixType2, typename IteratorType2 >
1891  inline bool operator!=( const RowIterator<MatrixType2,IteratorType2>& rhs ) const {
1892  return !( *this == rhs );
1893  }
1894  //*******************************************************************************************
1895 
1896  //**Subtraction operator*********************************************************************
1902  inline DifferenceType operator-( const RowIterator& rhs ) const {
1903  size_t counter( 0UL );
1904  for( size_t j=rhs.column_; j<column_; ++j ) {
1905  if( matrix_.find( row_, j ) != matrix_.end( j ) )
1906  ++counter;
1907  }
1908  return counter;
1909  }
1910  //*******************************************************************************************
1911 
1912  private:
1913  //**Member variables*************************************************************************
1914  MatrixType& matrix_;
1915  size_t row_;
1916  size_t column_;
1917  IteratorType pos_;
1918  //*******************************************************************************************
1919 
1920  //**Friend declarations**********************************************************************
1922  template< typename MatrixType2, typename IteratorType2 > friend class RowIterator;
1923  template< typename MT2, bool SO2 > friend class SparseRow;
1925  //*******************************************************************************************
1926  };
1927  //**********************************************************************************************
1928 
1929  //**Type definitions****************************************************************************
1931  typedef RowIterator<const MT,typename MT::ConstIterator> ConstIterator;
1932 
1934  typedef typename SelectType< useConst, ConstIterator, RowIterator<MT,typename MT::Iterator> >::Type Iterator;
1935  //**********************************************************************************************
1936 
1937  //**Constructors********************************************************************************
1940  explicit inline SparseRow( MT& matrix, size_t index );
1941  // No explicitly declared copy constructor.
1943  //**********************************************************************************************
1944 
1945  //**Destructor**********************************************************************************
1946  // No explicitly declared destructor.
1947  //**********************************************************************************************
1948 
1949  //**Data access functions***********************************************************************
1952  inline Reference operator[]( size_t index );
1953  inline ConstReference operator[]( size_t index ) const;
1954  inline Iterator begin ();
1955  inline ConstIterator begin () const;
1956  inline ConstIterator cbegin() const;
1957  inline Iterator end ();
1958  inline ConstIterator end () const;
1959  inline ConstIterator cend () const;
1961  //**********************************************************************************************
1962 
1963  //**Assignment operators************************************************************************
1966  inline SparseRow& operator= ( const SparseRow& rhs );
1967  template< typename VT > inline SparseRow& operator= ( const Vector<VT,true>& rhs );
1968  template< typename VT > inline SparseRow& operator+=( const Vector<VT,true>& rhs );
1969  template< typename VT > inline SparseRow& operator-=( const Vector<VT,true>& rhs );
1970  template< typename VT > inline SparseRow& operator*=( const Vector<VT,true>& rhs );
1971 
1972  template< typename Other >
1973  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
1974  operator*=( Other rhs );
1975 
1976  template< typename Other >
1977  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
1978  operator/=( Other rhs );
1980  //**********************************************************************************************
1981 
1982  //**Utility functions***************************************************************************
1985  inline size_t size() const;
1986  inline size_t capacity() const;
1987  inline size_t nonZeros() const;
1988  inline void reset();
1989  inline Iterator insert ( size_t index, const ElementType& value );
1990  inline void erase ( size_t index );
1991  inline Iterator erase ( Iterator pos );
1992  inline Iterator erase ( Iterator first, Iterator last );
1993  inline void reserve( size_t n );
1994  template< typename Other > inline SparseRow& scale ( Other scalar );
1996  //**********************************************************************************************
1997 
1998  //**Lookup functions****************************************************************************
2001  inline Iterator find ( size_t index );
2002  inline ConstIterator find ( size_t index ) const;
2003  inline Iterator lowerBound( size_t index );
2004  inline ConstIterator lowerBound( size_t index ) const;
2005  inline Iterator upperBound( size_t index );
2006  inline ConstIterator upperBound( size_t index ) const;
2008  //**********************************************************************************************
2009 
2010  //**Low-level utility functions*****************************************************************
2013  inline void append( size_t index, const ElementType& value, bool check=false );
2015  //**********************************************************************************************
2016 
2017  //**Expression template evaluation functions****************************************************
2020  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2021  template< typename Other > inline bool isAliased( const Other* alias ) const;
2022  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2023  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2024  template< typename VT > inline void addAssign( const Vector<VT,true>& rhs );
2025  template< typename VT > inline void subAssign( const Vector<VT,true>& rhs );
2027  //**********************************************************************************************
2028 
2029  private:
2030  //**Member variables****************************************************************************
2034  const size_t row_;
2035 
2036  //**********************************************************************************************
2037 
2038  //**Compile time checks*************************************************************************
2045  //**********************************************************************************************
2046 };
2048 //*************************************************************************************************
2049 
2050 
2051 
2052 
2053 //=================================================================================================
2054 //
2055 // CONSTRUCTOR
2056 //
2057 //=================================================================================================
2058 
2059 //*************************************************************************************************
2067 template< typename MT > // Type of the sparse matrix
2068 inline SparseRow<MT,false>::SparseRow( MT& matrix, size_t index )
2069  : matrix_( matrix ) // The sparse matrix containing the row
2070  , row_ ( index ) // The index of the row in the matrix
2071 {
2072  if( matrix_.rows() <= index )
2073  throw std::invalid_argument( "Invalid row access index" );
2074 }
2076 //*************************************************************************************************
2077 
2078 
2079 
2080 
2081 //=================================================================================================
2082 //
2083 // DATA ACCESS FUNCTIONS
2084 //
2085 //=================================================================================================
2086 
2087 //*************************************************************************************************
2094 template< typename MT > // Type of the sparse matrix
2095 inline typename SparseRow<MT,false>::Reference SparseRow<MT,false>::operator[]( size_t index )
2096 {
2097  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2098  return matrix_(row_,index);
2099 }
2101 //*************************************************************************************************
2102 
2103 
2104 //*************************************************************************************************
2111 template< typename MT > // Type of the sparse matrix
2112 inline typename SparseRow<MT,false>::ConstReference SparseRow<MT,false>::operator[]( size_t index ) const
2113 {
2114  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2115  return const_cast<const MT&>( matrix_ )(row_,index);
2116 }
2118 //*************************************************************************************************
2119 
2120 
2121 //*************************************************************************************************
2129 template< typename MT > // Type of the sparse matrix
2130 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::begin()
2131 {
2132  return Iterator( matrix_, row_, 0UL );
2133 }
2135 //*************************************************************************************************
2136 
2137 
2138 //*************************************************************************************************
2146 template< typename MT > // Type of the sparse matrix
2147 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::begin() const
2148 {
2149  return ConstIterator( matrix_, row_, 0UL );
2150 }
2152 //*************************************************************************************************
2153 
2154 
2155 //*************************************************************************************************
2163 template< typename MT > // Type of the sparse matrix
2164 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::cbegin() const
2165 {
2166  return ConstIterator( matrix_, row_, 0UL );
2167 }
2169 //*************************************************************************************************
2170 
2171 
2172 //*************************************************************************************************
2180 template< typename MT > // Type of the sparse matrix
2181 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::end()
2182 {
2183  return Iterator( matrix_, row_, size() );
2184 }
2186 //*************************************************************************************************
2187 
2188 
2189 //*************************************************************************************************
2197 template< typename MT > // Type of the sparse matrix
2198 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::end() const
2199 {
2200  return ConstIterator( matrix_, row_, size() );
2201 }
2203 //*************************************************************************************************
2204 
2205 
2206 //*************************************************************************************************
2214 template< typename MT > // Type of the sparse matrix
2215 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::cend() const
2216 {
2217  return ConstIterator( matrix_, row_, size() );
2218 }
2220 //*************************************************************************************************
2221 
2222 
2223 
2224 
2225 //=================================================================================================
2226 //
2227 // ASSIGNMENT OPERATORS
2228 //
2229 //=================================================================================================
2230 
2231 //*************************************************************************************************
2242 template< typename MT > // Type of the sparse matrix
2243 inline SparseRow<MT,false>& SparseRow<MT,false>::operator=( const SparseRow& rhs )
2244 {
2245  using blaze::assign;
2246 
2250 
2251  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2252  return *this;
2253 
2254  if( size() != rhs.size() )
2255  throw std::invalid_argument( "Row sizes do not match" );
2256 
2257  if( rhs.canAlias( &matrix_ ) ) {
2258  const ResultType tmp( rhs );
2259  assign( *this, tmp );
2260  }
2261  else {
2262  assign( *this, rhs );
2263  }
2264 
2265  return *this;
2266 }
2268 //*************************************************************************************************
2269 
2270 
2271 //*************************************************************************************************
2282 template< typename MT > // Type of the sparse matrix
2283 template< typename VT > // Type of the right-hand side vector
2284 inline SparseRow<MT,false>& SparseRow<MT,false>::operator=( const Vector<VT,true>& rhs )
2285 {
2286  using blaze::assign;
2287 
2288  if( size() != (~rhs).size() )
2289  throw std::invalid_argument( "Vector sizes do not match" );
2290 
2291  const typename VT::CompositeType tmp( ~rhs );
2292  assign( *this, tmp );
2293 
2294  return *this;
2295 }
2297 //*************************************************************************************************
2298 
2299 
2300 //*************************************************************************************************
2311 template< typename MT > // Type of the sparse matrix
2312 template< typename VT > // Type of the right-hand side vector
2313 inline SparseRow<MT,false>& SparseRow<MT,false>::operator+=( const Vector<VT,true>& rhs )
2314 {
2315  using blaze::addAssign;
2316 
2317  if( size() != (~rhs).size() )
2318  throw std::invalid_argument( "Vector sizes do not match" );
2319 
2320  addAssign( *this, ~rhs );
2321 
2322  return *this;
2323 }
2325 //*************************************************************************************************
2326 
2327 
2328 //*************************************************************************************************
2339 template< typename MT > // Type of the sparse matrix
2340 template< typename VT > // Type of the right-hand side vector
2341 inline SparseRow<MT,false>& SparseRow<MT,false>::operator-=( const Vector<VT,true>& rhs )
2342 {
2343  using blaze::subAssign;
2344 
2345  if( size() != (~rhs).size() )
2346  throw std::invalid_argument( "Vector sizes do not match" );
2347 
2348  subAssign( *this, ~rhs );
2349 
2350  return *this;
2351 }
2353 //*************************************************************************************************
2354 
2355 
2356 //*************************************************************************************************
2368 template< typename MT > // Type of the sparse matrix
2369 template< typename VT > // Type of the right-hand side vector
2370 inline SparseRow<MT,false>& SparseRow<MT,false>::operator*=( const Vector<VT,true>& rhs )
2371 {
2372  if( size() != (~rhs).size() )
2373  throw std::invalid_argument( "Vector sizes do not match" );
2374 
2375  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
2376 
2379 
2380  const MultType tmp( *this * (~rhs) );
2381  assign( tmp );
2382 
2383  return *this;
2384 }
2386 //*************************************************************************************************
2387 
2388 
2389 //*************************************************************************************************
2401 template< typename MT > // Type of the sparse matrix
2402 template< typename Other > // Data type of the right-hand side scalar
2403 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,false> >::Type&
2404  SparseRow<MT,false>::operator*=( Other rhs )
2405 {
2406  for( Iterator element=begin(); element!=end(); ++element )
2407  element->value() *= rhs;
2408  return *this;
2409 }
2411 //*************************************************************************************************
2412 
2413 
2414 //*************************************************************************************************
2427 template< typename MT > // Type of the sparse matrix
2428 template< typename Other > // Data type of the right-hand side scalar
2429 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,false> >::Type&
2430  SparseRow<MT,false>::operator/=( Other rhs )
2431 {
2432  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2433 
2434  typedef typename DivTrait<ElementType,Other>::Type DT;
2435  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2436 
2437  // Depending on the two involved data types, an integer division is applied or a
2438  // floating point division is selected.
2439  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2440  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2441  for( Iterator element=begin(); element!=end(); ++element )
2442  element->value() *= tmp;
2443  }
2444  else {
2445  for( Iterator element=begin(); element!=end(); ++element )
2446  element->value() /= rhs;
2447  }
2448 
2449  return *this;
2450 }
2452 //*************************************************************************************************
2453 
2454 
2455 
2456 
2457 //=================================================================================================
2458 //
2459 // UTILITY FUNCTIONS
2460 //
2461 //=================================================================================================
2462 
2463 //*************************************************************************************************
2469 template< typename MT > // Type of the sparse matrix
2470 inline size_t SparseRow<MT,false>::size() const
2471 {
2472  return matrix_.columns();
2473 }
2475 //*************************************************************************************************
2476 
2477 
2478 //*************************************************************************************************
2484 template< typename MT > // Type of the sparse matrix
2485 inline size_t SparseRow<MT,false>::capacity() const
2486 {
2487  return matrix_.columns();
2488 }
2490 //*************************************************************************************************
2491 
2492 
2493 //*************************************************************************************************
2502 template< typename MT > // Type of the sparse matrix
2503 inline size_t SparseRow<MT,false>::nonZeros() const
2504 {
2505  size_t counter( 0UL );
2506  for( ConstIterator element=begin(); element!=end(); ++element ) {
2507  ++counter;
2508  }
2509  return counter;
2510 }
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2521 template< typename MT > // Type of the sparse matrix
2522 inline void SparseRow<MT,false>::reset()
2523 {
2524  for( size_t j=0UL; j<size(); ++j ) {
2525  matrix_.erase( row_, j );
2526  }
2527 }
2529 //*************************************************************************************************
2530 
2531 
2532 //*************************************************************************************************
2545 template< typename MT > // Type of the sparse matrix
2546 inline typename SparseRow<MT,false>::Iterator
2547  SparseRow<MT,false>::insert( size_t index, const ElementType& value )
2548 {
2549  return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
2550 }
2552 //*************************************************************************************************
2553 
2554 
2555 //*************************************************************************************************
2564 template< typename MT > // Type of the sparse matrix
2565 inline void SparseRow<MT,false>::erase( size_t index )
2566 {
2567  matrix_.erase( row_, index );
2568 }
2570 //*************************************************************************************************
2571 
2572 
2573 //*************************************************************************************************
2582 template< typename MT > // Type of the sparse matrix
2583 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::erase( Iterator pos )
2584 {
2585  const size_t column( pos.column_ );
2586 
2587  if( column == size() )
2588  return pos;
2589 
2590  matrix_.erase( column, pos.pos_ );
2591  return Iterator( matrix_, row_, column+1UL );
2592 }
2594 //*************************************************************************************************
2595 
2596 
2597 //*************************************************************************************************
2607 template< typename MT > // Type of the sparse matrix
2608 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::erase( Iterator first, Iterator last )
2609 {
2610  for( ; first!=last; ++first ) {
2611  matrix_.erase( first.column_, first.pos_ );
2612  }
2613  return last;
2614 }
2616 //*************************************************************************************************
2617 
2618 
2619 //*************************************************************************************************
2629 template< typename MT > // Type of the sparse matrix
2630 void SparseRow<MT,false>::reserve( size_t n )
2631 {
2632  UNUSED_PARAMETER( n );
2633  return;
2634 }
2636 //*************************************************************************************************
2637 
2638 
2639 //*************************************************************************************************
2646 template< typename MT > // Type of the sparse matrix
2647 template< typename Other > // Data type of the scalar value
2648 inline SparseRow<MT,false>& SparseRow<MT,false>::scale( Other scalar )
2649 {
2650  for( Iterator element=begin(); element!=end(); ++element )
2651  element->value() *= scalar;
2652  return *this;
2653 }
2655 //*************************************************************************************************
2656 
2657 
2658 
2659 
2660 //=================================================================================================
2661 //
2662 // LOOKUP FUNCTIONS
2663 //
2664 //=================================================================================================
2665 
2666 //*************************************************************************************************
2680 template< typename MT > // Type of the sparse matrix
2681 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::find( size_t index )
2682 {
2683  const typename MT::Iterator pos( matrix_.find( row_, index ) );
2684 
2685  if( pos != matrix_.end( index ) )
2686  return Iterator( matrix_, row_, index, pos );
2687  else
2688  return end();
2689 }
2691 //*************************************************************************************************
2692 
2693 
2694 //*************************************************************************************************
2708 template< typename MT > // Type of the sparse matrix
2709 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::find( size_t index ) const
2710 {
2711  const typename MT::ConstIterator pos( matrix_.find( row_, index ) );
2712 
2713  if( pos != matrix_.end( index ) )
2714  return ConstIterator( matrix_, row_, index, pos );
2715  else
2716  return end();
2717 }
2719 //*************************************************************************************************
2720 
2721 
2722 //*************************************************************************************************
2735 template< typename MT > // Type of the sparse matrix
2736 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::lowerBound( size_t index )
2737 {
2738  for( size_t i=index; i<size(); ++i )
2739  {
2740  const typename MT::Iterator pos( matrix_.find( row_, i ) );
2741 
2742  if( pos != matrix_.end( i ) )
2743  return Iterator( matrix_, row_, i, pos );
2744  }
2745 
2746  return end();
2747 }
2749 //*************************************************************************************************
2750 
2751 
2752 //*************************************************************************************************
2765 template< typename MT > // Type of the sparse matrix
2766 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::lowerBound( size_t index ) const
2767 {
2768  for( size_t i=index; i<size(); ++i )
2769  {
2770  const typename MT::ConstIterator pos( matrix_.find( row_, i ) );
2771 
2772  if( pos != matrix_.end( i ) )
2773  return ConstIterator( matrix_, row_, i, pos );
2774  }
2775 
2776  return end();
2777 }
2779 //*************************************************************************************************
2780 
2781 
2782 //*************************************************************************************************
2795 template< typename MT > // Type of the sparse matrix
2796 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::upperBound( size_t index )
2797 {
2798  for( size_t i=index+1UL; i<size(); ++i )
2799  {
2800  const typename MT::Iterator pos( matrix_.find( row_, i ) );
2801 
2802  if( pos != matrix_.end( i ) )
2803  return Iterator( matrix_, row_, i, pos );
2804  }
2805 
2806  return end();
2807 }
2809 //*************************************************************************************************
2810 
2811 
2812 //*************************************************************************************************
2825 template< typename MT > // Type of the sparse matrix
2826 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::upperBound( size_t index ) const
2827 {
2828  for( size_t i=index+1UL; i<size(); ++i )
2829  {
2830  const typename MT::ConstIterator pos( matrix_.find( row_, i ) );
2831 
2832  if( pos != matrix_.end( i ) )
2833  return ConstIterator( matrix_, row_, i, pos );
2834  }
2835 
2836  return end();
2837 }
2839 //*************************************************************************************************
2840 
2841 
2842 
2843 
2844 //=================================================================================================
2845 //
2846 // LOW-LEVEL UTILITY FUNCTIONS
2847 //
2848 //=================================================================================================
2849 
2850 //*************************************************************************************************
2875 template< typename MT > // Type of the sparse matrix
2876 inline void SparseRow<MT,false>::append( size_t index, const ElementType& value, bool check )
2877 {
2878  if( !check || !isDefault( value ) )
2879  matrix_.insert( row_, index, value );
2880 }
2882 //*************************************************************************************************
2883 
2884 
2885 
2886 
2887 //=================================================================================================
2888 //
2889 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2890 //
2891 //=================================================================================================
2892 
2893 //*************************************************************************************************
2904 template< typename MT > // Type of the sparse matrix
2905 template< typename Other > // Data type of the foreign expression
2906 inline bool SparseRow<MT,false>::canAlias( const Other* alias ) const
2907 {
2908  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2909 }
2911 //*************************************************************************************************
2912 
2913 
2914 //*************************************************************************************************
2921 template< typename MT > // Type of the sparse matrix
2922 template< typename Other > // Data type of the foreign expression
2923 inline bool SparseRow<MT,false>::isAliased( const Other* alias ) const
2924 {
2925  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2926 }
2928 //*************************************************************************************************
2929 
2930 
2931 //*************************************************************************************************
2943 template< typename MT > // Type of the sparse matrix
2944 template< typename VT > // Type of the right-hand side dense vector
2945 inline void SparseRow<MT,false>::assign( const DenseVector<VT,true>& rhs )
2946 {
2947  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2948 
2949  for( size_t j=0UL; j<(~rhs).size(); ++j ) {
2950  matrix_(row_,j) = (~rhs)[j];
2951  }
2952 }
2954 //*************************************************************************************************
2955 
2956 
2957 //*************************************************************************************************
2969 template< typename MT > // Type of the sparse matrix
2970 template< typename VT > // Type of the right-hand side sparse vector
2971 inline void SparseRow<MT,false>::assign( const SparseVector<VT,true>& rhs )
2972 {
2973  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2974 
2975  size_t j( 0UL );
2976 
2977  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
2978  for( ; j<element->index(); ++j )
2979  matrix_.erase( row_, j );
2980  matrix_(row_,j++) = element->value();
2981  }
2982  for( ; j<size(); ++j ) {
2983  matrix_.erase( row_, j );
2984  }
2985 }
2987 //*************************************************************************************************
2988 
2989 
2990 //*************************************************************************************************
3002 template< typename MT > // Type of the sparse matrix
3003 template< typename VT > // Type of the right-hand side vector
3004 inline void SparseRow<MT,false>::addAssign( const Vector<VT,true>& rhs )
3005 {
3006  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3007 
3010 
3011  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3012 
3013  const AddType tmp( *this + (~rhs) );
3014  assign( tmp );
3015 }
3017 //*************************************************************************************************
3018 
3019 
3020 //*************************************************************************************************
3032 template< typename MT > // Type of the sparse matrix
3033 template< typename VT > // Type of the right-hand side vector
3034 inline void SparseRow<MT,false>::subAssign( const Vector<VT,true>& rhs )
3035 {
3036  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3037 
3040 
3041  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3042 
3043  const SubType tmp( *this - (~rhs) );
3044  assign( tmp );
3045 }
3047 //*************************************************************************************************
3048 
3049 
3050 
3051 
3052 
3053 
3054 
3055 
3056 //=================================================================================================
3057 //
3058 // SPARSEROW OPERATORS
3059 //
3060 //=================================================================================================
3061 
3062 //*************************************************************************************************
3065 template< typename MT, bool SO >
3066 inline void reset( SparseRow<MT,SO>& row );
3067 
3068 template< typename MT, bool SO >
3069 inline void clear( SparseRow<MT,SO>& row );
3070 
3071 template< typename MT, bool SO >
3072 inline bool isDefault( const SparseRow<MT,SO>& row );
3074 //*************************************************************************************************
3075 
3076 
3077 //*************************************************************************************************
3084 template< typename MT // Type of the sparse matrix
3085  , bool SO > // Storage order
3086 inline void reset( SparseRow<MT,SO>& row )
3087 {
3088  row.reset();
3089 }
3090 //*************************************************************************************************
3091 
3092 
3093 //*************************************************************************************************
3102 template< typename MT // Type of the sparse matrix
3103  , bool SO > // Storage order
3104 inline void clear( SparseRow<MT,SO>& row )
3105 {
3106  row.reset();
3107 }
3108 //*************************************************************************************************
3109 
3110 
3111 //*************************************************************************************************
3129 template< typename MT // Type of the sparse matrix
3130  , bool SO > // Storage order
3131 inline bool isDefault( const SparseRow<MT,SO>& row )
3132 {
3134 
3135  const ConstIterator end( row.end() );
3136  for( ConstIterator element=row.begin(); element!=end; ++element )
3137  if( !isDefault( element->value() ) ) return false;
3138  return true;
3139 }
3140 //*************************************************************************************************
3141 
3142 
3143 
3144 
3145 //=================================================================================================
3146 //
3147 // GLOBAL OPERATORS
3148 //
3149 //=================================================================================================
3150 
3151 //*************************************************************************************************
3172 template< typename MT // Type of the sparse matrix
3173  , bool SO > // Storage order
3174 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseRow<MT> >::Type
3175  row( SparseMatrix<MT,SO>& sm, size_t index )
3176 {
3178 
3179  return SparseRow<MT>( ~sm, index );
3180 }
3181 //*************************************************************************************************
3182 
3183 
3184 //*************************************************************************************************
3205 template< typename MT // Type of the sparse matrix
3206  , bool SO > // Storage order
3207 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >, SparseRow<const MT> >::Type
3208  row( const SparseMatrix<MT,SO>& sm, size_t index )
3209 {
3211 
3212  return SparseRow<const MT>( ~sm, index );
3213 }
3214 //*************************************************************************************************
3215 
3216 
3217 
3218 
3219 //=================================================================================================
3220 //
3221 // SUBVECTORTRAIT SPECIALIZATIONS
3222 //
3223 //=================================================================================================
3224 
3225 //*************************************************************************************************
3227 template< typename MT, bool SO >
3228 struct SubvectorTrait< SparseRow<MT,SO> >
3229 {
3230  typedef typename SubvectorTrait< typename SparseRow<MT,SO>::ResultType >::Type Type;
3231 };
3233 //*************************************************************************************************
3234 
3235 } // namespace blaze
3236 
3237 #endif
Constraint on the data type.
const size_t row_
The index of the row in the matrix.
Definition: SparseRow.h:488
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseColumn< MT > >::Type column(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific column of the given dense matrix.
Definition: DenseColumn.h:3026
Iterator end()
Returns an iterator just past the last element of the row.
Definition: SparseRow.h:628
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.
size_t nonZeros() const
Returns the number of non-zero elements in the row.
Definition: SparseRow.h:995
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:3703
Header file for the subtraction trait.
bool isAliased(const Other *alias) const
Returns whether the sparse row is aliased with the given address alias.
Definition: SparseRow.h:1370
Header file for the SparseVector base class.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseRow.h:365
size_t size() const
Returns the current size/dimension of the sparse row.
Definition: SparseRow.h:964
size_t capacity() const
Returns the maximum capacity of the sparse row.
Definition: SparseRow.h:978
void reset()
Reset to the default initial values.
Definition: SparseRow.h:1009
Header file for the View base class.
Header file for the row trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:118
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: SparseRow.h:375
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2375
Operand matrix_
The sparse matrix containing the row.
Definition: SparseRow.h:487
void erase(size_t index)
Erasing an element from the sparse row.
Definition: SparseRow.h:1048
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse row.
Definition: SparseRow.h:1322
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:2793
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
bool canAlias(const Other *alias) const
Returns whether the sparse row can alias with the given address alias.
Definition: SparseRow.h:1350
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseRow.h:1260
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
void assign(const DenseVector< VT, true > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseRow.h:1391
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: SparseRow.h:369
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the row.
Definition: SparseRow.h:580
Base template for the RowTrait class.
Definition: RowTrait.h:114
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 If class template.
ConstIterator cend() const
Returns an iterator just past the last element of the row.
Definition: SparseRow.h:660
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
Iterator find(size_t index)
Searches for a specific row element.
Definition: SparseRow.h:1175
Header file for the Or class template.
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: SparseRow.h:547
Header file for the subvector trait.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:79
SparseRow & operator=(const SparseRow &rhs)
Copy assignment operator for SparseRow.
Definition: SparseRow.h:687
void addAssign(const DenseVector< VT, true > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseRow.h:1447
Constraint on the data type.
Constraint on the data type.
Operand matrix_
The dense matrix containing the column.
Definition: DenseColumn.h:2069
Constraints on the storage order of matrix types.
Constraint on the data type.
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:94
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2373
Constraint on the data type.
Header file for the SelectType class template.
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:2794
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
Header file for the EnableIf class template.
void subAssign(const DenseVector< VT, true > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseRow.h:1510
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
void reserve(size_t n)
Setting the minimum capacity of the sparse row.
Definition: SparseRow.h:1101
Header file for the IsNumeric type trait.
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseRow.h:1218
const size_t row_
The index of the row in the matrix.
Definition: DenseRow.h:2069
ConstIterator cbegin() const
Returns an iterator to the first element of the row.
Definition: SparseRow.h:612
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2374
Header file for the IsConst type trait.
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:141
Base template for the MultTrait class.
Definition: MultTrait.h:141
Header file for the addition trait.
Reference to a specific row of a sparse matrix.The SparseRow template represents a reference to a spe...
Definition: Forward.h:52
Header file for the division trait.
size_t extendCapacity() const
Calculating a new sparse row capacity.
Definition: SparseRow.h:1136
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: SparseRow.h:363
Header file for the reset shim.
SparseRow(MT &matrix, size_t index)
The constructor for SparseRow.
Definition: SparseRow.h:521
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseRow< MT > >::Type row(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific row of the given dense matrix.
Definition: DenseRow.h:3025
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
const VT::ElementType max(const SparseVector< VT, TF > &sv)
Returns the largest element of the sparse vector.
Definition: SparseVector.h:405
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2378
Header file for the isDefault shim.
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: SparseRow.h:372
#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:141
#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
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: SparseRow.h:345
Header file for the IsRowMajorMatrix type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
Base class for all views.The View class serves as a tag for all views (subvectors, submatrices, rows, columns, ...). All classes that represent a view and that are used within the expression template environment of the Blaze library have to derive from this class in order to qualify as a view. Only in case a class is derived from the View base class, the IsView type trait recognizes the class as valid view.
Definition: View.h:64
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse row.
Definition: SparseRow.h:1031
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:247
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
RowTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseRow.h:362
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
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.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: TransposeFlag.h:81
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: SparseRow.h:378
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2376
Base template for the SubTrait class.
Definition: SubTrait.h:141
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
MT::ElementType ElementType
Type of the row elements.
Definition: SparseRow.h:364
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:2792
const SparseRow & CompositeType
Data type for composite expression templates.
Definition: SparseRow.h:366
#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
SparseRow< MT, SO > This
Type of this SparseRow instance.
Definition: SparseRow.h:361
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.