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>
56 #include <blaze/math/Intrinsics.h>
57 #include <blaze/math/shims/Clear.h>
83 #include <blaze/system/CacheSize.h>
84 #include <blaze/system/Inline.h>
87 #include <blaze/util/Assert.h>
91 #include <blaze/util/DisableIf.h>
92 #include <blaze/util/EnableIf.h>
93 #include <blaze/util/Exception.h>
95 #include <blaze/util/mpl/And.h>
96 #include <blaze/util/mpl/If.h>
97 #include <blaze/util/mpl/Not.h>
98 #include <blaze/util/mpl/Or.h>
99 #include <blaze/util/Null.h>
100 #include <blaze/util/Template.h>
101 #include <blaze/util/Types.h>
109 
110 
111 namespace blaze {
112 
113 //=================================================================================================
114 //
115 // CLASS DEFINITION
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
339 template< typename MT // Type of the dense matrix
340  , bool SO = IsRowMajorMatrix<MT>::value // Storage order
341  , bool SF = IsSymmetric<MT>::value > // Symmetry flag
342 class DenseRow : public DenseVector< DenseRow<MT,SO,SF>, true >
343  , private Row
344 {
345  private:
346  //**Type definitions****************************************************************************
348  typedef typename If< IsExpression<MT>, MT, MT& >::Type Operand;
349 
352  //**********************************************************************************************
353 
354  public:
355  //**Type definitions****************************************************************************
357  typedef typename RowTrait<MT>::Type ResultType;
359  typedef typename MT::ElementType ElementType;
360  typedef typename IT::Type IntrinsicType;
361  typedef typename MT::ReturnType ReturnType;
362  typedef const DenseRow& CompositeType;
363 
366 
368  typedef typename If< IsConst<MT>, ConstReference, typename MT::Reference >::Type Reference;
369 
371  typedef const ElementType* ConstPointer;
372 
375  , ConstPointer, ElementType* >::Type Pointer;
376 
379 
381  typedef typename If< IsConst<MT>, ConstIterator, typename MT::Iterator >::Type Iterator;
382  //**********************************************************************************************
383 
384  //**Compilation flags***************************************************************************
386  enum { vectorizable = MT::vectorizable };
387 
389  enum { smpAssignable = MT::smpAssignable };
390  //**********************************************************************************************
391 
392  //**Constructors********************************************************************************
395  explicit inline DenseRow( MT& matrix, size_t index );
396  // No explicitly declared copy constructor.
398  //**********************************************************************************************
399 
400  //**Destructor**********************************************************************************
401  // No explicitly declared destructor.
402  //**********************************************************************************************
403 
404  //**Data access functions***********************************************************************
407  inline Reference operator[]( size_t index );
408  inline ConstReference operator[]( size_t index ) const;
409  inline Reference at( size_t index );
410  inline ConstReference at( size_t index ) const;
411  inline Pointer data ();
412  inline ConstPointer data () const;
413  inline Iterator begin ();
414  inline ConstIterator begin () const;
415  inline ConstIterator cbegin() const;
416  inline Iterator end ();
417  inline ConstIterator end () const;
418  inline ConstIterator cend () const;
420  //**********************************************************************************************
421 
422  //**Assignment operators************************************************************************
425  inline DenseRow& operator=( const ElementType& rhs );
426  inline DenseRow& operator=( const DenseRow& rhs );
427 
428  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
429  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
430  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
431  template< typename VT > inline DenseRow& operator*=( const DenseVector<VT,true>& rhs );
432  template< typename VT > inline DenseRow& operator*=( const SparseVector<VT,true>& rhs );
433 
434  template< typename Other >
435  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
436  operator*=( Other rhs );
437 
438  template< typename Other >
439  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
440  operator/=( Other rhs );
442  //**********************************************************************************************
443 
444  //**Utility functions***************************************************************************
447  inline size_t size() const;
448  inline size_t capacity() const;
449  inline size_t nonZeros() const;
450  inline void reset();
451  template< typename Other > inline DenseRow& scale( const Other& scalar );
453  //**********************************************************************************************
454 
455  private:
456  //**********************************************************************************************
458  template< typename VT >
460  struct VectorizedAssign {
461  enum { value = useOptimizedKernels &&
462  vectorizable && VT::vectorizable &&
463  IsSame<ElementType,typename VT::ElementType>::value };
464  };
466  //**********************************************************************************************
467 
468  //**********************************************************************************************
470  template< typename VT >
472  struct VectorizedAddAssign {
473  enum { value = useOptimizedKernels &&
474  vectorizable && VT::vectorizable &&
475  IsSame<ElementType,typename VT::ElementType>::value &&
476  IntrinsicTrait<ElementType>::addition };
477  };
479  //**********************************************************************************************
480 
481  //**********************************************************************************************
483  template< typename VT >
485  struct VectorizedSubAssign {
486  enum { value = useOptimizedKernels &&
487  vectorizable && VT::vectorizable &&
488  IsSame<ElementType,typename VT::ElementType>::value &&
489  IntrinsicTrait<ElementType>::subtraction };
490  };
492  //**********************************************************************************************
493 
494  //**********************************************************************************************
496  template< typename VT >
498  struct VectorizedMultAssign {
499  enum { value = useOptimizedKernels &&
500  vectorizable && VT::vectorizable &&
501  IsSame<ElementType,typename VT::ElementType>::value &&
502  IntrinsicTrait<ElementType>::multiplication };
503  };
505  //**********************************************************************************************
506 
507  public:
508  //**Expression template evaluation functions****************************************************
511  template< typename Other >
512  inline bool canAlias( const Other* alias ) const;
513 
514  template< typename MT2, bool SO2, bool SF2 >
515  inline bool canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const;
516 
517  template< typename Other >
518  inline bool isAliased( const Other* alias ) const;
519 
520  template< typename MT2, bool SO2, bool SF2 >
521  inline bool isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const;
522 
523  inline bool isAligned () const;
524  inline bool canSMPAssign() const;
525 
526  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t index ) const;
527  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t index ) const;
528  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t index ) const;
529 
530  BLAZE_ALWAYS_INLINE void store ( size_t index, const IntrinsicType& value );
531  BLAZE_ALWAYS_INLINE void storea( size_t index, const IntrinsicType& value );
532  BLAZE_ALWAYS_INLINE void storeu( size_t index, const IntrinsicType& value );
533  BLAZE_ALWAYS_INLINE void stream( size_t index, const IntrinsicType& value );
534 
535  template< typename VT >
536  inline typename DisableIf< VectorizedAssign<VT> >::Type
537  assign( const DenseVector<VT,true>& rhs );
538 
539  template< typename VT >
540  inline typename EnableIf< VectorizedAssign<VT> >::Type
541  assign( const DenseVector<VT,true>& rhs );
542 
543  template< typename VT > inline void assign( const SparseVector<VT,true>& rhs );
544 
545  template< typename VT >
546  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
547  addAssign( const DenseVector<VT,true>& rhs );
548 
549  template< typename VT >
550  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
551  addAssign( const DenseVector<VT,true>& rhs );
552 
553  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
554 
555  template< typename VT >
556  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
557  subAssign( const DenseVector<VT,true>& rhs );
558 
559  template< typename VT >
560  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
561  subAssign( const DenseVector<VT,true>& rhs );
562 
563  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
564 
565  template< typename VT >
566  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
567  multAssign( const DenseVector<VT,true>& rhs );
568 
569  template< typename VT >
570  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
571  multAssign( const DenseVector<VT,true>& rhs );
572 
573  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
575  //**********************************************************************************************
576 
577  private:
578  //**Member variables****************************************************************************
581  Operand matrix_;
582  const size_t row_;
583 
584  //**********************************************************************************************
585 
586  //**Friend declarations*************************************************************************
588  template< typename MT2, bool SO2, bool SF2 > friend class DenseRow;
589 
590  template< typename MT2, bool SO2, bool SF2 >
591  friend bool isIntact( const DenseRow<MT2,SO2,SF2>& row );
592 
593  template< typename MT2, bool SO2, bool SF2 >
594  friend bool isSame( const DenseRow<MT2,SO2,SF2>& a, const DenseRow<MT2,SO2,SF2>& b );
595 
596  template< typename MT2, bool SO2, bool SF2, typename VT >
597  friend bool tryAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
598 
599  template< typename MT2, bool SO2, bool SF2, typename VT >
600  friend bool tryAddAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
601 
602  template< typename MT2, bool SO2, bool SF2, typename VT >
603  friend bool trySubAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
604 
605  template< typename MT2, bool SO2, bool SF2, typename VT >
606  friend bool tryMultAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
607 
608  template< typename MT2, bool SO2, bool SF2 >
609  friend typename DerestrictTrait< DenseRow<MT2,SO2,SF2> >::Type
610  derestrict( DenseRow<MT2,SO2,SF2>& dm );
612  //**********************************************************************************************
613 
614  //**Compile time checks*************************************************************************
623  //**********************************************************************************************
624 };
625 //*************************************************************************************************
626 
627 
628 
629 
630 //=================================================================================================
631 //
632 // CONSTRUCTOR
633 //
634 //=================================================================================================
635 
636 //*************************************************************************************************
643 template< typename MT // Type of the dense matrix
644  , bool SO // Storage order
645  , bool SF > // Symmetry flag
646 inline DenseRow<MT,SO,SF>::DenseRow( MT& matrix, size_t index )
647  : matrix_( matrix ) // The dense matrix containing the row
648  , row_ ( index ) // The index of the row in the matrix
649 {
650  if( matrix_.rows() <= index ) {
651  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
652  }
653 }
654 //*************************************************************************************************
655 
656 
657 
658 
659 //=================================================================================================
660 //
661 // DATA ACCESS FUNCTIONS
662 //
663 //=================================================================================================
664 
665 //*************************************************************************************************
674 template< typename MT // Type of the dense matrix
675  , bool SO // Storage order
676  , bool SF > // Symmetry flag
678 {
679  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
680  return matrix_(row_,index);
681 }
682 //*************************************************************************************************
683 
684 
685 //*************************************************************************************************
694 template< typename MT // Type of the dense matrix
695  , bool SO // Storage order
696  , bool SF > // Symmetry flag
698  DenseRow<MT,SO,SF>::operator[]( size_t index ) const
699 {
700  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
701  return const_cast<const MT&>( matrix_ )(row_,index);
702 }
703 //*************************************************************************************************
704 
705 
706 //*************************************************************************************************
716 template< typename MT // Type of the dense matrix
717  , bool SO // Storage order
718  , bool SF > // Symmetry flag
720 {
721  if( index >= size() ) {
722  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
723  }
724  return (*this)[index];
725 }
726 //*************************************************************************************************
727 
728 
729 //*************************************************************************************************
739 template< typename MT // Type of the dense matrix
740  , bool SO // Storage order
741  , bool SF > // Symmetry flag
742 inline typename DenseRow<MT,SO,SF>::ConstReference DenseRow<MT,SO,SF>::at( size_t index ) const
743 {
744  if( index >= size() ) {
745  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
746  }
747  return (*this)[index];
748 }
749 //*************************************************************************************************
750 
751 
752 //*************************************************************************************************
760 template< typename MT // Type of the dense matrix
761  , bool SO // Storage order
762  , bool SF > // Symmetry flag
764 {
765  return matrix_.data( row_ );
766 }
767 //*************************************************************************************************
768 
769 
770 //*************************************************************************************************
778 template< typename MT // Type of the dense matrix
779  , bool SO // Storage order
780  , bool SF > // Symmetry flag
782 {
783  return matrix_.data( row_ );
784 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
795 template< typename MT // Type of the dense matrix
796  , bool SO // Storage order
797  , bool SF > // Symmetry flag
799 {
800  return matrix_.begin( row_ );
801 }
802 //*************************************************************************************************
803 
804 
805 //*************************************************************************************************
812 template< typename MT // Type of the dense matrix
813  , bool SO // Storage order
814  , bool SF > // Symmetry flag
816 {
817  return matrix_.cbegin( row_ );
818 }
819 //*************************************************************************************************
820 
821 
822 //*************************************************************************************************
829 template< typename MT // Type of the dense matrix
830  , bool SO // Storage order
831  , bool SF > // Symmetry flag
833 {
834  return matrix_.cbegin( row_ );
835 }
836 //*************************************************************************************************
837 
838 
839 //*************************************************************************************************
846 template< typename MT // Type of the dense matrix
847  , bool SO // Storage order
848  , bool SF > // Symmetry flag
850 {
851  return matrix_.end( row_ );
852 }
853 //*************************************************************************************************
854 
855 
856 //*************************************************************************************************
863 template< typename MT // Type of the dense matrix
864  , bool SO // Storage order
865  , bool SF > // Symmetry flag
867 {
868  return matrix_.cend( row_ );
869 }
870 //*************************************************************************************************
871 
872 
873 //*************************************************************************************************
880 template< typename MT // Type of the dense matrix
881  , bool SO // Storage order
882  , bool SF > // Symmetry flag
884 {
885  return matrix_.cend( row_ );
886 }
887 //*************************************************************************************************
888 
889 
890 
891 
892 //=================================================================================================
893 //
894 // ASSIGNMENT OPERATORS
895 //
896 //=================================================================================================
897 
898 //*************************************************************************************************
908 template< typename MT // Type of the dense matrix
909  , bool SO // Storage order
910  , bool SF > // Symmetry flag
912 {
913  const size_t jbegin( ( IsUpper<MT>::value )
915  ?( row_+1UL )
916  :( row_ ) )
917  :( 0UL ) );
918  const size_t jend ( ( IsLower<MT>::value )
920  ?( row_ )
921  :( row_+1UL ) )
922  :( size() ) );
923 
924  for( size_t j=jbegin; j<jend; ++j )
925  matrix_(row_,j) = rhs;
926 
927  return *this;
928 }
929 //*************************************************************************************************
930 
931 
932 //*************************************************************************************************
945 template< typename MT // Type of the dense matrix
946  , bool SO // Storage order
947  , bool SF > // Symmetry flag
949 {
950  if( &rhs == this ) return *this;
951 
952  if( size() != rhs.size() ) {
953  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
954  }
955 
956  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
957  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
958  }
959 
960  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
961 
962  smpAssign( left, rhs );
963 
964  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
965 
966  return *this;
967 }
968 //*************************************************************************************************
969 
970 
971 //*************************************************************************************************
984 template< typename MT // Type of the dense matrix
985  , bool SO // Storage order
986  , bool SF > // Symmetry flag
987 template< typename VT > // Type of the right-hand side vector
989 {
992 
993  if( size() != (~rhs).size() ) {
994  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
995  }
996 
997  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
998  Right right( ~rhs );
999 
1000  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
1001  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1002  }
1003 
1004  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
1005 
1006  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1007  const typename VT::ResultType tmp( right );
1008  smpAssign( left, tmp );
1009  }
1010  else {
1012  reset();
1013  smpAssign( left, right );
1014  }
1015 
1016  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1017 
1018  return *this;
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1036 template< typename MT // Type of the dense matrix
1037  , bool SO // Storage order
1038  , bool SF > // Symmetry flag
1039 template< typename VT > // Type of the right-hand side vector
1041 {
1044 
1045  if( size() != (~rhs).size() ) {
1046  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1047  }
1048 
1049  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
1050  Right right( ~rhs );
1051 
1052  if( !tryAddAssign( matrix_, right, row_, 0UL ) ) {
1053  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1054  }
1055 
1056  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
1057 
1058  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1059  const typename VT::ResultType tmp( right );
1060  smpAddAssign( left, tmp );
1061  }
1062  else {
1063  smpAddAssign( left, right );
1064  }
1065 
1066  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1067 
1068  return *this;
1069 }
1070 //*************************************************************************************************
1071 
1072 
1073 //*************************************************************************************************
1086 template< typename MT // Type of the dense matrix
1087  , bool SO // Storage order
1088  , bool SF > // Symmetry flag
1089 template< typename VT > // Type of the right-hand side vector
1091 {
1094 
1095  if( size() != (~rhs).size() ) {
1096  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1097  }
1098 
1099  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
1100  Right right( ~rhs );
1101 
1102  if( !trySubAssign( matrix_, right, row_, 0UL ) ) {
1103  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1104  }
1105 
1106  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
1107 
1108  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1109  const typename VT::ResultType tmp( right );
1110  smpSubAssign( left, tmp );
1111  }
1112  else {
1113  smpSubAssign( left, right );
1114  }
1115 
1116  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1117 
1118  return *this;
1119 }
1120 //*************************************************************************************************
1121 
1122 
1123 //*************************************************************************************************
1135 template< typename MT // Type of the dense matrix
1136  , bool SO // Storage order
1137  , bool SF > // Symmetry flag
1138 template< typename VT > // Type of the right-hand side dense vector
1140 {
1143 
1144  if( size() != (~rhs).size() ) {
1145  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1146  }
1147 
1148  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
1149  Right right( ~rhs );
1150 
1151  if( !tryMultAssign( matrix_, right, row_, 0UL ) ) {
1152  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1153  }
1154 
1155  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
1156 
1157  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
1158  const typename VT::ResultType tmp( right );
1159  smpMultAssign( left, tmp );
1160  }
1161  else {
1162  smpMultAssign( left, right );
1163  }
1164 
1165  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1166 
1167  return *this;
1168 }
1169 //*************************************************************************************************
1170 
1171 
1172 //*************************************************************************************************
1184 template< typename MT // Type of the dense matrix
1185  , bool SO // Storage order
1186  , bool SF > // Symmetry flag
1187 template< typename VT > // Type of the right-hand side sparse vector
1189 {
1193 
1194  if( size() != (~rhs).size() ) {
1195  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1196  }
1197 
1198  const ResultType right( *this * (~rhs) );
1199 
1200  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
1201  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1202  }
1203 
1204  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
1205 
1206  smpAssign( left, right );
1207 
1208  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1209 
1210  return *this;
1211 }
1212 //*************************************************************************************************
1213 
1214 
1215 //*************************************************************************************************
1225 template< typename MT // Type of the dense matrix
1226  , bool SO // Storage order
1227  , bool SF > // Symmetry flag
1228 template< typename Other > // Data type of the right-hand side scalar
1229 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO,SF> >::Type&
1231 {
1233 
1234  return operator=( (*this) * rhs );
1235 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1251 template< typename MT // Type of the dense matrix
1252  , bool SO // Storage order
1253  , bool SF > // Symmetry flag
1254 template< typename Other > // Data type of the right-hand side scalar
1255 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,SO,SF> >::Type&
1257 {
1259 
1260  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1261 
1262  return operator=( (*this) / rhs );
1263 }
1264 //*************************************************************************************************
1265 
1266 
1267 
1268 
1269 //=================================================================================================
1270 //
1271 // UTILITY FUNCTIONS
1272 //
1273 //=================================================================================================
1274 
1275 //*************************************************************************************************
1280 template< typename MT // Type of the dense matrix
1281  , bool SO // Storage order
1282  , bool SF > // Symmetry flag
1283 inline size_t DenseRow<MT,SO,SF>::size() const
1284 {
1285  return matrix_.columns();
1286 }
1287 //*************************************************************************************************
1288 
1289 
1290 //*************************************************************************************************
1295 template< typename MT // Type of the dense matrix
1296  , bool SO // Storage order
1297  , bool SF > // Symmetry flag
1298 inline size_t DenseRow<MT,SO,SF>::capacity() const
1299 {
1300  return matrix_.capacity( row_ );
1301 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1313 template< typename MT // Type of the dense matrix
1314  , bool SO // Storage order
1315  , bool SF > // Symmetry flag
1316 inline size_t DenseRow<MT,SO,SF>::nonZeros() const
1317 {
1318  return matrix_.nonZeros( row_ );
1319 }
1320 //*************************************************************************************************
1321 
1322 
1323 //*************************************************************************************************
1328 template< typename MT // Type of the dense matrix
1329  , bool SO // Storage order
1330  , bool SF > // Symmetry flag
1332 {
1333  matrix_.reset( row_ );
1334 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1348 template< typename MT // Type of the dense matrix
1349  , bool SO // Storage order
1350  , bool SF > // Symmetry flag
1351 template< typename Other > // Data type of the scalar value
1352 inline DenseRow<MT,SO,SF>& DenseRow<MT,SO,SF>::scale( const Other& scalar )
1353 {
1355 
1356  const size_t jbegin( ( IsUpper<MT>::value )
1358  ?( row_+1UL )
1359  :( row_ ) )
1360  :( 0UL ) );
1361  const size_t jend ( ( IsLower<MT>::value )
1363  ?( row_ )
1364  :( row_+1UL ) )
1365  :( size() ) );
1366 
1367  for( size_t j=jbegin; j<jend; ++j ) {
1368  matrix_(row_,j) *= scalar;
1369  }
1370 
1371  return *this;
1372 }
1373 //*************************************************************************************************
1374 
1375 
1376 
1377 
1378 //=================================================================================================
1379 //
1380 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1381 //
1382 //=================================================================================================
1383 
1384 //*************************************************************************************************
1394 template< typename MT // Type of the dense matrix
1395  , bool SO // Storage order
1396  , bool SF > // Symmetry flag
1397 template< typename Other > // Data type of the foreign expression
1398 inline bool DenseRow<MT,SO,SF>::canAlias( const Other* alias ) const
1399 {
1400  return matrix_.isAliased( alias );
1401 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1415 template< typename MT // Type of the dense matrix
1416  , bool SO // Storage order
1417  , bool SF > // Symmetry flag
1418 template< typename MT2 // Data type of the foreign dense row
1419  , bool SO2 // Storage order of the foreign dense row
1420  , bool SF2 > // Symmetry flag of the foreign dense row
1421 inline bool DenseRow<MT,SO,SF>::canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const
1422 {
1423  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
1424 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1438 template< typename MT // Type of the dense matrix
1439  , bool SO // Storage order
1440  , bool SF > // Symmetry flag
1441 template< typename Other > // Data type of the foreign expression
1442 inline bool DenseRow<MT,SO,SF>::isAliased( const Other* alias ) const
1443 {
1444  return matrix_.isAliased( alias );
1445 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1459 template< typename MT // Type of the dense matrix
1460  , bool SO // Storage order
1461  , bool SF > // Symmetry flag
1462 template< typename MT2 // Data type of the foreign dense row
1463  , bool SO2 // Storage order of the foreign dense row
1464  , bool SF2 > // Symmetry flag of the foreign dense row
1465 inline bool DenseRow<MT,SO,SF>::isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const
1466 {
1467  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
1468 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1481 template< typename MT // Type of the dense matrix
1482  , bool SO // Storage order
1483  , bool SF > // Symmetry flag
1485 {
1486  return matrix_.isAligned();
1487 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1501 template< typename MT // Type of the dense matrix
1502  , bool SO // Storage order
1503  , bool SF > // Symmetry flag
1505 {
1506  return ( size() > SMP_DVECASSIGN_THRESHOLD );
1507 }
1508 //*************************************************************************************************
1509 
1510 
1511 //*************************************************************************************************
1523 template< typename MT // Type of the dense matrix
1524  , bool SO // Storage order
1525  , bool SF > // Symmetry flag
1527  DenseRow<MT,SO,SF>::load( size_t index ) const
1528 {
1529  return matrix_.load( row_, index );
1530 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1546 template< typename MT // Type of the dense matrix
1547  , bool SO // Storage order
1548  , bool SF > // Symmetry flag
1550  DenseRow<MT,SO,SF>::loada( size_t index ) const
1551 {
1552  return matrix_.loada( row_, index );
1553 }
1554 //*************************************************************************************************
1555 
1556 
1557 //*************************************************************************************************
1569 template< typename MT // Type of the dense matrix
1570  , bool SO // Storage order
1571  , bool SF > // Symmetry flag
1573  DenseRow<MT,SO,SF>::loadu( size_t index ) const
1574 {
1575  return matrix_.loadu( row_, index );
1576 }
1577 //*************************************************************************************************
1578 
1579 
1580 //*************************************************************************************************
1593 template< typename MT // Type of the dense matrix
1594  , bool SO // Storage order
1595  , bool SF > // Symmetry flag
1597 {
1598  matrix_.store( row_, index, value );
1599 }
1600 //*************************************************************************************************
1601 
1602 
1603 //*************************************************************************************************
1616 template< typename MT // Type of the dense matrix
1617  , bool SO // Storage order
1618  , bool SF > // Symmetry flag
1620 {
1621  matrix_.storea( row_, index, value );
1622 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1639 template< typename MT // Type of the dense matrix
1640  , bool SO // Storage order
1641  , bool SF > // Symmetry flag
1643 {
1644  matrix_.storeu( row_, index, value );
1645 }
1646 //*************************************************************************************************
1647 
1648 
1649 //*************************************************************************************************
1662 template< typename MT // Type of the dense matrix
1663  , bool SO // Storage order
1664  , bool SF > // Symmetry flag
1666 {
1667  matrix_.stream( row_, index, value );
1668 }
1669 //*************************************************************************************************
1670 
1671 
1672 //*************************************************************************************************
1683 template< typename MT // Type of the dense matrix
1684  , bool SO // Storage order
1685  , bool SF > // Symmetry flag
1686 template< typename VT > // Type of the right-hand side dense vector
1687 inline typename DisableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1689 {
1690  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1691 
1692  const size_t jpos( (~rhs).size() & size_t(-2) );
1693  for( size_t j=0UL; j<jpos; j+=2UL ) {
1694  matrix_(row_,j ) = (~rhs)[j ];
1695  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
1696  }
1697  if( jpos < (~rhs).size() )
1698  matrix_(row_,jpos) = (~rhs)[jpos];
1699 }
1700 //*************************************************************************************************
1701 
1702 
1703 //*************************************************************************************************
1714 template< typename MT // Type of the dense matrix
1715  , bool SO // Storage order
1716  , bool SF > // Symmetry flag
1717 template< typename VT > // Type of the right-hand side dense vector
1718 inline typename EnableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
1720 {
1722 
1723  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1724 
1725  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1726  const size_t columns( size() );
1727 
1728  const size_t jpos( ( remainder )?( columns & size_t(-IT::size) ):( columns ) );
1729  BLAZE_INTERNAL_ASSERT( !remainder || ( columns - ( columns % (IT::size) ) ) == jpos, "Invalid end calculation" );
1730 
1731  if( useStreaming && columns > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
1732  {
1733  size_t j( 0UL );
1734 
1735  for( ; j<jpos; j+=IT::size ) {
1736  matrix_.stream( row_, j, (~rhs).load(j) );
1737  }
1738  for( ; remainder && j<columns; ++j ) {
1739  matrix_(row_,j) = (~rhs)[j];
1740  }
1741  }
1742  else
1743  {
1744  size_t j( 0UL );
1745  typename VT::ConstIterator it( (~rhs).begin() );
1746 
1747  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
1748  matrix_.store( row_, j , it.load() ); it += IT::size;
1749  matrix_.store( row_, j+IT::size , it.load() ); it += IT::size;
1750  matrix_.store( row_, j+IT::size*2UL, it.load() ); it += IT::size;
1751  matrix_.store( row_, j+IT::size*3UL, it.load() ); it += IT::size;
1752  }
1753  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
1754  matrix_.store( row_, j, it.load() );
1755  }
1756  for( ; remainder && j<columns; ++j, ++it ) {
1757  matrix_(row_,j) = *it;
1758  }
1759  }
1760 }
1761 //*************************************************************************************************
1762 
1763 
1764 //*************************************************************************************************
1775 template< typename MT // Type of the dense matrix
1776  , bool SO // Storage order
1777  , bool SF > // Symmetry flag
1778 template< typename VT > // Type of the right-hand side sparse vector
1780 {
1781  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1782 
1783  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1784  matrix_(row_,element->index()) = element->value();
1785 }
1786 //*************************************************************************************************
1787 
1788 
1789 //*************************************************************************************************
1800 template< typename MT // Type of the dense matrix
1801  , bool SO // Storage order
1802  , bool SF > // Symmetry flag
1803 template< typename VT > // Type of the right-hand side dense vector
1804 inline typename DisableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1806 {
1807  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1808 
1809  const size_t jpos( (~rhs).size() & size_t(-2) );
1810  for( size_t j=0UL; j<jpos; j+=2UL ) {
1811  matrix_(row_,j ) += (~rhs)[j ];
1812  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
1813  }
1814  if( jpos < (~rhs).size() )
1815  matrix_(row_,jpos) += (~rhs)[jpos];
1816 }
1817 //*************************************************************************************************
1818 
1819 
1820 //*************************************************************************************************
1831 template< typename MT // Type of the dense matrix
1832  , bool SO // Storage order
1833  , bool SF > // Symmetry flag
1834 template< typename VT > // Type of the right-hand side dense vector
1835 inline typename EnableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
1837 {
1839 
1840  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1841 
1842  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1843  const size_t columns( size() );
1844 
1845  const size_t jpos( ( remainder )?( columns & size_t(-IT::size) ):( columns ) );
1846  BLAZE_INTERNAL_ASSERT( !remainder || ( columns - ( columns % (IT::size) ) ) == jpos, "Invalid end calculation" );
1847 
1848  size_t j( 0UL );
1849  typename VT::ConstIterator it( (~rhs).begin() );
1850 
1851  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
1852  matrix_.store( row_, j , matrix_.load(row_,j ) + it.load() ); it += IT::size;
1853  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) + it.load() ); it += IT::size;
1854  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) + it.load() ); it += IT::size;
1855  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) + it.load() ); it += IT::size;
1856  }
1857  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
1858  matrix_.store( row_, j, matrix_.load(row_,j) + it.load() );
1859  }
1860  for( ; remainder && j<columns; ++j, ++it ) {
1861  matrix_(row_,j) += *it;
1862  }
1863 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1878 template< typename MT // Type of the dense matrix
1879  , bool SO // Storage order
1880  , bool SF > // Symmetry flag
1881 template< typename VT > // Type of the right-hand side sparse vector
1883 {
1884  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1885 
1886  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1887  matrix_(row_,element->index()) += element->value();
1888 }
1889 //*************************************************************************************************
1890 
1891 
1892 //*************************************************************************************************
1903 template< typename MT // Type of the dense matrix
1904  , bool SO // Storage order
1905  , bool SF > // Symmetry flag
1906 template< typename VT > // Type of the right-hand side dense vector
1907 inline typename DisableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1909 {
1910  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1911 
1912  const size_t jpos( (~rhs).size() & size_t(-2) );
1913  for( size_t j=0UL; j<jpos; j+=2UL ) {
1914  matrix_(row_,j ) -= (~rhs)[j ];
1915  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
1916  }
1917  if( jpos < (~rhs).size() )
1918  matrix_(row_,jpos) -= (~rhs)[jpos];
1919 }
1920 //*************************************************************************************************
1921 
1922 
1923 //*************************************************************************************************
1934 template< typename MT // Type of the dense matrix
1935  , bool SO // Storage order
1936  , bool SF > // Symmetry flag
1937 template< typename VT > // Type of the right-hand side dense vector
1938 inline typename EnableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
1940 {
1942 
1943  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1944 
1945  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
1946  const size_t columns( size() );
1947 
1948  const size_t jpos( ( remainder )?( columns & size_t(-IT::size) ):( columns ) );
1949  BLAZE_INTERNAL_ASSERT( !remainder || ( columns - ( columns % (IT::size) ) ) == jpos, "Invalid end calculation" );
1950 
1951  size_t j( 0UL );
1952  typename VT::ConstIterator it( (~rhs).begin() );
1953 
1954  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
1955  matrix_.store( row_, j , matrix_.load(row_,j ) - it.load() ); it += IT::size;
1956  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) - it.load() ); it += IT::size;
1957  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) - it.load() ); it += IT::size;
1958  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) - it.load() ); it += IT::size;
1959  }
1960  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
1961  matrix_.store( row_, j, matrix_.load(row_,j) - it.load() );
1962  }
1963  for( ; remainder && j<columns; ++j, ++it ) {
1964  matrix_(row_,j) -= *it;
1965  }
1966 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1981 template< typename MT // Type of the dense matrix
1982  , bool SO // Storage order
1983  , bool SF > // Symmetry flag
1984 template< typename VT > // Type of the right-hand side sparse vector
1986 {
1987  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1988 
1989  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
1990  matrix_(row_,element->index()) -= element->value();
1991 }
1992 //*************************************************************************************************
1993 
1994 
1995 //*************************************************************************************************
2006 template< typename MT // Type of the dense matrix
2007  , bool SO // Storage order
2008  , bool SF > // Symmetry flag
2009 template< typename VT > // Type of the right-hand side dense vector
2010 inline typename DisableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2012 {
2013  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2014 
2015  const size_t jpos( (~rhs).size() & size_t(-2) );
2016  for( size_t j=0UL; j<jpos; j+=2UL ) {
2017  matrix_(row_,j ) *= (~rhs)[j ];
2018  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
2019  }
2020  if( jpos < (~rhs).size() )
2021  matrix_(row_,jpos) *= (~rhs)[jpos];
2022 }
2023 //*************************************************************************************************
2024 
2025 
2026 //*************************************************************************************************
2037 template< typename MT // Type of the dense matrix
2038  , bool SO // Storage order
2039  , bool SF > // Symmetry flag
2040 template< typename VT > // Type of the right-hand side dense vector
2041 inline typename EnableIf< typename DenseRow<MT,SO,SF>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
2043 {
2045 
2046  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2047 
2048  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
2049  const size_t columns( size() );
2050 
2051  const size_t jpos( ( remainder )?( columns & size_t(-IT::size) ):( columns ) );
2052  BLAZE_INTERNAL_ASSERT( !remainder || ( columns - ( columns % (IT::size) ) ) == jpos, "Invalid end calculation" );
2053 
2054  size_t j( 0UL );
2055  typename VT::ConstIterator it( (~rhs).begin() );
2056 
2057  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
2058  matrix_.store( row_, j , matrix_.load(row_,j ) * it.load() ); it += IT::size;
2059  matrix_.store( row_, j+IT::size , matrix_.load(row_,j+IT::size ) * it.load() ); it += IT::size;
2060  matrix_.store( row_, j+IT::size*2UL, matrix_.load(row_,j+IT::size*2UL) * it.load() ); it += IT::size;
2061  matrix_.store( row_, j+IT::size*3UL, matrix_.load(row_,j+IT::size*3UL) * it.load() ); it += IT::size;
2062  }
2063  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
2064  matrix_.store( row_, j, matrix_.load(row_,j) * it.load() );
2065  }
2066  for( ; remainder && j<columns; ++j, ++it ) {
2067  matrix_(row_,j) *= *it;
2068  }
2069 }
2070 //*************************************************************************************************
2071 
2072 
2073 //*************************************************************************************************
2084 template< typename MT // Type of the dense matrix
2085  , bool SO // Storage order
2086  , bool SF > // Symmetry flag
2087 template< typename VT > // Type of the right-hand side sparse vector
2089 {
2090  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2091 
2092  const ResultType tmp( serial( *this ) );
2093 
2094  reset();
2095 
2096  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
2097  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
2098 }
2099 //*************************************************************************************************
2100 
2101 
2102 
2103 
2104 
2105 
2106 
2107 
2108 //=================================================================================================
2109 //
2110 // CLASS TEMPLATE SPECIALIZATION FOR GENERAL COLUMN-MAJOR MATRICES
2111 //
2112 //=================================================================================================
2113 
2114 //*************************************************************************************************
2122 template< typename MT > // Type of the dense matrix
2123 class DenseRow<MT,false,false> : public DenseVector< DenseRow<MT,false,false>, true >
2124  , private Row
2125 {
2126  private:
2127  //**Type definitions****************************************************************************
2129  typedef typename If< IsExpression<MT>, MT, MT& >::Type Operand;
2130  //**********************************************************************************************
2131 
2132  public:
2133  //**Type definitions****************************************************************************
2134  typedef DenseRow<MT,false,false> This;
2135  typedef typename RowTrait<MT>::Type ResultType;
2136  typedef typename ResultType::TransposeType TransposeType;
2137  typedef typename MT::ElementType ElementType;
2138  typedef typename MT::ReturnType ReturnType;
2139  typedef const DenseRow& CompositeType;
2140 
2142  typedef typename MT::ConstReference ConstReference;
2143 
2145  typedef typename If< IsConst<MT>, ConstReference, typename MT::Reference >::Type Reference;
2146 
2148  typedef const ElementType* ConstPointer;
2149 
2152  , ConstPointer, ElementType* >::Type Pointer;
2153  //**********************************************************************************************
2154 
2155  //**RowIterator class definition****************************************************************
2158  template< typename MatrixType > // Type of the dense matrix
2159  class RowIterator
2160  {
2161  private:
2162  //*******************************************************************************************
2164 
2169  enum { returnConst = IsConst<MatrixType>::value };
2170  //*******************************************************************************************
2171 
2172  public:
2173  //**Type definitions*************************************************************************
2175  typedef typename IfTrue< returnConst
2176  , typename MatrixType::ConstReference
2177  , typename MatrixType::Reference >::Type Reference;
2178 
2179  typedef std::random_access_iterator_tag IteratorCategory;
2180  typedef RemoveReference<Reference> ValueType;
2181  typedef ValueType* PointerType;
2182  typedef Reference ReferenceType;
2183  typedef ptrdiff_t DifferenceType;
2184 
2185  // STL iterator requirements
2186  typedef IteratorCategory iterator_category;
2187  typedef ValueType value_type;
2188  typedef PointerType pointer;
2189  typedef ReferenceType reference;
2190  typedef DifferenceType difference_type;
2191  //*******************************************************************************************
2192 
2193  //**Constructor******************************************************************************
2196  inline RowIterator()
2197  : matrix_( NULL ) // The dense matrix containing the row.
2198  , row_ ( 0UL ) // The current row index.
2199  , column_( 0UL ) // The current column index.
2200  {}
2201  //*******************************************************************************************
2202 
2203  //**Constructor******************************************************************************
2210  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
2211  : matrix_( &matrix ) // The dense matrix containing the row.
2212  , row_ ( row ) // The current row index.
2213  , column_( column ) // The current column index.
2214  {}
2215  //*******************************************************************************************
2216 
2217  //**Constructor******************************************************************************
2222  template< typename MatrixType2 >
2223  inline RowIterator( const RowIterator<MatrixType2>& it )
2224  : matrix_( it.matrix_ ) // The dense matrix containing the row.
2225  , row_ ( it.row_ ) // The current row index.
2226  , column_( it.column_ ) // The current column index.
2227  {}
2228  //*******************************************************************************************
2229 
2230  //**Addition assignment operator*************************************************************
2236  inline RowIterator& operator+=( size_t inc ) {
2237  column_ += inc;
2238  return *this;
2239  }
2240  //*******************************************************************************************
2241 
2242  //**Subtraction assignment operator**********************************************************
2248  inline RowIterator& operator-=( size_t dec ) {
2249  column_ -= dec;
2250  return *this;
2251  }
2252  //*******************************************************************************************
2253 
2254  //**Prefix increment operator****************************************************************
2259  inline RowIterator& operator++() {
2260  ++column_;
2261  return *this;
2262  }
2263  //*******************************************************************************************
2264 
2265  //**Postfix increment operator***************************************************************
2270  inline const RowIterator operator++( int ) {
2271  const RowIterator tmp( *this );
2272  ++(*this);
2273  return tmp;
2274  }
2275  //*******************************************************************************************
2276 
2277  //**Prefix decrement operator****************************************************************
2282  inline RowIterator& operator--() {
2283  --column_;
2284  return *this;
2285  }
2286  //*******************************************************************************************
2287 
2288  //**Postfix decrement operator***************************************************************
2293  inline const RowIterator operator--( int ) {
2294  const RowIterator tmp( *this );
2295  --(*this);
2296  return tmp;
2297  }
2298  //*******************************************************************************************
2299 
2300  //**Subscript operator***********************************************************************
2306  inline ReferenceType operator[]( size_t index ) const {
2307  return (*matrix_)(row_,column_+index);
2308  }
2309  //*******************************************************************************************
2310 
2311  //**Element access operator******************************************************************
2316  inline ReferenceType operator*() const {
2317  return (*matrix_)(row_,column_);
2318  }
2319  //*******************************************************************************************
2320 
2321  //**Element access operator******************************************************************
2326  inline PointerType operator->() const {
2327  return &(*matrix_)(row_,column_);
2328  }
2329  //*******************************************************************************************
2330 
2331  //**Equality operator************************************************************************
2337  template< typename MatrixType2 >
2338  inline bool operator==( const RowIterator<MatrixType2>& rhs ) const {
2339  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ == rhs.column_ );
2340  }
2341  //*******************************************************************************************
2342 
2343  //**Inequality operator**********************************************************************
2349  template< typename MatrixType2 >
2350  inline bool operator!=( const RowIterator<MatrixType2>& rhs ) const {
2351  return !( *this == rhs );
2352  }
2353  //*******************************************************************************************
2354 
2355  //**Less-than operator***********************************************************************
2361  template< typename MatrixType2 >
2362  inline bool operator<( const RowIterator<MatrixType2>& rhs ) const {
2363  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ < rhs.column_ );
2364  }
2365  //*******************************************************************************************
2366 
2367  //**Greater-than operator********************************************************************
2373  template< typename MatrixType2 >
2374  inline bool operator>( const RowIterator<MatrixType2>& rhs ) const {
2375  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ > rhs.column_ );
2376  }
2377  //*******************************************************************************************
2378 
2379  //**Less-or-equal-than operator**************************************************************
2385  template< typename MatrixType2 >
2386  inline bool operator<=( const RowIterator<MatrixType2>& rhs ) const {
2387  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ <= rhs.column_ );
2388  }
2389  //*******************************************************************************************
2390 
2391  //**Greater-or-equal-than operator***********************************************************
2397  template< typename MatrixType2 >
2398  inline bool operator>=( const RowIterator<MatrixType2>& rhs ) const {
2399  return ( matrix_ == rhs.matrix_ ) && ( row_ == rhs.row_ ) && ( column_ >= rhs.column_ );
2400  }
2401  //*******************************************************************************************
2402 
2403  //**Subtraction operator*********************************************************************
2409  inline DifferenceType operator-( const RowIterator& rhs ) const {
2410  return column_ - rhs.column_;
2411  }
2412  //*******************************************************************************************
2413 
2414  //**Addition operator************************************************************************
2421  friend inline const RowIterator operator+( const RowIterator& it, size_t inc ) {
2422  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2423  }
2424  //*******************************************************************************************
2425 
2426  //**Addition operator************************************************************************
2433  friend inline const RowIterator operator+( size_t inc, const RowIterator& it ) {
2434  return RowIterator( *it.matrix_, it.row_, it.column_+inc );
2435  }
2436  //*******************************************************************************************
2437 
2438  //**Subtraction operator*********************************************************************
2445  friend inline const RowIterator operator-( const RowIterator& it, size_t dec ) {
2446  return RowIterator( *it.matrix_, it.row_, it.column_-dec );
2447  }
2448  //*******************************************************************************************
2449 
2450  private:
2451  //**Member variables*************************************************************************
2452  MatrixType* matrix_;
2453  size_t row_;
2454  size_t column_;
2455  //*******************************************************************************************
2456 
2457  //**Friend declarations**********************************************************************
2458  template< typename MatrixType2 > friend class RowIterator;
2459  //*******************************************************************************************
2460  };
2461  //**********************************************************************************************
2462 
2463  //**Type definitions****************************************************************************
2465  typedef RowIterator<const MT> ConstIterator;
2466 
2468  typedef typename If< IsConst<MT>, ConstIterator, RowIterator<MT> >::Type Iterator;
2469  //**********************************************************************************************
2470 
2471  //**Compilation flags***************************************************************************
2473  enum { vectorizable = 0 };
2474 
2476  enum { smpAssignable = MT::smpAssignable };
2477  //**********************************************************************************************
2478 
2479  //**Constructors********************************************************************************
2482  explicit inline DenseRow( MT& matrix, size_t index );
2483  // No explicitly declared copy constructor.
2485  //**********************************************************************************************
2486 
2487  //**Destructor**********************************************************************************
2488  // No explicitly declared destructor.
2489  //**********************************************************************************************
2490 
2491  //**Data access functions***********************************************************************
2494  inline Reference operator[]( size_t index );
2495  inline ConstReference operator[]( size_t index ) const;
2496  inline Reference at( size_t index );
2497  inline ConstReference at( size_t index ) const;
2498  inline Pointer data ();
2499  inline ConstPointer data () const;
2500  inline Iterator begin ();
2501  inline ConstIterator begin () const;
2502  inline ConstIterator cbegin() const;
2503  inline Iterator end ();
2504  inline ConstIterator end () const;
2505  inline ConstIterator cend () const;
2507  //**********************************************************************************************
2508 
2509  //**Assignment operators************************************************************************
2512  inline DenseRow& operator=( const ElementType& rhs );
2513  inline DenseRow& operator=( const DenseRow& rhs );
2514 
2515  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
2516  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
2517  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
2518  template< typename VT > inline DenseRow& operator*=( const DenseVector<VT,true>& rhs );
2519  template< typename VT > inline DenseRow& operator*=( const SparseVector<VT,true>& rhs );
2520 
2521  template< typename Other >
2522  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2523  operator*=( Other rhs );
2524 
2525  template< typename Other >
2526  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
2527  operator/=( Other rhs );
2529  //**********************************************************************************************
2530 
2531  //**Utility functions***************************************************************************
2534  inline size_t size() const;
2535  inline size_t capacity() const;
2536  inline size_t nonZeros() const;
2537  inline void reset();
2538  template< typename Other > inline DenseRow& scale( const Other& scalar );
2540  //**********************************************************************************************
2541 
2542  public:
2543  //**Expression template evaluation functions****************************************************
2546  template< typename Other >
2547  inline bool canAlias( const Other* alias ) const;
2548 
2549  template< typename MT2, bool SO2, bool SF2 >
2550  inline bool canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const;
2551 
2552  template< typename Other >
2553  inline bool isAliased( const Other* alias ) const;
2554 
2555  template< typename MT2, bool SO2, bool SF2 >
2556  inline bool isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const;
2557 
2558  inline bool isAligned () const;
2559  inline bool canSMPAssign() const;
2560 
2561  template< typename VT > inline void assign ( const DenseVector <VT,true>& rhs );
2562  template< typename VT > inline void assign ( const SparseVector<VT,true>& rhs );
2563  template< typename VT > inline void addAssign ( const DenseVector <VT,true>& rhs );
2564  template< typename VT > inline void addAssign ( const SparseVector<VT,true>& rhs );
2565  template< typename VT > inline void subAssign ( const DenseVector <VT,true>& rhs );
2566  template< typename VT > inline void subAssign ( const SparseVector<VT,true>& rhs );
2567  template< typename VT > inline void multAssign( const DenseVector <VT,true>& rhs );
2568  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
2570  //**********************************************************************************************
2571 
2572  private:
2573  //**Member variables****************************************************************************
2576  Operand matrix_;
2577  const size_t row_;
2578 
2579  //**********************************************************************************************
2580 
2581  //**Friend declarations*************************************************************************
2582  template< typename MT2, bool SO2, bool SF2 > friend class DenseRow;
2583 
2584  template< typename MT2, bool SO2, bool SF2 >
2585  friend bool isIntact( const DenseRow<MT2,SO2,SF2>& row );
2586 
2587  template< typename MT2, bool SO2, bool SF2 >
2588  friend bool isSame( const DenseRow<MT2,SO2,SF2>& a, const DenseRow<MT2,SO2,SF2>& b );
2589 
2590  template< typename MT2, bool SO2, bool SF2, typename VT >
2591  friend bool tryAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2592 
2593  template< typename MT2, bool SO2, bool SF2, typename VT >
2594  friend bool tryAddAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2595 
2596  template< typename MT2, bool SO2, bool SF2, typename VT >
2597  friend bool trySubAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2598 
2599  template< typename MT2, bool SO2, bool SF2, typename VT >
2600  friend bool tryMultAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
2601 
2602  template< typename MT2, bool SO2, bool SF2 >
2603  friend typename DerestrictTrait< DenseRow<MT2,SO2,SF2> >::Type
2604  derestrict( DenseRow<MT2,SO2,SF2>& dm );
2605  //**********************************************************************************************
2606 
2607  //**Compile time checks*************************************************************************
2615  //**********************************************************************************************
2616 };
2618 //*************************************************************************************************
2619 
2620 
2621 
2622 
2623 //=================================================================================================
2624 //
2625 // CONSTRUCTOR
2626 //
2627 //=================================================================================================
2628 
2629 //*************************************************************************************************
2637 template< typename MT > // Type of the dense matrix
2638 inline DenseRow<MT,false,false>::DenseRow( MT& matrix, size_t index )
2639  : matrix_( matrix ) // The dense matrix containing the row
2640  , row_ ( index ) // The index of the row in the matrix
2641 {
2642  if( matrix_.rows() <= index ) {
2643  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
2644  }
2645 }
2647 //*************************************************************************************************
2648 
2649 
2650 
2651 
2652 //=================================================================================================
2653 //
2654 // DATA ACCESS FUNCTIONS
2655 //
2656 //=================================================================================================
2657 
2658 //*************************************************************************************************
2668 template< typename MT > // Type of the dense matrix
2670  DenseRow<MT,false,false>::operator[]( size_t index )
2671 {
2672  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2673  return matrix_(row_,index);
2674 }
2676 //*************************************************************************************************
2677 
2678 
2679 //*************************************************************************************************
2689 template< typename MT > // Type of the dense matrix
2691  DenseRow<MT,false,false>::operator[]( size_t index ) const
2692 {
2693  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
2694  return const_cast<const MT&>( matrix_ )(row_,index);
2695 }
2697 //*************************************************************************************************
2698 
2699 
2700 //*************************************************************************************************
2711 template< typename MT > // Type of the dense matrix
2713  DenseRow<MT,false,false>::at( size_t index )
2714 {
2715  if( index >= size() ) {
2716  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2717  }
2718  return (*this)[index];
2719 }
2721 //*************************************************************************************************
2722 
2723 
2724 //*************************************************************************************************
2735 template< typename MT > // Type of the dense matrix
2737  DenseRow<MT,false,false>::at( size_t index ) const
2738 {
2739  if( index >= size() ) {
2740  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
2741  }
2742  return (*this)[index];
2743 }
2745 //*************************************************************************************************
2746 
2747 
2748 //*************************************************************************************************
2757 template< typename MT > // Type of the dense matrix
2758 inline typename DenseRow<MT,false,false>::Pointer DenseRow<MT,false,false>::data()
2759 {
2760  return matrix_.data() + row_;
2761 }
2763 //*************************************************************************************************
2764 
2765 
2766 //*************************************************************************************************
2775 template< typename MT > // Type of the dense matrix
2776 inline typename DenseRow<MT,false,false>::ConstPointer DenseRow<MT,false,false>::data() const
2777 {
2778  return matrix_.data() + row_;
2779 }
2781 //*************************************************************************************************
2782 
2783 
2784 //*************************************************************************************************
2792 template< typename MT > // Type of the dense matrix
2794 {
2795  return Iterator( matrix_, row_, 0UL );
2796 }
2798 //*************************************************************************************************
2799 
2800 
2801 //*************************************************************************************************
2809 template< typename MT > // Type of the dense matrix
2811 {
2812  return ConstIterator( matrix_, row_, 0UL );
2813 }
2815 //*************************************************************************************************
2816 
2817 
2818 //*************************************************************************************************
2826 template< typename MT > // Type of the dense matrix
2828 {
2829  return ConstIterator( matrix_, row_, 0UL );
2830 }
2832 //*************************************************************************************************
2833 
2834 
2835 //*************************************************************************************************
2843 template< typename MT > // Type of the dense matrix
2845 {
2846  return Iterator( matrix_, row_, size() );
2847 }
2849 //*************************************************************************************************
2850 
2851 
2852 //*************************************************************************************************
2860 template< typename MT > // Type of the dense matrix
2862 {
2863  return ConstIterator( matrix_, row_, size() );
2864 }
2866 //*************************************************************************************************
2867 
2868 
2869 //*************************************************************************************************
2877 template< typename MT > // Type of the dense matrix
2879 {
2880  return ConstIterator( matrix_, row_, size() );
2881 }
2883 //*************************************************************************************************
2884 
2885 
2886 
2887 
2888 //=================================================================================================
2889 //
2890 // ASSIGNMENT OPERATORS
2891 //
2892 //=================================================================================================
2893 
2894 //*************************************************************************************************
2905 template< typename MT > // Type of the dense matrix
2906 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator=( const ElementType& rhs )
2907 {
2908  const size_t jbegin( ( IsUpper<MT>::value )
2909  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
2910  ?( row_+1UL )
2911  :( row_ ) )
2912  :( 0UL ) );
2913  const size_t jend ( ( IsLower<MT>::value )
2914  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
2915  ?( row_ )
2916  :( row_+1UL ) )
2917  :( size() ) );
2918 
2919  for( size_t j=jbegin; j<jend; ++j )
2920  matrix_(row_,j) = rhs;
2921 
2922  return *this;
2923 }
2925 //*************************************************************************************************
2926 
2927 
2928 //*************************************************************************************************
2942 template< typename MT > // Type of the dense matrix
2943 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator=( const DenseRow& rhs )
2944 {
2945  if( &rhs == this ) return *this;
2946 
2947  if( size() != rhs.size() ) {
2948  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
2949  }
2950 
2951  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
2952  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2953  }
2954 
2955  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
2956 
2957  smpAssign( left, rhs );
2958 
2959  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
2960 
2961  return *this;
2962 }
2964 //*************************************************************************************************
2965 
2966 
2967 //*************************************************************************************************
2981 template< typename MT > // Type of the dense matrix
2982 template< typename VT > // Type of the right-hand side vector
2983 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator=( const Vector<VT,true>& rhs )
2984 {
2988 
2989  if( size() != (~rhs).size() ) {
2990  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
2991  }
2992 
2993  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
2994  Right right( ~rhs );
2995 
2996  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
2997  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
2998  }
2999 
3000  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
3001 
3002  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3003  const ResultType tmp( right );
3004  smpAssign( left, tmp );
3005  }
3006  else {
3007  if( IsSparseVector<VT>::value )
3008  reset();
3009  smpAssign( left, right );
3010  }
3011 
3012  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3013 
3014  return *this;
3015 }
3017 //*************************************************************************************************
3018 
3019 
3020 //*************************************************************************************************
3034 template< typename MT > // Type of the dense matrix
3035 template< typename VT > // Type of the right-hand side vector
3036 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator+=( const Vector<VT,true>& rhs )
3037 {
3040 
3041  if( size() != (~rhs).size() ) {
3042  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3043  }
3044 
3045  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
3046  Right right( ~rhs );
3047 
3048  if( !tryAddAssign( matrix_, right, row_, 0UL ) ) {
3049  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3050  }
3051 
3052  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
3053 
3054  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3055  const typename VT::ResultType tmp( right );
3056  smpAddAssign( left, tmp );
3057  }
3058  else {
3059  smpAddAssign( left, right );
3060  }
3061 
3062  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3063 
3064  return *this;
3065 }
3067 //*************************************************************************************************
3068 
3069 
3070 //*************************************************************************************************
3084 template< typename MT > // Type of the dense matrix
3085 template< typename VT > // Type of the right-hand side vector
3086 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator-=( const Vector<VT,true>& rhs )
3087 {
3090 
3091  if( size() != (~rhs).size() ) {
3092  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3093  }
3094 
3095  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
3096  Right right( ~rhs );
3097 
3098  if( !trySubAssign( matrix_, right, row_, 0UL ) ) {
3099  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3100  }
3101 
3102  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
3103 
3104  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3105  const typename VT::ResultType tmp( right );
3106  smpSubAssign( left, tmp );
3107  }
3108  else {
3109  smpSubAssign( left, right );
3110  }
3111 
3112  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3113 
3114  return *this;
3115 }
3117 //*************************************************************************************************
3118 
3119 
3120 //*************************************************************************************************
3133 template< typename MT > // Type of the dense matrix
3134 template< typename VT > // Type of the right-hand side dense vector
3135 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator*=( const DenseVector<VT,true>& rhs )
3136 {
3139 
3140  if( size() != (~rhs).size() ) {
3141  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3142  }
3143 
3144  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
3145  Right right( ~rhs );
3146 
3147  if( !tryMultAssign( matrix_, right, row_, 0UL ) ) {
3148  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3149  }
3150 
3151  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
3152 
3153  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
3154  const typename VT::ResultType tmp( right );
3155  smpMultAssign( left, tmp );
3156  }
3157  else {
3158  smpMultAssign( left, right );
3159  }
3160 
3161  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3162 
3163  return *this;
3164 }
3166 //*************************************************************************************************
3167 
3168 
3169 //*************************************************************************************************
3182 template< typename MT > // Type of the dense matrix
3183 template< typename VT > // Type of the right-hand side sparse vector
3184 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::operator*=( const SparseVector<VT,true>& rhs )
3185 {
3189 
3190  if( size() != (~rhs).size() ) {
3191  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
3192  }
3193 
3194  const ResultType right( *this * (~rhs) );
3195 
3196  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
3197  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
3198  }
3199 
3200  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
3201 
3202  smpAssign( left, right );
3203 
3204  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
3205 
3206  return *this;
3207 }
3209 //*************************************************************************************************
3210 
3211 
3212 //*************************************************************************************************
3223 template< typename MT > // Type of the dense matrix
3224 template< typename Other > // Data type of the right-hand side scalar
3225 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false,false> >::Type&
3226  DenseRow<MT,false,false>::operator*=( Other rhs )
3227 {
3229 
3230  return operator=( (*this) * rhs );
3231 }
3233 //*************************************************************************************************
3234 
3235 
3236 //*************************************************************************************************
3249 template< typename MT > // Type of the dense matrix
3250 template< typename Other > // Data type of the right-hand side scalar
3251 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false,false> >::Type&
3252  DenseRow<MT,false,false>::operator/=( Other rhs )
3253 {
3255 
3256  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3257 
3258  return operator=( (*this) / rhs );
3259 }
3261 //*************************************************************************************************
3262 
3263 
3264 
3265 
3266 //=================================================================================================
3267 //
3268 // UTILITY FUNCTIONS
3269 //
3270 //=================================================================================================
3271 
3272 //*************************************************************************************************
3278 template< typename MT > // Type of the dense matrix
3279 inline size_t DenseRow<MT,false,false>::size() const
3280 {
3281  return matrix_.columns();
3282 }
3284 //*************************************************************************************************
3285 
3286 
3287 //*************************************************************************************************
3293 template< typename MT > // Type of the dense matrix
3294 inline size_t DenseRow<MT,false,false>::capacity() const
3295 {
3296  return matrix_.columns();
3297 }
3299 //*************************************************************************************************
3300 
3301 
3302 //*************************************************************************************************
3311 template< typename MT > // Type of the dense matrix
3312 inline size_t DenseRow<MT,false,false>::nonZeros() const
3313 {
3314  const size_t columns( size() );
3315  size_t nonzeros( 0UL );
3316 
3317  for( size_t j=0UL; j<columns; ++j )
3318  if( !isDefault( matrix_(row_,j) ) )
3319  ++nonzeros;
3320 
3321  return nonzeros;
3322 }
3324 //*************************************************************************************************
3325 
3326 
3327 //*************************************************************************************************
3333 template< typename MT > // Type of the dense matrix
3334 inline void DenseRow<MT,false,false>::reset()
3335 {
3336  using blaze::clear;
3337 
3338  const size_t jbegin( ( IsUpper<MT>::value )
3339  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
3340  ?( row_+1UL )
3341  :( row_ ) )
3342  :( 0UL ) );
3343  const size_t jend ( ( IsLower<MT>::value )
3344  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
3345  ?( row_ )
3346  :( row_+1UL ) )
3347  :( size() ) );
3348 
3349  for( size_t j=jbegin; j<jend; ++j )
3350  clear( matrix_(row_,j) );
3351 }
3353 //*************************************************************************************************
3354 
3355 
3356 //*************************************************************************************************
3367 template< typename MT > // Type of the dense matrix
3368 template< typename Other > // Data type of the scalar value
3369 inline DenseRow<MT,false,false>& DenseRow<MT,false,false>::scale( const Other& scalar )
3370 {
3372 
3373  const size_t jbegin( ( IsUpper<MT>::value )
3374  ?( ( IsStrictlyUpper<MT>::value )
3375  ?( row_+1UL )
3376  :( row_ ) )
3377  :( 0UL ) );
3378  const size_t jend ( ( IsLower<MT>::value )
3379  ?( ( IsStrictlyLower<MT>::value )
3380  ?( row_ )
3381  :( row_+1UL ) )
3382  :( size() ) );
3383 
3384  for( size_t j=jbegin; j<jend; ++j ) {
3385  matrix_(row_,j) *= scalar;
3386  }
3387 
3388  return *this;
3389 }
3391 //*************************************************************************************************
3392 
3393 
3394 
3395 
3396 //=================================================================================================
3397 //
3398 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3399 //
3400 //=================================================================================================
3401 
3402 //*************************************************************************************************
3413 template< typename MT > // Type of the dense matrix
3414 template< typename Other > // Data type of the foreign expression
3415 inline bool DenseRow<MT,false,false>::canAlias( const Other* alias ) const
3416 {
3417  return matrix_.isAliased( alias );
3418 }
3420 //*************************************************************************************************
3421 
3422 
3423 //*************************************************************************************************
3434 template< typename MT > // Type of the dense matrix
3435 template< typename MT2 // Data type of the foreign dense row
3436  , bool SO2 // Storage order of the foreign dense row
3437  , bool SF2 > // Symmetry flag of the foreign dense row
3438 inline bool DenseRow<MT,false,false>::canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const
3439 {
3440  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
3441 }
3443 //*************************************************************************************************
3444 
3445 
3446 //*************************************************************************************************
3457 template< typename MT > // Type of the dense matrix
3458 template< typename Other > // Data type of the foreign expression
3459 inline bool DenseRow<MT,false,false>::isAliased( const Other* alias ) const
3460 {
3461  return matrix_.isAliased( alias );
3462 }
3464 //*************************************************************************************************
3465 
3466 
3467 //*************************************************************************************************
3478 template< typename MT > // Type of the dense matrix
3479 template< typename MT2 // Data type of the foreign dense row
3480  , bool SO2 // Storage order of the foreign dense row
3481  , bool SF2 > // Symmetry flag of the foreign dense row
3482 inline bool DenseRow<MT,false,false>::isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const
3483 {
3484  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
3485 }
3487 //*************************************************************************************************
3488 
3489 
3490 //*************************************************************************************************
3500 template< typename MT > // Type of the dense matrix
3501 inline bool DenseRow<MT,false,false>::isAligned() const
3502 {
3503  return false;
3504 }
3506 //*************************************************************************************************
3507 
3508 
3509 //*************************************************************************************************
3520 template< typename MT > // Type of the dense matrix
3521 inline bool DenseRow<MT,false,false>::canSMPAssign() const
3522 {
3523  return ( size() > SMP_DVECASSIGN_THRESHOLD );
3524 }
3526 //*************************************************************************************************
3527 
3528 
3529 //*************************************************************************************************
3541 template< typename MT > // Type of the dense matrix
3542 template< typename VT > // Type of the right-hand side dense vector
3543 inline void DenseRow<MT,false,false>::assign( const DenseVector<VT,true>& rhs )
3544 {
3545  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3546 
3547  const size_t jpos( (~rhs).size() & size_t(-2) );
3548  for( size_t j=0UL; j<jpos; j+=2UL ) {
3549  matrix_(row_,j ) = (~rhs)[j ];
3550  matrix_(row_,j+1UL) = (~rhs)[j+1UL];
3551  }
3552  if( jpos < (~rhs).size() )
3553  matrix_(row_,jpos) = (~rhs)[jpos];
3554 }
3556 //*************************************************************************************************
3557 
3558 
3559 //*************************************************************************************************
3571 template< typename MT > // Type of the dense matrix
3572 template< typename VT > // Type of the right-hand side sparse vector
3573 inline void DenseRow<MT,false,false>::assign( const SparseVector<VT,true>& rhs )
3574 {
3575  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3576 
3577  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3578  matrix_(row_,element->index()) = element->value();
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3596 template< typename MT > // Type of the dense matrix
3597 template< typename VT > // Type of the right-hand side dense vector
3598 inline void DenseRow<MT,false,false>::addAssign( const DenseVector<VT,true>& rhs )
3599 {
3600  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3601 
3602  const size_t jpos( (~rhs).size() & size_t(-2) );
3603  for( size_t j=0UL; j<jpos; j+=2UL ) {
3604  matrix_(row_,j ) += (~rhs)[j ];
3605  matrix_(row_,j+1UL) += (~rhs)[j+1UL];
3606  }
3607  if( jpos < (~rhs).size() )
3608  matrix_(row_,jpos) += (~rhs)[jpos];
3609 }
3611 //*************************************************************************************************
3612 
3613 
3614 //*************************************************************************************************
3626 template< typename MT > // Type of the dense matrix
3627 template< typename VT > // Type of the right-hand side sparse vector
3628 inline void DenseRow<MT,false,false>::addAssign( const SparseVector<VT,true>& rhs )
3629 {
3630  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3631 
3632  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3633  matrix_(row_,element->index()) += element->value();
3634 }
3636 //*************************************************************************************************
3637 
3638 
3639 //*************************************************************************************************
3651 template< typename MT > // Type of the dense matrix
3652 template< typename VT > // Type of the right-hand side dense vector
3653 inline void DenseRow<MT,false,false>::subAssign( const DenseVector<VT,true>& rhs )
3654 {
3655  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3656 
3657  const size_t jpos( (~rhs).size() & size_t(-2) );
3658  for( size_t j=0UL; j<jpos; j+=2UL ) {
3659  matrix_(row_,j ) -= (~rhs)[j ];
3660  matrix_(row_,j+1UL) -= (~rhs)[j+1UL];
3661  }
3662  if( jpos < (~rhs).size() )
3663  matrix_(row_,jpos) -= (~rhs)[jpos];
3664 }
3666 //*************************************************************************************************
3667 
3668 
3669 //*************************************************************************************************
3681 template< typename MT > // Type of the dense matrix
3682 template< typename VT > // Type of the right-hand side sparse vector
3683 inline void DenseRow<MT,false,false>::subAssign( const SparseVector<VT,true>& rhs )
3684 {
3685  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3686 
3687  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3688  matrix_(row_,element->index()) -= element->value();
3689 }
3691 //*************************************************************************************************
3692 
3693 
3694 //*************************************************************************************************
3706 template< typename MT > // Type of the dense matrix
3707 template< typename VT > // Type of the right-hand side dense vector
3708 inline void DenseRow<MT,false,false>::multAssign( const DenseVector<VT,true>& rhs )
3709 {
3710  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3711 
3712  const size_t jpos( (~rhs).size() & size_t(-2) );
3713  for( size_t j=0UL; j<jpos; j+=2UL ) {
3714  matrix_(row_,j ) *= (~rhs)[j ];
3715  matrix_(row_,j+1UL) *= (~rhs)[j+1UL];
3716  }
3717  if( jpos < (~rhs).size() )
3718  matrix_(row_,jpos) *= (~rhs)[jpos];
3719 }
3721 //*************************************************************************************************
3722 
3723 
3724 //*************************************************************************************************
3736 template< typename MT > // Type of the dense matrix
3737 template< typename VT > // Type of the right-hand side sparse vector
3738 inline void DenseRow<MT,false,false>::multAssign( const SparseVector<VT,true>& rhs )
3739 {
3740  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
3741 
3742  const ResultType tmp( serial( *this ) );
3743 
3744  reset();
3745 
3746  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
3747  matrix_(row_,element->index()) = tmp[element->index()] * element->value();
3748 }
3750 //*************************************************************************************************
3751 
3752 
3753 
3754 
3755 
3756 
3757 
3758 
3759 //=================================================================================================
3760 //
3761 // CLASS TEMPLATE SPECIALIZATION FOR SYMMETRIC COLUMN-MAJOR MATRICES
3762 //
3763 //=================================================================================================
3764 
3765 //*************************************************************************************************
3773 template< typename MT > // Type of the dense matrix
3774 class DenseRow<MT,false,true> : public DenseVector< DenseRow<MT,false,true>, true >
3775  , private Row
3776 {
3777  private:
3778  //**Type definitions****************************************************************************
3780  typedef typename If< IsExpression<MT>, MT, MT& >::Type Operand;
3781 
3783  typedef IntrinsicTrait<typename MT::ElementType> IT;
3784  //**********************************************************************************************
3785 
3786  public:
3787  //**Type definitions****************************************************************************
3788  typedef DenseRow<MT,false,true> This;
3789  typedef typename RowTrait<MT>::Type ResultType;
3790  typedef typename ResultType::TransposeType TransposeType;
3791  typedef typename MT::ElementType ElementType;
3792  typedef typename IT::Type IntrinsicType;
3793  typedef typename MT::ReturnType ReturnType;
3794  typedef const DenseRow& CompositeType;
3795 
3797  typedef typename MT::ConstReference ConstReference;
3798 
3800  typedef typename If< IsConst<MT>, ConstReference, typename MT::Reference >::Type Reference;
3801 
3803  typedef const ElementType* ConstPointer;
3804 
3806  typedef typename If< Or< IsConst<MT>, Not< HasMutableDataAccess<MT> > >
3807  , ConstPointer, ElementType* >::Type Pointer;
3808 
3810  typedef typename MT::ConstIterator ConstIterator;
3811 
3813  typedef typename If< IsConst<MT>, ConstIterator, typename MT::Iterator >::Type Iterator;
3814  //**********************************************************************************************
3815 
3816  //**Compilation flags***************************************************************************
3818  enum { vectorizable = MT::vectorizable };
3819 
3821  enum { smpAssignable = MT::smpAssignable };
3822  //**********************************************************************************************
3823 
3824  //**Constructors********************************************************************************
3827  explicit inline DenseRow( MT& matrix, size_t index );
3828  // No explicitly declared copy constructor.
3830  //**********************************************************************************************
3831 
3832  //**Destructor**********************************************************************************
3833  // No explicitly declared destructor.
3834  //**********************************************************************************************
3835 
3836  //**Data access functions***********************************************************************
3839  inline Reference operator[]( size_t index );
3840  inline ConstReference operator[]( size_t index ) const;
3841  inline Reference at( size_t index );
3842  inline ConstReference at( size_t index ) const;
3843  inline Pointer data ();
3844  inline ConstPointer data () const;
3845  inline Iterator begin ();
3846  inline ConstIterator begin () const;
3847  inline ConstIterator cbegin() const;
3848  inline Iterator end ();
3849  inline ConstIterator end () const;
3850  inline ConstIterator cend () const;
3852  //**********************************************************************************************
3853 
3854  //**Assignment operators************************************************************************
3857  inline DenseRow& operator=( const ElementType& rhs );
3858  inline DenseRow& operator=( const DenseRow& rhs );
3859 
3860  template< typename VT > inline DenseRow& operator= ( const Vector<VT,true>& rhs );
3861  template< typename VT > inline DenseRow& operator+=( const Vector<VT,true>& rhs );
3862  template< typename VT > inline DenseRow& operator-=( const Vector<VT,true>& rhs );
3863  template< typename VT > inline DenseRow& operator*=( const DenseVector<VT,true>& rhs );
3864  template< typename VT > inline DenseRow& operator*=( const SparseVector<VT,true>& rhs );
3865 
3866  template< typename Other >
3867  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
3868  operator*=( Other rhs );
3869 
3870  template< typename Other >
3871  inline typename EnableIf< IsNumeric<Other>, DenseRow >::Type&
3872  operator/=( Other rhs );
3874  //**********************************************************************************************
3875 
3876  //**Utility functions***************************************************************************
3879  inline size_t size() const;
3880  inline size_t capacity() const;
3881  inline size_t nonZeros() const;
3882  inline void reset();
3883  template< typename Other > inline DenseRow& scale( const Other& scalar );
3885  //**********************************************************************************************
3886 
3887  private:
3888  //**********************************************************************************************
3890  template< typename VT >
3891  struct VectorizedAssign {
3892  enum { value = useOptimizedKernels &&
3893  vectorizable && VT::vectorizable &&
3894  IsSame<ElementType,typename VT::ElementType>::value };
3895  };
3896  //**********************************************************************************************
3897 
3898  //**********************************************************************************************
3900  template< typename VT >
3901  struct VectorizedAddAssign {
3902  enum { value = useOptimizedKernels &&
3903  vectorizable && VT::vectorizable &&
3904  IsSame<ElementType,typename VT::ElementType>::value &&
3905  IntrinsicTrait<ElementType>::addition };
3906  };
3907  //**********************************************************************************************
3908 
3909  //**********************************************************************************************
3911  template< typename VT >
3912  struct VectorizedSubAssign {
3913  enum { value = useOptimizedKernels &&
3914  vectorizable && VT::vectorizable &&
3915  IsSame<ElementType,typename VT::ElementType>::value &&
3916  IntrinsicTrait<ElementType>::subtraction };
3917  };
3918  //**********************************************************************************************
3919 
3920  //**********************************************************************************************
3922  template< typename VT >
3923  struct VectorizedMultAssign {
3924  enum { value = useOptimizedKernels &&
3925  vectorizable && VT::vectorizable &&
3926  IsSame<ElementType,typename VT::ElementType>::value &&
3927  IntrinsicTrait<ElementType>::multiplication };
3928  };
3929  //**********************************************************************************************
3930 
3931  public:
3932  //**Expression template evaluation functions****************************************************
3935  template< typename Other >
3936  inline bool canAlias( const Other* alias ) const;
3937 
3938  template< typename MT2, bool SO2, bool SF2 >
3939  inline bool canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const;
3940 
3941  template< typename Other >
3942  inline bool isAliased( const Other* alias ) const;
3943 
3944  template< typename MT2, bool SO2, bool SF2 >
3945  inline bool isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const;
3946 
3947  inline bool isAligned () const;
3948  inline bool canSMPAssign() const;
3949 
3950  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t index ) const;
3951  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t index ) const;
3952  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t index ) const;
3953 
3954  BLAZE_ALWAYS_INLINE void store ( size_t index, const IntrinsicType& value );
3955  BLAZE_ALWAYS_INLINE void storea( size_t index, const IntrinsicType& value );
3956  BLAZE_ALWAYS_INLINE void storeu( size_t index, const IntrinsicType& value );
3957  BLAZE_ALWAYS_INLINE void stream( size_t index, const IntrinsicType& value );
3958 
3959  template< typename VT >
3960  inline typename DisableIf< VectorizedAssign<VT> >::Type
3961  assign( const DenseVector<VT,true>& rhs );
3962 
3963  template< typename VT >
3964  inline typename EnableIf< VectorizedAssign<VT> >::Type
3965  assign( const DenseVector<VT,true>& rhs );
3966 
3967  template< typename VT > inline void assign( const SparseVector<VT,true>& rhs );
3968 
3969  template< typename VT >
3970  inline typename DisableIf< VectorizedAddAssign<VT> >::Type
3971  addAssign( const DenseVector<VT,true>& rhs );
3972 
3973  template< typename VT >
3974  inline typename EnableIf< VectorizedAddAssign<VT> >::Type
3975  addAssign( const DenseVector<VT,true>& rhs );
3976 
3977  template< typename VT > inline void addAssign( const SparseVector<VT,true>& rhs );
3978 
3979  template< typename VT >
3980  inline typename DisableIf< VectorizedSubAssign<VT> >::Type
3981  subAssign( const DenseVector<VT,true>& rhs );
3982 
3983  template< typename VT >
3984  inline typename EnableIf< VectorizedSubAssign<VT> >::Type
3985  subAssign( const DenseVector<VT,true>& rhs );
3986 
3987  template< typename VT > inline void subAssign( const SparseVector<VT,true>& rhs );
3988 
3989  template< typename VT >
3990  inline typename DisableIf< VectorizedMultAssign<VT> >::Type
3991  multAssign( const DenseVector<VT,true>& rhs );
3992 
3993  template< typename VT >
3994  inline typename EnableIf< VectorizedMultAssign<VT> >::Type
3995  multAssign( const DenseVector<VT,true>& rhs );
3996 
3997  template< typename VT > inline void multAssign( const SparseVector<VT,true>& rhs );
3999  //**********************************************************************************************
4000 
4001  private:
4002  //**Member variables****************************************************************************
4005  Operand matrix_;
4006  const size_t row_;
4007 
4008  //**********************************************************************************************
4009 
4010  //**Friend declarations*************************************************************************
4011  template< typename MT2, bool SO2, bool SF2 > friend class DenseRow;
4012 
4013  template< typename MT2, bool SO2, bool SF2 >
4014  friend bool isIntact( const DenseRow<MT2,SO2,SF2>& row );
4015 
4016  template< typename MT2, bool SO2, bool SF2 >
4017  friend bool isSame( const DenseRow<MT2,SO2,SF2>& a, const DenseRow<MT2,SO2,SF2>& b );
4018 
4019  template< typename MT2, bool SO2, bool SF2, typename VT >
4020  friend bool tryAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4021 
4022  template< typename MT2, bool SO2, bool SF2, typename VT >
4023  friend bool tryAddAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4024 
4025  template< typename MT2, bool SO2, bool SF2, typename VT >
4026  friend bool trySubAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4027 
4028  template< typename MT2, bool SO2, bool SF2, typename VT >
4029  friend bool tryMultAssign( const DenseRow<MT2,SO2,SF2>& lhs, const Vector<VT,true>& rhs, size_t index );
4030 
4031  template< typename MT2, bool SO2, bool SF2 >
4032  friend typename DerestrictTrait< DenseRow<MT2,SO2,SF2> >::Type
4033  derestrict( DenseRow<MT2,SO2,SF2>& dm );
4034  //**********************************************************************************************
4035 
4036  //**Compile time checks*************************************************************************
4044  //**********************************************************************************************
4045 };
4047 //*************************************************************************************************
4048 
4049 
4050 
4051 
4052 //=================================================================================================
4053 //
4054 // CONSTRUCTOR
4055 //
4056 //=================================================================================================
4057 
4058 //*************************************************************************************************
4066 template< typename MT > // Type of the dense matrix
4067 inline DenseRow<MT,false,true>::DenseRow( MT& matrix, size_t index )
4068  : matrix_( matrix ) // The dense matrix containing the row
4069  , row_ ( index ) // The index of the row in the matrix
4070 {
4071  if( matrix_.rows() <= index ) {
4072  BLAZE_THROW_INVALID_ARGUMENT( "Invalid row access index" );
4073  }
4074 }
4076 //*************************************************************************************************
4077 
4078 
4079 
4080 
4081 //=================================================================================================
4082 //
4083 // DATA ACCESS FUNCTIONS
4084 //
4085 //=================================================================================================
4086 
4087 //*************************************************************************************************
4097 template< typename MT > // Type of the dense matrix
4098 inline typename DenseRow<MT,false,true>::Reference
4099  DenseRow<MT,false,true>::operator[]( size_t index )
4100 {
4101  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
4102  return matrix_(index,row_);
4103 }
4105 //*************************************************************************************************
4106 
4107 
4108 //*************************************************************************************************
4118 template< typename MT > // Type of the dense matrix
4120  DenseRow<MT,false,true>::operator[]( size_t index ) const
4121 {
4122  BLAZE_USER_ASSERT( index < size(), "Invalid row access index" );
4123  return const_cast<const MT&>( matrix_ )(row_,index);
4124 }
4126 //*************************************************************************************************
4127 
4128 
4129 //*************************************************************************************************
4140 template< typename MT > // Type of the dense matrix
4141 inline typename DenseRow<MT,false,true>::Reference
4142  DenseRow<MT,false,true>::at( size_t index )
4143 {
4144  if( index >= size() ) {
4145  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4146  }
4147  return (*this)[index];
4148 }
4150 //*************************************************************************************************
4151 
4152 
4153 //*************************************************************************************************
4164 template< typename MT > // Type of the dense matrix
4166  DenseRow<MT,false,true>::at( size_t index ) const
4167 {
4168  if( index >= size() ) {
4169  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4170  }
4171  return (*this)[index];
4172 }
4174 //*************************************************************************************************
4175 
4176 
4177 //*************************************************************************************************
4186 template< typename MT > // Type of the dense matrix
4187 inline typename DenseRow<MT,false,true>::Pointer DenseRow<MT,false,true>::data()
4188 {
4189  return matrix_.data( row_ );
4190 }
4192 //*************************************************************************************************
4193 
4194 
4195 //*************************************************************************************************
4204 template< typename MT > // Type of the dense matrix
4205 inline typename DenseRow<MT,false,true>::ConstPointer DenseRow<MT,false,true>::data() const
4206 {
4207  return matrix_.data( row_ );
4208 }
4210 //*************************************************************************************************
4211 
4212 
4213 //*************************************************************************************************
4221 template< typename MT > // Type of the dense matrix
4223 {
4224  return matrix_.begin( row_ );
4225 }
4227 //*************************************************************************************************
4228 
4229 
4230 //*************************************************************************************************
4238 template< typename MT > // Type of the dense matrix
4240 {
4241  return matrix_.cbegin( row_ );
4242 }
4244 //*************************************************************************************************
4245 
4246 
4247 //*************************************************************************************************
4255 template< typename MT > // Type of the dense matrix
4257 {
4258  return matrix_.cbegin( row_ );
4259 }
4261 //*************************************************************************************************
4262 
4263 
4264 //*************************************************************************************************
4272 template< typename MT > // Type of the dense matrix
4274 {
4275  return matrix_.end( row_ );
4276 }
4278 //*************************************************************************************************
4279 
4280 
4281 //*************************************************************************************************
4289 template< typename MT > // Type of the dense matrix
4291 {
4292  return matrix_.cend( row_ );
4293 }
4295 //*************************************************************************************************
4296 
4297 
4298 //*************************************************************************************************
4306 template< typename MT > // Type of the dense matrix
4308 {
4309  return matrix_.cend( row_ );
4310 }
4312 //*************************************************************************************************
4313 
4314 
4315 
4316 
4317 //=================================================================================================
4318 //
4319 // ASSIGNMENT OPERATORS
4320 //
4321 //=================================================================================================
4322 
4323 //*************************************************************************************************
4330 template< typename MT > // Type of the dense matrix
4331 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator=( const ElementType& rhs )
4332 {
4333  const size_t ibegin( ( IsLower<MT>::value )
4334  ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4335  ?( row_+1UL )
4336  :( row_ ) )
4337  :( 0UL ) );
4338  const size_t iend ( ( IsUpper<MT>::value )
4339  ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4340  ?( row_ )
4341  :( row_+1UL ) )
4342  :( size() ) );
4343 
4344  for( size_t i=ibegin; i<iend; ++i )
4345  matrix_(i,row_) = rhs;
4346 
4347  return *this;
4348 }
4350 //*************************************************************************************************
4351 
4352 
4353 //*************************************************************************************************
4367 template< typename MT > // Type of the dense matrix
4368 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator=( const DenseRow& rhs )
4369 {
4370  if( &rhs == this ) return *this;
4371 
4372  if( size() != rhs.size() ) {
4373  BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
4374  }
4375 
4376  if( !tryAssign( matrix_, rhs, row_, 0UL ) ) {
4377  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4378  }
4379 
4380  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4381 
4382  smpAssign( left, rhs );
4383 
4384  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4385 
4386  return *this;
4387 }
4389 //*************************************************************************************************
4390 
4391 
4392 //*************************************************************************************************
4406 template< typename MT > // Type of the dense matrix
4407 template< typename VT > // Type of the right-hand side vector
4408 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator=( const Vector<VT,true>& rhs )
4409 {
4412 
4413  if( size() != (~rhs).size() ) {
4414  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4415  }
4416 
4417  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
4418  Right right( ~rhs );
4419 
4420  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4421  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4422  }
4423 
4424  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4425 
4426  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4427  const typename VT::ResultType tmp( right );
4428  smpAssign( left, tmp );
4429  }
4430  else {
4431  if( IsSparseVector<VT>::value )
4432  reset();
4433  smpAssign( left, right );
4434  }
4435 
4436  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4437 
4438  return *this;
4439 }
4441 //*************************************************************************************************
4442 
4443 
4444 //*************************************************************************************************
4458 template< typename MT > // Type of the dense matrix
4459 template< typename VT > // Type of the right-hand side vector
4460 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator+=( const Vector<VT,true>& rhs )
4461 {
4464 
4465  if( size() != (~rhs).size() ) {
4466  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4467  }
4468 
4469  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
4470  Right right( ~rhs );
4471 
4472  if( !tryAddAssign( matrix_, right, row_, 0UL ) ) {
4473  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4474  }
4475 
4476  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4477 
4478  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4479  const typename VT::ResultType tmp( right );
4480  smpAddAssign( left, tmp );
4481  }
4482  else {
4483  smpAddAssign( left, right );
4484  }
4485 
4486  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4487 
4488  return *this;
4489 }
4491 //*************************************************************************************************
4492 
4493 
4494 //*************************************************************************************************
4508 template< typename MT > // Type of the dense matrix
4509 template< typename VT > // Type of the right-hand side vector
4510 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator-=( const Vector<VT,true>& rhs )
4511 {
4514 
4515  if( size() != (~rhs).size() ) {
4516  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4517  }
4518 
4519  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
4520  Right right( ~rhs );
4521 
4522  if( !trySubAssign( matrix_, right, row_, 0UL ) ) {
4523  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4524  }
4525 
4526  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4527 
4528  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4529  const typename VT::ResultType tmp( right );
4530  smpSubAssign( left, tmp );
4531  }
4532  else {
4533  smpSubAssign( left, right );
4534  }
4535 
4536  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4537 
4538  return *this;
4539 }
4541 //*************************************************************************************************
4542 
4543 
4544 //*************************************************************************************************
4557 template< typename MT > // Type of the dense matrix
4558 template< typename VT > // Type of the right-hand side dense vector
4559 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator*=( const DenseVector<VT,true>& rhs )
4560 {
4563 
4564  if( size() != (~rhs).size() ) {
4565  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4566  }
4567 
4568  typedef typename If< IsRestricted<MT>, typename VT::CompositeType, const VT& >::Type Right;
4569  Right right( ~rhs );
4570 
4571  if( !tryMultAssign( matrix_, right, row_, 0UL ) ) {
4572  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4573  }
4574 
4575  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4576 
4577  if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
4578  const typename VT::ResultType tmp( right );
4579  smpMultAssign( left, tmp );
4580  }
4581  else {
4582  smpMultAssign( left, right );
4583  }
4584 
4585  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4586 
4587  return *this;
4588 }
4590 //*************************************************************************************************
4591 
4592 
4593 //*************************************************************************************************
4606 template< typename MT > // Type of the dense matrix
4607 template< typename VT > // Type of the right-hand side sparse vector
4608 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::operator*=( const SparseVector<VT,true>& rhs )
4609 {
4613 
4614  if( size() != (~rhs).size() ) {
4615  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
4616  }
4617 
4618  const ResultType right( *this * (~rhs) );
4619 
4620  if( !tryAssign( matrix_, right, row_, 0UL ) ) {
4621  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
4622  }
4623 
4624  typename DerestrictTrait<This>::Type left( derestrict( *this ) );
4625 
4626  smpAssign( left, right );
4627 
4628  BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
4629 
4630  return *this;
4631 }
4633 //*************************************************************************************************
4634 
4635 
4636 //*************************************************************************************************
4647 template< typename MT > // Type of the dense matrix
4648 template< typename Other > // Data type of the right-hand side scalar
4649 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false,true> >::Type&
4650  DenseRow<MT,false,true>::operator*=( Other rhs )
4651 {
4653 
4654  return operator=( (*this) * rhs );
4655 }
4657 //*************************************************************************************************
4658 
4659 
4660 //*************************************************************************************************
4673 template< typename MT > // Type of the dense matrix
4674 template< typename Other > // Data type of the right-hand side scalar
4675 inline typename EnableIf< IsNumeric<Other>, DenseRow<MT,false,true> >::Type&
4676  DenseRow<MT,false,true>::operator/=( Other rhs )
4677 {
4679 
4680  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4681 
4682  return operator=( (*this) / rhs );
4683 }
4685 //*************************************************************************************************
4686 
4687 
4688 
4689 
4690 //=================================================================================================
4691 //
4692 // UTILITY FUNCTIONS
4693 //
4694 //=================================================================================================
4695 
4696 //*************************************************************************************************
4702 template< typename MT > // Type of the dense matrix
4703 inline size_t DenseRow<MT,false,true>::size() const
4704 {
4705  return matrix_.columns();
4706 }
4708 //*************************************************************************************************
4709 
4710 
4711 //*************************************************************************************************
4717 template< typename MT > // Type of the dense matrix
4718 inline size_t DenseRow<MT,false,true>::capacity() const
4719 {
4720  return matrix_.capacity( row_ );
4721 }
4723 //*************************************************************************************************
4724 
4725 
4726 //*************************************************************************************************
4735 template< typename MT > // Type of the dense matrix
4736 inline size_t DenseRow<MT,false,true>::nonZeros() const
4737 {
4738  return matrix_.nonZeros( row_ );
4739 }
4741 //*************************************************************************************************
4742 
4743 
4744 //*************************************************************************************************
4750 template< typename MT > // Type of the dense matrix
4751 inline void DenseRow<MT,false,true>::reset()
4752 {
4753  matrix_.reset( row_ );
4754 }
4756 //*************************************************************************************************
4757 
4758 
4759 //*************************************************************************************************
4770 template< typename MT > // Type of the dense matrix
4771 template< typename Other > // Data type of the scalar value
4772 inline DenseRow<MT,false,true>& DenseRow<MT,false,true>::scale( const Other& scalar )
4773 {
4775 
4776  const size_t ibegin( ( IsLower<MT>::value )
4777  ?( ( IsStrictlyLower<MT>::value )
4778  ?( row_+1UL )
4779  :( row_ ) )
4780  :( 0UL ) );
4781  const size_t iend ( ( IsUpper<MT>::value )
4782  ?( ( IsStrictlyUpper<MT>::value )
4783  ?( row_ )
4784  :( row_+1UL ) )
4785  :( size() ) );
4786 
4787  for( size_t i=ibegin; i<iend; ++i ) {
4788  matrix_(i,row_) *= scalar;
4789  }
4790 
4791  return *this;
4792 }
4794 //*************************************************************************************************
4795 
4796 
4797 
4798 
4799 //=================================================================================================
4800 //
4801 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4802 //
4803 //=================================================================================================
4804 
4805 //*************************************************************************************************
4816 template< typename MT > // Type of the dense matrix
4817 template< typename Other > // Data type of the foreign expression
4818 inline bool DenseRow<MT,false,true>::canAlias( const Other* alias ) const
4819 {
4820  return matrix_.isAliased( alias );
4821 }
4823 //*************************************************************************************************
4824 
4825 
4826 //*************************************************************************************************
4837 template< typename MT > // Type of the dense matrix
4838 template< typename MT2 // Data type of the foreign dense row
4839  , bool SO2 // Storage order of the foreign dense row
4840  , bool SF2 > // Symmetry flag of the foreign dense row
4841 inline bool DenseRow<MT,false,true>::canAlias( const DenseRow<MT2,SO2,SF2>* alias ) const
4842 {
4843  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
4844 }
4846 //*************************************************************************************************
4847 
4848 
4849 //*************************************************************************************************
4860 template< typename MT > // Type of the dense matrix
4861 template< typename Other > // Data type of the foreign expression
4862 inline bool DenseRow<MT,false,true>::isAliased( const Other* alias ) const
4863 {
4864  return matrix_.isAliased( alias );
4865 }
4867 //*************************************************************************************************
4868 
4869 
4870 //*************************************************************************************************
4881 template< typename MT > // Type of the dense matrix
4882 template< typename MT2 // Data type of the foreign dense row
4883  , bool SO2 // Storage order of the foreign dense row
4884  , bool SF2 > // Symmetry flag of the foreign dense row
4885 inline bool DenseRow<MT,false,true>::isAliased( const DenseRow<MT2,SO2,SF2>* alias ) const
4886 {
4887  return matrix_.isAliased( &alias->matrix_ ) && ( row_ == alias->row_ );
4888 }
4890 //*************************************************************************************************
4891 
4892 
4893 //*************************************************************************************************
4903 template< typename MT > // Type of the dense matrix
4904 inline bool DenseRow<MT,false,true>::isAligned() const
4905 {
4906  return matrix_.isAligned();
4907 }
4909 //*************************************************************************************************
4910 
4911 
4912 //*************************************************************************************************
4923 template< typename MT > // Type of the dense matrix
4924 inline bool DenseRow<MT,false,true>::canSMPAssign() const
4925 {
4926  return ( size() > SMP_DVECASSIGN_THRESHOLD );
4927 }
4929 //*************************************************************************************************
4930 
4931 
4932 //*************************************************************************************************
4945 template< typename MT > // Type of the dense matrix
4946 BLAZE_ALWAYS_INLINE typename DenseRow<MT,false,true>::IntrinsicType
4947  DenseRow<MT,false,true>::load( size_t index ) const
4948 {
4949  return matrix_.load( index, row_ );
4950 }
4952 //*************************************************************************************************
4953 
4954 
4955 //*************************************************************************************************
4968 template< typename MT > // Type of the dense matrix
4969 BLAZE_ALWAYS_INLINE typename DenseRow<MT,false,true>::IntrinsicType
4970  DenseRow<MT,false,true>::loada( size_t index ) const
4971 {
4972  return matrix_.loada( index, row_ );
4973 }
4975 //*************************************************************************************************
4976 
4977 
4978 //*************************************************************************************************
4991 template< typename MT > // Type of the dense matrix
4992 BLAZE_ALWAYS_INLINE typename DenseRow<MT,false,true>::IntrinsicType
4993  DenseRow<MT,false,true>::loadu( size_t index ) const
4994 {
4995  return matrix_.loadu( index, row_ );
4996 }
4998 //*************************************************************************************************
4999 
5000 
5001 //*************************************************************************************************
5015 template< typename MT > // Type of the dense matrix
5016 BLAZE_ALWAYS_INLINE void DenseRow<MT,false,true>::store( size_t index, const IntrinsicType& value )
5017 {
5018  matrix_.store( index, row_, value );
5019 }
5021 //*************************************************************************************************
5022 
5023 
5024 //*************************************************************************************************
5038 template< typename MT > // Type of the dense matrix
5039 BLAZE_ALWAYS_INLINE void DenseRow<MT,false,true>::storea( size_t index, const IntrinsicType& value )
5040 {
5041  matrix_.storea( index, row_, value );
5042 }
5044 //*************************************************************************************************
5045 
5046 
5047 //*************************************************************************************************
5061 template< typename MT > // Type of the dense matrix
5062 BLAZE_ALWAYS_INLINE void DenseRow<MT,false,true>::storeu( size_t index, const IntrinsicType& value )
5063 {
5064  matrix_.storeu( index, row_, value );
5065 }
5067 //*************************************************************************************************
5068 
5069 
5070 //*************************************************************************************************
5084 template< typename MT > // Type of the dense matrix
5085 BLAZE_ALWAYS_INLINE void DenseRow<MT,false,true>::stream( size_t index, const IntrinsicType& value )
5086 {
5087  matrix_.stream( index, row_, value );
5088 }
5090 //*************************************************************************************************
5091 
5092 
5093 //*************************************************************************************************
5105 template< typename MT > // Type of the dense matrix
5106 template< typename VT > // Type of the right-hand side dense vector
5107 inline typename DisableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
5108  DenseRow<MT,false,true>::assign( const DenseVector<VT,true>& rhs )
5109 {
5110  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5111 
5112  const size_t ipos( (~rhs).size() & size_t(-2) );
5113  for( size_t i=0UL; i<ipos; i+=2UL ) {
5114  matrix_(i ,row_) = (~rhs)[i ];
5115  matrix_(i+1UL,row_) = (~rhs)[i+1UL];
5116  }
5117  if( ipos < (~rhs).size() )
5118  matrix_(ipos,row_) = (~rhs)[ipos];
5119 }
5121 //*************************************************************************************************
5122 
5123 
5124 //*************************************************************************************************
5136 template< typename MT > // Type of the dense matrix
5137 template< typename VT > // Type of the right-hand side dense vector
5138 inline typename EnableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedAssign<VT> >::Type
5139  DenseRow<MT,false,true>::assign( const DenseVector<VT,true>& rhs )
5140 {
5142 
5143  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5144 
5145  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5146  const size_t rows( size() );
5147 
5148  const size_t ipos( ( remainder )?( rows & size_t(-IT::size) ):( rows ) );
5149  BLAZE_INTERNAL_ASSERT( !remainder || ( rows - ( rows % (IT::size) ) ) == ipos, "Invalid end calculation" );
5150 
5151  if( useStreaming && rows > ( cacheSize/( sizeof(ElementType) * 3UL ) ) && !(~rhs).isAliased( &matrix_ ) )
5152  {
5153  size_t i( 0UL );
5154 
5155  for( ; i<ipos; i+=IT::size ) {
5156  matrix_.stream( i, row_, (~rhs).load(i) );
5157  }
5158  for( ; remainder && i<rows; ++i ) {
5159  matrix_(i,row_) = (~rhs)[i];
5160  }
5161  }
5162  else
5163  {
5164  size_t i( 0UL );
5165  typename VT::ConstIterator it( (~rhs).begin() );
5166 
5167  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
5168  matrix_.store( i , row_, it.load() ); it += IT::size;
5169  matrix_.store( i+IT::size , row_, it.load() ); it += IT::size;
5170  matrix_.store( i+IT::size*2UL, row_, it.load() ); it += IT::size;
5171  matrix_.store( i+IT::size*3UL, row_, it.load() ); it += IT::size;
5172  }
5173  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
5174  matrix_.store( i, row_, it.load() );
5175  }
5176  for( ; remainder && i<rows; ++i, ++it ) {
5177  matrix_(i,row_) = *it;
5178  }
5179  }
5180 }
5182 //*************************************************************************************************
5183 
5184 
5185 //*************************************************************************************************
5197 template< typename MT > // Type of the dense matrix
5198 template< typename VT > // Type of the right-hand side sparse vector
5199 inline void DenseRow<MT,false,true>::assign( const SparseVector<VT,true>& rhs )
5200 {
5201  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5202 
5203  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
5204  matrix_(element->index(),row_) = element->value();
5205 }
5207 //*************************************************************************************************
5208 
5209 
5210 //*************************************************************************************************
5222 template< typename MT > // Type of the dense matrix
5223 template< typename VT > // Type of the right-hand side dense vector
5224 inline typename DisableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
5225  DenseRow<MT,false,true>::addAssign( const DenseVector<VT,true>& rhs )
5226 {
5227  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5228 
5229  const size_t ipos( (~rhs).size() & size_t(-2) );
5230  for( size_t i=0UL; i<ipos; i+=2UL ) {
5231  matrix_(i ,row_) += (~rhs)[i ];
5232  matrix_(i+1UL,row_) += (~rhs)[i+1UL];
5233  }
5234  if( ipos < (~rhs).size() )
5235  matrix_(ipos,row_) += (~rhs)[ipos];
5236 }
5238 //*************************************************************************************************
5239 
5240 
5241 //*************************************************************************************************
5253 template< typename MT > // Type of the dense matrix
5254 template< typename VT > // Type of the right-hand side dense vector
5255 inline typename EnableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedAddAssign<VT> >::Type
5256  DenseRow<MT,false,true>::addAssign( const DenseVector<VT,true>& rhs )
5257 {
5259 
5260  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5261 
5262  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5263  const size_t rows( size() );
5264 
5265  const size_t ipos( ( remainder )?( rows & size_t(-IT::size) ):( rows ) );
5266  BLAZE_INTERNAL_ASSERT( !remainder || ( rows - ( rows % (IT::size) ) ) == ipos, "Invalid end calculation" );
5267 
5268  size_t i( 0UL );
5269  typename VT::ConstIterator it( (~rhs).begin() );
5270 
5271  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
5272  matrix_.store( i , row_, matrix_.load(i ,row_) + it.load() ); it += IT::size;
5273  matrix_.store( i+IT::size , row_, matrix_.load(i+IT::size ,row_) + it.load() ); it += IT::size;
5274  matrix_.store( i+IT::size*2UL, row_, matrix_.load(i+IT::size*2UL,row_) + it.load() ); it += IT::size;
5275  matrix_.store( i+IT::size*3UL, row_, matrix_.load(i+IT::size*3UL,row_) + it.load() ); it += IT::size;
5276  }
5277  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
5278  matrix_.store( i, row_, matrix_.load(i,row_) + it.load() );
5279  }
5280  for( ; remainder && i<rows; ++i, ++it ) {
5281  matrix_(i,row_) += *it;
5282  }
5283 }
5285 //*************************************************************************************************
5286 
5287 
5288 //*************************************************************************************************
5300 template< typename MT > // Type of the dense matrix
5301 template< typename VT > // Type of the right-hand side sparse vector
5302 inline void DenseRow<MT,false,true>::addAssign( const SparseVector<VT,true>& rhs )
5303 {
5304  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5305 
5306  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
5307  matrix_(element->index(),row_) += element->value();
5308 }
5310 //*************************************************************************************************
5311 
5312 
5313 //*************************************************************************************************
5325 template< typename MT > // Type of the dense matrix
5326 template< typename VT > // Type of the right-hand side dense vector
5327 inline typename DisableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
5328  DenseRow<MT,false,true>::subAssign( const DenseVector<VT,true>& rhs )
5329 {
5330  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5331 
5332  const size_t ipos( (~rhs).size() & size_t(-2) );
5333  for( size_t i=0UL; i<ipos; i+=2UL ) {
5334  matrix_(i ,row_) -= (~rhs)[i ];
5335  matrix_(i+1UL,row_) -= (~rhs)[i+1UL];
5336  }
5337  if( ipos < (~rhs).size() )
5338  matrix_(ipos,row_) -= (~rhs)[ipos];
5339 }
5341 //*************************************************************************************************
5342 
5343 
5344 //*************************************************************************************************
5356 template< typename MT > // Type of the dense matrix
5357 template< typename VT > // Type of the right-hand side dense vector
5358 inline typename EnableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedSubAssign<VT> >::Type
5359  DenseRow<MT,false,true>::subAssign( const DenseVector<VT,true>& rhs )
5360 {
5362 
5363  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5364 
5365  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5366  const size_t rows( size() );
5367 
5368  const size_t ipos( ( remainder )?( rows & size_t(-IT::size) ):( rows ) );
5369  BLAZE_INTERNAL_ASSERT( !remainder || ( rows - ( rows % (IT::size) ) ) == ipos, "Invalid end calculation" );
5370 
5371  size_t i( 0UL );
5372  typename VT::ConstIterator it( (~rhs).begin() );
5373 
5374  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
5375  matrix_.store( i , row_, matrix_.load(i ,row_) - it.load() ); it += IT::size;
5376  matrix_.store( i+IT::size , row_, matrix_.load(i+IT::size ,row_) - it.load() ); it += IT::size;
5377  matrix_.store( i+IT::size*2UL, row_, matrix_.load(i+IT::size*2UL,row_) - it.load() ); it += IT::size;
5378  matrix_.store( i+IT::size*3UL, row_, matrix_.load(i+IT::size*3UL,row_) - it.load() ); it += IT::size;
5379  }
5380  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
5381  matrix_.store( i, row_, matrix_.load(i,row_) - it.load() );
5382  }
5383  for( ; remainder && i<rows; ++i, ++it ) {
5384  matrix_(i,row_) -= *it;
5385  }
5386 }
5388 //*************************************************************************************************
5389 
5390 
5391 //*************************************************************************************************
5403 template< typename MT > // Type of the dense matrix
5404 template< typename VT > // Type of the right-hand side sparse vector
5405 inline void DenseRow<MT,false,true>::subAssign( const SparseVector<VT,true>& rhs )
5406 {
5407  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5408 
5409  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
5410  matrix_(element->index(),row_) -= element->value();
5411 }
5413 //*************************************************************************************************
5414 
5415 
5416 //*************************************************************************************************
5428 template< typename MT > // Type of the dense matrix
5429 template< typename VT > // Type of the right-hand side dense vector
5430 inline typename DisableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
5431  DenseRow<MT,false,true>::multAssign( const DenseVector<VT,true>& rhs )
5432 {
5433  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5434 
5435  const size_t ipos( (~rhs).size() & size_t(-2) );
5436  for( size_t i=0UL; i<ipos; i+=2UL ) {
5437  matrix_(i ,row_) *= (~rhs)[i ];
5438  matrix_(i+1UL,row_) *= (~rhs)[i+1UL];
5439  }
5440  if( ipos < (~rhs).size() )
5441  matrix_(ipos,row_) *= (~rhs)[ipos];
5442 }
5444 //*************************************************************************************************
5445 
5446 
5447 //*************************************************************************************************
5459 template< typename MT > // Type of the dense matrix
5460 template< typename VT > // Type of the right-hand side dense vector
5461 inline typename EnableIf< typename DenseRow<MT,false,true>::BLAZE_TEMPLATE VectorizedMultAssign<VT> >::Type
5462  DenseRow<MT,false,true>::multAssign( const DenseVector<VT,true>& rhs )
5463 {
5465 
5466  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5467 
5468  const bool remainder( !IsPadded<MT>::value || !IsPadded<VT>::value );
5469  const size_t rows( size() );
5470 
5471  const size_t ipos( ( remainder )?( rows & size_t(-IT::size) ):( rows ) );
5472  BLAZE_INTERNAL_ASSERT( !remainder || ( rows - ( rows % (IT::size) ) ) == ipos, "Invalid end calculation" );
5473 
5474  size_t i( 0UL );
5475  typename VT::ConstIterator it( (~rhs).begin() );
5476 
5477  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
5478  matrix_.store( i , row_, matrix_.load(i ,row_) * it.load() ); it += IT::size;
5479  matrix_.store( i+IT::size , row_, matrix_.load(i+IT::size ,row_) * it.load() ); it += IT::size;
5480  matrix_.store( i+IT::size*2UL, row_, matrix_.load(i+IT::size*2UL,row_) * it.load() ); it += IT::size;
5481  matrix_.store( i+IT::size*3UL, row_, matrix_.load(i+IT::size*3UL,row_) * it.load() ); it += IT::size;
5482  }
5483  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
5484  matrix_.store( i, row_, matrix_.load(i,row_) * it.load() );
5485  }
5486  for( ; remainder && i<rows; ++i, ++it ) {
5487  matrix_(i,row_) *= *it;
5488  }
5489 }
5491 //*************************************************************************************************
5492 
5493 
5494 //*************************************************************************************************
5506 template< typename MT > // Type of the dense matrix
5507 template< typename VT > // Type of the right-hand side sparse vector
5508 inline void DenseRow<MT,false,true>::multAssign( const SparseVector<VT,true>& rhs )
5509 {
5510  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
5511 
5512  const ResultType tmp( serial( *this ) );
5513 
5514  reset();
5515 
5516  for( typename VT::ConstIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element )
5517  matrix_(element->index(),row_) = tmp[element->index()] * element->value();
5518 }
5520 //*************************************************************************************************
5521 
5522 
5523 
5524 
5525 
5526 
5527 
5528 
5529 //=================================================================================================
5530 //
5531 // DENSEROW OPERATORS
5532 //
5533 //=================================================================================================
5534 
5535 //*************************************************************************************************
5538 template< typename MT, bool SO, bool SF >
5539 inline void reset( DenseRow<MT,SO,SF>& row );
5540 
5541 template< typename MT, bool SO, bool SF >
5542 inline void clear( DenseRow<MT,SO,SF>& row );
5543 
5544 template< typename MT, bool SO, bool SF >
5545 inline bool isDefault( const DenseRow<MT,SO,SF>& row );
5546 
5547 template< typename MT, bool SO, bool SF >
5548 inline bool isIntact( const DenseRow<MT,SO,SF>& row );
5549 
5550 template< typename MT, bool SO, bool SF >
5551 inline bool isSame( const DenseRow<MT,SO,SF>& a, const DenseRow<MT,SO,SF>& b );
5553 //*************************************************************************************************
5554 
5555 
5556 //*************************************************************************************************
5563 template< typename MT // Type of the dense matrix
5564  , bool SO // Storage order
5565  , bool SF > // Symmetry flag
5567 {
5568  row.reset();
5569 }
5570 //*************************************************************************************************
5571 
5572 
5573 //*************************************************************************************************
5582 template< typename MT // Type of the dense matrix
5583  , bool SO // Storage order
5584  , bool SF > // Symmetry flag
5586 {
5587  row.reset();
5588 }
5589 //*************************************************************************************************
5590 
5591 
5592 //*************************************************************************************************
5610 template< typename MT // Type of the dense matrix
5611  , bool SO // Storage order
5612  , bool SF > // Symmetry flag
5613 inline bool isDefault( const DenseRow<MT,SO,SF>& row )
5614 {
5615  for( size_t i=0UL; i<row.size(); ++i )
5616  if( !isDefault( row[i] ) ) return false;
5617  return true;
5618 }
5619 //*************************************************************************************************
5620 
5621 
5622 //*************************************************************************************************
5639 template< typename MT // Type of the dense matrix
5640  , bool SO // Storage order
5641  , bool SF > // Symmetry flag
5642 inline bool isIntact( const DenseRow<MT,SO,SF>& row )
5643 {
5644  return ( row.row_ <= row.matrix_.rows() &&
5645  isIntact( row.matrix_ ) );
5646 }
5647 //*************************************************************************************************
5648 
5649 
5650 //*************************************************************************************************
5662 template< typename MT // Type of the dense matrix
5663  , bool SO // Storage order
5664  , bool SF > // Symmetry flag
5665 inline bool isSame( const DenseRow<MT,SO,SF>& a, const DenseRow<MT,SO,SF>& b )
5666 {
5667  return ( isSame( a.matrix_, b.matrix_ ) && ( a.row_ == b.row_ ) );
5668 }
5669 //*************************************************************************************************
5670 
5671 
5672 //*************************************************************************************************
5687 template< typename MT // Type of the dense matrix
5688  , bool SO // Storage order
5689  , bool SF // Symmetry flag
5690  , typename VT > // Type of the right-hand side vector
5691 inline bool tryAssign( const DenseRow<MT,SO,SF>& lhs, const Vector<VT,true>& rhs, size_t index )
5692 {
5693  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
5694  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
5695 
5696  return tryAssign( lhs.matrix_, ~rhs, lhs.row_, index );
5697 }
5699 //*************************************************************************************************
5700 
5701 
5702 //*************************************************************************************************
5717 template< typename MT // Type of the dense matrix
5718  , bool SO // Storage order
5719  , bool SF // Symmetry flag
5720  , typename VT > // Type of the right-hand side vector
5721 inline bool tryAddAssign( const DenseRow<MT,SO,SF>& lhs, const Vector<VT,true>& rhs, size_t index )
5722 {
5723  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
5724  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
5725 
5726  return tryAddAssign( lhs.matrix_, ~rhs, lhs.row_, index );
5727 }
5729 //*************************************************************************************************
5730 
5731 
5732 //*************************************************************************************************
5747 template< typename MT // Type of the dense matrix
5748  , bool SO // Storage order
5749  , bool SF // Symmetry flag
5750  , typename VT > // Type of the right-hand side vector
5751 inline bool trySubAssign( const DenseRow<MT,SO,SF>& lhs, const Vector<VT,true>& rhs, size_t index )
5752 {
5753  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
5754  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
5755 
5756  return trySubAssign( lhs.matrix_, ~rhs, lhs.row_, index );
5757 }
5759 //*************************************************************************************************
5760 
5761 
5762 //*************************************************************************************************
5777 template< typename MT // Type of the dense matrix
5778  , bool SO // Storage order
5779  , bool SF // Symmetry flag
5780  , typename VT > // Type of the right-hand side vector
5781 inline bool tryMultAssign( const DenseRow<MT,SO,SF>& lhs, const Vector<VT,true>& rhs, size_t index )
5782 {
5783  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
5784  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
5785 
5786  return tryMultAssign( lhs.matrix_, ~rhs, lhs.row_, index );
5787 }
5789 //*************************************************************************************************
5790 
5791 
5792 //*************************************************************************************************
5807 template< typename MT // Type of the dense matrix
5808  , bool SO // Storage order
5809  , bool SF > // Symmetry flag
5810 inline typename DerestrictTrait< DenseRow<MT,SO,SF> >::Type
5811  derestrict( DenseRow<MT,SO,SF>& row )
5812 {
5813  typedef typename DerestrictTrait< DenseRow<MT,SO,SF> >::Type ReturnType;
5814  return ReturnType( derestrict( row.matrix_ ), row.row_ );
5815 }
5817 //*************************************************************************************************
5818 
5819 
5820 
5821 
5822 //=================================================================================================
5823 //
5824 // ISRESTRICTED SPECIALIZATIONS
5825 //
5826 //=================================================================================================
5827 
5828 //*************************************************************************************************
5830 template< typename MT, bool SO, bool SF >
5831 struct IsRestricted< DenseRow<MT,SO,SF> > : public IsTrue< IsRestricted<MT>::value >
5832 {};
5834 //*************************************************************************************************
5835 
5836 
5837 
5838 
5839 //=================================================================================================
5840 //
5841 // DERESTRICTTRAIT SPECIALIZATIONS
5842 //
5843 //=================================================================================================
5844 
5845 //*************************************************************************************************
5847 template< typename MT, bool SO, bool SF >
5848 struct DerestrictTrait< DenseRow<MT,SO,SF> >
5849 {
5850  typedef DenseRow< typename RemoveReference< typename DerestrictTrait<MT>::Type >::Type > Type;
5851 };
5853 //*************************************************************************************************
5854 
5855 
5856 
5857 
5858 //=================================================================================================
5859 //
5860 // HASCONSTDATAACCESS SPECIALIZATIONS
5861 //
5862 //=================================================================================================
5863 
5864 //*************************************************************************************************
5866 template< typename MT, bool SO, bool SF >
5867 struct HasConstDataAccess< DenseRow<MT,SO,SF> >
5868  : public IsTrue< HasConstDataAccess<MT>::value >
5869 {};
5871 //*************************************************************************************************
5872 
5873 
5874 
5875 
5876 //=================================================================================================
5877 //
5878 // HASMUTABLEDATAACCESS SPECIALIZATIONS
5879 //
5880 //=================================================================================================
5881 
5882 //*************************************************************************************************
5884 template< typename MT, bool SO, bool SF >
5885 struct HasMutableDataAccess< DenseRow<MT,SO,SF> >
5886  : public IsTrue< HasMutableDataAccess<MT>::value >
5887 {};
5889 //*************************************************************************************************
5890 
5891 
5892 
5893 
5894 //=================================================================================================
5895 //
5896 // ISALIGNED SPECIALIZATIONS
5897 //
5898 //=================================================================================================
5899 
5900 //*************************************************************************************************
5902 template< typename MT, bool SO, bool SF >
5903 struct IsAligned< DenseRow<MT,SO,SF> >
5904  : public IsTrue< And< IsAligned<MT>, Or< IsRowMajorMatrix<MT>, IsSymmetric<MT> > >::value >
5905 {};
5907 //*************************************************************************************************
5908 
5909 
5910 
5911 
5912 //=================================================================================================
5913 //
5914 // ISPADDED SPECIALIZATIONS
5915 //
5916 //=================================================================================================
5917 
5918 //*************************************************************************************************
5920 template< typename MT, bool SO, bool SF >
5921 struct IsPadded< DenseRow<MT,SO,SF> >
5922  : public IsTrue< And< IsPadded<MT>, Or< IsRowMajorMatrix<MT>, IsSymmetric<MT> > >::value >
5923 {};
5925 //*************************************************************************************************
5926 
5927 
5928 
5929 
5930 //=================================================================================================
5931 //
5932 // ADDTRAIT SPECIALIZATIONS
5933 //
5934 //=================================================================================================
5935 
5936 //*************************************************************************************************
5938 template< typename MT, bool SO, bool SF, typename T >
5939 struct AddTrait< DenseRow<MT,SO,SF>, T >
5940 {
5941  typedef typename AddTrait< typename RowTrait<MT>::Type, T >::Type Type;
5942 };
5943 
5944 template< typename T, typename MT, bool SO, bool SF >
5945 struct AddTrait< T, DenseRow<MT,SO,SF> >
5946 {
5947  typedef typename AddTrait< T, typename RowTrait<MT>::Type >::Type Type;
5948 };
5950 //*************************************************************************************************
5951 
5952 
5953 
5954 
5955 //=================================================================================================
5956 //
5957 // SUBTRAIT SPECIALIZATIONS
5958 //
5959 //=================================================================================================
5960 
5961 //*************************************************************************************************
5963 template< typename MT, bool SO, bool SF, typename T >
5964 struct SubTrait< DenseRow<MT,SO,SF>, T >
5965 {
5966  typedef typename SubTrait< typename RowTrait<MT>::Type, T >::Type Type;
5967 };
5968 
5969 template< typename T, typename MT, bool SO, bool SF >
5970 struct SubTrait< T, DenseRow<MT,SO,SF> >
5971 {
5972  typedef typename SubTrait< T, typename RowTrait<MT>::Type >::Type Type;
5973 };
5975 //*************************************************************************************************
5976 
5977 
5978 
5979 
5980 //=================================================================================================
5981 //
5982 // MULTTRAIT SPECIALIZATIONS
5983 //
5984 //=================================================================================================
5985 
5986 //*************************************************************************************************
5988 template< typename MT, bool SO, bool SF, typename T >
5989 struct MultTrait< DenseRow<MT,SO,SF>, T >
5990 {
5991  typedef typename MultTrait< typename RowTrait<MT>::Type, T >::Type Type;
5992 };
5993 
5994 template< typename T, typename MT, bool SO, bool SF >
5995 struct MultTrait< T, DenseRow<MT,SO,SF> >
5996 {
5997  typedef typename MultTrait< T, typename RowTrait<MT>::Type >::Type Type;
5998 };
6000 //*************************************************************************************************
6001 
6002 
6003 
6004 
6005 //=================================================================================================
6006 //
6007 // CROSSTRAIT SPECIALIZATIONS
6008 //
6009 //=================================================================================================
6010 
6011 //*************************************************************************************************
6013 template< typename MT, bool SO, bool SF, typename T >
6014 struct CrossTrait< DenseRow<MT,SO,SF>, T >
6015 {
6016  typedef typename CrossTrait< typename RowTrait<MT>::Type, T >::Type Type;
6017 };
6018 
6019 template< typename T, typename MT, bool SO, bool SF >
6020 struct CrossTrait< T, DenseRow<MT,SO,SF> >
6021 {
6022  typedef typename CrossTrait< T, typename RowTrait<MT>::Type >::Type Type;
6023 };
6025 //*************************************************************************************************
6026 
6027 
6028 
6029 
6030 //=================================================================================================
6031 //
6032 // DIVTRAIT SPECIALIZATIONS
6033 //
6034 //=================================================================================================
6035 
6036 //*************************************************************************************************
6038 template< typename MT, bool SO, bool SF, typename T >
6039 struct DivTrait< DenseRow<MT,SO,SF>, T >
6040 {
6041  typedef typename DivTrait< typename RowTrait<MT>::Type, T >::Type Type;
6042 };
6043 
6044 template< typename T, typename MT, bool SO, bool SF >
6045 struct DivTrait< T, DenseRow<MT,SO,SF> >
6046 {
6047  typedef typename DivTrait< T, typename RowTrait<MT>::Type >::Type Type;
6048 };
6050 //*************************************************************************************************
6051 
6052 
6053 
6054 
6055 //=================================================================================================
6056 //
6057 // SUBVECTORTRAIT SPECIALIZATIONS
6058 //
6059 //=================================================================================================
6060 
6061 //*************************************************************************************************
6063 template< typename MT, bool SO, bool SF >
6064 struct SubvectorTrait< DenseRow<MT,SO,SF> >
6065 {
6066  typedef typename SubvectorTrait< typename DenseRow<MT,SO,SF>::ResultType >::Type Type;
6067 };
6069 //*************************************************************************************************
6070 
6071 } // namespace blaze
6072 
6073 #endif
Pointer data()
Low-level data access to the row elements.
Definition: DenseRow.h:763
Constraint on the data type.
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the IsUniUpper type trait.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7820
Header file for the subtraction trait.
ConstIterator cend() const
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:883
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
Operand matrix_
The dense matrix containing the row.
Definition: DenseRow.h:581
Header file for the row trait.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
ConstIterator cbegin() const
Returns an iterator to the first element of the row.
Definition: DenseRow.h:832
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:207
Header file for the row base class.
Header file for the IsDiagonal type trait.
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseRow.h:358
#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
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:647
BLAZE_ALWAYS_INLINE void stream(size_t index, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the dense row.
Definition: DenseRow.h:1665
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: Optimizations.h:68
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
size_t nonZeros() const
Returns the number of non-zero elements in the row.
Definition: DenseRow.h:1316
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
Reference operator[](size_t index)
Subscript operator for the direct access to the row elements.
Definition: DenseRow.h:677
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:107
Header file for the And class template.
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.
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:118
If< IsExpression< MT >, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseRow.h:348
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
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t index) const
Unaligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1573
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:721
If< Or< IsConst< MT >, Not< HasMutableDataAccess< MT > > >, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant row value.
Definition: DenseRow.h:375
#define BLAZE_CONSTRAINT_MUST_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a symmetric matrix type...
Definition: Symmetric.h:78
size_t size() const
Returns the current size/dimension of the row.
Definition: DenseRow.h:1283
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Constraints on the storage order of matrix types.
#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
System settings for performance optimizations.
Header file for the IsUniLower type trait.
MT::ElementType ElementType
Type of the row elements.
Definition: DenseRow.h:359
void reset()
Reset to the default initial values.
Definition: DenseRow.h:1331
bool canAlias(const Other *alias) const
Returns whether the dense row can alias with the given address alias.
Definition: DenseRow.h:1398
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Constraint on the data type.
If< IsConst< MT >, ConstIterator, typename MT::Iterator >::Type Iterator
Iterator over non-constant elements.
Definition: DenseRow.h:381
Base template for the RowTrait class.
Definition: RowTrait.h:115
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:85
Header file for the DisableIf class template.
Reference at(size_t index)
Checked access to the row elements.
Definition: DenseRow.h:719
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:79
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:116
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:75
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
bool isAligned() const
Returns whether the dense row is properly aligned in memory.
Definition: DenseRow.h:1484
Header file for the Not class template.
Header file for the subvector trait.
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseRow.h:378
const ElementType * ConstPointer
Pointer to a constant row value.
Definition: DenseRow.h:371
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
Iterator begin()
Returns an iterator to the first element of the row.
Definition: DenseRow.h:798
IT::Type IntrinsicType
Intrinsic type of the row elements.
Definition: DenseRow.h:360
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
Constraint on the data type.
#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
const size_t row_
The index of the row in the matrix.
Definition: DenseRow.h:582
BLAZE_ALWAYS_INLINE void storea(size_t index, const IntrinsicType &value)
Aligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1619
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the IsPadded type trait.
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:85
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
DenseRow & operator=(const ElementType &rhs)
Homogenous assignment to all row elements.
Definition: DenseRow.h:911
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:107
If< IsConst< MT >, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant row value.
Definition: DenseRow.h:368
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
Header file for the IsSparseVector type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Header file for the IsConst type trait.
RowTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseRow.h:357
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:1232
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.
bool canSMPAssign() const
Returns whether the dense row can be used in SMP assignments.
Definition: DenseRow.h:1504
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the row element type.
Definition: DenseRow.h:351
Header file for the addition trait.
const DenseRow & CompositeType
Data type for composite expression templates.
Definition: DenseRow.h:362
Header file for the cross product trait.
Header file for the division trait.
DenseRow< MT, SO, SF > This
Type of this DenseRow instance.
Definition: DenseRow.h:356
DenseRow(MT &matrix, size_t index)
The constructor for DenseRow.
Definition: DenseRow.h:646
bool isAliased(const Other *alias) const
Returns whether the dense row is aliased with the given address alias.
Definition: DenseRow.h:1442
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
const bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Reference to a specific row of a dense matrix.The DenseRow template represents a reference to a speci...
Definition: DenseRow.h:342
Header file for the cache size of the target architecture.
Compile time type negation.The Not class template negates the given compile time condition. In case the given condition would evaluate to true, the nested member enumeration is set to false and vice versa:
Definition: Not.h:70
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Constraints on the storage order of matrix types.
Header file for the HasMutableDataAccess type trait.
Iterator end()
Returns an iterator just past the last element of the row.
Definition: DenseRow.h:849
BLAZE_ALWAYS_INLINE void store(size_t index, const IntrinsicType &value)
Store of an intrinsic element of the dense row.
Definition: DenseRow.h:1596
#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
Evaluation of the return type of the derestrict function.Via this type trait it is possible to evalua...
Definition: DerestrictTrait.h:74
Header file for the IsReference type trait.
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.
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
#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
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:164
BLAZE_ALWAYS_INLINE IntrinsicType loada(size_t index) const
Aligned load of an intrinsic element of the dense row.
Definition: DenseRow.h:1550
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:258
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t index) const
Load of an intrinsic element of the dense row.
Definition: DenseRow.h:1527
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< 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:129
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:118
size_t capacity() const
Returns the maximum capacity of the dense row.
Definition: DenseRow.h:1298
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:94
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
#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: RowVector.h:79
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
MT::ConstReference ConstReference
Reference to a constant row value.
Definition: DenseRow.h:365
Header file for the IsUpper type trait.
Header file for exception macros.
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
Header file for the IsRestricted type trait.
BLAZE_ALWAYS_INLINE void storeu(size_t index, const IntrinsicType &value)
Unligned store of an intrinsic element of the dense row.
Definition: DenseRow.h:1642
System settings for the inline keywords.
EnableIf< IsDenseVector< VT1 > >::Type smpMultAssign(Vector< 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:189
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
Constraint on the transpose flag of vector types.
Header file for the IsExpression type trait class.
Header file for the FunctionTrace class.
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseRow.h:361
Header file for a safe C++ NULL pointer implementation.