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>
67 #include <blaze/util/Assert.h>
68 #include <blaze/util/DisableIf.h>
69 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/mpl/If.h>
72 #include <blaze/util/mpl/Or.h>
73 #include <blaze/util/SelectType.h>
74 #include <blaze/util/Types.h>
78 #include <blaze/util/Unused.h>
79 
80 
81 namespace blaze {
82 
83 //=================================================================================================
84 //
85 // CLASS DEFINITION
86 //
87 //=================================================================================================
88 
89 //*************************************************************************************************
338 template< typename MT // Type of the sparse matrix
339  , bool SO = IsRowMajorMatrix<MT>::value > // Storage order
340 class SparseRow : public SparseVector< SparseRow<MT,SO>, true >
341  , private Row
342 {
343  private:
344  //**Type definitions****************************************************************************
346  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
347  //**********************************************************************************************
348 
349  //**********************************************************************************************
351 
357  enum { useConst = IsConst<MT>::value };
358  //**********************************************************************************************
359 
360  public:
361  //**Type definitions****************************************************************************
363  typedef typename RowTrait<MT>::Type ResultType;
365  typedef typename MT::ElementType ElementType;
366  typedef typename MT::ReturnType ReturnType;
367  typedef const SparseRow& CompositeType;
368 
371 
374 
377 
380  //**********************************************************************************************
381 
382  //**Compilation flags***************************************************************************
384  enum { smpAssignable = 0 };
385  //**********************************************************************************************
386 
387  //**Constructors********************************************************************************
390  explicit inline SparseRow( MT& matrix, size_t index );
391  // No explicitly declared copy constructor.
393  //**********************************************************************************************
394 
395  //**Destructor**********************************************************************************
396  // No explicitly declared destructor.
397  //**********************************************************************************************
398 
399  //**Data access functions***********************************************************************
402  inline Reference operator[]( size_t index );
403  inline ConstReference operator[]( size_t index ) const;
404  inline Iterator begin ();
405  inline ConstIterator begin () const;
406  inline ConstIterator cbegin() const;
407  inline Iterator end ();
408  inline ConstIterator end () const;
409  inline ConstIterator cend () const;
411  //**********************************************************************************************
412 
413  //**Assignment operators************************************************************************
416  inline SparseRow& operator= ( const SparseRow& rhs );
417  template< typename VT > inline SparseRow& operator= ( const DenseVector <VT,true>& rhs );
418  template< typename VT > inline SparseRow& operator= ( const SparseVector<VT,true>& rhs );
419  template< typename VT > inline SparseRow& operator+=( const Vector<VT,true>& rhs );
420  template< typename VT > inline SparseRow& operator-=( const Vector<VT,true>& rhs );
421  template< typename VT > inline SparseRow& operator*=( const Vector<VT,true>& rhs );
422 
423  template< typename Other >
424  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
425  operator*=( Other rhs );
426 
427  template< typename Other >
428  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
429  operator/=( Other rhs );
431  //**********************************************************************************************
432 
433  //**Utility functions***************************************************************************
436  inline size_t size() const;
437  inline size_t capacity() const;
438  inline size_t nonZeros() const;
439  inline void reset();
440  inline Iterator insert ( size_t index, const ElementType& value );
441  inline void erase ( size_t index );
442  inline Iterator erase ( Iterator pos );
443  inline Iterator erase ( Iterator first, Iterator last );
444  inline void reserve( size_t n );
445  template< typename Other > inline SparseRow& scale ( Other scalar );
447  //**********************************************************************************************
448 
449  //**Lookup functions****************************************************************************
452  inline Iterator find ( size_t index );
453  inline ConstIterator find ( size_t index ) const;
454  inline Iterator lowerBound( size_t index );
455  inline ConstIterator lowerBound( size_t index ) const;
456  inline Iterator upperBound( size_t index );
457  inline ConstIterator upperBound( size_t index ) const;
459  //**********************************************************************************************
460 
461  //**Low-level utility functions*****************************************************************
464  inline void append( size_t index, const ElementType& value, bool check=false );
466  //**********************************************************************************************
467 
468  //**Expression template evaluation functions****************************************************
471  template< typename Other > inline bool canAlias ( const Other* alias ) const;
472  template< typename Other > inline bool isAliased( const Other* alias ) const;
473 
474  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
475  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
476  template< typename VT > inline void addAssign( const DenseVector <VT,true>& rhs );
477  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
478  template< typename VT > inline void subAssign( const DenseVector <VT,true>& rhs );
479  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
481  //**********************************************************************************************
482 
483  private:
484  //**Utility functions***************************************************************************
487  inline size_t extendCapacity() const;
489  //**********************************************************************************************
490 
491  //**Member variables****************************************************************************
495  const size_t row_;
496 
497  //**********************************************************************************************
498 
499  //**Friend declarations*************************************************************************
501  template< typename MT2, bool SO2 >
502  friend bool isSame( const SparseRow<MT2,SO2>& a, const SparseRow<MT2,SO2>& b );
504  //**********************************************************************************************
505 
506  //**Compile time checks*************************************************************************
513  //**********************************************************************************************
514 };
515 //*************************************************************************************************
516 
517 
518 
519 
520 //=================================================================================================
521 //
522 // CONSTRUCTOR
523 //
524 //=================================================================================================
525 
526 //*************************************************************************************************
533 template< typename MT // Type of the sparse matrix
534  , bool SO > // Storage order
535 inline SparseRow<MT,SO>::SparseRow( MT& matrix, size_t index )
536  : matrix_( matrix ) // The sparse matrix containing the row
537  , row_ ( index ) // The index of the row in the matrix
538 {
539  if( matrix_.rows() <= index )
540  throw std::invalid_argument( "Invalid row access index" );
541 }
542 //*************************************************************************************************
543 
544 
545 
546 
547 //=================================================================================================
548 //
549 // DATA ACCESS FUNCTIONS
550 //
551 //=================================================================================================
552 
553 //*************************************************************************************************
559 template< typename MT // Type of the sparse matrix
560  , bool SO > // Storage order
562 {
563  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
564  return matrix_(row_,index);
565 }
566 //*************************************************************************************************
567 
568 
569 //*************************************************************************************************
575 template< typename MT // Type of the sparse matrix
576  , bool SO > // Storage order
578 {
579  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
580  return const_cast<const MT&>( matrix_ )(row_,index);
581 }
582 //*************************************************************************************************
583 
584 
585 //*************************************************************************************************
592 template< typename MT // Type of the sparse matrix
593  , bool SO > // Storage order
595 {
596  return matrix_.begin( row_ );
597 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
608 template< typename MT // Type of the sparse matrix
609  , bool SO > // Storage order
611 {
612  return matrix_.cbegin( row_ );
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
624 template< typename MT // Type of the sparse matrix
625  , bool SO > // Storage order
627 {
628  return matrix_.cbegin( row_ );
629 }
630 //*************************************************************************************************
631 
632 
633 //*************************************************************************************************
640 template< typename MT // Type of the sparse matrix
641  , bool SO > // Storage order
643 {
644  return matrix_.end( row_ );
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
656 template< typename MT // Type of the sparse matrix
657  , bool SO > // Storage order
659 {
660  return matrix_.cend( row_ );
661 }
662 //*************************************************************************************************
663 
664 
665 //*************************************************************************************************
672 template< typename MT // Type of the sparse matrix
673  , bool SO > // Storage order
675 {
676  return matrix_.cend( row_ );
677 }
678 //*************************************************************************************************
679 
680 
681 
682 
683 //=================================================================================================
684 //
685 // ASSIGNMENT OPERATORS
686 //
687 //=================================================================================================
688 
689 //*************************************************************************************************
699 template< typename MT // Type of the sparse matrix
700  , bool SO > // Storage order
702 {
703  using blaze::assign;
704 
708 
709  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
710  return *this;
711 
712  if( size() != rhs.size() )
713  throw std::invalid_argument( "Row sizes do not match" );
714 
715  if( rhs.canAlias( &matrix_ ) ) {
716  const ResultType tmp( rhs );
717  matrix_.reset ( row_ );
718  matrix_.reserve( row_, tmp.nonZeros() );
719  assign( *this, tmp );
720  }
721  else {
722  matrix_.reset ( row_ );
723  matrix_.reserve( row_, rhs.nonZeros() );
724  assign( *this, rhs );
725  }
726 
727  return *this;
728 }
729 //*************************************************************************************************
730 
731 
732 //*************************************************************************************************
742 template< typename MT // Type of the sparse matrix
743  , bool SO > // Storage order
744 template< typename VT > // Type of the right-hand side dense vector
746 {
747  using blaze::assign;
748 
752 
753  if( size() != (~rhs).size() )
754  throw std::invalid_argument( "Vector sizes do not match" );
755 
756  if( (~rhs).canAlias( &matrix_ ) ) {
757  const typename VT::ResultType tmp( ~rhs );
758  matrix_.reset( row_ );
759  assign( *this, tmp );
760  }
761  else {
762  matrix_.reset( row_ );
763  assign( *this, ~rhs );
764  }
765 
766  return *this;
767 }
768 //*************************************************************************************************
769 
770 
771 //*************************************************************************************************
781 template< typename MT // Type of the sparse matrix
782  , bool SO > // Storage order
783 template< typename VT > // Type of the right-hand side sparse vector
785 {
786  using blaze::assign;
787 
791 
792  if( size() != (~rhs).size() )
793  throw std::invalid_argument( "Vector sizes do not match" );
794 
795  if( (~rhs).canAlias( &matrix_ ) ) {
796  const typename VT::ResultType tmp( ~rhs );
797  matrix_.reset ( row_ );
798  matrix_.reserve( row_, tmp.nonZeros() );
799  assign( *this, tmp );
800  }
801  else {
802  matrix_.reset ( row_ );
803  matrix_.reserve( row_, (~rhs).nonZeros() );
804  assign( *this, ~rhs );
805  }
806 
807  return *this;
808 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
822 template< typename MT // Type of the sparse matrix
823  , bool SO > // Storage order
824 template< typename VT > // Type of the right-hand side vector
826 {
827  using blaze::addAssign;
828 
829  if( size() != (~rhs).size() )
830  throw std::invalid_argument( "Vector sizes do not match" );
831 
832  addAssign( *this, ~rhs );
833 
834  return *this;
835 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
849 template< typename MT // Type of the sparse matrix
850  , bool SO > // Storage order
851 template< typename VT > // Type of the right-hand side vector
853 {
854  using blaze::subAssign;
855 
856  if( size() != (~rhs).size() )
857  throw std::invalid_argument( "Vector sizes do not match" );
858 
859  subAssign( *this, ~rhs );
860 
861  return *this;
862 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
877 template< typename MT // Type of the sparse matrix
878  , bool SO > // Storage order
879 template< typename VT > // Type of the right-hand side vector
881 {
882  if( size() != (~rhs).size() )
883  throw std::invalid_argument( "Vector sizes do not match" );
884 
885  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
886 
889 
890  const MultType tmp( *this * (~rhs) );
891  matrix_.reset( row_ );
892  assign( tmp );
893 
894  return *this;
895 }
896 //*************************************************************************************************
897 
898 
899 //*************************************************************************************************
910 template< typename MT // Type of the sparse matrix
911  , bool SO > // Storage order
912 template< typename Other > // Data type of the right-hand side scalar
913 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,SO> >::Type&
915 {
916  for( Iterator element=begin(); element!=end(); ++element )
917  element->value() *= rhs;
918  return *this;
919 }
920 //*************************************************************************************************
921 
922 
923 //*************************************************************************************************
935 template< typename MT // Type of the sparse matrix
936  , bool SO > // Storage order
937 template< typename Other > // Data type of the right-hand side scalar
938 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,SO> >::Type&
940 {
941  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
942 
943  typedef typename DivTrait<ElementType,Other>::Type DT;
944  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
945 
946  // Depending on the two involved data types, an integer division is applied or a
947  // floating point division is selected.
949  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
950  for( Iterator element=begin(); element!=end(); ++element )
951  element->value() *= tmp;
952  }
953  else {
954  for( Iterator element=begin(); element!=end(); ++element )
955  element->value() /= rhs;
956  }
957 
958  return *this;
959 }
960 //*************************************************************************************************
961 
962 
963 
964 
965 //=================================================================================================
966 //
967 // UTILITY FUNCTIONS
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>::size() const
979 {
980  return matrix_.columns();
981 }
982 //*************************************************************************************************
983 
984 
985 //*************************************************************************************************
990 template< typename MT // Type of the sparse matrix
991  , bool SO > // Storage order
992 inline size_t SparseRow<MT,SO>::capacity() const
993 {
994  return matrix_.capacity( row_ );
995 }
996 //*************************************************************************************************
997 
998 
999 //*************************************************************************************************
1007 template< typename MT // Type of the sparse matrix
1008  , bool SO > // Storage order
1009 inline size_t SparseRow<MT,SO>::nonZeros() const
1010 {
1011  return matrix_.nonZeros( row_ );
1012 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1021 template< typename MT // Type of the sparse matrix
1022  , bool SO > // Storage order
1024 {
1025  matrix_.reset( row_ );
1026 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1042 template< typename MT // Type of the sparse matrix
1043  , bool SO > // Storage order
1044 inline typename SparseRow<MT,SO>::Iterator
1045  SparseRow<MT,SO>::insert( size_t index, const ElementType& value )
1046 {
1047  return matrix_.insert( row_, index, value );
1048 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1060 template< typename MT // Type of the sparse matrix
1061  , bool SO > // Storage order
1062 inline void SparseRow<MT,SO>::erase( size_t index )
1063 {
1064  matrix_.erase( row_, index );
1065 }
1066 //*************************************************************************************************
1067 
1068 
1069 //*************************************************************************************************
1077 template< typename MT // Type of the sparse matrix
1078  , bool SO > // Storage order
1080 {
1081  return matrix_.erase( row_, pos );
1082 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1095 template< typename MT // Type of the sparse matrix
1096  , bool SO > // Storage order
1098 {
1099  return matrix_.erase( row_, first, last );
1100 }
1101 //*************************************************************************************************
1102 
1103 
1104 //*************************************************************************************************
1113 template< typename MT // Type of the sparse matrix
1114  , bool SO > // Storage order
1116 {
1117  matrix_.reserve( row_, n );
1118 }
1119 //*************************************************************************************************
1120 
1121 
1122 //*************************************************************************************************
1128 template< typename MT // Type of the sparse matrix
1129  , bool SO > // Storage order
1130 template< typename Other > // Data type of the scalar value
1132 {
1133  for( Iterator element=begin(); element!=end(); ++element )
1134  element->value() *= scalar;
1135  return *this;
1136 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1148 template< typename MT // Type of the sparse matrix
1149  , bool SO > // Storage order
1151 {
1152  using blaze::max;
1153  using blaze::min;
1154 
1155  size_t nonzeros( 2UL*capacity()+1UL );
1156  nonzeros = max( nonzeros, 7UL );
1157  nonzeros = min( nonzeros, size() );
1158 
1159  BLAZE_INTERNAL_ASSERT( nonzeros > capacity(), "Invalid capacity value" );
1160 
1161  return nonzeros;
1162 }
1163 //*************************************************************************************************
1164 
1165 
1166 
1167 
1168 //=================================================================================================
1169 //
1170 // LOOKUP FUNCTIONS
1171 //
1172 //=================================================================================================
1173 
1174 //*************************************************************************************************
1187 template< typename MT // Type of the sparse matrix
1188  , bool SO > // Storage order
1190 {
1191  return matrix_.find( row_, index );
1192 }
1193 //*************************************************************************************************
1194 
1195 
1196 //*************************************************************************************************
1209 template< typename MT // Type of the sparse matrix
1210  , bool SO > // Storage order
1211 inline typename SparseRow<MT,SO>::ConstIterator SparseRow<MT,SO>::find( size_t index ) const
1212 {
1213  return matrix_.find( row_, index );
1214 }
1215 //*************************************************************************************************
1216 
1217 
1218 //*************************************************************************************************
1230 template< typename MT // Type of the sparse matrix
1231  , bool SO > // Storage order
1233 {
1234  return matrix_.lowerBound( row_, index );
1235 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1251 template< typename MT // Type of the sparse matrix
1252  , bool SO > // Storage order
1254 {
1255  return matrix_.lowerBound( row_, index );
1256 }
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1272 template< typename MT // Type of the sparse matrix
1273  , bool SO > // Storage order
1275 {
1276  return matrix_.upperBound( row_, index );
1277 }
1278 //*************************************************************************************************
1279 
1280 
1281 //*************************************************************************************************
1293 template< typename MT // Type of the sparse matrix
1294  , bool SO > // Storage order
1296 {
1297  return matrix_.upperBound( row_, index );
1298 }
1299 //*************************************************************************************************
1300 
1301 
1302 
1303 
1304 //=================================================================================================
1305 //
1306 // LOW-LEVEL UTILITY FUNCTIONS
1307 //
1308 //=================================================================================================
1309 
1310 //*************************************************************************************************
1334 template< typename MT // Type of the sparse matrix
1335  , bool SO > // Storage order
1336 inline void SparseRow<MT,SO>::append( size_t index, const ElementType& value, bool check )
1337 {
1338  matrix_.append( row_, index, value, check );
1339 }
1340 //*************************************************************************************************
1341 
1342 
1343 
1344 
1345 //=================================================================================================
1346 //
1347 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1348 //
1349 //=================================================================================================
1350 
1351 //*************************************************************************************************
1361 template< typename MT // Type of the sparse matrix
1362  , bool SO > // Storage order
1363 template< typename Other > // Data type of the foreign expression
1364 inline bool SparseRow<MT,SO>::canAlias( const Other* alias ) const
1365 {
1366  return matrix_.isAliased( alias );
1367 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1381 template< typename MT // Type of the sparse matrix
1382  , bool SO > // Storage order
1383 template< typename Other > // Data type of the foreign expression
1384 inline bool SparseRow<MT,SO>::isAliased( const Other* alias ) const
1385 {
1386  return matrix_.isAliased( alias );
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1402 template< typename MT // Type of the sparse matrix
1403  , bool SO > // Storage order
1404 template< typename VT > // Type of the right-hand side dense vector
1406 {
1407  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1408  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1409 
1410  for( size_t j=0UL; j<size(); ++j )
1411  {
1412  if( matrix_.nonZeros( row_ ) == matrix_.capacity( row_ ) )
1413  matrix_.reserve( row_, extendCapacity() );
1414 
1415  matrix_.append( row_, j, (~rhs)[j], true );
1416  }
1417 }
1418 //*************************************************************************************************
1419 
1420 
1421 //*************************************************************************************************
1432 template< typename MT // Type of the sparse matrix
1433  , bool SO > // Storage order
1434 template< typename VT > // Type of the right-hand side sparse vector
1436 {
1437  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1438  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1439 
1440  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1441  matrix_.append( row_, element->index(), element->value() );
1442  }
1443 }
1444 //*************************************************************************************************
1445 
1446 
1447 //*************************************************************************************************
1458 template< typename MT // Type of the sparse matrix
1459  , bool SO > // Storage order
1460 template< typename VT > // Type of the right-hand side dense vector
1462 {
1463  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1464 
1468 
1469  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1470 
1471  const AddType tmp( serial( *this + (~rhs) ) );
1472  matrix_.reset( row_ );
1473  assign( tmp );
1474 }
1475 //*************************************************************************************************
1476 
1477 
1478 //*************************************************************************************************
1489 template< typename MT // Type of the sparse matrix
1490  , bool SO > // Storage order
1491 template< typename VT > // Type of the right-hand side sparse vector
1493 {
1494  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
1495 
1499 
1500  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1501 
1502  const AddType tmp( serial( *this + (~rhs) ) );
1503  matrix_.reset ( row_ );
1504  matrix_.reserve( row_, tmp.nonZeros() );
1505  assign( tmp );
1506 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1521 template< typename MT // Type of the sparse matrix
1522  , bool SO > // Storage order
1523 template< typename VT > // Type of the right-hand side dense vector
1525 {
1526  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1527 
1531 
1532  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1533 
1534  const SubType tmp( serial( *this - (~rhs) ) );
1535  matrix_.reset ( row_ );
1536  assign( tmp );
1537 }
1538 //*************************************************************************************************
1539 
1540 
1541 //*************************************************************************************************
1552 template< typename MT // Type of the sparse matrix
1553  , bool SO > // Storage order
1554 template< typename VT > // Type of the right-hand side sparse vector
1556 {
1557  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
1558 
1562 
1563  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1564 
1565  const SubType tmp( serial( *this - (~rhs) ) );
1566  matrix_.reset ( row_ );
1567  matrix_.reserve( row_, tmp.nonZeros() );
1568  assign( tmp );
1569 }
1570 //*************************************************************************************************
1571 
1572 
1573 
1574 
1575 
1576 
1577 
1578 
1579 //=================================================================================================
1580 //
1581 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
1582 //
1583 //=================================================================================================
1584 
1585 //*************************************************************************************************
1593 template< typename MT > // Type of the sparse matrix
1594 class SparseRow<MT,false> : public SparseVector< SparseRow<MT,false>, true >
1595  , private Row
1596 {
1597  private:
1598  //**Type definitions****************************************************************************
1600  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1601  //**********************************************************************************************
1602 
1603  //**********************************************************************************************
1605 
1611  enum { useConst = IsConst<MT>::value };
1612  //**********************************************************************************************
1613 
1614  public:
1615  //**Type definitions****************************************************************************
1616  typedef SparseRow<MT,false> This;
1617  typedef typename RowTrait<MT>::Type ResultType;
1618  typedef typename ResultType::TransposeType TransposeType;
1619  typedef typename MT::ElementType ElementType;
1620  typedef typename MT::ReturnType ReturnType;
1621  typedef const ResultType CompositeType;
1622 
1624  typedef typename MT::ConstReference ConstReference;
1625 
1627  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1628  //**********************************************************************************************
1629 
1630  //**RowElement class definition*****************************************************************
1633  template< typename MatrixType // Type of the sparse matrix
1634  , typename IteratorType > // Type of the sparse matrix iterator
1635  class RowElement
1636  {
1637  private:
1638  //*******************************************************************************************
1640 
1645  enum { returnConst = IsConst<MatrixType>::value };
1646  //*******************************************************************************************
1647 
1648  public:
1649  //**Type definitions*************************************************************************
1650  typedef typename SelectType< returnConst, const ElementType&, ElementType& >::Type ReferenceType;
1651  //*******************************************************************************************
1652 
1653  //**Constructor******************************************************************************
1659  inline RowElement( IteratorType pos, size_t column )
1660  : pos_ ( pos ) // Iterator to the current position within the sparse row
1661  , column_( column ) // Index of the according column
1662  {}
1663  //*******************************************************************************************
1664 
1665  //**Assignment operator**********************************************************************
1671  template< typename T > inline RowElement& operator=( const T& v ) {
1672  *pos_ = v;
1673  return *this;
1674  }
1675  //*******************************************************************************************
1676 
1677  //**Addition assignment operator*************************************************************
1683  template< typename T > inline RowElement& operator+=( const T& v ) {
1684  *pos_ += v;
1685  return *this;
1686  }
1687  //*******************************************************************************************
1688 
1689  //**Subtraction assignment operator**********************************************************
1695  template< typename T > inline RowElement& operator-=( const T& v ) {
1696  *pos_ -= v;
1697  return *this;
1698  }
1699  //*******************************************************************************************
1700 
1701  //**Multiplication assignment operator*******************************************************
1707  template< typename T > inline RowElement& operator*=( const T& v ) {
1708  *pos_ *= v;
1709  return *this;
1710  }
1711  //*******************************************************************************************
1712 
1713  //**Division assignment operator*************************************************************
1719  template< typename T > inline RowElement& operator/=( const T& v ) {
1720  *pos_ /= v;
1721  return *this;
1722  }
1723  //*******************************************************************************************
1724 
1725  //**Element access operator******************************************************************
1730  inline const RowElement* operator->() const {
1731  return this;
1732  }
1733  //*******************************************************************************************
1734 
1735  //**Value function***************************************************************************
1740  inline ReferenceType value() const {
1741  return pos_->value();
1742  }
1743  //*******************************************************************************************
1744 
1745  //**Index function***************************************************************************
1750  inline size_t index() const {
1751  return column_;
1752  }
1753  //*******************************************************************************************
1754 
1755  private:
1756  //**Member variables*************************************************************************
1757  IteratorType pos_;
1758  size_t column_;
1759  //*******************************************************************************************
1760  };
1761  //**********************************************************************************************
1762 
1763  //**RowIterator class definition****************************************************************
1766  template< typename MatrixType // Type of the sparse matrix
1767  , typename IteratorType > // Type of the sparse matrix iterator
1768  class RowIterator
1769  {
1770  public:
1771  //**Type definitions*************************************************************************
1772  typedef std::forward_iterator_tag IteratorCategory;
1773  typedef RowElement<MatrixType,IteratorType> ValueType;
1774  typedef ValueType PointerType;
1775  typedef ValueType ReferenceType;
1776  typedef ptrdiff_t DifferenceType;
1777 
1778  // STL iterator requirements
1779  typedef IteratorCategory iterator_category;
1780  typedef ValueType value_type;
1781  typedef PointerType pointer;
1782  typedef ReferenceType reference;
1783  typedef DifferenceType difference_type;
1784  //*******************************************************************************************
1785 
1786  //**Constructor******************************************************************************
1793  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
1794  : matrix_( matrix ) // The sparse matrix containing the row.
1795  , row_ ( row ) // The current row index.
1796  , column_( column ) // The current column index.
1797  , pos_ () // Iterator to the current sparse element.
1798  {
1799  for( ; column_<matrix_.columns(); ++column_ ) {
1800  pos_ = matrix_.find( row_, column_ );
1801  if( pos_ != matrix_.end( column_ ) ) break;
1802  }
1803  }
1804  //*******************************************************************************************
1805 
1806  //**Constructor******************************************************************************
1814  inline RowIterator( MatrixType& matrix, size_t row, size_t column, IteratorType pos )
1815  : matrix_( matrix ) // The sparse matrix containing the row.
1816  , row_ ( row ) // The current row index.
1817  , column_( column ) // The current column index.
1818  , pos_ ( pos ) // Iterator to the current sparse element.
1819  {
1820  BLAZE_INTERNAL_ASSERT( matrix.find( row, column ) == pos, "Invalid initial iterator position" );
1821  }
1822  //*******************************************************************************************
1823 
1824  //**Constructor******************************************************************************
1829  template< typename MatrixType2, typename IteratorType2 >
1830  inline RowIterator( const RowIterator<MatrixType2,IteratorType2>& it )
1831  : matrix_( it.matrix_ ) // The sparse matrix containing the row.
1832  , row_ ( it.row_ ) // The current row index.
1833  , column_( it.column_ ) // The current column index.
1834  , pos_ ( it.pos_ ) // Iterator to the current sparse element.
1835  {}
1836  //*******************************************************************************************
1837 
1838  //**Prefix increment operator****************************************************************
1843  inline RowIterator& operator++() {
1844  ++column_;
1845  for( ; column_<matrix_.columns(); ++column_ ) {
1846  pos_ = matrix_.find( row_, column_ );
1847  if( pos_ != matrix_.end( column_ ) ) break;
1848  }
1849 
1850  return *this;
1851  }
1852  //*******************************************************************************************
1853 
1854  //**Postfix increment operator***************************************************************
1859  inline const RowIterator operator++( int ) {
1860  const RowIterator tmp( *this );
1861  ++(*this);
1862  return tmp;
1863  }
1864  //*******************************************************************************************
1865 
1866  //**Element access operator******************************************************************
1871  inline ReferenceType operator*() const {
1872  return ReferenceType( pos_, column_ );
1873  }
1874  //*******************************************************************************************
1875 
1876  //**Element access operator******************************************************************
1881  inline PointerType operator->() const {
1882  return PointerType( pos_, column_ );
1883  }
1884  //*******************************************************************************************
1885 
1886  //**Equality operator************************************************************************
1892  template< typename MatrixType2, typename IteratorType2 >
1893  inline bool operator==( const RowIterator<MatrixType2,IteratorType2>& rhs ) const {
1894  return ( &matrix_ == &rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1895  }
1896  //*******************************************************************************************
1897 
1898  //**Inequality operator**********************************************************************
1904  template< typename MatrixType2, typename IteratorType2 >
1905  inline bool operator!=( const RowIterator<MatrixType2,IteratorType2>& rhs ) const {
1906  return !( *this == rhs );
1907  }
1908  //*******************************************************************************************
1909 
1910  //**Subtraction operator*********************************************************************
1916  inline DifferenceType operator-( const RowIterator& rhs ) const {
1917  size_t counter( 0UL );
1918  for( size_t j=rhs.column_; j<column_; ++j ) {
1919  if( matrix_.find( row_, j ) != matrix_.end( j ) )
1920  ++counter;
1921  }
1922  return counter;
1923  }
1924  //*******************************************************************************************
1925 
1926  private:
1927  //**Member variables*************************************************************************
1928  MatrixType& matrix_;
1929  size_t row_;
1930  size_t column_;
1931  IteratorType pos_;
1932  //*******************************************************************************************
1933 
1934  //**Friend declarations**********************************************************************
1935  template< typename MatrixType2, typename IteratorType2 > friend class RowIterator;
1936  template< typename MT2, bool SO2 > friend class SparseRow;
1937  //*******************************************************************************************
1938  };
1939  //**********************************************************************************************
1940 
1941  //**Type definitions****************************************************************************
1943  typedef RowIterator<const MT,typename MT::ConstIterator> ConstIterator;
1944 
1946  typedef typename SelectType< useConst, ConstIterator, RowIterator<MT,typename MT::Iterator> >::Type Iterator;
1947  //**********************************************************************************************
1948 
1949  //**Compilation flags***************************************************************************
1951  enum { smpAssignable = 0 };
1952  //**********************************************************************************************
1953 
1954  //**Constructors********************************************************************************
1957  explicit inline SparseRow( MT& matrix, size_t index );
1958  // No explicitly declared copy constructor.
1960  //**********************************************************************************************
1961 
1962  //**Destructor**********************************************************************************
1963  // No explicitly declared destructor.
1964  //**********************************************************************************************
1965 
1966  //**Data access functions***********************************************************************
1969  inline Reference operator[]( size_t index );
1970  inline ConstReference operator[]( size_t index ) const;
1971  inline Iterator begin ();
1972  inline ConstIterator begin () const;
1973  inline ConstIterator cbegin() const;
1974  inline Iterator end ();
1975  inline ConstIterator end () const;
1976  inline ConstIterator cend () const;
1978  //**********************************************************************************************
1979 
1980  //**Assignment operators************************************************************************
1983  inline SparseRow& operator= ( const SparseRow& rhs );
1984  template< typename VT > inline SparseRow& operator= ( const Vector<VT,true>& rhs );
1985  template< typename VT > inline SparseRow& operator+=( const Vector<VT,true>& rhs );
1986  template< typename VT > inline SparseRow& operator-=( const Vector<VT,true>& rhs );
1987  template< typename VT > inline SparseRow& operator*=( const Vector<VT,true>& rhs );
1988 
1989  template< typename Other >
1990  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
1991  operator*=( Other rhs );
1992 
1993  template< typename Other >
1994  inline typename EnableIf< IsNumeric<Other>, SparseRow >::Type&
1995  operator/=( Other rhs );
1997  //**********************************************************************************************
1998 
1999  //**Utility functions***************************************************************************
2002  inline size_t size() const;
2003  inline size_t capacity() const;
2004  inline size_t nonZeros() const;
2005  inline void reset();
2006  inline Iterator insert ( size_t index, const ElementType& value );
2007  inline void erase ( size_t index );
2008  inline Iterator erase ( Iterator pos );
2009  inline Iterator erase ( Iterator first, Iterator last );
2010  inline void reserve( size_t n );
2011  template< typename Other > inline SparseRow& scale ( Other scalar );
2013  //**********************************************************************************************
2014 
2015  //**Lookup functions****************************************************************************
2018  inline Iterator find ( size_t index );
2019  inline ConstIterator find ( size_t index ) const;
2020  inline Iterator lowerBound( size_t index );
2021  inline ConstIterator lowerBound( size_t index ) const;
2022  inline Iterator upperBound( size_t index );
2023  inline ConstIterator upperBound( size_t index ) const;
2025  //**********************************************************************************************
2026 
2027  //**Low-level utility functions*****************************************************************
2030  inline void append( size_t index, const ElementType& value, bool check=false );
2032  //**********************************************************************************************
2033 
2034  //**Expression template evaluation functions****************************************************
2037  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2038  template< typename Other > inline bool isAliased( const Other* alias ) const;
2039 
2040  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2041  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2042  template< typename VT > inline void addAssign( const Vector<VT,true>& rhs );
2043  template< typename VT > inline void subAssign( const Vector<VT,true>& rhs );
2045  //**********************************************************************************************
2046 
2047  private:
2048  //**Member variables****************************************************************************
2051  Operand matrix_;
2052  const size_t row_;
2053 
2054  //**********************************************************************************************
2055 
2056  //**Friend declarations*************************************************************************
2057  template< typename MT2, bool SO2 >
2058  friend bool isSame( const SparseRow<MT2,SO2>& a, const SparseRow<MT2,SO2>& b );
2059  //**********************************************************************************************
2060 
2061  //**Compile time checks*************************************************************************
2066  //**********************************************************************************************
2067 };
2069 //*************************************************************************************************
2070 
2071 
2072 
2073 
2074 //=================================================================================================
2075 //
2076 // CONSTRUCTOR
2077 //
2078 //=================================================================================================
2079 
2080 //*************************************************************************************************
2088 template< typename MT > // Type of the sparse matrix
2089 inline SparseRow<MT,false>::SparseRow( MT& matrix, size_t index )
2090  : matrix_( matrix ) // The sparse matrix containing the row
2091  , row_ ( index ) // The index of the row in the matrix
2092 {
2093  if( matrix_.rows() <= index )
2094  throw std::invalid_argument( "Invalid row access index" );
2095 }
2097 //*************************************************************************************************
2098 
2099 
2100 
2101 
2102 //=================================================================================================
2103 //
2104 // DATA ACCESS FUNCTIONS
2105 //
2106 //=================================================================================================
2107 
2108 //*************************************************************************************************
2115 template< typename MT > // Type of the sparse matrix
2117 {
2118  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2119  return matrix_(row_,index);
2120 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2132 template< typename MT > // Type of the sparse matrix
2133 inline typename SparseRow<MT,false>::ConstReference SparseRow<MT,false>::operator[]( size_t index ) const
2134 {
2135  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2136  return const_cast<const MT&>( matrix_ )(row_,index);
2137 }
2139 //*************************************************************************************************
2140 
2141 
2142 //*************************************************************************************************
2150 template< typename MT > // Type of the sparse matrix
2152 {
2153  return Iterator( matrix_, row_, 0UL );
2154 }
2156 //*************************************************************************************************
2157 
2158 
2159 //*************************************************************************************************
2167 template< typename MT > // Type of the sparse matrix
2169 {
2170  return ConstIterator( matrix_, row_, 0UL );
2171 }
2173 //*************************************************************************************************
2174 
2175 
2176 //*************************************************************************************************
2184 template< typename MT > // Type of the sparse matrix
2186 {
2187  return ConstIterator( matrix_, row_, 0UL );
2188 }
2190 //*************************************************************************************************
2191 
2192 
2193 //*************************************************************************************************
2201 template< typename MT > // Type of the sparse matrix
2203 {
2204  return Iterator( matrix_, row_, size() );
2205 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2218 template< typename MT > // Type of the sparse matrix
2220 {
2221  return ConstIterator( matrix_, row_, size() );
2222 }
2224 //*************************************************************************************************
2225 
2226 
2227 //*************************************************************************************************
2235 template< typename MT > // Type of the sparse matrix
2237 {
2238  return ConstIterator( matrix_, row_, size() );
2239 }
2241 //*************************************************************************************************
2242 
2243 
2244 
2245 
2246 //=================================================================================================
2247 //
2248 // ASSIGNMENT OPERATORS
2249 //
2250 //=================================================================================================
2251 
2252 //*************************************************************************************************
2263 template< typename MT > // Type of the sparse matrix
2264 inline SparseRow<MT,false>& SparseRow<MT,false>::operator=( const SparseRow& rhs )
2265 {
2266  using blaze::assign;
2267 
2271 
2272  if( this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ ) )
2273  return *this;
2274 
2275  if( size() != rhs.size() )
2276  throw std::invalid_argument( "Row sizes do not match" );
2277 
2278  if( rhs.canAlias( &matrix_ ) ) {
2279  const ResultType tmp( rhs );
2280  assign( *this, tmp );
2281  }
2282  else {
2283  assign( *this, rhs );
2284  }
2285 
2286  return *this;
2287 }
2289 //*************************************************************************************************
2290 
2291 
2292 //*************************************************************************************************
2303 template< typename MT > // Type of the sparse matrix
2304 template< typename VT > // Type of the right-hand side vector
2305 inline SparseRow<MT,false>& SparseRow<MT,false>::operator=( const Vector<VT,true>& rhs )
2306 {
2307  using blaze::assign;
2308 
2309  if( size() != (~rhs).size() )
2310  throw std::invalid_argument( "Vector sizes do not match" );
2311 
2312  const typename VT::CompositeType tmp( ~rhs );
2313  assign( *this, tmp );
2314 
2315  return *this;
2316 }
2318 //*************************************************************************************************
2319 
2320 
2321 //*************************************************************************************************
2332 template< typename MT > // Type of the sparse matrix
2333 template< typename VT > // Type of the right-hand side vector
2334 inline SparseRow<MT,false>& SparseRow<MT,false>::operator+=( const Vector<VT,true>& rhs )
2335 {
2336  using blaze::addAssign;
2337 
2338  if( size() != (~rhs).size() )
2339  throw std::invalid_argument( "Vector sizes do not match" );
2340 
2341  addAssign( *this, ~rhs );
2342 
2343  return *this;
2344 }
2346 //*************************************************************************************************
2347 
2348 
2349 //*************************************************************************************************
2360 template< typename MT > // Type of the sparse matrix
2361 template< typename VT > // Type of the right-hand side vector
2362 inline SparseRow<MT,false>& SparseRow<MT,false>::operator-=( const Vector<VT,true>& rhs )
2363 {
2364  using blaze::subAssign;
2365 
2366  if( size() != (~rhs).size() )
2367  throw std::invalid_argument( "Vector sizes do not match" );
2368 
2369  subAssign( *this, ~rhs );
2370 
2371  return *this;
2372 }
2374 //*************************************************************************************************
2375 
2376 
2377 //*************************************************************************************************
2389 template< typename MT > // Type of the sparse matrix
2390 template< typename VT > // Type of the right-hand side vector
2391 inline SparseRow<MT,false>& SparseRow<MT,false>::operator*=( const Vector<VT,true>& rhs )
2392 {
2393  if( size() != (~rhs).size() )
2394  throw std::invalid_argument( "Vector sizes do not match" );
2395 
2396  typedef typename MultTrait<ResultType,typename VT::ResultType>::Type MultType;
2397 
2400 
2401  const MultType tmp( *this * (~rhs) );
2402  assign( tmp );
2403 
2404  return *this;
2405 }
2407 //*************************************************************************************************
2408 
2409 
2410 //*************************************************************************************************
2422 template< typename MT > // Type of the sparse matrix
2423 template< typename Other > // Data type of the right-hand side scalar
2424 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,false> >::Type&
2425  SparseRow<MT,false>::operator*=( Other rhs )
2426 {
2427  for( Iterator element=begin(); element!=end(); ++element )
2428  element->value() *= rhs;
2429  return *this;
2430 }
2432 //*************************************************************************************************
2433 
2434 
2435 //*************************************************************************************************
2448 template< typename MT > // Type of the sparse matrix
2449 template< typename Other > // Data type of the right-hand side scalar
2450 inline typename EnableIf< IsNumeric<Other>, SparseRow<MT,false> >::Type&
2451  SparseRow<MT,false>::operator/=( Other rhs )
2452 {
2453  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2454 
2455  typedef typename DivTrait<ElementType,Other>::Type DT;
2456  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2457 
2458  // Depending on the two involved data types, an integer division is applied or a
2459  // floating point division is selected.
2460  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2461  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2462  for( Iterator element=begin(); element!=end(); ++element )
2463  element->value() *= tmp;
2464  }
2465  else {
2466  for( Iterator element=begin(); element!=end(); ++element )
2467  element->value() /= rhs;
2468  }
2469 
2470  return *this;
2471 }
2473 //*************************************************************************************************
2474 
2475 
2476 
2477 
2478 //=================================================================================================
2479 //
2480 // UTILITY FUNCTIONS
2481 //
2482 //=================================================================================================
2483 
2484 //*************************************************************************************************
2490 template< typename MT > // Type of the sparse matrix
2491 inline size_t SparseRow<MT,false>::size() const
2492 {
2493  return matrix_.columns();
2494 }
2496 //*************************************************************************************************
2497 
2498 
2499 //*************************************************************************************************
2505 template< typename MT > // Type of the sparse matrix
2506 inline size_t SparseRow<MT,false>::capacity() const
2507 {
2508  return matrix_.columns();
2509 }
2511 //*************************************************************************************************
2512 
2513 
2514 //*************************************************************************************************
2523 template< typename MT > // Type of the sparse matrix
2524 inline size_t SparseRow<MT,false>::nonZeros() const
2525 {
2526  size_t counter( 0UL );
2527  for( ConstIterator element=begin(); element!=end(); ++element ) {
2528  ++counter;
2529  }
2530  return counter;
2531 }
2533 //*************************************************************************************************
2534 
2535 
2536 //*************************************************************************************************
2542 template< typename MT > // Type of the sparse matrix
2543 inline void SparseRow<MT,false>::reset()
2544 {
2545  for( size_t j=0UL; j<size(); ++j ) {
2546  matrix_.erase( row_, j );
2547  }
2548 }
2550 //*************************************************************************************************
2551 
2552 
2553 //*************************************************************************************************
2566 template< typename MT > // Type of the sparse matrix
2567 inline typename SparseRow<MT,false>::Iterator
2568  SparseRow<MT,false>::insert( size_t index, const ElementType& value )
2569 {
2570  return Iterator( matrix_, row_, index, matrix_.insert( row_, index, value ) );
2571 }
2573 //*************************************************************************************************
2574 
2575 
2576 //*************************************************************************************************
2585 template< typename MT > // Type of the sparse matrix
2586 inline void SparseRow<MT,false>::erase( size_t index )
2587 {
2588  matrix_.erase( row_, index );
2589 }
2591 //*************************************************************************************************
2592 
2593 
2594 //*************************************************************************************************
2603 template< typename MT > // Type of the sparse matrix
2605 {
2606  const size_t column( pos.column_ );
2607 
2608  if( column == size() )
2609  return pos;
2610 
2611  matrix_.erase( column, pos.pos_ );
2612  return Iterator( matrix_, row_, column+1UL );
2613 }
2615 //*************************************************************************************************
2616 
2617 
2618 //*************************************************************************************************
2628 template< typename MT > // Type of the sparse matrix
2630 {
2631  for( ; first!=last; ++first ) {
2632  matrix_.erase( first.column_, first.pos_ );
2633  }
2634  return last;
2635 }
2637 //*************************************************************************************************
2638 
2639 
2640 //*************************************************************************************************
2650 template< typename MT > // Type of the sparse matrix
2651 void SparseRow<MT,false>::reserve( size_t n )
2652 {
2653  UNUSED_PARAMETER( n );
2654  return;
2655 }
2657 //*************************************************************************************************
2658 
2659 
2660 //*************************************************************************************************
2667 template< typename MT > // Type of the sparse matrix
2668 template< typename Other > // Data type of the scalar value
2669 inline SparseRow<MT,false>& SparseRow<MT,false>::scale( Other scalar )
2670 {
2671  for( Iterator element=begin(); element!=end(); ++element )
2672  element->value() *= scalar;
2673  return *this;
2674 }
2676 //*************************************************************************************************
2677 
2678 
2679 
2680 
2681 //=================================================================================================
2682 //
2683 // LOOKUP FUNCTIONS
2684 //
2685 //=================================================================================================
2686 
2687 //*************************************************************************************************
2701 template< typename MT > // Type of the sparse matrix
2702 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::find( size_t index )
2703 {
2704  const typename MT::Iterator pos( matrix_.find( row_, index ) );
2705 
2706  if( pos != matrix_.end( index ) )
2707  return Iterator( matrix_, row_, index, pos );
2708  else
2709  return end();
2710 }
2712 //*************************************************************************************************
2713 
2714 
2715 //*************************************************************************************************
2729 template< typename MT > // Type of the sparse matrix
2730 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::find( size_t index ) const
2731 {
2732  const typename MT::ConstIterator pos( matrix_.find( row_, index ) );
2733 
2734  if( pos != matrix_.end( index ) )
2735  return ConstIterator( matrix_, row_, index, pos );
2736  else
2737  return end();
2738 }
2740 //*************************************************************************************************
2741 
2742 
2743 //*************************************************************************************************
2756 template< typename MT > // Type of the sparse matrix
2757 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::lowerBound( size_t index )
2758 {
2759  for( size_t i=index; i<size(); ++i )
2760  {
2761  const typename MT::Iterator pos( matrix_.find( row_, i ) );
2762 
2763  if( pos != matrix_.end( i ) )
2764  return Iterator( matrix_, row_, i, pos );
2765  }
2766 
2767  return end();
2768 }
2770 //*************************************************************************************************
2771 
2772 
2773 //*************************************************************************************************
2786 template< typename MT > // Type of the sparse matrix
2787 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::lowerBound( size_t index ) const
2788 {
2789  for( size_t i=index; i<size(); ++i )
2790  {
2791  const typename MT::ConstIterator pos( matrix_.find( row_, i ) );
2792 
2793  if( pos != matrix_.end( i ) )
2794  return ConstIterator( matrix_, row_, i, pos );
2795  }
2796 
2797  return end();
2798 }
2800 //*************************************************************************************************
2801 
2802 
2803 //*************************************************************************************************
2816 template< typename MT > // Type of the sparse matrix
2817 inline typename SparseRow<MT,false>::Iterator SparseRow<MT,false>::upperBound( size_t index )
2818 {
2819  for( size_t i=index+1UL; i<size(); ++i )
2820  {
2821  const typename MT::Iterator pos( matrix_.find( row_, i ) );
2822 
2823  if( pos != matrix_.end( i ) )
2824  return Iterator( matrix_, row_, i, pos );
2825  }
2826 
2827  return end();
2828 }
2830 //*************************************************************************************************
2831 
2832 
2833 //*************************************************************************************************
2846 template< typename MT > // Type of the sparse matrix
2847 inline typename SparseRow<MT,false>::ConstIterator SparseRow<MT,false>::upperBound( size_t index ) const
2848 {
2849  for( size_t i=index+1UL; i<size(); ++i )
2850  {
2851  const typename MT::ConstIterator pos( matrix_.find( row_, i ) );
2852 
2853  if( pos != matrix_.end( i ) )
2854  return ConstIterator( matrix_, row_, i, pos );
2855  }
2856 
2857  return end();
2858 }
2860 //*************************************************************************************************
2861 
2862 
2863 
2864 
2865 //=================================================================================================
2866 //
2867 // LOW-LEVEL UTILITY FUNCTIONS
2868 //
2869 //=================================================================================================
2870 
2871 //*************************************************************************************************
2896 template< typename MT > // Type of the sparse matrix
2897 inline void SparseRow<MT,false>::append( size_t index, const ElementType& value, bool check )
2898 {
2899  if( !check || !isDefault( value ) )
2900  matrix_.insert( row_, index, value );
2901 }
2903 //*************************************************************************************************
2904 
2905 
2906 
2907 
2908 //=================================================================================================
2909 //
2910 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2911 //
2912 //=================================================================================================
2913 
2914 //*************************************************************************************************
2925 template< typename MT > // Type of the sparse matrix
2926 template< typename Other > // Data type of the foreign expression
2927 inline bool SparseRow<MT,false>::canAlias( const Other* alias ) const
2928 {
2929  return matrix_.isAliased( alias );
2930 }
2932 //*************************************************************************************************
2933 
2934 
2935 //*************************************************************************************************
2942 template< typename MT > // Type of the sparse matrix
2943 template< typename Other > // Data type of the foreign expression
2944 inline bool SparseRow<MT,false>::isAliased( const Other* alias ) const
2945 {
2946  return matrix_.isAliased( alias );
2947 }
2949 //*************************************************************************************************
2950 
2951 
2952 //*************************************************************************************************
2964 template< typename MT > // Type of the sparse matrix
2965 template< typename VT > // Type of the right-hand side dense vector
2966 inline void SparseRow<MT,false>::assign( const DenseVector<VT,true>& rhs )
2967 {
2968  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2969 
2970  for( size_t j=0UL; j<(~rhs).size(); ++j ) {
2971  matrix_(row_,j) = (~rhs)[j];
2972  }
2973 }
2975 //*************************************************************************************************
2976 
2977 
2978 //*************************************************************************************************
2990 template< typename MT > // Type of the sparse matrix
2991 template< typename VT > // Type of the right-hand side sparse vector
2992 inline void SparseRow<MT,false>::assign( const SparseVector<VT,true>& rhs )
2993 {
2994  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2995 
2996  size_t j( 0UL );
2997 
2998  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
2999  for( ; j<element->index(); ++j )
3000  matrix_.erase( row_, j );
3001  matrix_(row_,j++) = element->value();
3002  }
3003  for( ; j<size(); ++j ) {
3004  matrix_.erase( row_, j );
3005  }
3006 }
3008 //*************************************************************************************************
3009 
3010 
3011 //*************************************************************************************************
3023 template< typename MT > // Type of the sparse matrix
3024 template< typename VT > // Type of the right-hand side vector
3025 inline void SparseRow<MT,false>::addAssign( const Vector<VT,true>& rhs )
3026 {
3027  typedef typename AddTrait<ResultType,typename VT::ResultType>::Type AddType;
3028 
3031 
3032  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3033 
3034  const AddType tmp( serial( *this + (~rhs) ) );
3035  assign( tmp );
3036 }
3038 //*************************************************************************************************
3039 
3040 
3041 //*************************************************************************************************
3053 template< typename MT > // Type of the sparse matrix
3054 template< typename VT > // Type of the right-hand side vector
3055 inline void SparseRow<MT,false>::subAssign( const Vector<VT,true>& rhs )
3056 {
3057  typedef typename SubTrait<ResultType,typename VT::ResultType>::Type SubType;
3058 
3061 
3062  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3063 
3064  const SubType tmp( serial( *this - (~rhs) ) );
3065  assign( tmp );
3066 }
3068 //*************************************************************************************************
3069 
3070 
3071 
3072 
3073 
3074 
3075 
3076 
3077 //=================================================================================================
3078 //
3079 // SPARSEROW OPERATORS
3080 //
3081 //=================================================================================================
3082 
3083 //*************************************************************************************************
3086 template< typename MT, bool SO >
3087 inline void reset( SparseRow<MT,SO>& row );
3088 
3089 template< typename MT, bool SO >
3090 inline void clear( SparseRow<MT,SO>& row );
3091 
3092 template< typename MT, bool SO >
3093 inline bool isDefault( const SparseRow<MT,SO>& row );
3094 
3095 template< typename MT, bool SO >
3096 inline bool isSame( const SparseRow<MT,SO>& a, const SparseRow<MT,SO>& b );
3098 //*************************************************************************************************
3099 
3100 
3101 //*************************************************************************************************
3108 template< typename MT // Type of the sparse matrix
3109  , bool SO > // Storage order
3110 inline void reset( SparseRow<MT,SO>& row )
3111 {
3112  row.reset();
3113 }
3114 //*************************************************************************************************
3115 
3116 
3117 //*************************************************************************************************
3126 template< typename MT // Type of the sparse matrix
3127  , bool SO > // Storage order
3128 inline void clear( SparseRow<MT,SO>& row )
3129 {
3130  row.reset();
3131 }
3132 //*************************************************************************************************
3133 
3134 
3135 //*************************************************************************************************
3153 template< typename MT // Type of the sparse matrix
3154  , bool SO > // Storage order
3155 inline bool isDefault( const SparseRow<MT,SO>& row )
3156 {
3158 
3159  const ConstIterator end( row.end() );
3160  for( ConstIterator element=row.begin(); element!=end; ++element )
3161  if( !isDefault( element->value() ) ) return false;
3162  return true;
3163 }
3164 //*************************************************************************************************
3165 
3166 
3167 //*************************************************************************************************
3179 template< typename MT, bool SO >
3180 inline bool isSame( const SparseRow<MT,SO>& a, const SparseRow<MT,SO>& b )
3181 {
3182  return ( isSame( a.matrix_, b.matrix_ ) && ( a.row_ == b.row_ ) );
3183 }
3184 //*************************************************************************************************
3185 
3186 
3187 
3188 
3189 //=================================================================================================
3190 //
3191 // SUBVECTORTRAIT SPECIALIZATIONS
3192 //
3193 //=================================================================================================
3194 
3195 //*************************************************************************************************
3197 template< typename MT, bool SO >
3198 struct SubvectorTrait< SparseRow<MT,SO> >
3199 {
3200  typedef typename SubvectorTrait< typename SparseRow<MT,SO>::ResultType >::Type Type;
3201 };
3203 //*************************************************************************************************
3204 
3205 } // namespace blaze
3206 
3207 #endif
Constraint on the data type.
const size_t row_
The index of the row in the matrix.
Definition: SparseRow.h:495
Iterator end()
Returns an iterator just past the last element of the row.
Definition: SparseRow.h:642
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:1009
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#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:4329
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:1384
Header file for the SparseVector base class.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: SparseRow.h:366
size_t size() const
Returns the current size/dimension of the sparse row.
Definition: SparseRow.h:978
size_t capacity() const
Returns the maximum capacity of the sparse row.
Definition: SparseRow.h:992
void reset()
Reset to the default initial values.
Definition: SparseRow.h:1023
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:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
Header file for the row base class.
#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:376
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2408
Operand matrix_
The sparse matrix containing the row.
Definition: SparseRow.h:494
void erase(size_t index)
Erasing an element from the sparse row.
Definition: SparseRow.h:1062
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
void append(size_t index, const ElementType &value, bool check=false)
Appending an element to the sparse row.
Definition: SparseRow.h:1336
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:86
#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:1364
Iterator upperBound(size_t index)
Returns an iterator to the first index greater then the given index.
Definition: SparseRow.h:1274
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:409
void assign(const DenseVector< VT, true > &rhs)
Default implementation of the assignment of a dense vector.
Definition: SparseRow.h:1405
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: SparseRow.h:370
Constraint on the data type.
Iterator begin()
Returns an iterator to the first element of the row.
Definition: SparseRow.h:594
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:674
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:2412
Iterator find(size_t index)
Searches for a specific row element.
Definition: SparseRow.h:1189
Header file for the Or class template.
size_t nonZeros(const Matrix< MT, SO > &m)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:224
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: SparseRow.h:561
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:271
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:701
void addAssign(const DenseVector< VT, true > &rhs)
Default implementation of the addition assignment of a dense vector.
Definition: SparseRow.h:1461
Constraint on the data type.
Constraint on the data type.
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:2406
Constraint on the data type.
Header file for the SelectType class template.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
Header file for the EnableIf class template.
Header file for the serial shim.
void subAssign(const DenseVector< VT, true > &rhs)
Default implementation of the subtraction assignment of a dense vector.
Definition: SparseRow.h:1524
void reserve(size_t n)
Setting the minimum capacity of the sparse row.
Definition: SparseRow.h:1115
Header file for the IsNumeric type trait.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
Iterator lowerBound(size_t index)
Returns an iterator to the first index not less then the given index.
Definition: SparseRow.h:1232
ConstIterator cbegin() const
Returns an iterator to the first element of the row.
Definition: SparseRow.h:626
#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:2407
Header file for the IsConst type trait.
Base class for all rows.The Row class serves as a tag for all rows (i.e. dense and sparse rows)...
Definition: Row.h:63
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:1150
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:301
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:364
Header file for the reset shim.
SparseRow(MT &matrix, size_t index)
The constructor for SparseRow.
Definition: SparseRow.h:535
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:331
const VT::ElementType max(const SparseVector< VT, TF > &sv)
Returns the largest element of the sparse vector.
Definition: SparseVector.h:408
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
Header file for the isDefault shim.
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: SparseRow.h:373
#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:346
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:151
Iterator insert(size_t index, const ElementType &value)
Inserting an element into the sparse row.
Definition: SparseRow.h:1045
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:250
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:108
RowTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: SparseRow.h:363
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:2403
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:379
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
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:351
MT::ElementType ElementType
Type of the row elements.
Definition: SparseRow.h:365
#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
const SparseRow & CompositeType
Data type for composite expression templates.
Definition: SparseRow.h:367
#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:362
size_t capacity(const Matrix< MT, SO > &m)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:186
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.