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>
65 #include <blaze/system/CacheSize.h>
66 #include <blaze/system/Streaming.h>
68 #include <blaze/util/Assert.h>
70 #include <blaze/util/DisableIf.h>
71 #include <blaze/util/EnableIf.h>
73 #include <blaze/util/mpl/Or.h>
74 #include <blaze/util/Template.h>
75 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS DEFINITION
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
308 template< typename MT // Type of the dense matrix
309  , bool SO = IsRowMajorMatrix<MT>::value > // Storage order
310 class DenseRow : public DenseVector< DenseRow<MT,SO>, true >
311  , private Row
312 {
313  private:
314  //**Type definitions****************************************************************************
316  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
317 
320  //**********************************************************************************************
321 
322  //**********************************************************************************************
324 
330  enum { useConst = IsConst<MT>::value };
331  //**********************************************************************************************
332 
333  public:
334  //**Type definitions****************************************************************************
336  typedef typename RowTrait<MT>::Type ResultType;
338  typedef typename MT::ElementType ElementType;
339  typedef typename IT::Type IntrinsicType;
340  typedef typename MT::ReturnType ReturnType;
341  typedef const DenseRow& CompositeType;
342 
345 
348 
350  typedef const ElementType* ConstPointer;
351 
354 
357 
360  //**********************************************************************************************
361 
362  //**Compilation flags***************************************************************************
364  enum { vectorizable = MT::vectorizable };
365 
367  enum { smpAssignable = MT::smpAssignable };
368  //**********************************************************************************************
369 
370  //**Constructors********************************************************************************
373  explicit inline DenseRow( MT& matrix, size_t index );
374  // No explicitly declared copy constructor.
376  //**********************************************************************************************
377 
378  //**Destructor**********************************************************************************
379  // No explicitly declared destructor.
380  //**********************************************************************************************
381 
382  //**Data access functions***********************************************************************
385  inline Reference operator[]( size_t index );
386  inline ConstReference operator[]( size_t index ) const;
387  inline Pointer data ();
388  inline ConstPointer data () const;
389  inline Iterator begin ();
390  inline ConstIterator begin () const;
391  inline ConstIterator cbegin() const;
392  inline Iterator end ();
393  inline ConstIterator end () const;
394  inline ConstIterator cend () const;
396  //**********************************************************************************************
397 
398  //**Assignment operators************************************************************************
401  inline DenseRow& operator= ( const ElementType& rhs );
402  inline DenseRow& operator= ( const DenseRow& 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  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
406  template< typename VT > inline DenseRow& operator*=( const Vector<VT,true>& rhs );
407 
408  template< typename Other >
409  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
410  operator*=( Other rhs );
411 
412  template< typename Other >
413  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
414  operator/=( Other rhs );
416  //**********************************************************************************************
417 
418  //**Utility functions***************************************************************************
421  inline size_t size() const;
422  inline size_t capacity() const;
423  inline size_t nonZeros() const;
424  inline void reset();
425  template< typename Other > inline DenseRow& scale( const Other& scalar );
427  //**********************************************************************************************
428 
429  private:
430  //**********************************************************************************************
432  template< typename VT >
434  struct VectorizedAssign {
435  enum { value = vectorizable && VT::vectorizable &&
436  IsSame<ElementType,typename VT::ElementType>::value };
437  };
439  //**********************************************************************************************
440 
441  //**********************************************************************************************
443  template< typename VT >
445  struct VectorizedAddAssign {
446  enum { value = vectorizable && VT::vectorizable &&
447  IsSame<ElementType,typename VT::ElementType>::value &&
448  IntrinsicTrait<ElementType>::addition };
449  };
451  //**********************************************************************************************
452 
453  //**********************************************************************************************
455  template< typename VT >
457  struct VectorizedSubAssign {
458  enum { value = vectorizable && VT::vectorizable &&
459  IsSame<ElementType,typename VT::ElementType>::value &&
460  IntrinsicTrait<ElementType>::subtraction };
461  };
463  //**********************************************************************************************
464 
465  //**********************************************************************************************
467  template< typename VT >
469  struct VectorizedMultAssign {
470  enum { value = vectorizable && VT::vectorizable &&
471  IsSame<ElementType,typename VT::ElementType>::value &&
472  IntrinsicTrait<ElementType>::multiplication };
473  };
475  //**********************************************************************************************
476 
477  public:
478  //**Expression template evaluation functions****************************************************
481  template< typename Other > inline bool canAlias ( const Other* alias ) const;
482  template< typename Other > inline bool isAliased( const Other* 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  //**Compile time checks*************************************************************************
551  //**********************************************************************************************
552 };
553 //*************************************************************************************************
554 
555 
556 
557 
558 //=================================================================================================
559 //
560 // CONSTRUCTOR
561 //
562 //=================================================================================================
563 
564 //*************************************************************************************************
571 template< typename MT // Type of the dense matrix
572  , bool SO > // Storage order
573 inline DenseRow<MT,SO>::DenseRow( MT& matrix, size_t index )
574  : matrix_( matrix ) // The dense matrix containing the row
575  , row_ ( index ) // The index of the row in the matrix
576 {
577  if( matrix_.rows() <= index )
578  throw std::invalid_argument( "Invalid row access index" );
579 }
580 //*************************************************************************************************
581 
582 
583 
584 
585 //=================================================================================================
586 //
587 // DATA ACCESS FUNCTIONS
588 //
589 //=================================================================================================
590 
591 //*************************************************************************************************
597 template< typename MT // Type of the dense matrix
598  , bool SO > // Storage order
600 {
601  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
602  return matrix_(row_,index);
603 }
604 //*************************************************************************************************
605 
606 
607 //*************************************************************************************************
613 template< typename MT // Type of the dense matrix
614  , bool SO > // Storage order
616 {
617  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
618  return matrix_(row_,index);
619 }
620 //*************************************************************************************************
621 
622 
623 //*************************************************************************************************
630 template< typename MT // Type of the dense matrix
631  , bool SO > // Storage order
633 {
634  return matrix_.data( row_ );
635 }
636 //*************************************************************************************************
637 
638 
639 //*************************************************************************************************
646 template< typename MT // Type of the dense matrix
647  , bool SO > // Storage order
649 {
650  return matrix_.data( row_ );
651 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
662 template< typename MT // Type of the dense matrix
663  , bool SO > // Storage order
665 {
666  return matrix_.begin( row_ );
667 }
668 //*************************************************************************************************
669 
670 
671 //*************************************************************************************************
678 template< typename MT // Type of the dense matrix
679  , bool SO > // Storage order
681 {
682  return matrix_.cbegin( row_ );
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
694 template< typename MT // Type of the dense matrix
695  , bool SO > // Storage order
697 {
698  return matrix_.cbegin( row_ );
699 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
710 template< typename MT // Type of the dense matrix
711  , bool SO > // Storage order
713 {
714  return matrix_.end( row_ );
715 }
716 //*************************************************************************************************
717 
718 
719 //*************************************************************************************************
726 template< typename MT // Type of the dense matrix
727  , bool SO > // Storage order
729 {
730  return matrix_.cend( row_ );
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
742 template< typename MT // Type of the dense matrix
743  , bool SO > // Storage order
745 {
746  return matrix_.cend( row_ );
747 }
748 //*************************************************************************************************
749 
750 
751 
752 
753 //=================================================================================================
754 //
755 // ASSIGNMENT OPERATORS
756 //
757 //=================================================================================================
758 
759 //*************************************************************************************************
765 template< typename MT // Type of the dense matrix
766  , bool SO > // Storage order
768 {
769  const size_t columns( size() );
770 
771  for( size_t j=0UL; j<columns; ++j )
772  matrix_(row_,j) = rhs;
773 
774  return *this;
775 }
776 //*************************************************************************************************
777 
778 
779 //*************************************************************************************************
789 template< typename MT // Type of the dense matrix
790  , bool SO > // Storage order
792 {
793  if( &rhs == this ) return *this;
794 
795  if( size() != rhs.size() )
796  throw std::invalid_argument( "Row sizes do not match" );
797 
798  const size_t columns( size() );
799 
800  for( size_t j=0UL; j<columns; ++j )
801  matrix_(row_,j) = rhs[j];
802 
803  return *this;
804 }
805 //*************************************************************************************************
806 
807 
808 //*************************************************************************************************
818 template< typename MT // Type of the dense matrix
819  , bool SO > // Storage order
820 template< typename VT > // Type of the right-hand side vector
822 {
825 
826  if( size() != (~rhs).size() )
827  throw std::invalid_argument( "Vector sizes do not match" );
828 
829  if( (~rhs).canAlias( &matrix_ ) ) {
830  const typename VT::ResultType tmp( ~rhs );
831  smpAssign( *this, tmp );
832  }
833  else {
835  reset();
836  smpAssign( *this, ~rhs );
837  }
838 
839  return *this;
840 }
841 //*************************************************************************************************
842 
843 
844 //*************************************************************************************************
854 template< typename MT // Type of the dense matrix
855  , bool SO > // Storage order
856 template< typename VT > // Type of the right-hand side vector
858 {
861 
862  if( size() != (~rhs).size() )
863  throw std::invalid_argument( "Vector sizes do not match" );
864 
865  if( (~rhs).canAlias( &matrix_ ) ) {
866  const typename VT::ResultType tmp( ~rhs );
867  smpAddAssign( *this, tmp );
868  }
869  else {
870  smpAddAssign( *this, ~rhs );
871  }
872 
873  return *this;
874 }
875 //*************************************************************************************************
876 
877 
878 //*************************************************************************************************
888 template< typename MT // Type of the dense matrix
889  , bool SO > // Storage order
890 template< typename VT > // Type of the right-hand side vector
892 {
895 
896  if( size() != (~rhs).size() )
897  throw std::invalid_argument( "Vector sizes do not match" );
898 
899  if( (~rhs).canAlias( &matrix_ ) ) {
900  const typename VT::ResultType tmp( ~rhs );
901  smpSubAssign( *this, tmp );
902  }
903  else {
904  smpSubAssign( *this, ~rhs );
905  }
906 
907  return *this;
908 }
909 //*************************************************************************************************
910 
911 
912 //*************************************************************************************************
923 template< typename MT // Type of the dense matrix
924  , bool SO > // Storage order
925 template< typename VT > // Type of the right-hand side vector
927 {
930 
931  if( size() != (~rhs).size() )
932  throw std::invalid_argument( "Vector sizes do not match" );
933 
934  if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
935  const typename VT::ResultType tmp( ~rhs );
936  smpMultAssign( *this, tmp );
937  }
938  else {
939  smpMultAssign( *this, ~rhs );
940  }
941 
942  return *this;
943 }
944 //*************************************************************************************************
945 
946 
947 //*************************************************************************************************
954 template< typename MT // Type of the dense matrix
955  , bool SO > // Storage order
956 template< typename Other > // Data type of the right-hand side scalar
957 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO> >::Type&
959 {
960  return operator=( (*this) * rhs );
961 }
962 //*************************************************************************************************
963 
964 
965 //*************************************************************************************************
974 template< typename MT // Type of the dense matrix
975  , bool SO > // Storage order
976 template< typename Other > // Data type of the right-hand side scalar
977 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO> >::Type&
979 {
980  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
981 
982  return operator=( (*this) / rhs );
983 }
984 //*************************************************************************************************
985 
986 
987 
988 
989 //=================================================================================================
990 //
991 // UTILITY FUNCTIONS
992 //
993 //=================================================================================================
994 
995 //*************************************************************************************************
1000 template< typename MT // Type of the dense matrix
1001  , bool SO > // Storage order
1002 inline size_t DenseRow<MT,SO>::size() const
1003 {
1004  return matrix_.columns();
1005 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1014 template< typename MT // Type of the dense matrix
1015  , bool SO > // Storage order
1016 inline size_t DenseRow<MT,SO>::capacity() const
1017 {
1018  return matrix_.capacity( row_ );
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1031 template< typename MT // Type of the dense matrix
1032  , bool SO > // Storage order
1033 inline size_t DenseRow<MT,SO>::nonZeros() const
1034 {
1035  return matrix_.nonZeros( row_ );
1036 }
1037 //*************************************************************************************************
1038 
1039 
1040 //*************************************************************************************************
1045 template< typename MT // Type of the dense matrix
1046  , bool SO > // Storage order
1048 {
1049  matrix_.reset( row_ );
1050 }
1051 //*************************************************************************************************
1052 
1053 
1054 //*************************************************************************************************
1060 template< typename MT // Type of the dense matrix
1061  , bool SO > // Storage order
1062 template< typename Other > // Data type of the scalar value
1063 inline DenseRow<MT,SO>& DenseRow<MT,SO>::scale( const Other& scalar )
1064 {
1065  for( size_t j=0UL; j<size(); ++j ) {
1066  matrix_(row_,j) *= scalar;
1067  }
1068  return *this;
1069 }
1070 //*************************************************************************************************
1071 
1072 
1073 
1074 
1075 //=================================================================================================
1076 //
1077 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1078 //
1079 //=================================================================================================
1080 
1081 //*************************************************************************************************
1091 template< typename MT // Type of the dense matrix
1092  , bool SO > // Storage order
1093 template< typename Other > // Data type of the foreign expression
1094 inline bool DenseRow<MT,SO>::canAlias( const Other* alias ) const
1095 {
1096  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1097 }
1098 //*************************************************************************************************
1099 
1100 
1101 //*************************************************************************************************
1111 template< typename MT // Type of the dense matrix
1112  , bool SO > // Storage order
1113 template< typename Other > // Data type of the foreign expression
1114 inline bool DenseRow<MT,SO>::isAliased( const Other* alias ) const
1115 {
1116  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
1117 }
1118 //*************************************************************************************************
1119 
1120 
1121 //*************************************************************************************************
1130 template< typename MT // Type of the dense matrix
1131  , bool SO > // Storage order
1132 inline bool DenseRow<MT,SO>::isAligned() const
1133 {
1134  return matrix_.isAligned();
1135 }
1136 //*************************************************************************************************
1137 
1138 
1139 //*************************************************************************************************
1149 template< typename MT // Type of the dense matrix
1150  , bool SO > // Storage order
1152 {
1153  return ( size() > OPENMP_DVECASSIGN_THRESHOLD );
1154 }
1155 //*************************************************************************************************
1156 
1157 
1158 //*************************************************************************************************
1170 template< typename MT // Type of the dense matrix
1171  , bool SO > // Storage order
1172 inline typename DenseRow<MT,SO>::IntrinsicType DenseRow<MT,SO>::load( size_t index ) const
1173 {
1174  return matrix_.load( row_, index );
1175 }
1176 //*************************************************************************************************
1177 
1178 
1179 //*************************************************************************************************
1191 template< typename MT // Type of the dense matrix
1192  , bool SO > // Storage order
1193 inline typename DenseRow<MT,SO>::IntrinsicType DenseRow<MT,SO>::loadu( size_t index ) const
1194 {
1195  return matrix_.loadu( row_, index );
1196 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1213 template< typename MT // Type of the dense matrix
1214  , bool SO > // Storage order
1215 inline void DenseRow<MT,SO>::store( size_t index, const IntrinsicType& value )
1216 {
1217  matrix_.store( row_, index, value );
1218 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1235 template< typename MT // Type of the dense matrix
1236  , bool SO > // Storage order
1237 inline void DenseRow<MT,SO>::storeu( size_t index, const IntrinsicType& value )
1238 {
1239  matrix_.storeu( row_, index, value );
1240 }
1241 //*************************************************************************************************
1242 
1243 
1244 //*************************************************************************************************
1257 template< typename MT // Type of the dense matrix
1258  , bool SO > // Storage order
1259 inline void DenseRow<MT,SO>::stream( size_t index, const IntrinsicType& value )
1260 {
1261  matrix_.stream( row_, index, value );
1262 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1277 template< typename MT // Type of the dense matrix
1278  , bool SO > // Storage order
1279 template< typename VT > // Type of the right-hand side dense vector
1280 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1282 {
1283  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1284 
1285  const size_t jend( (~rhs).size() & size_t(-2) );
1286  for( size_t j=0UL; j<jend; j+=2UL ) {
1287  matrix_(row_,j ) = (~rhs)[j ];
1288  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
1289  }
1290  if( jend < (~rhs).size() )
1291  matrix_(row_,jend) = (~rhs)[jend];
1292 }
1293 //*************************************************************************************************
1294 
1295 
1296 //*************************************************************************************************
1307 template< typename MT // Type of the dense matrix
1308  , bool SO > // Storage order
1309 template< typename VT > // Type of the right-hand side dense vector
1310 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1312 {
1313  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1314 
1316 
1317  const size_t columns( size() );
1318 
1319  if( useStreaming && columns > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
1320  {
1321  for( size_t j=0UL; j<columns; j+=IT::size ) {
1322  matrix_.stream( row_, j, (~rhs).load(j) );
1323  }
1324  }
1325  else
1326  {
1327  const size_t jend( columns & size_t(-IT::size*4) );
1328  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1329 
1330  typename VT::ConstIterator it( (~rhs).begin() );
1331  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1332  matrix_.store( row_, j , it.load() ); it += IT::size;
1333  matrix_.store( row_, j+IT::size , it.load() ); it += IT::size;
1334  matrix_.store( row_, j+IT::size*2UL, it.load() ); it += IT::size;
1335  matrix_.store( row_, j+IT::size*3UL, it.load() ); it += IT::size;
1336  }
1337  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1338  matrix_.store( row_, j, it.load() );
1339  }
1340  }
1341 }
1342 //*************************************************************************************************
1343 
1344 
1345 //*************************************************************************************************
1356 template< typename MT // Type of the dense matrix
1357  , bool SO > // Storage order
1358 template< typename VT > // Type of the right-hand side sparse vector
1360 {
1361  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1362 
1363  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1364  matrix_(row_,element->index()) = element->value();
1365 }
1366 //*************************************************************************************************
1367 
1368 
1369 //*************************************************************************************************
1380 template< typename MT // Type of the dense matrix
1381  , bool SO > // Storage order
1382 template< typename VT > // Type of the right-hand side dense vector
1383 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1385 {
1386  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1387 
1388  const size_t jend( (~rhs).size() & size_t(-2) );
1389  for( size_t j=0UL; j<jend; j+=2UL ) {
1390  matrix_(row_,j ) += (~rhs)[j ];
1391  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
1392  }
1393  if( jend < (~rhs).size() )
1394  matrix_(row_,jend) += (~rhs)[jend];
1395 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1410 template< typename MT // Type of the dense matrix
1411  , bool SO > // Storage order
1412 template< typename VT > // Type of the right-hand side dense vector
1413 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1415 {
1416  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1417 
1419 
1420  const size_t columns( size() );
1421 
1422  const size_t jend( columns & size_t(-IT::size*4) );
1423  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1424 
1425  typename VT::ConstIterator it( (~rhs).begin() );
1426  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1427  matrix_.store( row_, j , matrix_.load(row_,j ) + it.load() ); it += IT::size;
1428  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) + it.load() ); it += IT::size;
1429  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) + it.load() ); it += IT::size;
1430  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) + it.load() ); it += IT::size;
1431  }
1432  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1433  matrix_.store( row_, j, matrix_.load(row_,j) + it.load() );
1434  }
1435 }
1436 //*************************************************************************************************
1437 
1438 
1439 //*************************************************************************************************
1450 template< typename MT // Type of the dense matrix
1451  , bool SO > // Storage order
1452 template< typename VT > // Type of the right-hand side sparse vector
1454 {
1455  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1456 
1457  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1458  matrix_(row_,element->index()) += element->value();
1459 }
1460 //*************************************************************************************************
1461 
1462 
1463 //*************************************************************************************************
1474 template< typename MT // Type of the dense matrix
1475  , bool SO > // Storage order
1476 template< typename VT > // Type of the right-hand side dense vector
1477 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1479 {
1480  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1481 
1482  const size_t jend( (~rhs).size() & size_t(-2) );
1483  for( size_t j=0UL; j<jend; j+=2UL ) {
1484  matrix_(row_,j ) -= (~rhs)[j ];
1485  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
1486  }
1487  if( jend < (~rhs).size() )
1488  matrix_(row_,jend) -= (~rhs)[jend];
1489 }
1490 //*************************************************************************************************
1491 
1492 
1493 //*************************************************************************************************
1504 template< typename MT // Type of the dense matrix
1505  , bool SO > // Storage order
1506 template< typename VT > // Type of the right-hand side dense vector
1507 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1509 {
1510  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1511 
1513 
1514  const size_t columns( size() );
1515 
1516  const size_t jend( columns & size_t(-IT::size*4) );
1517  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1518 
1519  typename VT::ConstIterator it( (~rhs).begin() );
1520  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1521  matrix_.store( row_, j , matrix_.load(row_,j ) - it.load() ); it += IT::size;
1522  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) - it.load() ); it += IT::size;
1523  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) - it.load() ); it += IT::size;
1524  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) - it.load() ); it += IT::size;
1525  }
1526  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1527  matrix_.store( row_, j, matrix_.load(row_,j) - it.load() );
1528  }
1529 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1544 template< typename MT // Type of the dense matrix
1545  , bool SO > // Storage order
1546 template< typename VT > // Type of the right-hand side sparse vector
1548 {
1549  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1550 
1551  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1552  matrix_(row_,element->index()) -= element->value();
1553 }
1554 //*************************************************************************************************
1555 
1556 
1557 //*************************************************************************************************
1568 template< typename MT // Type of the dense matrix
1569  , bool SO > // Storage order
1570 template< typename VT > // Type of the right-hand side dense vector
1571 inline typename DisableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1573 {
1574  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1575 
1576  const size_t jend( (~rhs).size() & size_t(-2) );
1577  for( size_t j=0UL; j<jend; j+=2UL ) {
1578  matrix_(row_,j ) *= (~rhs)[j ];
1579  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
1580  }
1581  if( jend < (~rhs).size() )
1582  matrix_(row_,jend) *= (~rhs)[jend];
1583 }
1584 //*************************************************************************************************
1585 
1586 
1587 //*************************************************************************************************
1598 template< typename MT // Type of the dense matrix
1599  , bool SO > // Storage order
1600 template< typename VT > // Type of the right-hand side dense vector
1601 inline typename EnableIf< typename DenseRow<MT,SO>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
1603 {
1604  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1605 
1607 
1608  const size_t columns( size() );
1609 
1610  const size_t jend( columns & size_t(-IT::size*4) );
1611  BLAZE_INTERNAL_ASSERT( ( columns - ( columns % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1612 
1613  typename VT::ConstIterator it( (~rhs).begin() );
1614  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1615  matrix_.store( row_, j , matrix_.load(row_,j ) * it.load() ); it += IT::size;
1616  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) * it.load() ); it += IT::size;
1617  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) * it.load() ); it += IT::size;
1618  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) * it.load() ); it += IT::size;
1619  }
1620  for( size_t j=jend; j<columns; j+=IT::size, it+=IT::size ) {
1621  matrix_.store( row_, j, matrix_.load(row_,j) * it.load() );
1622  }
1623 }
1624 //*************************************************************************************************
1625 
1626 
1627 //*************************************************************************************************
1638 template< typename MT // Type of the dense matrix
1639  , bool SO > // Storage order
1640 template< typename VT > // Type of the right-hand side sparse vector
1642 {
1643  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1644 
1645  const ResultType tmp( *this );
1646 
1647  reset();
1648 
1649  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1650  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
1651 }
1652 //*************************************************************************************************
1653 
1654 
1655 
1656 
1657 
1658 
1659 
1660 
1661 //=================================================================================================
1662 //
1663 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
1664 //
1665 //=================================================================================================
1666 
1667 //*************************************************************************************************
1675 template< typename MT > // Type of the dense matrix
1676 class DenseRow<MT,false> : public DenseVector< DenseRow<MT,false>, true >
1677  , private Row
1678 {
1679  private:
1680  //**Type definitions****************************************************************************
1682  typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type Operand;
1683  //**********************************************************************************************
1684 
1685  //**********************************************************************************************
1687 
1693  enum { useConst = IsConst<MT>::value };
1694  //**********************************************************************************************
1695 
1696  public:
1697  //**Type definitions****************************************************************************
1698  typedef DenseRow<MT,false> This;
1699  typedef typename RowTrait<MT>::Type ResultType;
1700  typedef typename ResultType::TransposeType TransposeType;
1701  typedef typename MT::ElementType ElementType;
1702  typedef typename MT::ReturnType ReturnType;
1703  typedef const ResultType CompositeType;
1704 
1706  typedef typename MT::ConstReference ConstReference;
1707 
1709  typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference;
1710  //**********************************************************************************************
1711 
1712  //**RowIterator class definition****************************************************************
1715  template< typename MatrixType > // Type of the dense matrix
1716  class RowIterator
1717  {
1718  private:
1719  //*******************************************************************************************
1721 
1726  enum { returnConst = IsConst<MatrixType>::value };
1727  //*******************************************************************************************
1728 
1729  public:
1730  //**Type definitions*************************************************************************
1732  typedef typename SelectType< returnConst, typename MT::ConstReference, typename MT::Reference >::Type Reference;
1733 
1734  typedef std::random_access_iterator_tag IteratorCategory;
1735  typedef RemoveReference<Reference> ValueType;
1736  typedef ValueType* PointerType;
1737  typedef Reference ReferenceType;
1738  typedef ptrdiff_t DifferenceType;
1739 
1740  // STL iterator requirements
1741  typedef IteratorCategory iterator_category;
1742  typedef ValueType value_type;
1743  typedef PointerType pointer;
1744  typedef ReferenceType reference;
1745  typedef DifferenceType difference_type;
1746  //*******************************************************************************************
1747 
1748  //**Constructor******************************************************************************
1755  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
1756  : matrix_( &matrix ) // The dense matrix containing the row.
1757  , row_ ( row ) // The current row index.
1758  , column_( column ) // The current column index.
1759  {}
1760  //*******************************************************************************************
1761 
1762  //**Constructor******************************************************************************
1767  template< typename MatrixType2 >
1768  inline RowIterator( const RowIterator<MatrixType2>& it )
1769  : matrix_( it.matrix_ ) // The dense matrix containing the row.
1770  , row_ ( it.row_ ) // The current row index.
1771  , column_( it.column_ ) // The current column index.
1772  {}
1773  //*******************************************************************************************
1774 
1775  //**Addition assignment operator*************************************************************
1781  inline RowIterator& operator+=( size_t inc ) {
1782  column_ += inc;
1783  return *this;
1784  }
1785  //*******************************************************************************************
1786 
1787  //**Subtraction assignment operator**********************************************************
1793  inline RowIterator& operator-=( size_t dec ) {
1794  column_ -= dec;
1795  return *this;
1796  }
1797  //*******************************************************************************************
1798 
1799  //**Prefix increment operator****************************************************************
1804  inline RowIterator& operator++() {
1805  ++column_;
1806  return *this;
1807  }
1808  //*******************************************************************************************
1809 
1810  //**Postfix increment operator***************************************************************
1815  inline const RowIterator operator++( int ) {
1816  const RowIterator tmp( *this );
1817  ++(*this);
1818  return tmp;
1819  }
1820  //*******************************************************************************************
1821 
1822  //**Prefix decrement operator****************************************************************
1827  inline RowIterator& operator--() {
1828  --column_;
1829  return *this;
1830  }
1831  //*******************************************************************************************
1832 
1833  //**Postfix decrement operator***************************************************************
1838  inline const RowIterator operator--( int ) {
1839  const RowIterator tmp( *this );
1840  --(*this);
1841  return tmp;
1842  }
1843  //*******************************************************************************************
1844 
1845  //**Subscript operator***********************************************************************
1851  inline ReferenceType operator[]( size_t index ) const {
1852  return (*matrix_)(row_,column_+index);
1853  }
1854  //*******************************************************************************************
1855 
1856  //**Element access operator******************************************************************
1861  inline ReferenceType operator*() const {
1862  return (*matrix_)(row_,column_);
1863  }
1864  //*******************************************************************************************
1865 
1866  //**Element access operator******************************************************************
1871  inline PointerType operator->() const {
1872  return &(*matrix_)(row_,column_);
1873  }
1874  //*******************************************************************************************
1875 
1876  //**Equality operator************************************************************************
1882  template< typename MatrixType2 >
1883  inline bool operator==( const RowIterator<MatrixType2>& rhs ) const {
1884  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
1885  }
1886  //*******************************************************************************************
1887 
1888  //**Inequality operator**********************************************************************
1894  template< typename MatrixType2 >
1895  inline bool operator!=( const RowIterator<MatrixType2>& rhs ) const {
1896  return !( *this == rhs );
1897  }
1898  //*******************************************************************************************
1899 
1900  //**Less-than operator***********************************************************************
1906  template< typename MatrixType2 >
1907  inline bool operator<( const RowIterator<MatrixType2>& rhs ) const {
1908  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ < rhs.column_ );
1909  }
1910  //*******************************************************************************************
1911 
1912  //**Greater-than operator********************************************************************
1918  template< typename MatrixType2 >
1919  inline bool operator>( const RowIterator<MatrixType2>& rhs ) const {
1920  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ > rhs.column_ );
1921  }
1922  //*******************************************************************************************
1923 
1924  //**Less-or-equal-than operator**************************************************************
1930  template< typename MatrixType2 >
1931  inline bool operator<=( const RowIterator<MatrixType2>& rhs ) const {
1932  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ <= rhs.column_ );
1933  }
1934  //*******************************************************************************************
1935 
1936  //**Greater-or-equal-than operator***********************************************************
1942  template< typename MatrixType2 >
1943  inline bool operator>=( const RowIterator<MatrixType2>& rhs ) const {
1944  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ >= rhs.column_ );
1945  }
1946  //*******************************************************************************************
1947 
1948  //**Subtraction operator*********************************************************************
1954  inline DifferenceType operator-( const RowIterator& rhs ) const {
1955  return column_ - rhs.column_;
1956  }
1957  //*******************************************************************************************
1958 
1959  //**Addition operator************************************************************************
1966  friend inline const RowIterator operator+( const RowIterator& it, size_t inc ) {
1967  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
1968  }
1969  //*******************************************************************************************
1970 
1971  //**Addition operator************************************************************************
1978  friend inline const RowIterator operator+( size_t inc, const RowIterator& it ) {
1979  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
1980  }
1981  //*******************************************************************************************
1982 
1983  //**Subtraction operator*********************************************************************
1990  friend inline const RowIterator operator-( const RowIterator& it, size_t dec ) {
1991  return RowIterator( *it.matrix_, it.row_, it.column_-dec );
1992  }
1993  //*******************************************************************************************
1994 
1995  private:
1996  //**Member variables*************************************************************************
1997  MatrixType* matrix_;
1998  size_t row_;
1999  size_t column_;
2000  //*******************************************************************************************
2001 
2002  //**Friend declarations**********************************************************************
2003  template< typename MatrixType2 > friend class RowIterator;
2004  //*******************************************************************************************
2005  };
2006  //**********************************************************************************************
2007 
2008  //**Type definitions****************************************************************************
2010  typedef RowIterator<const MT> ConstIterator;
2011 
2013  typedef typename SelectType< useConst, ConstIterator, RowIterator<MT> >::Type Iterator;
2014  //**********************************************************************************************
2015 
2016  //**Compilation flags***************************************************************************
2018  enum { vectorizable = 0 };
2019 
2021  enum { smpAssignable = MT::smpAssignable };
2022  //**********************************************************************************************
2023 
2024  //**Constructors********************************************************************************
2027  explicit inline DenseRow( MT& matrix, size_t index );
2028  // No explicitly declared copy constructor.
2030  //**********************************************************************************************
2031 
2032  //**Destructor**********************************************************************************
2033  // No explicitly declared destructor.
2034  //**********************************************************************************************
2035 
2036  //**Data access functions***********************************************************************
2039  inline Reference operator[]( size_t index );
2040  inline ConstReference operator[]( size_t index ) const;
2041  inline Iterator begin ();
2042  inline ConstIterator begin () const;
2043  inline ConstIterator cbegin() const;
2044  inline Iterator end ();
2045  inline ConstIterator end () const;
2046  inline ConstIterator cend () const;
2048  //**********************************************************************************************
2049 
2050  //**Assignment operators************************************************************************
2053  inline DenseRow& operator= ( const ElementType& rhs );
2054  inline DenseRow& operator= ( const DenseRow& rhs );
2055  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
2056  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
2057  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
2058  template< typename VT > inline DenseRow& operator*=( const Vector<VT,true>& rhs );
2059 
2060  template< typename Other >
2061  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2062  operator*=( Other rhs );
2063 
2064  template< typename Other >
2065  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2066  operator/=( Other rhs );
2068  //**********************************************************************************************
2069 
2070  //**Utility functions***************************************************************************
2073  inline size_t size() const;
2074  inline size_t capacity() const;
2075  inline size_t nonZeros() const;
2076  inline void reset();
2077  template< typename Other > inline DenseRow& scale( const Other& scalar );
2079  //**********************************************************************************************
2080 
2081  public:
2082  //**Expression template evaluation functions****************************************************
2085  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2086  template< typename Other > inline bool isAliased( const Other* alias ) const;
2087 
2088  inline bool isAligned () const;
2089  inline bool canSMPAssign() const;
2090 
2091  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2092  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2093  template< typename VT > inline void addAssign ( const DenseVector <VT,true>& rhs );
2094  template< typename VT > inline void addAssign ( const SparseVector<VT,true>& rhs );
2095  template< typename VT > inline void subAssign ( const DenseVector <VT,true>& rhs );
2096  template< typename VT > inline void subAssign ( const SparseVector<VT,true>& rhs );
2097  template< typename VT > inline void multAssign( const DenseVector <VT,true>& rhs );
2098  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
2100  //**********************************************************************************************
2101 
2102  private:
2103  //**Member variables****************************************************************************
2106  Operand matrix_;
2107  const size_t row_;
2108 
2109  //**********************************************************************************************
2110 
2111  //**Compile time checks*************************************************************************
2116  //**********************************************************************************************
2117 };
2119 //*************************************************************************************************
2120 
2121 
2122 
2123 
2124 //=================================================================================================
2125 //
2126 // CONSTRUCTOR
2127 //
2128 //=================================================================================================
2129 
2130 //*************************************************************************************************
2138 template< typename MT > // Type of the dense matrix
2139 inline DenseRow<MT,false>::DenseRow( MT& matrix, size_t index )
2140  : matrix_( matrix ) // The dense matrix containing the row
2141  , row_ ( index ) // The index of the row in the matrix
2142 {
2143  if( matrix_.rows() <= index )
2144  throw std::invalid_argument( "Invalid row access index" );
2145 }
2147 //*************************************************************************************************
2148 
2149 
2150 
2151 
2152 //=================================================================================================
2153 //
2154 // DATA ACCESS FUNCTIONS
2155 //
2156 //=================================================================================================
2157 
2158 //*************************************************************************************************
2165 template< typename MT > // Type of the dense matrix
2166 inline typename DenseRow<MT,false>::Reference DenseRow<MT,false>::operator[]( size_t index )
2167 {
2168  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2169  return matrix_(row_,index);
2170 }
2172 //*************************************************************************************************
2173 
2174 
2175 //*************************************************************************************************
2182 template< typename MT > // Type of the dense matrix
2183 inline typename DenseRow<MT,false>::ConstReference DenseRow<MT,false>::operator[]( size_t index ) const
2184 {
2185  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2186  return matrix_(row_,index);
2187 }
2189 //*************************************************************************************************
2190 
2191 
2192 //*************************************************************************************************
2200 template< typename MT > // Type of the dense matrix
2202 {
2203  return Iterator( matrix_, row_, 0UL );
2204 }
2206 //*************************************************************************************************
2207 
2208 
2209 //*************************************************************************************************
2217 template< typename MT > // Type of the dense matrix
2219 {
2220  return ConstIterator( matrix_, row_, 0UL );
2221 }
2223 //*************************************************************************************************
2224 
2225 
2226 //*************************************************************************************************
2234 template< typename MT > // Type of the dense matrix
2236 {
2237  return ConstIterator( matrix_, row_, 0UL );
2238 }
2240 //*************************************************************************************************
2241 
2242 
2243 //*************************************************************************************************
2251 template< typename MT > // Type of the dense matrix
2253 {
2254  return Iterator( matrix_, row_, size() );
2255 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2268 template< typename MT > // Type of the dense matrix
2270 {
2271  return ConstIterator( matrix_, row_, size() );
2272 }
2274 //*************************************************************************************************
2275 
2276 
2277 //*************************************************************************************************
2285 template< typename MT > // Type of the dense matrix
2287 {
2288  return ConstIterator( matrix_, row_, size() );
2289 }
2291 //*************************************************************************************************
2292 
2293 
2294 
2295 
2296 //=================================================================================================
2297 //
2298 // ASSIGNMENT OPERATORS
2299 //
2300 //=================================================================================================
2301 
2302 //*************************************************************************************************
2309 template< typename MT > // Type of the dense matrix
2310 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const ElementType& rhs )
2311 {
2312  const size_t columns( size() );
2313 
2314  for( size_t j=0UL; j<columns; ++j )
2315  matrix_(row_,j) = rhs;
2316 
2317  return *this;
2318 }
2320 //*************************************************************************************************
2321 
2322 
2323 //*************************************************************************************************
2334 template< typename MT > // Type of the dense matrix
2335 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const DenseRow& rhs )
2336 {
2337  if( &rhs == this ) return *this;
2338 
2339  if( size() != rhs.size() )
2340  throw std::invalid_argument( "Row sizes do not match" );
2341 
2342  const size_t columns( size() );
2343 
2344  for( size_t j=0UL; j<columns; ++j )
2345  matrix_(row_,j) = rhs[j];
2346 
2347  return *this;
2348 }
2350 //*************************************************************************************************
2351 
2352 
2353 //*************************************************************************************************
2364 template< typename MT > // Type of the dense matrix
2365 template< typename VT > // Type of the right-hand side vector
2366 inline DenseRow<MT,false>& DenseRow<MT,false>::operator=( const Vector<VT,true>& rhs )
2367 {
2371 
2372  if( size() != (~rhs).size() )
2373  throw std::invalid_argument( "Vector sizes do not match" );
2374 
2375  if( (~rhs).canAlias( &matrix_ ) ) {
2376  const ResultType tmp( ~rhs );
2377  smpAssign( *this, tmp );
2378  }
2379  else {
2380  if( IsSparseVector<VT>::value )
2381  reset();
2382  smpAssign( *this, ~rhs );
2383  }
2384 
2385  return *this;
2386 }
2388 //*************************************************************************************************
2389 
2390 
2391 //*************************************************************************************************
2402 template< typename MT > // Type of the dense matrix
2403 template< typename VT > // Type of the right-hand side vector
2404 inline DenseRow<MT,false>& DenseRow<MT,false>::operator+=( const Vector<VT,true>& rhs )
2405 {
2408 
2409  if( size() != (~rhs).size() )
2410  throw std::invalid_argument( "Vector sizes do not match" );
2411 
2412  if( (~rhs).canAlias( &matrix_ ) ) {
2413  const typename VT::ResultType tmp( ~rhs );
2414  smpAddAssign( *this, tmp );
2415  }
2416  else {
2417  smpAddAssign( *this, ~rhs );
2418  }
2419 
2420  return *this;
2421 }
2423 //*************************************************************************************************
2424 
2425 
2426 //*************************************************************************************************
2437 template< typename MT > // Type of the dense matrix
2438 template< typename VT > // Type of the right-hand side vector
2439 inline DenseRow<MT,false>& DenseRow<MT,false>::operator-=( const Vector<VT,true>& rhs )
2440 {
2443 
2444  if( size() != (~rhs).size() )
2445  throw std::invalid_argument( "Vector sizes do not match" );
2446 
2447  if( (~rhs).canAlias( &matrix_ ) ) {
2448  const typename VT::ResultType tmp( ~rhs );
2449  smpSubAssign( *this, tmp );
2450  }
2451  else {
2452  smpSubAssign( *this, ~rhs );
2453  }
2454 
2455  return *this;
2456 }
2458 //*************************************************************************************************
2459 
2460 
2461 //*************************************************************************************************
2473 template< typename MT > // Type of the dense matrix
2474 template< typename VT > // Type of the right-hand side vector
2475 inline DenseRow<MT,false>& DenseRow<MT,false>::operator*=( const Vector<VT,true>& rhs )
2476 {
2479 
2480  if( size() != (~rhs).size() )
2481  throw std::invalid_argument( "Vector sizes do not match" );
2482 
2483  if( (~rhs).canAlias( &matrix_ ) || IsSparseVector<VT>::value ) {
2484  const typename VT::ResultType tmp( ~rhs );
2485  smpMultAssign( *this, tmp );
2486  }
2487  else {
2488  smpMultAssign( *this, ~rhs );
2489  }
2490 
2491  return *this;
2492 }
2494 //*************************************************************************************************
2495 
2496 
2497 //*************************************************************************************************
2505 template< typename MT > // Type of the dense matrix
2506 template< typename Other > // Data type of the right-hand side scalar
2507 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2508  DenseRow<MT,false>::operator*=( Other rhs )
2509 {
2510  for( size_t j=0UL; j<size(); ++j )
2511  matrix_(row_,j) *= rhs;
2512  return *this;
2513 }
2515 //*************************************************************************************************
2516 
2517 
2518 //*************************************************************************************************
2528 template< typename MT > // Type of the dense matrix
2529 template< typename Other > // Data type of the right-hand side scalar
2530 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false> >::Type&
2531  DenseRow<MT,false>::operator/=( Other rhs )
2532 {
2533  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2534 
2535  typedef typename DivTrait<ElementType,Other>::Type DT;
2536  typedef typename If< IsNumeric<DT>, DT, Other >::Type Tmp;
2537 
2538  // Depending on the two involved data types, an integer division is applied or a
2539  // floating point division is selected.
2540  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
2541  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
2542  for( size_t j=0UL; j<size(); ++j )
2543  matrix_(row_,j) *= tmp;
2544  }
2545  else {
2546  for( size_t j=0UL; j<size(); ++j )
2547  matrix_(row_,j) /= rhs;
2548  }
2549 
2550  return *this;
2551 }
2553 //*************************************************************************************************
2554 
2555 
2556 
2557 
2558 //=================================================================================================
2559 //
2560 // UTILITY FUNCTIONS
2561 //
2562 //=================================================================================================
2563 
2564 //*************************************************************************************************
2570 template< typename MT > // Type of the dense matrix
2571 inline size_t DenseRow<MT,false>::size() const
2572 {
2573  return matrix_.columns();
2574 }
2576 //*************************************************************************************************
2577 
2578 
2579 //*************************************************************************************************
2585 template< typename MT > // Type of the dense matrix
2586 inline size_t DenseRow<MT,false>::capacity() const
2587 {
2588  return matrix_.columns();
2589 }
2591 //*************************************************************************************************
2592 
2593 
2594 //*************************************************************************************************
2603 template< typename MT > // Type of the dense matrix
2604 inline size_t DenseRow<MT,false>::nonZeros() const
2605 {
2606  const size_t columns( size() );
2607  size_t nonzeros( 0UL );
2608 
2609  for( size_t j=0UL; j<columns; ++j )
2610  if( !isDefault( matrix_(row_,j) ) )
2611  ++nonzeros;
2612 
2613  return nonzeros;
2614 }
2616 //*************************************************************************************************
2617 
2618 
2619 //*************************************************************************************************
2625 template< typename MT > // Type of the dense matrix
2626 inline void DenseRow<MT,false>::reset()
2627 {
2628  using blaze::reset;
2629  const size_t columns( size() );
2630  for( size_t j=0UL; j<columns; ++j )
2631  reset( matrix_(row_,j) );
2632 }
2634 //*************************************************************************************************
2635 
2636 
2637 //*************************************************************************************************
2644 template< typename MT > // Type of the dense matrix
2645 template< typename Other > // Data type of the scalar value
2646 inline DenseRow<MT,false>& DenseRow<MT,false>::scale( const Other& scalar )
2647 {
2648  for( size_t j=0UL; j<size(); ++j ) {
2649  matrix_(row_,j) *= scalar;
2650  }
2651  return *this;
2652 }
2654 //*************************************************************************************************
2655 
2656 
2657 
2658 
2659 //=================================================================================================
2660 //
2661 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2662 //
2663 //=================================================================================================
2664 
2665 //*************************************************************************************************
2676 template< typename MT > // Type of the dense matrix
2677 template< typename Other > // Data type of the foreign expression
2678 inline bool DenseRow<MT,false>::canAlias( const Other* alias ) const
2679 {
2680  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2681 }
2683 //*************************************************************************************************
2684 
2685 
2686 //*************************************************************************************************
2697 template< typename MT > // Type of the dense matrix
2698 template< typename Other > // Data type of the foreign expression
2699 inline bool DenseRow<MT,false>::isAliased( const Other* alias ) const
2700 {
2701  return static_cast<const void*>( &matrix_ ) == static_cast<const void*>( alias );
2702 }
2704 //*************************************************************************************************
2705 
2706 
2707 //*************************************************************************************************
2717 template< typename MT > // Type of the dense matrix
2718 inline bool DenseRow<MT,false>::isAligned() const
2719 {
2720  return false;
2721 }
2723 //*************************************************************************************************
2724 
2725 
2726 //*************************************************************************************************
2737 template< typename MT > // Type of the dense matrix
2738 inline bool DenseRow<MT,false>::canSMPAssign() const
2739 {
2740  return ( size() > OPENMP_DVECASSIGN_THRESHOLD );
2741 }
2743 //*************************************************************************************************
2744 
2745 
2746 //*************************************************************************************************
2758 template< typename MT > // Type of the dense matrix
2759 template< typename VT > // Type of the right-hand side dense vector
2760 inline void DenseRow<MT,false>::assign( const DenseVector<VT,true>& rhs )
2761 {
2762  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2763 
2764  const size_t jend( (~rhs).size() & size_t(-2) );
2765  for( size_t j=0UL; j<jend; j+=2UL ) {
2766  matrix_(row_,j ) = (~rhs)[j ];
2767  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
2768  }
2769  if( jend < (~rhs).size() )
2770  matrix_(row_,jend) = (~rhs)[jend];
2771 }
2773 //*************************************************************************************************
2774 
2775 
2776 //*************************************************************************************************
2788 template< typename MT > // Type of the dense matrix
2789 template< typename VT > // Type of the right-hand side sparse vector
2790 inline void DenseRow<MT,false>::assign( const SparseVector<VT,true>& rhs )
2791 {
2792  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2793 
2794  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2795  matrix_(row_,element->index()) = element->value();
2796 }
2798 //*************************************************************************************************
2799 
2800 
2801 //*************************************************************************************************
2813 template< typename MT > // Type of the dense matrix
2814 template< typename VT > // Type of the right-hand side dense vector
2815 inline void DenseRow<MT,false>::addAssign( const DenseVector<VT,true>& rhs )
2816 {
2817  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2818 
2819  const size_t jend( (~rhs).size() & size_t(-2) );
2820  for( size_t j=0UL; j<jend; j+=2UL ) {
2821  matrix_(row_,j ) += (~rhs)[j ];
2822  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
2823  }
2824  if( jend < (~rhs).size() )
2825  matrix_(row_,jend) += (~rhs)[jend];
2826 }
2828 //*************************************************************************************************
2829 
2830 
2831 //*************************************************************************************************
2843 template< typename MT > // Type of the dense matrix
2844 template< typename VT > // Type of the right-hand side sparse vector
2845 inline void DenseRow<MT,false>::addAssign( const SparseVector<VT,true>& rhs )
2846 {
2847  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2848 
2849  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2850  matrix_(row_,element->index()) += element->value();
2851 }
2853 //*************************************************************************************************
2854 
2855 
2856 //*************************************************************************************************
2868 template< typename MT > // Type of the dense matrix
2869 template< typename VT > // Type of the right-hand side dense vector
2870 inline void DenseRow<MT,false>::subAssign( const DenseVector<VT,true>& rhs )
2871 {
2872  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2873 
2874  const size_t jend( (~rhs).size() & size_t(-2) );
2875  for( size_t j=0UL; j<jend; j+=2UL ) {
2876  matrix_(row_,j ) -= (~rhs)[j ];
2877  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
2878  }
2879  if( jend < (~rhs).size() )
2880  matrix_(row_,jend) -= (~rhs)[jend];
2881 }
2883 //*************************************************************************************************
2884 
2885 
2886 //*************************************************************************************************
2898 template< typename MT > // Type of the dense matrix
2899 template< typename VT > // Type of the right-hand side sparse vector
2900 inline void DenseRow<MT,false>::subAssign( const SparseVector<VT,true>& rhs )
2901 {
2902  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2903 
2904  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2905  matrix_(row_,element->index()) -= element->value();
2906 }
2908 //*************************************************************************************************
2909 
2910 
2911 //*************************************************************************************************
2923 template< typename MT > // Type of the dense matrix
2924 template< typename VT > // Type of the right-hand side dense vector
2925 inline void DenseRow<MT,false>::multAssign( const DenseVector<VT,true>& rhs )
2926 {
2927  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2928 
2929  const size_t jend( (~rhs).size() & size_t(-2) );
2930  for( size_t j=0UL; j<jend; j+=2UL ) {
2931  matrix_(row_,j ) *= (~rhs)[j ];
2932  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
2933  }
2934  if( jend < (~rhs).size() )
2935  matrix_(row_,jend) *= (~rhs)[jend];
2936 }
2938 //*************************************************************************************************
2939 
2940 
2941 //*************************************************************************************************
2953 template< typename MT > // Type of the dense matrix
2954 template< typename VT > // Type of the right-hand side sparse vector
2955 inline void DenseRow<MT,false>::multAssign( const SparseVector<VT,true>& rhs )
2956 {
2957  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2958 
2959  const ResultType tmp( *this );
2960 
2961  reset();
2962 
2963  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2964  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
2965 }
2967 //*************************************************************************************************
2968 
2969 
2970 
2971 
2972 
2973 
2974 
2975 
2976 //=================================================================================================
2977 //
2978 // DENSEROW OPERATORS
2979 //
2980 //=================================================================================================
2981 
2982 //*************************************************************************************************
2985 template< typename MT, bool SO >
2986 inline void reset( DenseRow<MT,SO>& row );
2987 
2988 template< typename MT, bool SO >
2989 inline void clear( DenseRow<MT,SO>& row );
2990 
2991 template< typename MT, bool SO >
2992 inline bool isDefault( const DenseRow<MT,SO>& row );
2994 //*************************************************************************************************
2995 
2996 
2997 //*************************************************************************************************
3004 template< typename MT // Type of the dense matrix
3005  , bool SO > // Storage order
3006 inline void reset( DenseRow<MT,SO>& row )
3007 {
3008  row.reset();
3009 }
3010 //*************************************************************************************************
3011 
3012 
3013 //*************************************************************************************************
3022 template< typename MT // Type of the dense matrix
3023  , bool SO > // Storage order
3024 inline void clear( DenseRow<MT,SO>& row )
3025 {
3026  row.reset();
3027 }
3028 //*************************************************************************************************
3029 
3030 
3031 //*************************************************************************************************
3049 template< typename MT // Type of the dense matrix
3050  , bool SO > // Storage order
3051 inline bool isDefault( const DenseRow<MT,SO>& row )
3052 {
3053  for( size_t i=0UL; i<row.size(); ++i )
3054  if( !isDefault( row[i] ) ) return false;
3055  return true;
3056 }
3057 //*************************************************************************************************
3058 
3059 
3060 
3061 
3062 //=================================================================================================
3063 //
3064 // SUBVECTORTRAIT SPECIALIZATIONS
3065 //
3066 //=================================================================================================
3067 
3068 //*************************************************************************************************
3070 template< typename MT, bool SO >
3071 struct SubvectorTrait< DenseRow<MT,SO> >
3072 {
3073  typedef typename SubvectorTrait< typename DenseRow<MT,SO>::ResultType >::Type Type;
3074 };
3076 //*************************************************************************************************
3077 
3078 } // namespace blaze
3079 
3080 #endif
Constraint on the data type.
Constraint on the data type.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseRow.h:340
const size_t OPENMP_DVECASSIGN_THRESHOLD
OpenMP dense vector assignment threshold.This threshold specifies when an assignment of a plain dense...
Definition: Thresholds.h:200
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4579
#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:4075
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:151
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4622
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:197
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:178
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:712
IT::Type IntrinsicType
Intrinsic type of the row elements.
Definition: DenseRow.h:339
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:1094
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
#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:4595
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseRow.h:337
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: DenseRow.h:347
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:121
bool isAligned() const
Returns whether the dense row is properly aligned in memory.
Definition: DenseRow.h:1132
Base template for the RowTrait class.
Definition: RowTrait.h:114
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
Header file for the DisableIf class template.
Header file for the dense vector SMP implementation.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseRow.h:356
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:1172
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
Header file for the Or class template.
DenseRow & operator=(const ElementType &rhs)
Homogenous assignment to all row elements.
Definition: DenseRow.h:767
void storeu(size_t index, const IntrinsicType &value)
Unligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1237
Header file for the subvector trait.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:179
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:336
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:744
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: DenseRow.h:599
#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:696
Constraints on the storage order of matrix types.
Constraint on the data type.
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2382
MT::ElementType ElementType
Type of the row elements.
Definition: DenseRow.h:338
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:269
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2386
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:1033
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a constant row value.
Definition: DenseRow.h:353
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:91
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:1002
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:2383
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:1151
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: DenseRow.h:344
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:664
void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense row.
Definition: DenseRow.h:1259
Header file for the division trait.
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:209
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:1193
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:310
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:359
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:239
void reset()
Reset to the default initial values.
Definition: DenseRow.h:1047
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2387
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:1215
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:350
const DenseRow & CompositeType
Data type for composite expression templates.
Definition: DenseRow.h:341
Header file for the IsRowMajorMatrix type trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the row element type.
Definition: DenseRow.h:319
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:248
Header file for the sparse vector SMP implementation.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:105
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:573
DenseRow< MT, SO > This
Type of this DenseRow instance.
Definition: DenseRow.h:335
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2379
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
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:1016
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2385
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:1114
Pointer data()
Low-level data access to the row elements.
Definition: DenseRow.h:632
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:316