All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseRow.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_DENSEROW_H_
36 #define _BLAZE_MATH_VIEWS_DENSEROW_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <stdexcept>
54 #include <blaze/math/Intrinsics.h>
56 #include <blaze/math/shims/Reset.h>
63 #include <blaze/system/CacheSize.h>
64 #include <blaze/system/Streaming.h>
66 #include <blaze/util/Assert.h>
68 #include <blaze/util/DisableIf.h>
69 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/mpl/Or.h>
72 #include <blaze/util/Template.h>
73 #include <blaze/util/Types.h>
79 
80 
81 namespace blaze {
82 
83 //=================================================================================================
84 //
85 // CLASS DEFINITION
86 //
87 //=================================================================================================
88 
89 //*************************************************************************************************
306 template< typename MT // Type of the dense matrix
307  , bool SO = IsRowMajorMatrix<MT>::value > // Storage order
308 class DenseRow : public DenseVector< DenseRow<MT,SO>, true >
309  , private Row
310 {
311  private:
312  //**Type definitions****************************************************************************
314  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
315 
318  //**********************************************************************************************
319 
320  //**********************************************************************************************
322 
328  enum { useConst = IsConst<MT>::value };
329  //**********************************************************************************************
330 
331  public:
332  //**Type definitions****************************************************************************
334  typedef typename RowTrait<MT>::Type ResultType;
336  typedef typename MT::ElementType ElementType;
337  typedef typename IT::Type IntrinsicType;
338  typedef typename MT::ReturnType ReturnType;
339  typedef const DenseRow& CompositeType;
340 
343 
346 
348  typedef const ElementType* ConstPointer;
349 
352 
355 
358  //**********************************************************************************************
359 
360  //**Compilation flags***************************************************************************
362  enum { vectorizable = MT::vectorizable };
363 
365  enum { smpAssignable = MT::smpAssignable };
366  //**********************************************************************************************
367 
368  //**Constructors********************************************************************************
371  explicit inline DenseRow( MT& matrix, size_t index );
372  // No explicitly declared copy constructor.
374  //**********************************************************************************************
375 
376  //**Destructor**********************************************************************************
377  // No explicitly declared destructor.
378  //**********************************************************************************************
379 
380  //**Data access functions***********************************************************************
383  inline Reference operator[]( size_t index );
384  inline ConstReference operator[]( size_t index ) const;
385  inline Pointer data ();
386  inline ConstPointer data () const;
387  inline Iterator begin ();
388  inline ConstIterator begin () const;
389  inline ConstIterator cbegin() const;
390  inline Iterator end ();
391  inline ConstIterator end () const;
392  inline ConstIterator cend () const;
394  //**********************************************************************************************
395 
396  //**Assignment operators************************************************************************
399  inline DenseRow& operator= ( const ElementType& rhs );
400  inline DenseRow& operator= ( const DenseRow& rhs );
401  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
402  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
403  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
404  template< typename VT > inline DenseRow& operator*=( const Vector<VT,true>& rhs );
405 
406  template< typename Other >
407  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
408  operator*=( Other rhs );
409 
410  template< typename Other >
411  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
412  operator/=( Other rhs );
414  //**********************************************************************************************
415 
416  //**Utility functions***************************************************************************
419  inline size_t size() const;
420  inline size_t capacity() const;
421  inline size_t nonZeros() const;
422  inline void reset();
423  template< typename Other > inline DenseRow& scale( const Other& scalar );
425  //**********************************************************************************************
426 
427  private:
428  //**********************************************************************************************
430  template< typename VT >
432  struct VectorizedAssign {
433  enum { value = vectorizable && VT::vectorizable &&
434  IsSame<ElementType,typename VT::ElementType>::value };
435  };
437  //**********************************************************************************************
438 
439  //**********************************************************************************************
441  template< typename VT >
443  struct VectorizedAddAssign {
444  enum { value = vectorizable && VT::vectorizable &&
445  IsSame<ElementType,typename VT::ElementType>::value &&
446  IntrinsicTrait<ElementType>::addition };
447  };
449  //**********************************************************************************************
450 
451  //**********************************************************************************************
453  template< typename VT >
455  struct VectorizedSubAssign {
456  enum { value = vectorizable && VT::vectorizable &&
457  IsSame<ElementType,typename VT::ElementType>::value &&
458  IntrinsicTrait<ElementType>::subtraction };
459  };
461  //**********************************************************************************************
462 
463  //**********************************************************************************************
465  template< typename VT >
467  struct VectorizedMultAssign {
468  enum { value = vectorizable && VT::vectorizable &&
469  IsSame<ElementType,typename VT::ElementType>::value &&
470  IntrinsicTrait<ElementType>::multiplication };
471  };
473  //**********************************************************************************************
474 
475  public:
476  //**Expression template evaluation functions****************************************************
479  template< typename Other > inline bool canAlias ( const Other* alias ) const;
480  template< typename MT2, bool SO2 > inline bool canAlias ( const DenseRow<MT2,SO2>* alias ) const;
481  template< typename Other > inline bool isAliased( const Other* alias ) const;
482  template< typename MT2, bool SO2 > inline bool isAliased( const DenseRow<MT2,SO2>* alias ) const;
483 
484  inline bool isAligned () const;
485  inline bool canSMPAssign() const;
486 
487  inline IntrinsicType load ( size_t index ) const;
488  inline IntrinsicType loadu ( size_t index ) const;
489  inline void store ( size_t index, const IntrinsicType& value );
490  inline void storeu( size_t index, const IntrinsicType& value );
491  inline void stream( size_t index, const IntrinsicType& value );
492 
493  template< typename VT >
494  inline typename DisableIf< VectorizedAssign<VT> >::Type
495  assign( const DenseVector<VT,true>& rhs );
496 
497  template< typename VT >
498  inline typename EnableIf< VectorizedAssign<VT> >::Type
499  assign( const DenseVector<VT,true>& rhs );
500 
501  template< typename VT > inline void assign( const SparseVector<VT,true>& rhs );
502 
503  template< typename VT >
504  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
505  addAssign( const DenseVector<VT,true>& rhs );
506 
507  template< typename VT >
508  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
509  addAssign( const DenseVector<VT,true>& rhs );
510 
511  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
512 
513  template< typename VT >
514  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
515  subAssign( const DenseVector<VT,true>& rhs );
516 
517  template< typename VT >
518  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
519  subAssign( const DenseVector<VT,true>& rhs );
520 
521  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
522 
523  template< typename VT >
524  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
525  multAssign( const DenseVector<VT,true>& rhs );
526 
527  template< typename VT >
528  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
529  multAssign( const DenseVector<VT,true>& rhs );
530 
531  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
533  //**********************************************************************************************
534 
535  private:
536  //**Member variables****************************************************************************
540  const size_t row_;
541 
542  //**********************************************************************************************
543 
544  //**Friend declarations*************************************************************************
546  template< typename MT2, bool SO2 > friend class DenseRow;
547 
548  template< typename MT2, bool SO2 >
549  friend bool isSame( const DenseRow<MT2,SO2>& a, const DenseRow<MT2,SO2>& b );
551  //**********************************************************************************************
552 
553  //**Compile time checks*************************************************************************
560  //**********************************************************************************************
561 };
562 //*************************************************************************************************
563 
564 
565 
566 
567 //=================================================================================================
568 //
569 // CONSTRUCTOR
570 //
571 //=================================================================================================
572 
573 //*************************************************************************************************
580 template< typename MT // Type of the dense matrix
581  , bool SO > // Storage order
582 inline DenseRow<MT,SO>::DenseRow( MT& matrix, size_t index )
583  : matrix_( matrix ) // The dense matrix containing the row
584  , row_ ( index ) // The index of the row in the matrix
585 {
586  if( matrix_.rows() <= index )
587  throw std::invalid_argument( "Invalid row access index" );
588 }
589 //*************************************************************************************************
590 
591 
592 
593 
594 //=================================================================================================
595 //
596 // DATA ACCESS FUNCTIONS
597 //
598 //=================================================================================================
599 
600 //*************************************************************************************************
606 template< typename MT // Type of the dense matrix
607  , bool SO > // Storage order
609 {
610  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
611  return matrix_(row_,index);
612 }
613 //*************************************************************************************************
614 
615 
616 //*************************************************************************************************
622 template< typename MT // Type of the dense matrix
623  , bool SO > // Storage order
625 {
626  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
627  return matrix_(row_,index);
628 }
629 //*************************************************************************************************
630 
631 
632 //*************************************************************************************************
639 template< typename MT // Type of the dense matrix
640  , bool SO > // Storage order
642 {
643  return matrix_.data( row_ );
644 }
645 //*************************************************************************************************
646 
647 
648 //*************************************************************************************************
655 template< typename MT // Type of the dense matrix
656  , bool SO > // Storage order
658 {
659  return matrix_.data( row_ );
660 }
661 //*************************************************************************************************
662 
663 
664 //*************************************************************************************************
671 template< typename MT // Type of the dense matrix
672  , bool SO > // Storage order
674 {
675  return matrix_.begin( row_ );
676 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
687 template< typename MT // Type of the dense matrix
688  , bool SO > // Storage order
690 {
691  return matrix_.cbegin( row_ );
692 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
703 template< typename MT // Type of the dense matrix
704  , bool SO > // Storage order
706 {
707  return matrix_.cbegin( row_ );
708 }
709 //*************************************************************************************************
710 
711 
712 //*************************************************************************************************
719 template< typename MT // Type of the dense matrix
720  , bool SO > // Storage order
722 {
723  return matrix_.end( row_ );
724 }
725 //*************************************************************************************************
726 
727 
728 //*************************************************************************************************
735 template< typename MT // Type of the dense matrix
736  , bool SO > // Storage order
738 {
739  return matrix_.cend( row_ );
740 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
751 template< typename MT // Type of the dense matrix
752  , bool SO > // Storage order
754 {
755  return matrix_.cend( row_ );
756 }
757 //*************************************************************************************************
758 
759 
760 
761 
762 //=================================================================================================
763 //
764 // ASSIGNMENT OPERATORS
765 //
766 //=================================================================================================
767 
768 //*************************************************************************************************
774 template< typename MT // Type of the dense matrix
775  , bool SO > // Storage order
777 {
778  const size_t columns( size() );
779 
780  for( size_t j=0UL; j<columns; ++j )
781  matrix_(row_,j) = rhs;
782 
783  return *this;
784 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
798 template< typename MT // Type of the dense matrix
799  , bool SO > // Storage order
801 {
802  if( &rhs == this ) return *this;
803 
804  if( size() != rhs.size() )
805  throw std::invalid_argument( "Row sizes do not match" );
806 
807  const size_t columns( size() );
808 
809  for( size_t j=0UL; j<columns; ++j )
810  matrix_(row_,j) = rhs[j];
811 
812  return *this;
813 }
814 //*************************************************************************************************
815 
816 
817 //*************************************************************************************************
827 template< typename MT // Type of the dense matrix
828  , bool SO > // Storage order
829 template< typename VT > // Type of the right-hand side vector
831 {
834 
835  if( size() != (~rhs).size() )
836  throw std::invalid_argument( "Vector sizes do not match" );
837 
838  if( (~rhs).canAlias( &matrix_ ) ) {
839  const typename VT::ResultType tmp( ~rhs );
840  smpAssign( *this, tmp );
841  }
842  else {
844  reset();
845  smpAssign( *this, ~rhs );
846  }
847 
848  return *this;
849 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
863 template< typename MT // Type of the dense matrix
864  , bool SO > // Storage order
865 template< typename VT > // Type of the right-hand side vector
867 {
870 
871  if( size() != (~rhs).size() )
872  throw std::invalid_argument( "Vector sizes do not match" );
873 
874  if( (~rhs).canAlias( &matrix_ ) ) {
875  const typename VT::ResultType tmp( ~rhs );
876  smpAddAssign( *this, tmp );
877  }
878  else {
879  smpAddAssign( *this, ~rhs );
880  }
881 
882  return *this;
883 }
884 //*************************************************************************************************
885 
886 
887 //*************************************************************************************************
897 template< typename MT // Type of the dense matrix
898  , bool SO > // Storage order
899 template< typename VT > // Type of the right-hand side vector
901 {
904 
905  if( size() != (~rhs).size() )
906  throw std::invalid_argument( "Vector sizes do not match" );
907 
908  if( (~rhs).canAlias( &matrix_ ) ) {
909  const typename VT::ResultType tmp( ~rhs );
910  smpSubAssign( *this, tmp );
911  }
912  else {
913  smpSubAssign( *this, ~rhs );
914  }
915 
916  return *this;
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
932 template< typename MT // Type of the dense matrix
933  , bool SO > // Storage order
934 template< typename VT > // Type of the right-hand side vector
936 {
939 
940  if( size() != (~rhs).size() )
941  throw std::invalid_argument( "Vector sizes do not match" );
942 
943  if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
944  const ResultType tmp( *this * (~rhs) );
945  smpAssign( *this, tmp );
946  }
947  else {
948  smpMultAssign( *this, ~rhs );
949  }
950 
951  return *this;
952 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
963 template< typename MT // Type of the dense matrix
964  , bool SO > // Storage order
965 template< typename Other > // Data type of the right-hand side scalar
966 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO> >::Type&
968 {
969  return operator=( (*this) * rhs );
970 }
971 //*************************************************************************************************
972 
973 
974 //*************************************************************************************************
983 template< typename MT // Type of the dense matrix
984  , bool SO > // Storage order
985 template< typename Other > // Data type of the right-hand side scalar
986 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO> >::Type&
988 {
989  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
990 
991  return operator=( (*this) / rhs );
992 }
993 //*************************************************************************************************
994 
995 
996 
997 
998 //=================================================================================================
999 //
1000 // UTILITY FUNCTIONS
1001 //
1002 //=================================================================================================
1003 
1004 //*************************************************************************************************
1009 template< typename MT // Type of the dense matrix
1010  , bool SO > // Storage order
1011 inline size_t DenseRow<MT,SO>::size() const
1012 {
1013  return matrix_.columns();
1014 }
1015 //*************************************************************************************************
1016 
1017 
1018 //*************************************************************************************************
1023 template< typename MT // Type of the dense matrix
1024  , bool SO > // Storage order
1025 inline size_t DenseRow<MT,SO>::capacity() const
1026 {
1027  return matrix_.capacity( row_ );
1028 }
1029 //*************************************************************************************************
1030 
1031 
1032 //*************************************************************************************************
1040 template< typename MT // Type of the dense matrix
1041  , bool SO > // Storage order
1042 inline size_t DenseRow<MT,SO>::nonZeros() const
1043 {
1044  return matrix_.nonZeros( row_ );
1045 }
1046 //*************************************************************************************************
1047 
1048 
1049 //*************************************************************************************************
1054 template< typename MT // Type of the dense matrix
1055  , bool SO > // Storage order
1057 {
1058  matrix_.reset( row_ );
1059 }
1060 //*************************************************************************************************
1061 
1062 
1063 //*************************************************************************************************
1069 template< typename MT // Type of the dense matrix
1070  , bool SO > // Storage order
1071 template< typename Other > // Data type of the scalar value
1072 inline DenseRow<MT,SO>& DenseRow<MT,SO>::scale( const Other& scalar )
1073 {
1074  for( size_t j=0UL; j<size(); ++j ) {
1075  matrix_(row_,j) *= scalar;
1076  }
1077  return *this;
1078 }
1079 //*************************************************************************************************
1080 
1081 
1082 
1083 
1084 //=================================================================================================
1085 //
1086 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1087 //
1088 //=================================================================================================
1089 
1090 //*************************************************************************************************
1100 template< typename MT // Type of the dense matrix
1101  , bool SO > // Storage order
1102 template< typename Other > // Data type of the foreign expression
1103 inline bool DenseRow<MT,SO>::canAlias( const Other* alias ) const
1104 {
1105  return matrix_.isAliased( alias );
1106 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1120 template< typename MT // Type of the dense matrix
1121  , bool SO > // Storage order
1122 template< typename MT2 // Data type of the foreign dense row
1123  , bool SO2 > // Storage order of the foreign dense row
1124 inline bool DenseRow<MT,SO>::canAlias( const DenseRow<MT2,SO2>* alias ) const
1125 {
1126  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
1127 }
1128 //*************************************************************************************************
1129 
1130 
1131 //*************************************************************************************************
1141 template< typename MT // Type of the dense matrix
1142  , bool SO > // Storage order
1143 template< typename Other > // Data type of the foreign expression
1144 inline bool DenseRow<MT,SO>::isAliased( const Other* alias ) const
1145 {
1146  return matrix_.isAliased( alias );
1147 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1161 template< typename MT // Type of the dense matrix
1162  , bool SO > // Storage order
1163 template< typename MT2 // Data type of the foreign dense row
1164  , bool SO2 > // Storage order of the foreign dense row
1165 inline bool DenseRow<MT,SO>::isAliased( const DenseRow<MT2,SO2>* alias ) const
1166 {
1167  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
1168 }
1169 //*************************************************************************************************
1170 
1171 
1172 //*************************************************************************************************
1181 template< typename MT // Type of the dense matrix
1182  , bool SO > // Storage order
1183 inline bool DenseRow<MT,SO>::isAligned() const
1184 {
1185  return matrix_.isAligned();
1186 }
1187 //*************************************************************************************************
1188 
1189 
1190 //*************************************************************************************************
1200 template< typename MT // Type of the dense matrix
1201  , bool SO > // Storage order
1203 {
1204  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1205 }
1206 //*************************************************************************************************
1207 
1208 
1209 //*************************************************************************************************
1221 template< typename MT // Type of the dense matrix
1222  , bool SO > // Storage order
1223 inline typename DenseRow<MT,SO>::IntrinsicType DenseRow<MT,SO>::load( size_t index ) const
1224 {
1225  return matrix_.load( row_, index );
1226 }
1227 //*************************************************************************************************
1228 
1229 
1230 //*************************************************************************************************
1242 template< typename MT // Type of the dense matrix
1243  , bool SO > // Storage order
1244 inline typename DenseRow<MT,SO>::IntrinsicType DenseRow<MT,SO>::loadu( size_t index ) const
1245 {
1246  return matrix_.loadu( row_, index );
1247 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1264 template< typename MT // Type of the dense matrix
1265  , bool SO > // Storage order
1266 inline void DenseRow<MT,SO>::store( size_t index, const IntrinsicType& value )
1267 {
1268  matrix_.store( row_, index, value );
1269 }
1270 //*************************************************************************************************
1271 
1272 
1273 //*************************************************************************************************
1286 template< typename MT // Type of the dense matrix
1287  , bool SO > // Storage order
1288 inline void DenseRow<MT,SO>::storeu( size_t index, const IntrinsicType& value )
1289 {
1290  matrix_.storeu( row_, index, value );
1291 }
1292 //*************************************************************************************************
1293 
1294 
1295 //*************************************************************************************************
1308 template< typename MT // Type of the dense matrix
1309  , bool SO > // Storage order
1310 inline void DenseRow<MT,SO>::stream( size_t index, const IntrinsicType& value )
1311 {
1312  matrix_.stream( row_, index, value );
1313 }
1314 //*************************************************************************************************
1315 
1316 
1317 //*************************************************************************************************
1328 template< typename MT // Type of the dense matrix
1329  , bool SO > // Storage order
1330 template< typename VT > // Type of the right-hand side dense vector
1331 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1333 {
1334  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1335 
1336  const size_t jend( (~rhs).size() & size_t(-2) );
1337  for( size_t j=0UL; j<jend; j+=2UL ) {
1338  matrix_(row_,j ) = (~rhs)[j ];
1339  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
1340  }
1341  if( jend < (~rhs).size() )
1342  matrix_(row_,jend) = (~rhs)[jend];
1343 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1358 template< typename MT // Type of the dense matrix
1359  , bool SO > // Storage order
1360 template< typename VT > // Type of the right-hand side dense vector
1361 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1363 {
1364  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1365 
1367 
1368  const size_t columns( size() );
1369 
1370  if( useStreaming && columns > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
1371  {
1372  for( size_t j=0UL; j<columns; j+=IT::size ) {
1373  matrix_.stream( row_, j, (~rhs).load(j) );
1374  }
1375  }
1376  else
1377  {
1378  const size_t jend( columns & size_t(-IT::size*4) );
1379  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1380 
1381  typename VT::ConstIterator it( (~rhs).begin() );
1382  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1383  matrix_.store( row_, j , it.load() ); it += IT::size;
1384  matrix_.store( row_, j+IT::size , it.load() ); it += IT::size;
1385  matrix_.store( row_, j+IT::size*2UL, it.load() ); it += IT::size;
1386  matrix_.store( row_, j+IT::size*3UL, it.load() ); it += IT::size;
1387  }
1388  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1389  matrix_.store( row_, j, it.load() );
1390  }
1391  }
1392 }
1393 //*************************************************************************************************
1394 
1395 
1396 //*************************************************************************************************
1407 template< typename MT // Type of the dense matrix
1408  , bool SO > // Storage order
1409 template< typename VT > // Type of the right-hand side sparse vector
1411 {
1412  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1413 
1414  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1415  matrix_(row_,element->index()) = element->value();
1416 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1431 template< typename MT // Type of the dense matrix
1432  , bool SO > // Storage order
1433 template< typename VT > // Type of the right-hand side dense vector
1434 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1436 {
1437  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1438 
1439  const size_t jend( (~rhs).size() & size_t(-2) );
1440  for( size_t j=0UL; j<jend; j+=2UL ) {
1441  matrix_(row_,j ) += (~rhs)[j ];
1442  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
1443  }
1444  if( jend < (~rhs).size() )
1445  matrix_(row_,jend) += (~rhs)[jend];
1446 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1461 template< typename MT // Type of the dense matrix
1462  , bool SO > // Storage order
1463 template< typename VT > // Type of the right-hand side dense vector
1464 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1466 {
1467  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1468 
1470 
1471  const size_t columns( size() );
1472 
1473  const size_t jend( columns & size_t(-IT::size*4) );
1474  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1475 
1476  typename VT::ConstIterator it( (~rhs).begin() );
1477  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1478  matrix_.store( row_, j , matrix_.load(row_,j ) + it.load() ); it += IT::size;
1479  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) + it.load() ); it += IT::size;
1480  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) + it.load() ); it += IT::size;
1481  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) + it.load() ); it += IT::size;
1482  }
1483  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1484  matrix_.store( row_, j, matrix_.load(row_,j) + it.load() );
1485  }
1486 }
1487 //*************************************************************************************************
1488 
1489 
1490 //*************************************************************************************************
1501 template< typename MT // Type of the dense matrix
1502  , bool SO > // Storage order
1503 template< typename VT > // Type of the right-hand side sparse vector
1505 {
1506  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1507 
1508  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1509  matrix_(row_,element->index()) += element->value();
1510 }
1511 //*************************************************************************************************
1512 
1513 
1514 //*************************************************************************************************
1525 template< typename MT // Type of the dense matrix
1526  , bool SO > // Storage order
1527 template< typename VT > // Type of the right-hand side dense vector
1528 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1530 {
1531  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1532 
1533  const size_t jend( (~rhs).size() & size_t(-2) );
1534  for( size_t j=0UL; j<jend; j+=2UL ) {
1535  matrix_(row_,j ) -= (~rhs)[j ];
1536  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
1537  }
1538  if( jend < (~rhs).size() )
1539  matrix_(row_,jend) -= (~rhs)[jend];
1540 }
1541 //*************************************************************************************************
1542 
1543 
1544 //*************************************************************************************************
1555 template< typename MT // Type of the dense matrix
1556  , bool SO > // Storage order
1557 template< typename VT > // Type of the right-hand side dense vector
1558 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1560 {
1561  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1562 
1564 
1565  const size_t columns( size() );
1566 
1567  const size_t jend( columns & size_t(-IT::size*4) );
1568  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1569 
1570  typename VT::ConstIterator it( (~rhs).begin() );
1571  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1572  matrix_.store( row_, j , matrix_.load(row_,j ) - it.load() ); it += IT::size;
1573  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) - it.load() ); it += IT::size;
1574  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) - it.load() ); it += IT::size;
1575  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) - it.load() ); it += IT::size;
1576  }
1577  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1578  matrix_.store( row_, j, matrix_.load(row_,j) - it.load() );
1579  }
1580 }
1581 //*************************************************************************************************
1582 
1583 
1584 //*************************************************************************************************
1595 template< typename MT // Type of the dense matrix
1596  , bool SO > // Storage order
1597 template< typename VT > // Type of the right-hand side sparse vector
1599 {
1600  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1601 
1602  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1603  matrix_(row_,element->index()) -= element->value();
1604 }
1605 //*************************************************************************************************
1606 
1607 
1608 //*************************************************************************************************
1619 template< typename MT // Type of the dense matrix
1620  , bool SO > // Storage order
1621 template< typename VT > // Type of the right-hand side dense vector
1622 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1624 {
1625  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1626 
1627  const size_t jend( (~rhs).size() & size_t(-2) );
1628  for( size_t j=0UL; j<jend; j+=2UL ) {
1629  matrix_(row_,j ) *= (~rhs)[j ];
1630  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
1631  }
1632  if( jend < (~rhs).size() )
1633  matrix_(row_,jend) *= (~rhs)[jend];
1634 }
1635 //*************************************************************************************************
1636 
1637 
1638 //*************************************************************************************************
1649 template< typename MT // Type of the dense matrix
1650  , bool SO > // Storage order
1651 template< typename VT > // Type of the right-hand side dense vector
1652 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1654 {
1655  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1656 
1658 
1659  const size_t columns( size() );
1660 
1661  const size_t jend( columns & size_t(-IT::size*4) );
1662  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1663 
1664  typename VT::ConstIterator it( (~rhs).begin() );
1665  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1666  matrix_.store( row_, j , matrix_.load(row_,j ) * it.load() ); it += IT::size;
1667  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) * it.load() ); it += IT::size;
1668  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) * it.load() ); it += IT::size;
1669  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) * it.load() ); it += IT::size;
1670  }
1671  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1672  matrix_.store( row_, j, matrix_.load(row_,j) * it.load() );
1673  }
1674 }
1675 //*************************************************************************************************
1676 
1677 
1678 //*************************************************************************************************
1689 template< typename MT // Type of the dense matrix
1690  , bool SO > // Storage order
1691 template< typename VT > // Type of the right-hand side sparse vector
1693 {
1694  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1695 
1696  const ResultType tmp( serial( *this ) );
1697 
1698  reset();
1699 
1700  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1701  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
1702 }
1703 //*************************************************************************************************
1704 
1705 
1706 
1707 
1708 
1709 
1710 
1711 
1712 //=================================================================================================
1713 //
1714 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
1715 //
1716 //=================================================================================================
1717 
1718 //*************************************************************************************************
1726 template< typename MT > // Type of the dense matrix
1727 class DenseRow<MT,false> : public DenseVector< DenseRow<MT,false>, true >
1728  , private Row
1729 {
1730  private:
1731  //**Type definitions****************************************************************************
1733  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1734  //**********************************************************************************************
1735 
1736  //**********************************************************************************************
1738 
1744  enum { useConst = IsConst<MT>::value };
1745  //**********************************************************************************************
1746 
1747  public:
1748  //**Type definitions****************************************************************************
1749  typedef DenseRow<MT,false> This;
1750  typedef typename RowTrait<MT>::Type ResultType;
1751  typedef typename ResultType::TransposeType TransposeType;
1752  typedef typename MT::ElementType ElementType;
1753  typedef typename MT::ReturnType ReturnType;
1754  typedef const DenseRow& CompositeType;
1755 
1757  typedef typename MT::ConstReference ConstReference;
1758 
1760  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1761  //**********************************************************************************************
1762 
1763  //**RowIterator class definition****************************************************************
1766  template< typename MatrixType > // Type of the dense matrix
1767  class RowIterator
1768  {
1769  private:
1770  //*******************************************************************************************
1772 
1777  enum { returnConst = IsConst<MatrixType>::value };
1778  //*******************************************************************************************
1779 
1780  public:
1781  //**Type definitions*************************************************************************
1783  typedef typename SelectType< returnConst, typename MT::ConstReference, typename MT::Reference >::Type Reference;
1784 
1785  typedef std::random_access_iterator_tag IteratorCategory;
1786  typedef RemoveReference<Reference> ValueType;
1787  typedef ValueType* PointerType;
1788  typedef Reference ReferenceType;
1789  typedef ptrdiff_t DifferenceType;
1790 
1791  // STL iterator requirements
1792  typedef IteratorCategory iterator_category;
1793  typedef ValueType value_type;
1794  typedef PointerType pointer;
1795  typedef ReferenceType reference;
1796  typedef DifferenceType difference_type;
1797  //*******************************************************************************************
1798 
1799  //**Constructor******************************************************************************
1806  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
1807  : matrix_( &matrix ) // The dense matrix containing the row.
1808  , row_ ( row ) // The current row index.
1809  , column_( column ) // The current column index.
1810  {}
1811  //*******************************************************************************************
1812 
1813  //**Constructor******************************************************************************
1818  template< typename MatrixType2 >
1819  inline RowIterator( const RowIterator<MatrixType2>& it )
1820  : matrix_( it.matrix_ ) // The dense matrix containing the row.
1821  , row_ ( it.row_ ) // The current row index.
1822  , column_( it.column_ ) // The current column index.
1823  {}
1824  //*******************************************************************************************
1825 
1826  //**Addition assignment operator*************************************************************
1832  inline RowIterator& operator+=( size_t inc ) {
1833  column_ += inc;
1834  return *this;
1835  }
1836  //*******************************************************************************************
1837 
1838  //**Subtraction assignment operator**********************************************************
1844  inline RowIterator& operator-=( size_t dec ) {
1845  column_ -= dec;
1846  return *this;
1847  }
1848  //*******************************************************************************************
1849 
1850  //**Prefix increment operator****************************************************************
1855  inline RowIterator& operator++() {
1856  ++column_;
1857  return *this;
1858  }
1859  //*******************************************************************************************
1860 
1861  //**Postfix increment operator***************************************************************
1866  inline const RowIterator operator++( int ) {
1867  const RowIterator tmp( *this );
1868  ++(*this);
1869  return tmp;
1870  }
1871  //*******************************************************************************************
1872 
1873  //**Prefix decrement operator****************************************************************
1878  inline RowIterator& operator--() {
1879  --column_;
1880  return *this;
1881  }
1882  //*******************************************************************************************
1883 
1884  //**Postfix decrement operator***************************************************************
1889  inline const RowIterator operator--( int ) {
1890  const RowIterator tmp( *this );
1891  --(*this);
1892  return tmp;
1893  }
1894  //*******************************************************************************************
1895 
1896  //**Subscript operator***********************************************************************
1902  inline ReferenceType operator[]( size_t index ) const {
1903  return (*matrix_)(row_,column_+index);
1904  }
1905  //*******************************************************************************************
1906 
1907  //**Element access operator******************************************************************
1912  inline ReferenceType operator*() const {
1913  return (*matrix_)(row_,column_);
1914  }
1915  //*******************************************************************************************
1916 
1917  //**Element access operator******************************************************************
1922  inline PointerType operator->() const {
1923  return &(*matrix_)(row_,column_);
1924  }
1925  //*******************************************************************************************
1926 
1927  //**Equality operator************************************************************************
1933  template< typename MatrixType2 >
1934  inline bool operator==( const RowIterator<MatrixType2>& rhs ) const {
1935  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1936  }
1937  //*******************************************************************************************
1938 
1939  //**Inequality operator**********************************************************************
1945  template< typename MatrixType2 >
1946  inline bool operator!=( const RowIterator<MatrixType2>& rhs ) const {
1947  return !( *this == rhs );
1948  }
1949  //*******************************************************************************************
1950 
1951  //**Less-than operator***********************************************************************
1957  template< typename MatrixType2 >
1958  inline bool operator<( const RowIterator<MatrixType2>& rhs ) const {
1959  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ < rhs.column_ );
1960  }
1961  //*******************************************************************************************
1962 
1963  //**Greater-than operator********************************************************************
1969  template< typename MatrixType2 >
1970  inline bool operator>( const RowIterator<MatrixType2>& rhs ) const {
1971  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ > rhs.column_ );
1972  }
1973  //*******************************************************************************************
1974 
1975  //**Less-or-equal-than operator**************************************************************
1981  template< typename MatrixType2 >
1982  inline bool operator<=( const RowIterator<MatrixType2>& rhs ) const {
1983  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ <= rhs.column_ );
1984  }
1985  //*******************************************************************************************
1986 
1987  //**Greater-or-equal-than operator***********************************************************
1993  template< typename MatrixType2 >
1994  inline bool operator>=( const RowIterator<MatrixType2>& rhs ) const {
1995  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ >= rhs.column_ );
1996  }
1997  //*******************************************************************************************
1998 
1999  //**Subtraction operator*********************************************************************
2005  inline DifferenceType operator-( const RowIterator& rhs ) const {
2006  return column_ - rhs.column_;
2007  }
2008  //*******************************************************************************************
2009 
2010  //**Addition operator************************************************************************
2017  friend inline const RowIterator operator+( const RowIterator& it, size_t inc ) {
2018  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2019  }
2020  //*******************************************************************************************
2021 
2022  //**Addition operator************************************************************************
2029  friend inline const RowIterator operator+( size_t inc, const RowIterator& it ) {
2030  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2031  }
2032  //*******************************************************************************************
2033 
2034  //**Subtraction operator*********************************************************************
2041  friend inline const RowIterator operator-( const RowIterator& it, size_t dec ) {
2042  return RowIterator( *it.matrix_, it.row_, it.column_-dec );
2043  }
2044  //*******************************************************************************************
2045 
2046  private:
2047  //**Member variables*************************************************************************
2048  MatrixType* matrix_;
2049  size_t row_;
2050  size_t column_;
2051  //*******************************************************************************************
2052 
2053  //**Friend declarations**********************************************************************
2054  template< typename MatrixType2 > friend class RowIterator;
2055  //*******************************************************************************************
2056  };
2057  //**********************************************************************************************
2058 
2059  //**Type definitions****************************************************************************
2061  typedef RowIterator<const MT> ConstIterator;
2062 
2064  typedef typename SelectType< useConst, ConstIterator, RowIterator<MT> >::Type Iterator;
2065  //**********************************************************************************************
2066 
2067  //**Compilation flags***************************************************************************
2069  enum { vectorizable = 0 };
2070 
2072  enum { smpAssignable = MT::smpAssignable };
2073  //**********************************************************************************************
2074 
2075  //**Constructors********************************************************************************
2078  explicit inline DenseRow( MT& matrix, size_t index );
2079  // No explicitly declared copy constructor.
2081  //**********************************************************************************************
2082 
2083  //**Destructor**********************************************************************************
2084  // No explicitly declared destructor.
2085  //**********************************************************************************************
2086 
2087  //**Data access functions***********************************************************************
2090  inline Reference operator[]( size_t index );
2091  inline ConstReference operator[]( size_t index ) const;
2092  inline Iterator begin ();
2093  inline ConstIterator begin () const;
2094  inline ConstIterator cbegin() const;
2095  inline Iterator end ();
2096  inline ConstIterator end () const;
2097  inline ConstIterator cend () const;
2099  //**********************************************************************************************
2100 
2101  //**Assignment operators************************************************************************
2104  inline DenseRow& operator= ( const ElementType& rhs );
2105  inline DenseRow& operator= ( const DenseRow& rhs );
2106  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
2107  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
2108  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
2109  template< typename VT > inline DenseRow& operator*=( const Vector<VT,true>& rhs );
2110 
2111  template< typename Other >
2112  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2113  operator*=( Other rhs );
2114 
2115  template< typename Other >
2116  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2117  operator/=( Other rhs );
2119  //**********************************************************************************************
2120 
2121  //**Utility functions***************************************************************************
2124  inline size_t size() const;
2125  inline size_t capacity() const;
2126  inline size_t nonZeros() const;
2127  inline void reset();
2128  template< typename Other > inline DenseRow& scale( const Other& scalar );
2130  //**********************************************************************************************
2131 
2132  public:
2133  //**Expression template evaluation functions****************************************************
2136  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2137  template< typename MT2, bool SO2 > inline bool canAlias ( const DenseRow<MT2,SO2>* alias ) const;
2138  template< typename Other > inline bool isAliased( const Other* alias ) const;
2139  template< typename MT2, bool SO2 > inline bool isAliased( const DenseRow<MT2,SO2>* alias ) const;
2140 
2141  inline bool isAligned () const;
2142  inline bool canSMPAssign() const;
2143 
2144  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2145  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2146  template< typename VT > inline void addAssign ( const DenseVector <VT,true>& rhs );
2147  template< typename VT > inline void addAssign ( const SparseVector<VT,true>& rhs );
2148  template< typename VT > inline void subAssign ( const DenseVector <VT,true>& rhs );
2149  template< typename VT > inline void subAssign ( const SparseVector<VT,true>& rhs );
2150  template< typename VT > inline void multAssign( const DenseVector <VT,true>& rhs );
2151  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
2153  //**********************************************************************************************
2154 
2155  private:
2156  //**Member variables****************************************************************************
2159  Operand matrix_;
2160  const size_t row_;
2161 
2162  //**********************************************************************************************
2163 
2164  //**Friend declarations*************************************************************************
2165  template< typename MT2, bool SO2 > friend class DenseRow;
2166 
2167  template< typename MT2, bool SO2 >
2168  friend bool isSame( const DenseRow<MT2,SO2>& a, const DenseRow<MT2,SO2>& b );
2169  //**********************************************************************************************
2170 
2171  //**Compile time checks*************************************************************************
2176  //**********************************************************************************************
2177 };
2179 //*************************************************************************************************
2180 
2181 
2182 
2183 
2184 //=================================================================================================
2185 //
2186 // CONSTRUCTOR
2187 //
2188 //=================================================================================================
2189 
2190 //*************************************************************************************************
2198 template< typename MT > // Type of the dense matrix
2199 inline DenseRow<MT,false>::DenseRow( MT& matrix, size_t index )
2200  : matrix_( matrix ) // The dense matrix containing the row
2201  , row_ ( index ) // The index of the row in the matrix
2202 {
2203  if( matrix_.rows() <= index )
2204  throw std::invalid_argument( "Invalid row access index" );
2205 }
2207 //*************************************************************************************************
2208 
2209 
2210 
2211 
2212 //=================================================================================================
2213 //
2214 // DATA ACCESS FUNCTIONS
2215 //
2216 //=================================================================================================
2217 
2218 //*************************************************************************************************
2225 template< typename MT > // Type of the dense matrix
2226 inline typename DenseRow<MT,false>::Reference DenseRow<MT,false>::operator[]( size_t index )
2227 {
2228  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2229  return matrix_(row_,index);
2230 }
2232 //*************************************************************************************************
2233 
2234 
2235 //*************************************************************************************************
2242 template< typename MT > // Type of the dense matrix
2243 inline typename DenseRow<MT,false>::ConstReference DenseRow<MT,false>::operator[]( size_t index ) const
2244 {
2245  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2246  return matrix_(row_,index);
2247 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2260 template< typename MT > // Type of the dense matrix
2262 {
2263  return Iterator( matrix_, row_, 0UL );
2264 }
2266 //*************************************************************************************************
2267 
2268 
2269 //*************************************************************************************************
2277 template< typename MT > // Type of the dense matrix
2279 {
2280  return ConstIterator( matrix_, row_, 0UL );
2281 }
2283 //*************************************************************************************************
2284 
2285 
2286 //*************************************************************************************************
2294 template< typename MT > // Type of the dense matrix
2296 {
2297  return ConstIterator( matrix_, row_, 0UL );
2298 }
2300 //*************************************************************************************************
2301 
2302 
2303 //*************************************************************************************************
2311 template< typename MT > // Type of the dense matrix
2313 {
2314  return Iterator( matrix_, row_, size() );
2315 }
2317 //*************************************************************************************************
2318 
2319 
2320 //*************************************************************************************************
2328 template< typename MT > // Type of the dense matrix
2330 {
2331  return ConstIterator( matrix_, row_, size() );
2332 }
2334 //*************************************************************************************************
2335 
2336 
2337 //*************************************************************************************************
2345 template< typename MT > // Type of the dense matrix
2347 {
2348  return ConstIterator( matrix_, row_, size() );
2349 }
2351 //*************************************************************************************************
2352 
2353 
2354 
2355 
2356 //=================================================================================================
2357 //
2358 // ASSIGNMENT OPERATORS
2359 //
2360 //=================================================================================================
2361 
2362 //*************************************************************************************************
2369 template< typename MT > // Type of the dense matrix
2370 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const ElementType& rhs )
2371 {
2372  const size_t columns( size() );
2373 
2374  for( size_t j=0UL; j<columns; ++j )
2375  matrix_(row_,j) = rhs;
2376 
2377  return *this;
2378 }
2380 //*************************************************************************************************
2381 
2382 
2383 //*************************************************************************************************
2394 template< typename MT > // Type of the dense matrix
2395 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const DenseRow& rhs )
2396 {
2397  if( &rhs == this ) return *this;
2398 
2399  if( size() != rhs.size() )
2400  throw std::invalid_argument( "Row sizes do not match" );
2401 
2402  const size_t columns( size() );
2403 
2404  for( size_t j=0UL; j<columns; ++j )
2405  matrix_(row_,j) = rhs[j];
2406 
2407  return *this;
2408 }
2410 //*************************************************************************************************
2411 
2412 
2413 //*************************************************************************************************
2424 template< typename MT > // Type of the dense matrix
2425 template< typename VT > // Type of the right-hand side vector
2426 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const Vector<VT,true>& rhs )
2427 {
2431 
2432  if( size() != (~rhs).size() )
2433  throw std::invalid_argument( "Vector sizes do not match" );
2434 
2435  if( (~rhs).canAlias( &matrix_ ) ) {
2436  const ResultType tmp( ~rhs );
2437  smpAssign( *this, tmp );
2438  }
2439  else {
2440  if( IsSparseVector<VT>::value )
2441  reset();
2442  smpAssign( *this, ~rhs );
2443  }
2444 
2445  return *this;
2446 }
2448 //*************************************************************************************************
2449 
2450 
2451 //*************************************************************************************************
2462 template< typename MT > // Type of the dense matrix
2463 template< typename VT > // Type of the right-hand side vector
2464 inline DenseRow<MT,false>& DenseRow<MT,false>::operator+=( const Vector<VT,true>& rhs )
2465 {
2468 
2469  if( size() != (~rhs).size() )
2470  throw std::invalid_argument( "Vector sizes do not match" );
2471 
2472  if( (~rhs).canAlias( &matrix_ ) ) {
2473  const typename VT::ResultType tmp( ~rhs );
2474  smpAddAssign( *this, tmp );
2475  }
2476  else {
2477  smpAddAssign( *this, ~rhs );
2478  }
2479 
2480  return *this;
2481 }
2483 //*************************************************************************************************
2484 
2485 
2486 //*************************************************************************************************
2497 template< typename MT > // Type of the dense matrix
2498 template< typename VT > // Type of the right-hand side vector
2499 inline DenseRow<MT,false>& DenseRow<MT,false>::operator-=( const Vector<VT,true>& rhs )
2500 {
2503 
2504  if( size() != (~rhs).size() )
2505  throw std::invalid_argument( "Vector sizes do not match" );
2506 
2507  if( (~rhs).canAlias( &matrix_ ) ) {
2508  const typename VT::ResultType tmp( ~rhs );
2509  smpSubAssign( *this, tmp );
2510  }
2511  else {
2512  smpSubAssign( *this, ~rhs );
2513  }
2514 
2515  return *this;
2516 }
2518 //*************************************************************************************************
2519 
2520 
2521 //*************************************************************************************************
2533 template< typename MT > // Type of the dense matrix
2534 template< typename VT > // Type of the right-hand side vector
2535 inline DenseRow<MT,false>& DenseRow<MT,false>::operator*=( const Vector<VT,true>& rhs )
2536 {
2539 
2540  if( size() != (~rhs).size() )
2541  throw std::invalid_argument( "Vector sizes do not match" );
2542 
2543  if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
2544  const ResultType tmp( *this * (~rhs) );
2545  smpAssign( *this, tmp );
2546  }
2547  else {
2548  smpMultAssign( *this, ~rhs );
2549  }
2550 
2551  return *this;
2552 }
2554 //*************************************************************************************************
2555 
2556 
2557 //*************************************************************************************************
2565 template< typename MT > // Type of the dense matrix
2566 template< typename Other > // Data type of the right-hand side scalar
2567 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2568  DenseRow<MT,false>::operator*=( Other rhs )
2569 {
2570  for( size_t j=0UL; j<size(); ++j )
2571  matrix_(row_,j) *= rhs;
2572  return *this;
2573 }
2575 //*************************************************************************************************
2576 
2577 
2578 //*************************************************************************************************
2588 template< typename MT > // Type of the dense matrix
2589 template< typename Other > // Data type of the right-hand side scalar
2590 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2591  DenseRow<MT,false>::operator/=( Other rhs )
2592 {
2593  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2594 
2595  typedef typename DivTrait<ElementType,Other>::Type DT;
2596  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2597 
2598  // Depending on the two involved data types, an integer division is applied or a
2599  // floating point division is selected.
2600  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2601  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2602  for( size_t j=0UL; j<size(); ++j )
2603  matrix_(row_,j) *= tmp;
2604  }
2605  else {
2606  for( size_t j=0UL; j<size(); ++j )
2607  matrix_(row_,j) /= rhs;
2608  }
2609 
2610  return *this;
2611 }
2613 //*************************************************************************************************
2614 
2615 
2616 
2617 
2618 //=================================================================================================
2619 //
2620 // UTILITY FUNCTIONS
2621 //
2622 //=================================================================================================
2623 
2624 //*************************************************************************************************
2630 template< typename MT > // Type of the dense matrix
2631 inline size_t DenseRow<MT,false>::size() const
2632 {
2633  return matrix_.columns();
2634 }
2636 //*************************************************************************************************
2637 
2638 
2639 //*************************************************************************************************
2645 template< typename MT > // Type of the dense matrix
2646 inline size_t DenseRow<MT,false>::capacity() const
2647 {
2648  return matrix_.columns();
2649 }
2651 //*************************************************************************************************
2652 
2653 
2654 //*************************************************************************************************
2663 template< typename MT > // Type of the dense matrix
2664 inline size_t DenseRow<MT,false>::nonZeros() const
2665 {
2666  const size_t columns( size() );
2667  size_t nonzeros( 0UL );
2668 
2669  for( size_t j=0UL; j<columns; ++j )
2670  if( !isDefault( matrix_(row_,j) ) )
2671  ++nonzeros;
2672 
2673  return nonzeros;
2674 }
2676 //*************************************************************************************************
2677 
2678 
2679 //*************************************************************************************************
2685 template< typename MT > // Type of the dense matrix
2686 inline void DenseRow<MT,false>::reset()
2687 {
2688  using blaze::reset;
2689  const size_t columns( size() );
2690  for( size_t j=0UL; j<columns; ++j )
2691  reset( matrix_(row_,j) );
2692 }
2694 //*************************************************************************************************
2695 
2696 
2697 //*************************************************************************************************
2704 template< typename MT > // Type of the dense matrix
2705 template< typename Other > // Data type of the scalar value
2706 inline DenseRow<MT,false>& DenseRow<MT,false>::scale( const Other& scalar )
2707 {
2708  for( size_t j=0UL; j<size(); ++j ) {
2709  matrix_(row_,j) *= scalar;
2710  }
2711  return *this;
2712 }
2714 //*************************************************************************************************
2715 
2716 
2717 
2718 
2719 //=================================================================================================
2720 //
2721 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2722 //
2723 //=================================================================================================
2724 
2725 //*************************************************************************************************
2736 template< typename MT > // Type of the dense matrix
2737 template< typename Other > // Data type of the foreign expression
2738 inline bool DenseRow<MT,false>::canAlias( const Other* alias ) const
2739 {
2740  return matrix_.isAliased( alias );
2741 }
2743 //*************************************************************************************************
2744 
2745 
2746 //*************************************************************************************************
2757 template< typename MT > // Type of the dense matrix
2758 template< typename MT2 // Data type of the foreign dense row
2759  , bool SO2 > // Storage order of the foreign dense row
2760 inline bool DenseRow<MT,false>::canAlias( const DenseRow<MT2,SO2>* alias ) const
2761 {
2762  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
2763 }
2765 //*************************************************************************************************
2766 
2767 
2768 //*************************************************************************************************
2779 template< typename MT > // Type of the dense matrix
2780 template< typename Other > // Data type of the foreign expression
2781 inline bool DenseRow<MT,false>::isAliased( const Other* alias ) const
2782 {
2783  return matrix_.isAliased( alias );
2784 }
2786 //*************************************************************************************************
2787 
2788 
2789 //*************************************************************************************************
2800 template< typename MT > // Type of the dense matrix
2801 template< typename MT2 // Data type of the foreign dense row
2802  , bool SO2 > // Storage order of the foreign dense row
2803 inline bool DenseRow<MT,false>::isAliased( const DenseRow<MT2,SO2>* alias ) const
2804 {
2805  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
2806 }
2808 //*************************************************************************************************
2809 
2810 
2811 //*************************************************************************************************
2821 template< typename MT > // Type of the dense matrix
2822 inline bool DenseRow<MT,false>::isAligned() const
2823 {
2824  return false;
2825 }
2827 //*************************************************************************************************
2828 
2829 
2830 //*************************************************************************************************
2841 template< typename MT > // Type of the dense matrix
2842 inline bool DenseRow<MT,false>::canSMPAssign() const
2843 {
2844  return ( size() > SMP_DVECASSIGN_THRESHOLD );
2845 }
2847 //*************************************************************************************************
2848 
2849 
2850 //*************************************************************************************************
2862 template< typename MT > // Type of the dense matrix
2863 template< typename VT > // Type of the right-hand side dense vector
2864 inline void DenseRow<MT,false>::assign( const DenseVector<VT,true>& rhs )
2865 {
2866  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2867 
2868  const size_t jend( (~rhs).size() & size_t(-2) );
2869  for( size_t j=0UL; j<jend; j+=2UL ) {
2870  matrix_(row_,j ) = (~rhs)[j ];
2871  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
2872  }
2873  if( jend < (~rhs).size() )
2874  matrix_(row_,jend) = (~rhs)[jend];
2875 }
2877 //*************************************************************************************************
2878 
2879 
2880 //*************************************************************************************************
2892 template< typename MT > // Type of the dense matrix
2893 template< typename VT > // Type of the right-hand side sparse vector
2894 inline void DenseRow<MT,false>::assign( const SparseVector<VT,true>& rhs )
2895 {
2896  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2897 
2898  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2899  matrix_(row_,element->index()) = element->value();
2900 }
2902 //*************************************************************************************************
2903 
2904 
2905 //*************************************************************************************************
2917 template< typename MT > // Type of the dense matrix
2918 template< typename VT > // Type of the right-hand side dense vector
2919 inline void DenseRow<MT,false>::addAssign( const DenseVector<VT,true>& rhs )
2920 {
2921  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2922 
2923  const size_t jend( (~rhs).size() & size_t(-2) );
2924  for( size_t j=0UL; j<jend; j+=2UL ) {
2925  matrix_(row_,j ) += (~rhs)[j ];
2926  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
2927  }
2928  if( jend < (~rhs).size() )
2929  matrix_(row_,jend) += (~rhs)[jend];
2930 }
2932 //*************************************************************************************************
2933 
2934 
2935 //*************************************************************************************************
2947 template< typename MT > // Type of the dense matrix
2948 template< typename VT > // Type of the right-hand side sparse vector
2949 inline void DenseRow<MT,false>::addAssign( const SparseVector<VT,true>& rhs )
2950 {
2951  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2952 
2953  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2954  matrix_(row_,element->index()) += element->value();
2955 }
2957 //*************************************************************************************************
2958 
2959 
2960 //*************************************************************************************************
2972 template< typename MT > // Type of the dense matrix
2973 template< typename VT > // Type of the right-hand side dense vector
2974 inline void DenseRow<MT,false>::subAssign( const DenseVector<VT,true>& rhs )
2975 {
2976  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2977 
2978  const size_t jend( (~rhs).size() & size_t(-2) );
2979  for( size_t j=0UL; j<jend; j+=2UL ) {
2980  matrix_(row_,j ) -= (~rhs)[j ];
2981  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
2982  }
2983  if( jend < (~rhs).size() )
2984  matrix_(row_,jend) -= (~rhs)[jend];
2985 }
2987 //*************************************************************************************************
2988 
2989 
2990 //*************************************************************************************************
3002 template< typename MT > // Type of the dense matrix
3003 template< typename VT > // Type of the right-hand side sparse vector
3004 inline void DenseRow<MT,false>::subAssign( const SparseVector<VT,true>& rhs )
3005 {
3006  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3007 
3008  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3009  matrix_(row_,element->index()) -= element->value();
3010 }
3012 //*************************************************************************************************
3013 
3014 
3015 //*************************************************************************************************
3027 template< typename MT > // Type of the dense matrix
3028 template< typename VT > // Type of the right-hand side dense vector
3029 inline void DenseRow<MT,false>::multAssign( const DenseVector<VT,true>& rhs )
3030 {
3031  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3032 
3033  const size_t jend( (~rhs).size() & size_t(-2) );
3034  for( size_t j=0UL; j<jend; j+=2UL ) {
3035  matrix_(row_,j ) *= (~rhs)[j ];
3036  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
3037  }
3038  if( jend < (~rhs).size() )
3039  matrix_(row_,jend) *= (~rhs)[jend];
3040 }
3042 //*************************************************************************************************
3043 
3044 
3045 //*************************************************************************************************
3057 template< typename MT > // Type of the dense matrix
3058 template< typename VT > // Type of the right-hand side sparse vector
3059 inline void DenseRow<MT,false>::multAssign( const SparseVector<VT,true>& rhs )
3060 {
3061  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3062 
3063  const ResultType tmp( serial( *this ) );
3064 
3065  reset();
3066 
3067  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3068  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
3069 }
3071 //*************************************************************************************************
3072 
3073 
3074 
3075 
3076 
3077 
3078 
3079 
3080 //=================================================================================================
3081 //
3082 // DENSEROW OPERATORS
3083 //
3084 //=================================================================================================
3085 
3086 //*************************************************************************************************
3089 template< typename MT, bool SO >
3090 inline void reset( DenseRow<MT,SO>& row );
3091 
3092 template< typename MT, bool SO >
3093 inline void clear( DenseRow<MT,SO>& row );
3094 
3095 template< typename MT, bool SO >
3096 inline bool isDefault( const DenseRow<MT,SO>& row );
3097 
3098 template< typename MT, bool SO >
3099 inline bool isSame( const DenseRow<MT,SO>& a, const DenseRow<MT,SO>& b );
3101 //*************************************************************************************************
3102 
3103 
3104 //*************************************************************************************************
3111 template< typename MT // Type of the dense matrix
3112  , bool SO > // Storage order
3113 inline void reset( DenseRow<MT,SO>& row )
3114 {
3115  row.reset();
3116 }
3117 //*************************************************************************************************
3118 
3119 
3120 //*************************************************************************************************
3129 template< typename MT // Type of the dense matrix
3130  , bool SO > // Storage order
3131 inline void clear( DenseRow<MT,SO>& row )
3132 {
3133  row.reset();
3134 }
3135 //*************************************************************************************************
3136 
3137 
3138 //*************************************************************************************************
3156 template< typename MT // Type of the dense matrix
3157  , bool SO > // Storage order
3158 inline bool isDefault( const DenseRow<MT,SO>& row )
3159 {
3160  for( size_t i=0UL; i<row.size(); ++i )
3161  if( !isDefault( row[i] ) ) return false;
3162  return true;
3163 }
3164 //*************************************************************************************************
3165 
3166 
3167 //*************************************************************************************************
3179 template< typename MT, bool SO >
3180 inline bool isSame( const DenseRow<MT,SO>& a, const DenseRow<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< DenseRow<MT,SO> >
3199 {
3200  typedef typename SubvectorTrait< typename DenseRow<MT,SO>::ResultType >::Type Type;
3201 };
3203 //*************************************************************************************************
3204 
3205 } // namespace blaze
3206 
3207 #endif
Constraint on the data type.
Constraint on the data type.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseRow.h:338
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
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
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 row trait.
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:152
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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
void smpMultAssign(DenseVector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
Default implementation of the SMP multiplication assignment of a vector to a dense vector...
Definition: DenseVector.h:179
Header file for the IsSame and IsStrictlySame type traits.
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
Iterator end()
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:721
IT::Type IntrinsicType
Intrinsic type of the row elements.
Definition: DenseRow.h:337
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
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
Header file for the DenseVector base class.
bool canAlias(const Other *alias) const
Returns whether the dense row can alias with the given address alias.
Definition: DenseRow.h:1103
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h: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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseRow.h:335
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: DenseRow.h:345
Constraint on the data type.
void smpAddAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:122
bool isAligned() const
Returns whether the dense row is properly aligned in memory.
Definition: DenseRow.h:1183
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.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseRow.h:354
Header file for nested template disabiguation.
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
IntrinsicType load(size_t index) const
Aligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1223
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
Header file for the Or class template.
DenseRow & operator=(const ElementType &rhs)
Homogenous assignment to all row elements.
Definition: DenseRow.h:776
void storeu(size_t index, const IntrinsicType &value)
Unligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1288
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
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
RowTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseRow.h:334
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for sparse vector types.This type trait tests whether or not the given template pa...
Definition: IsSparseVector.h:103
Constraint on the data type.
Constraint on the data type.
ConstIterator cend() const
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:753
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: DenseRow.h:608
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:79
ConstIterator cbegin() const
Returns an iterator to the first element of the row.
Definition: DenseRow.h:705
Constraints on the storage order of matrix types.
Constraint on the data type.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
MT::ElementType ElementType
Type of the row elements.
Definition: DenseRow.h:336
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:361
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
size_t nonZeros() const
Returns the number of non-zero elements in the row.
Definition: DenseRow.h:1042
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant row value.
Definition: DenseRow.h:351
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
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
size_t size() const
Returns the current size/dimension of the row.
Definition: DenseRow.h:1011
Operand matrix_
The dense matrix containing the row.
Definition: DenseRow.h:539
Header file for the IsSparseVector type trait.
#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.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
bool canSMPAssign() const
Returns whether the dense row can be used in SMP assignments.
Definition: DenseRow.h:1202
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: DenseRow.h:342
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.
const size_t row_
The index of the row in the matrix.
Definition: DenseRow.h:540
Iterator begin()
Returns an iterator to the first element of the row.
Definition: DenseRow.h:673
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense row.
Definition: DenseRow.h:1310
Header file for the division trait.
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1244
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Header file for the reset shim.
Reference to a specific row of a dense matrix.The DenseRow template represents a reference to a speci...
Definition: DenseRow.h:308
Header file for the cache size of the target architecture.
SelectType< useConst, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: DenseRow.h:357
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
void reset()
Reset to the default initial values.
Definition: DenseRow.h:1056
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
Header file for the isDefault shim.
#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
void store(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1266
Header file for the RemoveReference type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
Header file for all intrinsic functionality.
#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
const ElementType * ConstPointer
Pointer to a constant row value.
Definition: DenseRow.h:348
const DenseRow & CompositeType
Data type for composite expression templates.
Definition: DenseRow.h:339
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
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the row element type.
Definition: DenseRow.h:317
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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
DenseRow(MT &matrix, size_t index)
The constructor for DenseRow.
Definition: DenseRow.h:582
DenseRow< MT, SO > This
Type of this DenseRow instance.
Definition: DenseRow.h:333
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
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
size_t capacity() const
Returns the maximum capacity of the dense row.
Definition: DenseRow.h:1025
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
const size_t SMP_DVECASSIGN_THRESHOLD
SMP dense vector assignment threshold.This threshold specifies when an assignment of a plain dense ve...
Definition: Thresholds.h:207
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
bool isAliased(const Other *alias) const
Returns whether the dense row is aliased with the given address alias.
Definition: DenseRow.h:1144
Pointer data()
Low-level data access to the row elements.
Definition: DenseRow.h:641
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseRow.h:314