DynamicMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <stdexcept>
50 #include <blaze/math/Forward.h>
51 #include <blaze/math/Functions.h>
52 #include <blaze/math/Intrinsics.h>
53 #include <blaze/math/shims/Clear.h>
73 #include <blaze/system/CacheSize.h>
74 #include <blaze/system/Inline.h>
75 #include <blaze/system/Restrict.h>
77 #include <blaze/system/Streaming.h>
79 #include <blaze/util/Assert.h>
86 #include <blaze/util/DisableIf.h>
87 #include <blaze/util/EnableIf.h>
88 #include <blaze/util/Memory.h>
89 #include <blaze/util/Null.h>
90 #include <blaze/util/Template.h>
91 #include <blaze/util/Types.h>
95 #include <blaze/util/Unused.h>
96 
97 
98 namespace blaze {
99 
100 //=================================================================================================
101 //
102 // CLASS DEFINITION
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
185 template< typename Type // Data type of the matrix
186  , bool SO = defaultStorageOrder > // Storage order
187 class DynamicMatrix : public DenseMatrix< DynamicMatrix<Type,SO>, SO >
188 {
189  private:
190  //**Type definitions****************************************************************************
192  //**********************************************************************************************
193 
194  public:
195  //**Type definitions****************************************************************************
197  typedef This ResultType;
200  typedef Type ElementType;
201  typedef typename IT::Type IntrinsicType;
202  typedef const Type& ReturnType;
203  typedef const This& CompositeType;
204  typedef Type& Reference;
205  typedef const Type& ConstReference;
206  typedef Type* Pointer;
207  typedef const Type* ConstPointer;
210  //**********************************************************************************************
211 
212  //**Rebind struct definition********************************************************************
215  template< typename ET > // Data type of the other matrix
216  struct Rebind {
218  };
219  //**********************************************************************************************
220 
221  //**Compilation flags***************************************************************************
223 
227  enum { vectorizable = IsVectorizable<Type>::value };
228 
230 
233  enum { smpAssignable = !IsSMPAssignable<Type>::value };
234  //**********************************************************************************************
235 
236  //**Constructors********************************************************************************
239  explicit inline DynamicMatrix();
240  explicit inline DynamicMatrix( size_t m, size_t n );
241  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
242  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
243 
244  template< typename Other, size_t M, size_t N >
245  explicit inline DynamicMatrix( const Other (&array)[M][N] );
246 
247  inline DynamicMatrix( const DynamicMatrix& m );
248  template< typename MT, bool SO2 > inline DynamicMatrix( const Matrix<MT,SO2>& m );
250  //**********************************************************************************************
251 
252  //**Destructor**********************************************************************************
255  inline ~DynamicMatrix();
257  //**********************************************************************************************
258 
259  //**Data access functions***********************************************************************
262  inline Reference operator()( size_t i, size_t j );
263  inline ConstReference operator()( size_t i, size_t j ) const;
264  inline Pointer data ();
265  inline ConstPointer data () const;
266  inline Pointer data ( size_t i );
267  inline ConstPointer data ( size_t i ) const;
268  inline Iterator begin ( size_t i );
269  inline ConstIterator begin ( size_t i ) const;
270  inline ConstIterator cbegin( size_t i ) const;
271  inline Iterator end ( size_t i );
272  inline ConstIterator end ( size_t i ) const;
273  inline ConstIterator cend ( size_t i ) const;
275  //**********************************************************************************************
276 
277  //**Assignment operators************************************************************************
280  template< typename Other, size_t M, size_t N >
281  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
282 
283  inline DynamicMatrix& operator= ( Type set );
284  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
285  template< typename MT, bool SO2 > inline DynamicMatrix& operator= ( const Matrix<MT,SO2>& rhs );
286  template< typename MT, bool SO2 > inline DynamicMatrix& operator+=( const Matrix<MT,SO2>& rhs );
287  template< typename MT, bool SO2 > inline DynamicMatrix& operator-=( const Matrix<MT,SO2>& rhs );
288  template< typename MT, bool SO2 > inline DynamicMatrix& operator*=( const Matrix<MT,SO2>& rhs );
289 
290  template< typename Other >
291  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
292  operator*=( Other rhs );
293 
294  template< typename Other >
295  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
296  operator/=( Other rhs );
298  //**********************************************************************************************
299 
300  //**Utility functions***************************************************************************
303  inline size_t rows() const;
304  inline size_t columns() const;
305  inline size_t spacing() const;
306  inline size_t capacity() const;
307  inline size_t capacity( size_t i ) const;
308  inline size_t nonZeros() const;
309  inline size_t nonZeros( size_t i ) const;
310  inline void reset();
311  inline void reset( size_t i );
312  inline void clear();
313  void resize ( size_t m, size_t n, bool preserve=true );
314  inline void extend ( size_t m, size_t n, bool preserve=true );
315  inline void reserve( size_t elements );
316  inline DynamicMatrix& transpose();
317  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
318  inline void swap( DynamicMatrix& m ) /* throw() */;
320  //**********************************************************************************************
321 
322  private:
323  //**********************************************************************************************
325  template< typename MT >
327  struct VectorizedAssign {
328  enum { value = vectorizable && MT::vectorizable &&
329  IsSame<Type,typename MT::ElementType>::value };
330  };
332  //**********************************************************************************************
333 
334  //**********************************************************************************************
336  template< typename MT >
338  struct VectorizedAddAssign {
339  enum { value = vectorizable && MT::vectorizable &&
340  IsSame<Type,typename MT::ElementType>::value &&
341  IntrinsicTrait<Type>::addition &&
342  !IsDiagonal<MT>::value };
343  };
345  //**********************************************************************************************
346 
347  //**********************************************************************************************
349  template< typename MT >
351  struct VectorizedSubAssign {
352  enum { value = vectorizable && MT::vectorizable &&
353  IsSame<Type,typename MT::ElementType>::value &&
354  IntrinsicTrait<Type>::subtraction &&
355  !IsDiagonal<MT>::value };
356  };
358  //**********************************************************************************************
359 
360  public:
361  //**Expression template evaluation functions****************************************************
364  template< typename Other > inline bool canAlias ( const Other* alias ) const;
365  template< typename Other > inline bool isAliased( const Other* alias ) const;
366 
367  inline bool isAligned () const;
368  inline bool canSMPAssign() const;
369 
370  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
371  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
372 
373  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
374  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
375  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
376 
377  template< typename MT >
378  inline typename DisableIf< VectorizedAssign<MT> >::Type
379  assign( const DenseMatrix<MT,SO>& rhs );
380 
381  template< typename MT >
382  inline typename EnableIf< VectorizedAssign<MT> >::Type
383  assign( const DenseMatrix<MT,SO>& rhs );
384 
385  template< typename MT > inline void assign( const DenseMatrix<MT,!SO>& rhs );
386  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
387  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
388 
389  template< typename MT >
390  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
391  addAssign( const DenseMatrix<MT,SO>& rhs );
392 
393  template< typename MT >
394  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
395  addAssign( const DenseMatrix<MT,SO>& rhs );
396 
397  template< typename MT > inline void addAssign( const DenseMatrix<MT,!SO>& rhs );
398  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
399  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
400 
401  template< typename MT >
402  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
403  subAssign( const DenseMatrix<MT,SO>& rhs );
404 
405  template< typename MT >
406  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
407  subAssign( const DenseMatrix<MT,SO>& rhs );
408 
409  template< typename MT > inline void subAssign( const DenseMatrix<MT,!SO>& rhs );
410  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
411  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
413  //**********************************************************************************************
414 
415  private:
416  //**Utility functions***************************************************************************
419  inline size_t adjustColumns( size_t minColumns ) const;
421  //**********************************************************************************************
422 
423  //**Member variables****************************************************************************
426  size_t m_;
427  size_t n_;
428  size_t nn_;
429  size_t capacity_;
431 
441  //**********************************************************************************************
442 
443  //**Compile time checks*************************************************************************
450  //**********************************************************************************************
451 };
452 //*************************************************************************************************
453 
454 
455 
456 
457 //=================================================================================================
458 //
459 // CONSTRUCTORS
460 //
461 //=================================================================================================
462 
463 //*************************************************************************************************
466 template< typename Type // Data type of the matrix
467  , bool SO > // Storage order
469  : m_ ( 0UL ) // The current number of rows of the matrix
470  , n_ ( 0UL ) // The current number of columns of the matrix
471  , nn_ ( 0UL ) // The alignment adjusted number of columns
472  , capacity_( 0UL ) // The maximum capacity of the matrix
473  , v_ ( NULL ) // The matrix elements
474 {}
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
487 template< typename Type // Data type of the matrix
488  , bool SO > // Storage order
489 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n )
490  : m_ ( m ) // The current number of rows of the matrix
491  , n_ ( n ) // The current number of columns of the matrix
492  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
493  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
494  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
495 {
497  for( size_t i=0UL; i<m_; ++i ) {
498  for( size_t j=n_; j<nn_; ++j )
499  v_[i*nn_+j] = Type();
500  }
501  }
502 }
503 //*************************************************************************************************
504 
505 
506 //*************************************************************************************************
515 template< typename Type // Data type of the matrix
516  , bool SO > // Storage order
517 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Type& init )
518  : m_ ( m ) // The current number of rows of the matrix
519  , n_ ( n ) // The current number of columns of the matrix
520  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
521  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
522  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
523 {
524  for( size_t i=0UL; i<m; ++i ) {
525  for( size_t j=0UL; j<n_; ++j )
526  v_[i*nn_+j] = init;
527 
529  for( size_t j=n_; j<nn_; ++j )
530  v_[i*nn_+j] = Type();
531  }
532  }
533 }
534 //*************************************************************************************************
535 
536 
537 //*************************************************************************************************
560 template< typename Type // Data type of the matrix
561  , bool SO > // Storage order
562 template< typename Other > // Data type of the initialization array
563 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Other* array )
564  : m_ ( m ) // The current number of rows of the matrix
565  , n_ ( n ) // The current number of columns of the matrix
566  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
567  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
568  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
569 {
570  for( size_t i=0UL; i<m; ++i ) {
571  for( size_t j=0UL; j<n; ++j )
572  v_[i*nn_+j] = array[i*n+j];
573 
575  for( size_t j=n; j<nn_; ++j )
576  v_[i*nn_+j] = Type();
577  }
578  }
579 }
580 //*************************************************************************************************
581 
582 
583 //*************************************************************************************************
604 template< typename Type // Data type of the matrix
605  , bool SO > // Storage order
606 template< typename Other // Data type of the initialization array
607  , size_t M // Number of rows of the initialization array
608  , size_t N > // Number of columns of the initialization array
609 inline DynamicMatrix<Type,SO>::DynamicMatrix( const Other (&array)[M][N] )
610  : m_ ( M ) // The current number of rows of the matrix
611  , n_ ( N ) // The current number of columns of the matrix
612  , nn_ ( adjustColumns( N ) ) // The alignment adjusted number of columns
613  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
614  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
615 {
616  for( size_t i=0UL; i<M; ++i ) {
617  for( size_t j=0UL; j<N; ++j )
618  v_[i*nn_+j] = array[i][j];
619 
621  for( size_t j=N; j<nn_; ++j )
622  v_[i*nn_+j] = Type();
623  }
624  }
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
637 template< typename Type // Data type of the matrix
638  , bool SO > // Storage order
640  : m_ ( m.m_ ) // The current number of rows of the matrix
641  , n_ ( m.n_ ) // The current number of columns of the matrix
642  , nn_ ( m.nn_ ) // The alignment adjusted number of columns
643  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
644  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
645 {
646  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
647 
648  for( size_t i=0UL; i<capacity_; ++i )
649  v_[i] = m.v_[i];
650 }
651 //*************************************************************************************************
652 
653 
654 //*************************************************************************************************
659 template< typename Type // Data type of the matrix
660  , bool SO > // Storage order
661 template< typename MT // Type of the foreign matrix
662  , bool SO2 > // Storage order of the foreign matrix
664  : m_ ( (~m).rows() ) // The current number of rows of the matrix
665  , n_ ( (~m).columns() ) // The current number of columns of the matrix
666  , nn_ ( adjustColumns( n_ ) ) // The alignment adjusted number of columns
667  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
668  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
669 {
670  for( size_t i=0UL; i<m_; ++i ) {
671  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : n_ );
672  j<( IsVectorizable<Type>::value ? nn_ : n_ ); ++j ) {
673  v_[i*nn_+j] = Type();
674  }
675  }
676 
677  smpAssign( *this, ~m );
678 }
679 //*************************************************************************************************
680 
681 
682 
683 
684 //=================================================================================================
685 //
686 // DESTRUCTOR
687 //
688 //=================================================================================================
689 
690 //*************************************************************************************************
693 template< typename Type // Data type of the matrix
694  , bool SO > // Storage order
696 {
697  deallocate( v_ );
698 }
699 //*************************************************************************************************
700 
701 
702 
703 
704 //=================================================================================================
705 //
706 // DATA ACCESS FUNCTIONS
707 //
708 //=================================================================================================
709 
710 //*************************************************************************************************
717 template< typename Type // Data type of the matrix
718  , bool SO > // Storage order
719 inline typename DynamicMatrix<Type,SO>::Reference
721 {
722  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
723  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
724  return v_[i*nn_+j];
725 }
726 //*************************************************************************************************
727 
728 
729 //*************************************************************************************************
736 template< typename Type // Data type of the matrix
737  , bool SO > // Storage order
739  DynamicMatrix<Type,SO>::operator()( size_t i, size_t j ) const
740 {
741  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
742  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
743  return v_[i*nn_+j];
744 }
745 //*************************************************************************************************
746 
747 
748 //*************************************************************************************************
760 template< typename Type // Data type of the matrix
761  , bool SO > // Storage order
763 {
764  return v_;
765 }
766 //*************************************************************************************************
767 
768 
769 //*************************************************************************************************
781 template< typename Type // Data type of the matrix
782  , bool SO > // Storage order
784 {
785  return v_;
786 }
787 //*************************************************************************************************
788 
789 
790 //*************************************************************************************************
798 template< typename Type // Data type of the matrix
799  , bool SO > // Storage order
801 {
802  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
803  return v_ + i*nn_;
804 }
805 //*************************************************************************************************
806 
807 
808 //*************************************************************************************************
816 template< typename Type // Data type of the matrix
817  , bool SO > // Storage order
819 {
820  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
821  return v_ + i*nn_;
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
837 template< typename Type // Data type of the matrix
838  , bool SO > // Storage order
839 inline typename DynamicMatrix<Type,SO>::Iterator
841 {
842  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
843  return Iterator( v_ + i*nn_ );
844 }
845 //*************************************************************************************************
846 
847 
848 //*************************************************************************************************
859 template< typename Type // Data type of the matrix
860  , bool SO > // Storage order
863 {
864  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
865  return ConstIterator( v_ + i*nn_ );
866 }
867 //*************************************************************************************************
868 
869 
870 //*************************************************************************************************
881 template< typename Type // Data type of the matrix
882  , bool SO > // Storage order
885 {
886  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
887  return ConstIterator( v_ + i*nn_ );
888 }
889 //*************************************************************************************************
890 
891 
892 //*************************************************************************************************
903 template< typename Type // Data type of the matrix
904  , bool SO > // Storage order
905 inline typename DynamicMatrix<Type,SO>::Iterator
907 {
908  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
909  return Iterator( v_ + i*nn_ + n_ );
910 }
911 //*************************************************************************************************
912 
913 
914 //*************************************************************************************************
925 template< typename Type // Data type of the matrix
926  , bool SO > // Storage order
928  DynamicMatrix<Type,SO>::end( size_t i ) const
929 {
930  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
931  return ConstIterator( v_ + i*nn_ + n_ );
932 }
933 //*************************************************************************************************
934 
935 
936 //*************************************************************************************************
947 template< typename Type // Data type of the matrix
948  , bool SO > // Storage order
951 {
952  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
953  return ConstIterator( v_ + i*nn_ + n_ );
954 }
955 //*************************************************************************************************
956 
957 
958 
959 
960 //=================================================================================================
961 //
962 // ASSIGNMENT OPERATORS
963 //
964 //=================================================================================================
965 
966 //*************************************************************************************************
987 template< typename Type // Data type of the matrix
988  , bool SO > // Storage order
989 template< typename Other // Data type of the initialization array
990  , size_t M // Number of rows of the initialization array
991  , size_t N > // Number of columns of the initialization array
992 inline DynamicMatrix<Type,SO>& DynamicMatrix<Type,SO>::operator=( const Other (&array)[M][N] )
993 {
994  resize( M, N, false );
995 
996  for( size_t i=0UL; i<M; ++i )
997  for( size_t j=0UL; j<N; ++j )
998  v_[i*nn_+j] = array[i][j];
999 
1000  return *this;
1001 }
1002 //*************************************************************************************************
1003 
1004 
1005 //*************************************************************************************************
1011 template< typename Type // Data type of the matrix
1012  , bool SO > // Storage order
1014 {
1015  for( size_t i=0UL; i<m_; ++i )
1016  for( size_t j=0UL; j<n_; ++j )
1017  v_[i*nn_+j] = rhs;
1018 
1019  return *this;
1020 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1033 template< typename Type // Data type of the matrix
1034  , bool SO > // Storage order
1036 {
1037  if( &rhs == this ) return *this;
1038 
1039  resize( rhs.m_, rhs.n_, false );
1040  smpAssign( *this, ~rhs );
1041 
1042  return *this;
1043 }
1044 //*************************************************************************************************
1045 
1046 
1047 //*************************************************************************************************
1056 template< typename Type // Data type of the matrix
1057  , bool SO > // Storage order
1058 template< typename MT // Type of the right-hand side matrix
1059  , bool SO2 > // Storage order of the right-hand side matrix
1061 {
1062  if( (~rhs).canAlias( this ) ) {
1063  DynamicMatrix tmp( ~rhs );
1064  swap( tmp );
1065  }
1066  else {
1067  resize( (~rhs).rows(), (~rhs).columns(), false );
1069  reset();
1070  smpAssign( *this, ~rhs );
1071  }
1072 
1073  return *this;
1074 }
1075 //*************************************************************************************************
1076 
1077 
1078 //*************************************************************************************************
1088 template< typename Type // Data type of the matrix
1089  , bool SO > // Storage order
1090 template< typename MT // Type of the right-hand side matrix
1091  , bool SO2 > // Storage order of the right-hand side matrix
1093 {
1094  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1095  throw std::invalid_argument( "Matrix sizes do not match" );
1096 
1097  if( (~rhs).canAlias( this ) ) {
1098  typename MT::ResultType tmp( ~rhs );
1099  smpAddAssign( *this, tmp );
1100  }
1101  else {
1102  smpAddAssign( *this, ~rhs );
1103  }
1104 
1105  return *this;
1106 }
1107 //*************************************************************************************************
1108 
1109 
1110 //*************************************************************************************************
1120 template< typename Type // Data type of the matrix
1121  , bool SO > // Storage order
1122 template< typename MT // Type of the right-hand side matrix
1123  , bool SO2 > // Storage order of the right-hand side matrix
1125 {
1126  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1127  throw std::invalid_argument( "Matrix sizes do not match" );
1128 
1129  if( (~rhs).canAlias( this ) ) {
1130  typename MT::ResultType tmp( ~rhs );
1131  smpSubAssign( *this, tmp );
1132  }
1133  else {
1134  smpSubAssign( *this, ~rhs );
1135  }
1136 
1137  return *this;
1138 }
1139 //*************************************************************************************************
1140 
1141 
1142 //*************************************************************************************************
1152 template< typename Type // Data type of the matrix
1153  , bool SO > // Storage order
1154 template< typename MT // Type of the right-hand side matrix
1155  , bool SO2 > // Storage order of the right-hand side matrix
1157 {
1158  if( (~rhs).rows() != n_ )
1159  throw std::invalid_argument( "Matrix sizes do not match" );
1160 
1161  DynamicMatrix tmp( *this * (~rhs) );
1162  swap( tmp );
1163 
1164  return *this;
1165 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1176 template< typename Type // Data type of the matrix
1177  , bool SO > // Storage order
1178 template< typename Other > // Data type of the right-hand side scalar
1179 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1181 {
1182  smpAssign( *this, (*this) * rhs );
1183  return *this;
1184 }
1185 //*************************************************************************************************
1186 
1187 
1188 //*************************************************************************************************
1195 template< typename Type // Data type of the matrix
1196  , bool SO > // Storage order
1197 template< typename Other > // Data type of the right-hand side scalar
1198 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1200 {
1201  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1202 
1203  smpAssign( *this, (*this) / rhs );
1204  return *this;
1205 }
1206 //*************************************************************************************************
1207 
1208 
1209 
1210 
1211 //=================================================================================================
1212 //
1213 // UTILITY FUNCTIONS
1214 //
1215 //=================================================================================================
1216 
1217 //*************************************************************************************************
1222 template< typename Type // Data type of the matrix
1223  , bool SO > // Storage order
1224 inline size_t DynamicMatrix<Type,SO>::rows() const
1225 {
1226  return m_;
1227 }
1228 //*************************************************************************************************
1229 
1230 
1231 //*************************************************************************************************
1236 template< typename Type // Data type of the matrix
1237  , bool SO > // Storage order
1238 inline size_t DynamicMatrix<Type,SO>::columns() const
1239 {
1240  return n_;
1241 }
1242 //*************************************************************************************************
1243 
1244 
1245 //*************************************************************************************************
1255 template< typename Type // Data type of the matrix
1256  , bool SO > // Storage order
1257 inline size_t DynamicMatrix<Type,SO>::spacing() const
1258 {
1259  return nn_;
1260 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1269 template< typename Type // Data type of the matrix
1270  , bool SO > // Storage order
1272 {
1273  return capacity_;
1274 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1289 template< typename Type // Data type of the sparse matrix
1290  , bool SO > // Storage order
1291 inline size_t DynamicMatrix<Type,SO>::capacity( size_t i ) const
1292 {
1293  UNUSED_PARAMETER( i );
1294  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1295  return nn_;
1296 }
1297 //*************************************************************************************************
1298 
1299 
1300 //*************************************************************************************************
1305 template< typename Type // Data type of the matrix
1306  , bool SO > // Storage order
1308 {
1309  size_t nonzeros( 0UL );
1310 
1311  for( size_t i=0UL; i<m_; ++i )
1312  for( size_t j=0UL; j<n_; ++j )
1313  if( !isDefault( v_[i*nn_+j] ) )
1314  ++nonzeros;
1315 
1316  return nonzeros;
1317 }
1318 //*************************************************************************************************
1319 
1320 
1321 //*************************************************************************************************
1332 template< typename Type // Data type of the matrix
1333  , bool SO > // Storage order
1334 inline size_t DynamicMatrix<Type,SO>::nonZeros( size_t i ) const
1335 {
1336  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1337 
1338  const size_t jend( (i+1UL)*nn_ );
1339  size_t nonzeros( 0UL );
1340 
1341  for( size_t j=i*nn_; j<jend; ++j )
1342  if( !isDefault( v_[j] ) )
1343  ++nonzeros;
1344 
1345  return nonzeros;
1346 }
1347 //*************************************************************************************************
1348 
1349 
1350 //*************************************************************************************************
1355 template< typename Type // Data type of the matrix
1356  , bool SO > // Storage order
1358 {
1359  using blaze::clear;
1360 
1361  for( size_t i=0UL; i<m_; ++i )
1362  for( size_t j=0UL; j<n_; ++j )
1363  clear( v_[i*nn_+j] );
1364 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1379 template< typename Type // Data type of the sparse matrix
1380  , bool SO > // Storage order
1381 inline void DynamicMatrix<Type,SO>::reset( size_t i )
1382 {
1383  using blaze::clear;
1384 
1385  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1386  for( size_t j=0UL; j<n_; ++j )
1387  clear( v_[i*nn_+j] );
1388 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1399 template< typename Type // Data type of the matrix
1400  , bool SO > // Storage order
1402 {
1403  resize( 0UL, 0UL, false );
1404 }
1405 //*************************************************************************************************
1406 
1407 
1408 //*************************************************************************************************
1442 template< typename Type // Data type of the matrix
1443  , bool SO > // Storage order
1444 void DynamicMatrix<Type,SO>::resize( size_t m, size_t n, bool preserve )
1445 {
1446  using blaze::min;
1447 
1448  if( m == m_ && n == n_ ) return;
1449 
1450  const size_t nn( adjustColumns( n ) );
1451 
1452  if( preserve )
1453  {
1454  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1455  const size_t min_m( min( m, m_ ) );
1456  const size_t min_n( min( n, n_ ) );
1457 
1458  for( size_t i=0UL; i<min_m; ++i )
1459  for( size_t j=0UL; j<min_n; ++j )
1460  v[i*nn+j] = v_[i*nn_+j];
1461 
1462  std::swap( v_, v );
1463  deallocate( v );
1464  capacity_ = m*nn;
1465  }
1466  else if( m*nn > capacity_ ) {
1467  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1468  std::swap( v_, v );
1469  deallocate( v );
1470  capacity_ = m*nn;
1471  }
1472 
1474  for( size_t i=0UL; i<m; ++i )
1475  for( size_t j=n; j<nn; ++j )
1476  v_[i*nn+j] = Type();
1477  }
1478 
1479  m_ = m;
1480  n_ = n;
1481  nn_ = nn;
1482 }
1483 //*************************************************************************************************
1484 
1485 
1486 //*************************************************************************************************
1500 template< typename Type // Data type of the matrix
1501  , bool SO > // Storage order
1502 inline void DynamicMatrix<Type,SO>::extend( size_t m, size_t n, bool preserve )
1503 {
1504  resize( m_+m, n_+n, preserve );
1505 }
1506 //*************************************************************************************************
1507 
1508 
1509 //*************************************************************************************************
1518 template< typename Type // Data type of the matrix
1519  , bool SO > // Storage order
1520 inline void DynamicMatrix<Type,SO>::reserve( size_t elements )
1521 {
1522  if( elements > capacity_ )
1523  {
1524  // Allocating a new array
1525  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
1526 
1527  // Initializing the new array
1528  std::copy( v_, v_+capacity_, tmp );
1529 
1531  for( size_t i=capacity_; i<elements; ++i )
1532  tmp[i] = Type();
1533  }
1534 
1535  // Replacing the old array
1536  std::swap( tmp, v_ );
1537  deallocate( tmp );
1538  capacity_ = elements;
1539  }
1540 }
1541 //*************************************************************************************************
1542 
1543 
1544 //*************************************************************************************************
1549 template< typename Type // Data type of the matrix
1550  , bool SO > // Storage order
1552 {
1553  DynamicMatrix tmp( trans(*this) );
1554  swap( tmp );
1555  return *this;
1556 }
1557 //*************************************************************************************************
1558 
1559 
1560 //*************************************************************************************************
1566 template< typename Type // Data type of the matrix
1567  , bool SO > // Storage order
1568 template< typename Other > // Data type of the scalar value
1570 {
1571  for( size_t i=0UL; i<m_; ++i )
1572  for( size_t j=0UL; j<n_; ++j )
1573  v_[i*nn_+j] *= scalar;
1574 
1575  return *this;
1576 }
1577 //*************************************************************************************************
1578 
1579 
1580 //*************************************************************************************************
1587 template< typename Type // Data type of the matrix
1588  , bool SO > // Storage order
1589 inline void DynamicMatrix<Type,SO>::swap( DynamicMatrix& m ) /* throw() */
1590 {
1591  std::swap( m_ , m.m_ );
1592  std::swap( n_ , m.n_ );
1593  std::swap( nn_, m.nn_ );
1595  std::swap( v_ , m.v_ );
1596 }
1597 //*************************************************************************************************
1598 
1599 
1600 //*************************************************************************************************
1606 template< typename Type // Data type of the matrix
1607  , bool SO > // Storage order
1608 inline size_t DynamicMatrix<Type,SO>::adjustColumns( size_t minColumns ) const
1609 {
1611  return minColumns + ( IT::size - ( minColumns % IT::size ) ) % IT::size;
1612  else return minColumns;
1613 }
1614 //*************************************************************************************************
1615 
1616 
1617 
1618 
1619 //=================================================================================================
1620 //
1621 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1622 //
1623 //=================================================================================================
1624 
1625 //*************************************************************************************************
1635 template< typename Type // Data type of the matrix
1636  , bool SO > // Storage order
1637 template< typename Other > // Data type of the foreign expression
1638 inline bool DynamicMatrix<Type,SO>::canAlias( const Other* alias ) const
1639 {
1640  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1641 }
1642 //*************************************************************************************************
1643 
1644 
1645 //*************************************************************************************************
1655 template< typename Type // Data type of the matrix
1656  , bool SO > // Storage order
1657 template< typename Other > // Data type of the foreign expression
1658 inline bool DynamicMatrix<Type,SO>::isAliased( const Other* alias ) const
1659 {
1660  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1661 }
1662 //*************************************************************************************************
1663 
1664 
1665 //*************************************************************************************************
1674 template< typename Type // Data type of the matrix
1675  , bool SO > // Storage order
1677 {
1678  return true;
1679 }
1680 //*************************************************************************************************
1681 
1682 
1683 //*************************************************************************************************
1693 template< typename Type // Data type of the matrix
1694  , bool SO > // Storage order
1696 {
1697  return ( rows() > SMP_DMATASSIGN_THRESHOLD );
1698 }
1699 //*************************************************************************************************
1700 
1701 
1702 //*************************************************************************************************
1717 template< typename Type // Data type of the matrix
1718  , bool SO > // Storage order
1720  DynamicMatrix<Type,SO>::load( size_t i, size_t j ) const
1721 {
1722  using blaze::load;
1723 
1725 
1726  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1727  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1728  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1729  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1730 
1731  return load( v_+i*nn_+j );
1732 }
1733 //*************************************************************************************************
1734 
1735 
1736 //*************************************************************************************************
1751 template< typename Type // Data type of the matrix
1752  , bool SO > // Storage order
1754  DynamicMatrix<Type,SO>::loadu( size_t i, size_t j ) const
1755 {
1756  using blaze::loadu;
1757 
1759 
1760  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1761  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1762  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1763 
1764  return loadu( v_+i*nn_+j );
1765 }
1766 //*************************************************************************************************
1767 
1768 
1769 //*************************************************************************************************
1785 template< typename Type // Data type of the matrix
1786  , bool SO > // Storage order
1788  DynamicMatrix<Type,SO>::store( size_t i, size_t j, const IntrinsicType& value )
1789 {
1790  using blaze::store;
1791 
1793 
1794  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1795  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1796  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1797  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1798 
1799  store( v_+i*nn_+j, value );
1800 }
1801 //*************************************************************************************************
1802 
1803 
1804 //*************************************************************************************************
1820 template< typename Type // Data type of the matrix
1821  , bool SO > // Storage order
1823  DynamicMatrix<Type,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
1824 {
1825  using blaze::storeu;
1826 
1828 
1829  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1830  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1831  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1832 
1833  storeu( v_+i*nn_+j, value );
1834 }
1835 //*************************************************************************************************
1836 
1837 
1838 //*************************************************************************************************
1854 template< typename Type // Data type of the matrix
1855  , bool SO > // Storage order
1857  DynamicMatrix<Type,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
1858 {
1859  using blaze::stream;
1860 
1862 
1863  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1864  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1865  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1866  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1867 
1868  stream( v_+i*nn_+j, value );
1869 }
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1884 template< typename Type // Data type of the matrix
1885  , bool SO > // Storage order
1886 template< typename MT > // Type of the right-hand side dense matrix
1887 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
1889 {
1890  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1891  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1892 
1893  const size_t jpos( n_ & size_t(-2) );
1894  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % 2UL ) ) == jpos, "Invalid end calculation" );
1895 
1896  for( size_t i=0UL; i<m_; ++i ) {
1897  for( size_t j=0UL; j<jpos; j+=2UL ) {
1898  v_[i*nn_+j ] = (~rhs)(i,j );
1899  v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1900  }
1901  if( jpos < n_ ) {
1902  v_[i*nn_+jpos] = (~rhs)(i,jpos);
1903  }
1904  }
1905 }
1906 //*************************************************************************************************
1907 
1908 
1909 //*************************************************************************************************
1920 template< typename Type // Data type of the matrix
1921  , bool SO > // Storage order
1922 template< typename MT > // Type of the right-hand side dense matrix
1923 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
1925 {
1926  using blaze::store;
1927  using blaze::stream;
1928 
1930 
1931  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1932  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1933 
1934  if( useStreaming && m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
1935  {
1936  for( size_t i=0UL; i<m_; ++i )
1937  for( size_t j=0UL; j<n_; j+=IT::size )
1938  stream( v_+i*nn_+j, (~rhs).load(i,j) );
1939  }
1940  else
1941  {
1942  const size_t jpos( n_ & size_t(-IT::size*4) );
1943  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % (IT::size*4UL) ) ) == jpos, "Invalid end calculation" );
1944 
1945  for( size_t i=0UL; i<m_; ++i ) {
1946  typename MT::ConstIterator it( (~rhs).begin(i) );
1947  for( size_t j=0UL; j<jpos; j+=IT::size*4UL ) {
1948  store( v_+i*nn_+j , it.load() ); it += IT::size;
1949  store( v_+i*nn_+j+IT::size , it.load() ); it += IT::size;
1950  store( v_+i*nn_+j+IT::size*2UL, it.load() ); it += IT::size;
1951  store( v_+i*nn_+j+IT::size*3UL, it.load() ); it += IT::size;
1952  }
1953  for( size_t j=jpos; j<n_; j+=IT::size, it+=IT::size ) {
1954  store( v_+i*nn_+j, it.load() );
1955  }
1956  }
1957  }
1958 }
1959 //*************************************************************************************************
1960 
1961 
1962 //*************************************************************************************************
1973 template< typename Type // Data type of the matrix
1974  , bool SO > // Storage order
1975 template< typename MT > // Type of the right-hand side dense matrix
1977 {
1979 
1980  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1981  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1982 
1983  const size_t block( 16UL );
1984 
1985  for( size_t ii=0UL; ii<m_; ii+=block ) {
1986  const size_t iend( min( m_, ii+block ) );
1987  for( size_t jj=0UL; jj<n_; jj+=block ) {
1988  const size_t jend( min( n_, jj+block ) );
1989  for( size_t i=ii; i<iend; ++i ) {
1990  for( size_t j=jj; j<jend; ++j ) {
1991  v_[i*nn_+j] = (~rhs)(i,j);
1992  }
1993  }
1994  }
1995  }
1996 }
1997 //*************************************************************************************************
1998 
1999 
2000 //*************************************************************************************************
2011 template< typename Type // Data type of the matrix
2012  , bool SO > // Storage order
2013 template< typename MT > // Type of the right-hand side sparse matrix
2015 {
2016  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2017  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2018 
2019  for( size_t i=0UL; i<m_; ++i )
2020  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2021  v_[i*nn_+element->index()] = element->value();
2022 }
2023 //*************************************************************************************************
2024 
2025 
2026 //*************************************************************************************************
2037 template< typename Type // Data type of the matrix
2038  , bool SO > // Storage order
2039 template< typename MT > // Type of the right-hand side sparse matrix
2041 {
2043 
2044  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2045  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2046 
2047  for( size_t j=0UL; j<n_; ++j )
2048  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2049  v_[element->index()*nn_+j] = element->value();
2050 }
2051 //*************************************************************************************************
2052 
2053 
2054 //*************************************************************************************************
2065 template< typename Type // Data type of the matrix
2066  , bool SO > // Storage order
2067 template< typename MT > // Type of the right-hand side dense matrix
2068 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2070 {
2071  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2072  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2073 
2074  for( size_t i=0UL; i<m_; ++i )
2075  {
2076  if( IsDiagonal<MT>::value )
2077  {
2078  v_[i*nn_+i] += (~rhs)(i,i);
2079  }
2080  else
2081  {
2082  const size_t jbegin( ( IsUpper<MT>::value )
2083  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2084  :( 0UL ) );
2085  const size_t jend ( ( IsLower<MT>::value )
2086  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2087  :( n_ ) );
2088  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2089 
2090  size_t j( jbegin );
2091 
2092  for( ; (j+2UL) <= jend; j+=2UL ) {
2093  v_[i*nn_+j ] += (~rhs)(i,j );
2094  v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2095  }
2096  if( j < jend ) {
2097  v_[i*nn_+j] += (~rhs)(i,j);
2098  }
2099  }
2100  }
2101 }
2102 //*************************************************************************************************
2103 
2104 
2105 //*************************************************************************************************
2116 template< typename Type // Data type of the matrix
2117  , bool SO > // Storage order
2118 template< typename MT > // Type of the right-hand side dense matrix
2119 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2121 {
2122  using blaze::load;
2123  using blaze::store;
2124 
2127 
2128  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2129  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2130 
2131  for( size_t i=0UL; i<m_; ++i )
2132  {
2133  const size_t jbegin( ( IsUpper<MT>::value )
2134  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
2135  :( 0UL ) );
2136  const size_t jend ( ( IsLower<MT>::value )
2137  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2138  :( n_ ) );
2139  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2140 
2141  size_t j( jbegin );
2142  typename MT::ConstIterator it( (~rhs).begin(i) + jbegin );
2143 
2144  for( ; (j+IT::size*3UL) < jend; j+=IT::size*4UL ) {
2145  store( v_+i*nn_+j , load( v_+i*nn_+j ) + it.load() ); it += IT::size;
2146  store( v_+i*nn_+j+IT::size , load( v_+i*nn_+j+IT::size ) + it.load() ); it += IT::size;
2147  store( v_+i*nn_+j+IT::size*2UL, load( v_+i*nn_+j+IT::size*2UL ) + it.load() ); it += IT::size;
2148  store( v_+i*nn_+j+IT::size*3UL, load( v_+i*nn_+j+IT::size*3UL ) + it.load() ); it += IT::size;
2149  }
2150  for( ; j<jend; j+=IT::size, it+=IT::size ) {
2151  store( v_+i*nn_+j, load( v_+i*nn_+j ) + it.load() );
2152  }
2153  }
2154 }
2155 //*************************************************************************************************
2156 
2157 
2158 //*************************************************************************************************
2169 template< typename Type // Data type of the matrix
2170  , bool SO > // Storage order
2171 template< typename MT > // Type of the right-hand side dense matrix
2173 {
2175 
2176  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2177  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2178 
2179  const size_t block( 16UL );
2180 
2181  for( size_t ii=0UL; ii<m_; ii+=block ) {
2182  const size_t iend( min( m_, ii+block ) );
2183  for( size_t jj=0UL; jj<n_; jj+=block )
2184  {
2185  if( IsLower<MT>::value && ii < jj ) break;
2186  if( IsUpper<MT>::value && ii > jj ) continue;
2187 
2188  for( size_t i=ii; i<iend; ++i )
2189  {
2190  const size_t jbegin( ( IsUpper<MT>::value )
2191  ?( max( ( IsStrictlyUpper<MT>::value ? i+1UL : i ), jj ) )
2192  :( jj ) );
2193  const size_t jend ( ( IsLower<MT>::value )
2194  ?( min( ( IsStrictlyLower<MT>::value ? i : i+1UL ), n_, jj+block ) )
2195  :( min( n_, jj+block ) ) );
2196  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2197 
2198  for( size_t j=jbegin; j<jend; ++j ) {
2199  v_[i*nn_+j] += (~rhs)(i,j);
2200  }
2201  }
2202  }
2203  }
2204 }
2205 //*************************************************************************************************
2206 
2207 
2208 //*************************************************************************************************
2219 template< typename Type // Data type of the matrix
2220  , bool SO > // Storage order
2221 template< typename MT > // Type of the right-hand side sparse matrix
2223 {
2224  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2225  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2226 
2227  for( size_t i=0UL; i<m_; ++i )
2228  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2229  v_[i*nn_+element->index()] += element->value();
2230 }
2231 //*************************************************************************************************
2232 
2233 
2234 //*************************************************************************************************
2245 template< typename Type // Data type of the matrix
2246  , bool SO > // Storage order
2247 template< typename MT > // Type of the right-hand side sparse matrix
2249 {
2251 
2252  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2253  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2254 
2255  for( size_t j=0UL; j<n_; ++j )
2256  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2257  v_[element->index()*nn_+j] += element->value();
2258 }
2259 //*************************************************************************************************
2260 
2261 
2262 //*************************************************************************************************
2273 template< typename Type // Data type of the matrix
2274  , bool SO > // Storage order
2275 template< typename MT > // Type of the right-hand side dense matrix
2276 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2278 {
2279  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2280  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2281 
2282  for( size_t i=0UL; i<m_; ++i )
2283  {
2284  if( IsDiagonal<MT>::value )
2285  {
2286  v_[i*nn_+i] -= (~rhs)(i,i);
2287  }
2288  else
2289  {
2290  const size_t jbegin( ( IsUpper<MT>::value )
2291  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2292  :( 0UL ) );
2293  const size_t jend ( ( IsLower<MT>::value )
2294  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2295  :( n_ ) );
2296  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2297 
2298  size_t j( jbegin );
2299 
2300  for( ; (j+2UL) <= jend; j+=2UL ) {
2301  v_[i*nn_+j ] -= (~rhs)(i,j );
2302  v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2303  }
2304  if( j < jend ) {
2305  v_[i*nn_+j] -= (~rhs)(i,j);
2306  }
2307  }
2308  }
2309 }
2310 //*************************************************************************************************
2311 
2312 
2313 //*************************************************************************************************
2324 template< typename Type // Data type of the matrix
2325  , bool SO > // Storage order
2326 template< typename MT > // Type of the right-hand side dense matrix
2327 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2329 {
2330  using blaze::load;
2331  using blaze::store;
2332 
2335 
2336  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2337  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2338 
2339  for( size_t i=0UL; i<m_; ++i )
2340  {
2341  const size_t jbegin( ( IsUpper<MT>::value )
2342  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
2343  :( 0UL ) );
2344  const size_t jend ( ( IsLower<MT>::value )
2345  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2346  :( n_ ) );
2347  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2348 
2349  size_t j( jbegin );
2350  typename MT::ConstIterator it( (~rhs).begin(i) + jbegin );
2351 
2352  for( ; (j+IT::size*3UL) < jend; j+=IT::size*4UL ) {
2353  store( v_+i*nn_+j , load( v_+i*nn_+j ) - it.load() ); it += IT::size;
2354  store( v_+i*nn_+j+IT::size , load( v_+i*nn_+j+IT::size ) - it.load() ); it += IT::size;
2355  store( v_+i*nn_+j+IT::size*2UL, load( v_+i*nn_+j+IT::size*2UL ) - it.load() ); it += IT::size;
2356  store( v_+i*nn_+j+IT::size*3UL, load( v_+i*nn_+j+IT::size*3UL ) - it.load() ); it += IT::size;
2357  }
2358  for( ; j<jend; j+=IT::size, it+=IT::size ) {
2359  store( v_+i*nn_+j, load( v_+i*nn_+j ) - it.load() );
2360  }
2361  }
2362 }
2363 //*************************************************************************************************
2364 
2365 
2366 //*************************************************************************************************
2377 template< typename Type // Data type of the matrix
2378  , bool SO > // Storage order
2379 template< typename MT > // Type of the right-hand side dense matrix
2381 {
2383 
2384  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2385  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2386 
2387  const size_t block( 16UL );
2388 
2389  for( size_t ii=0UL; ii<m_; ii+=block ) {
2390  const size_t iend( min( m_, ii+block ) );
2391  for( size_t jj=0UL; jj<n_; jj+=block )
2392  {
2393  if( IsLower<MT>::value && ii < jj ) break;
2394  if( IsUpper<MT>::value && ii > jj ) continue;
2395 
2396  for( size_t i=ii; i<iend; ++i )
2397  {
2398  const size_t jbegin( ( IsUpper<MT>::value )
2399  ?( max( ( IsStrictlyUpper<MT>::value ? i+1UL : i ), jj ) )
2400  :( jj ) );
2401  const size_t jend ( ( IsLower<MT>::value )
2402  ?( min( ( IsStrictlyLower<MT>::value ? i : i+1UL ), n_, jj+block ) )
2403  :( min( n_, jj+block ) ) );
2404  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2405 
2406  for( size_t j=jbegin; j<jend; ++j ) {
2407  v_[i*nn_+j] -= (~rhs)(i,j);
2408  }
2409  }
2410  }
2411  }
2412 }
2413 //*************************************************************************************************
2414 
2415 
2416 //*************************************************************************************************
2427 template< typename Type // Data type of the matrix
2428  , bool SO > // Storage order
2429 template< typename MT > // Type of the right-hand side sparse matrix
2431 {
2432  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2433  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2434 
2435  for( size_t i=0UL; i<m_; ++i )
2436  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2437  v_[i*nn_+element->index()] -= element->value();
2438 }
2439 //*************************************************************************************************
2440 
2441 
2442 //*************************************************************************************************
2453 template< typename Type // Data type of the matrix
2454  , bool SO > // Storage order
2455 template< typename MT > // Type of the right-hand side sparse matrix
2457 {
2459 
2460  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2461  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2462 
2463  for( size_t j=0UL; j<n_; ++j )
2464  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2465  v_[element->index()*nn_+j] -= element->value();
2466 }
2467 //*************************************************************************************************
2468 
2469 
2470 
2471 
2472 
2473 
2474 
2475 
2476 //=================================================================================================
2477 //
2478 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2479 //
2480 //=================================================================================================
2481 
2482 //*************************************************************************************************
2490 template< typename Type > // Data type of the matrix
2491 class DynamicMatrix<Type,true> : public DenseMatrix< DynamicMatrix<Type,true>, true >
2492 {
2493  private:
2494  //**Type definitions****************************************************************************
2495  typedef IntrinsicTrait<Type> IT;
2496  //**********************************************************************************************
2497 
2498  public:
2499  //**Type definitions****************************************************************************
2500  typedef DynamicMatrix<Type,true> This;
2501  typedef This ResultType;
2504  typedef Type ElementType;
2505  typedef typename IT::Type IntrinsicType;
2506  typedef const Type& ReturnType;
2507  typedef const This& CompositeType;
2508  typedef Type& Reference;
2509  typedef const Type& ConstReference;
2510  typedef Type* Pointer;
2511  typedef const Type* ConstPointer;
2512  typedef DenseIterator<Type> Iterator;
2514  //**********************************************************************************************
2515 
2516  //**Rebind struct definition********************************************************************
2519  template< typename ET > // Data type of the other matrix
2520  struct Rebind {
2521  typedef DynamicMatrix<ET,true> Other;
2522  };
2523  //**********************************************************************************************
2524 
2525  //**Compilation flags***************************************************************************
2527 
2531  enum { vectorizable = IsVectorizable<Type>::value };
2532 
2534 
2537  enum { smpAssignable = !IsSMPAssignable<Type>::value };
2538  //**********************************************************************************************
2539 
2540  //**Constructors********************************************************************************
2543  explicit inline DynamicMatrix();
2544  explicit inline DynamicMatrix( size_t m, size_t n );
2545  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
2546  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
2547 
2548  template< typename Other, size_t M, size_t N >
2549  explicit inline DynamicMatrix( const Other (&array)[M][N] );
2550 
2551  inline DynamicMatrix( const DynamicMatrix& m );
2552  template< typename MT, bool SO > inline DynamicMatrix( const Matrix<MT,SO>& m );
2554  //**********************************************************************************************
2555 
2556  //**Destructor**********************************************************************************
2559  inline ~DynamicMatrix();
2561  //**********************************************************************************************
2562 
2563  //**Data access functions***********************************************************************
2566  inline Reference operator()( size_t i, size_t j );
2567  inline ConstReference operator()( size_t i, size_t j ) const;
2568  inline Pointer data ();
2569  inline ConstPointer data () const;
2570  inline Pointer data ( size_t j );
2571  inline ConstPointer data ( size_t j ) const;
2572  inline Iterator begin ( size_t j );
2573  inline ConstIterator begin ( size_t j ) const;
2574  inline ConstIterator cbegin( size_t j ) const;
2575  inline Iterator end ( size_t j );
2576  inline ConstIterator end ( size_t j ) const;
2577  inline ConstIterator cend ( size_t j ) const;
2579  //**********************************************************************************************
2580 
2581  //**Assignment operators************************************************************************
2584  template< typename Other, size_t M, size_t N >
2585  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
2586 
2587  inline DynamicMatrix& operator= ( Type set );
2588  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
2589  template< typename MT, bool SO > inline DynamicMatrix& operator= ( const Matrix<MT,SO>& rhs );
2590  template< typename MT, bool SO > inline DynamicMatrix& operator+=( const Matrix<MT,SO>& rhs );
2591  template< typename MT, bool SO > inline DynamicMatrix& operator-=( const Matrix<MT,SO>& rhs );
2592  template< typename MT, bool SO > inline DynamicMatrix& operator*=( const Matrix<MT,SO>& rhs );
2593 
2594  template< typename Other >
2595  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2596  operator*=( Other rhs );
2597 
2598  template< typename Other >
2599  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2600  operator/=( Other rhs );
2602  //**********************************************************************************************
2603 
2604  //**Utility functions***************************************************************************
2607  inline size_t rows() const;
2608  inline size_t columns() const;
2609  inline size_t spacing() const;
2610  inline size_t capacity() const;
2611  inline size_t capacity( size_t j ) const;
2612  inline size_t nonZeros() const;
2613  inline size_t nonZeros( size_t j ) const;
2614  inline void reset();
2615  inline void reset( size_t j );
2616  inline void clear();
2617  void resize ( size_t m, size_t n, bool preserve=true );
2618  inline void extend ( size_t m, size_t n, bool preserve=true );
2619  inline void reserve( size_t elements );
2620  inline DynamicMatrix& transpose();
2621  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
2622  inline void swap( DynamicMatrix& m ) /* throw() */;
2624  //**********************************************************************************************
2625 
2626  private:
2627  //**********************************************************************************************
2629  template< typename MT >
2630  struct VectorizedAssign {
2631  enum { value = vectorizable && MT::vectorizable &&
2632  IsSame<Type,typename MT::ElementType>::value };
2633  };
2634  //**********************************************************************************************
2635 
2636  //**********************************************************************************************
2638  template< typename MT >
2639  struct VectorizedAddAssign {
2640  enum { value = vectorizable && MT::vectorizable &&
2641  IsSame<Type,typename MT::ElementType>::value &&
2642  IntrinsicTrait<Type>::addition &&
2643  !IsDiagonal<MT>::value };
2644  };
2645  //**********************************************************************************************
2646 
2647  //**********************************************************************************************
2649  template< typename MT >
2650  struct VectorizedSubAssign {
2651  enum { value = vectorizable && MT::vectorizable &&
2652  IsSame<Type,typename MT::ElementType>::value &&
2653  IntrinsicTrait<Type>::subtraction &&
2654  !IsDiagonal<MT>::value };
2655  };
2656  //**********************************************************************************************
2657 
2658  public:
2659  //**Expression template evaluation functions****************************************************
2662  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2663  template< typename Other > inline bool isAliased( const Other* alias ) const;
2664 
2665  inline bool isAligned () const;
2666  inline bool canSMPAssign() const;
2667 
2668  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
2669  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
2670 
2671  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
2672  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
2673  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
2674 
2675  template< typename MT >
2676  inline typename DisableIf< VectorizedAssign<MT> >::Type
2677  assign( const DenseMatrix<MT,true>& rhs );
2678 
2679  template< typename MT >
2680  inline typename EnableIf< VectorizedAssign<MT> >::Type
2681  assign( const DenseMatrix<MT,true>& rhs );
2682 
2683  template< typename MT > inline void assign( const DenseMatrix<MT,false>& rhs );
2684  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2685  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2686 
2687  template< typename MT >
2688  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2689  addAssign( const DenseMatrix<MT,true>& rhs );
2690 
2691  template< typename MT >
2692  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2693  addAssign( const DenseMatrix<MT,true>& rhs );
2694 
2695  template< typename MT > inline void addAssign( const DenseMatrix<MT,false>& rhs );
2696  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2697  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2698 
2699  template< typename MT >
2700  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2701  subAssign ( const DenseMatrix<MT,true>& rhs );
2702 
2703  template< typename MT >
2704  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2705  subAssign ( const DenseMatrix<MT,true>& rhs );
2706 
2707  template< typename MT > inline void subAssign( const DenseMatrix<MT,false>& rhs );
2708  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2709  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2711  //**********************************************************************************************
2712 
2713  private:
2714  //**Utility functions***************************************************************************
2717  inline size_t adjustRows( size_t minRows ) const;
2719  //**********************************************************************************************
2720 
2721  //**Member variables****************************************************************************
2724  size_t m_;
2725  size_t mm_;
2726  size_t n_;
2727  size_t capacity_;
2728  Type* BLAZE_RESTRICT v_;
2729 
2739  //**********************************************************************************************
2740 
2741  //**Compile time checks*************************************************************************
2746  //**********************************************************************************************
2747 };
2749 //*************************************************************************************************
2750 
2751 
2752 
2753 
2754 //=================================================================================================
2755 //
2756 // CONSTRUCTORS
2757 //
2758 //=================================================================================================
2759 
2760 //*************************************************************************************************
2764 template< typename Type > // Data type of the matrix
2766  : m_ ( 0UL ) // The current number of rows of the matrix
2767  , mm_ ( 0UL ) // The alignment adjusted number of rows
2768  , n_ ( 0UL ) // The current number of columns of the matrix
2769  , capacity_( 0UL ) // The maximum capacity of the matrix
2770  , v_ ( NULL ) // The matrix elements
2771 {}
2773 //*************************************************************************************************
2774 
2775 
2776 //*************************************************************************************************
2786 template< typename Type > // Data type of the matrix
2787 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n )
2788  : m_ ( m ) // The current number of rows of the matrix
2789  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2790  , n_ ( n ) // The current number of columns of the matrix
2791  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2792  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2793 {
2794  if( IsVectorizable<Type>::value ) {
2795  for( size_t j=0UL; j<n_; ++j )
2796  for( size_t i=m_; i<mm_; ++i ) {
2797  v_[i+j*mm_] = Type();
2798  }
2799  }
2800 }
2802 //*************************************************************************************************
2803 
2804 
2805 //*************************************************************************************************
2815 template< typename Type > // Data type of the matrix
2816 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Type& init )
2817  : m_ ( m ) // The current number of rows of the matrix
2818  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2819  , n_ ( n ) // The current number of columns of the matrix
2820  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2821  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2822 {
2823  for( size_t j=0UL; j<n_; ++j ) {
2824  for( size_t i=0UL; i<m_; ++i )
2825  v_[i+j*mm_] = init;
2826 
2827  if( IsVectorizable<Type>::value ) {
2828  for( size_t i=m_; i<mm_; ++i )
2829  v_[i+j*mm_] = Type();
2830  }
2831  }
2832 }
2834 //*************************************************************************************************
2835 
2836 
2837 //*************************************************************************************************
2861 template< typename Type > // Data type of the matrix
2862 template< typename Other > // Data type of the initialization array
2863 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Other* array )
2864  : m_ ( m ) // The current number of rows of the matrix
2865  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2866  , n_ ( n ) // The current number of columns of the matrix
2867  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2868  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2869 {
2870  for( size_t j=0UL; j<n; ++j ) {
2871  for( size_t i=0UL; i<m; ++i )
2872  v_[i+j*mm_] = array[i+j*m];
2873 
2874  if( IsVectorizable<Type>::value ) {
2875  for( size_t i=m; i<mm_; ++i )
2876  v_[i+j*mm_] = Type();
2877  }
2878  }
2879 }
2881 //*************************************************************************************************
2882 
2883 
2884 //*************************************************************************************************
2906 template< typename Type > // Data type of the matrix
2907 template< typename Other // Data type of the initialization array
2908  , size_t M // Number of rows of the initialization array
2909  , size_t N > // Number of columns of the initialization array
2910 inline DynamicMatrix<Type,true>::DynamicMatrix( const Other (&array)[M][N] )
2911  : m_ ( M ) // The current number of rows of the matrix
2912  , mm_ ( adjustRows( M ) ) // The alignment adjusted number of rows
2913  , n_ ( N ) // The current number of columns of the matrix
2914  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2915  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2916 {
2917  for( size_t j=0UL; j<N; ++j ) {
2918  for( size_t i=0UL; i<M; ++i )
2919  v_[i+j*mm_] = array[i][j];
2920 
2921  if( IsVectorizable<Type>::value ) {
2922  for( size_t i=M; i<mm_; ++i )
2923  v_[i+j*mm_] = Type();
2924  }
2925  }
2926 }
2928 //*************************************************************************************************
2929 
2930 
2931 //*************************************************************************************************
2940 template< typename Type > // Data type of the matrix
2941 inline DynamicMatrix<Type,true>::DynamicMatrix( const DynamicMatrix& m )
2942  : m_ ( m.m_ ) // The current number of rows of the matrix
2943  , mm_ ( m.mm_ ) // The alignment adjusted number of rows
2944  , n_ ( m.n_ ) // The current number of columns of the matrix
2945  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2946  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2947 {
2948  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
2949 
2950  for( size_t i=0UL; i<capacity_; ++i )
2951  v_[i] = m.v_[i];
2952 }
2954 //*************************************************************************************************
2955 
2956 
2957 //*************************************************************************************************
2963 template< typename Type > // Data type of the matrix
2964 template< typename MT // Type of the foreign matrix
2965  , bool SO > // Storage order of the foreign matrix
2966 inline DynamicMatrix<Type,true>::DynamicMatrix( const Matrix<MT,SO>& m )
2967  : m_ ( (~m).rows() ) // The current number of rows of the matrix
2968  , mm_ ( adjustRows( m_ ) ) // The alignment adjusted number of rows
2969  , n_ ( (~m).columns() ) // The current number of columns of the matrix
2970  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2971  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2972 {
2973  for( size_t j=0UL; j<n_; ++j ) {
2974  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
2975  i<( IsVectorizable<Type>::value ? mm_ : m_ ); ++i ) {
2976  v_[i+j*mm_] = Type();
2977  }
2978  }
2979 
2980  smpAssign( *this, ~m );
2981 }
2983 //*************************************************************************************************
2984 
2985 
2986 
2987 
2988 //=================================================================================================
2989 //
2990 // DESTRUCTOR
2991 //
2992 //=================================================================================================
2993 
2994 //*************************************************************************************************
2998 template< typename Type > // Data type of the matrix
3000 {
3001  deallocate( v_ );
3002 }
3004 //*************************************************************************************************
3005 
3006 
3007 
3008 
3009 //=================================================================================================
3010 //
3011 // DATA ACCESS FUNCTIONS
3012 //
3013 //=================================================================================================
3014 
3015 //*************************************************************************************************
3023 template< typename Type > // Data type of the matrix
3025  DynamicMatrix<Type,true>::operator()( size_t i, size_t j )
3026 {
3027  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
3028  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
3029  return v_[i+j*mm_];
3030 }
3032 //*************************************************************************************************
3033 
3034 
3035 //*************************************************************************************************
3043 template< typename Type > // Data type of the matrix
3045  DynamicMatrix<Type,true>::operator()( size_t i, size_t j ) const
3046 {
3047  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
3048  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
3049  return v_[i+j*mm_];
3050 }
3052 //*************************************************************************************************
3053 
3054 
3055 //*************************************************************************************************
3067 template< typename Type > // Data type of the matrix
3068 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data()
3069 {
3070  return v_;
3071 }
3073 //*************************************************************************************************
3074 
3075 
3076 //*************************************************************************************************
3088 template< typename Type > // Data type of the matrix
3089 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data() const
3090 {
3091  return v_;
3092 }
3094 //*************************************************************************************************
3095 
3096 
3097 //*************************************************************************************************
3106 template< typename Type > // Data type of the matrix
3107 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data( size_t j )
3108 {
3109  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3110  return v_ + j*mm_;
3111 }
3113 //*************************************************************************************************
3114 
3115 
3116 //*************************************************************************************************
3125 template< typename Type > // Data type of the matrix
3126 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data( size_t j ) const
3127 {
3128  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3129  return v_ + j*mm_;
3130 }
3132 //*************************************************************************************************
3133 
3134 
3135 //*************************************************************************************************
3142 template< typename Type > // Data type of the matrix
3143 inline typename DynamicMatrix<Type,true>::Iterator
3145 {
3146  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3147  return Iterator( v_ + j*mm_ );
3148 }
3150 //*************************************************************************************************
3151 
3152 
3153 //*************************************************************************************************
3160 template< typename Type > // Data type of the matrix
3162  DynamicMatrix<Type,true>::begin( size_t j ) const
3163 {
3164  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3165  return ConstIterator( v_ + j*mm_ );
3166 }
3168 //*************************************************************************************************
3169 
3170 
3171 //*************************************************************************************************
3178 template< typename Type > // Data type of the matrix
3180  DynamicMatrix<Type,true>::cbegin( size_t j ) const
3181 {
3182  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3183  return ConstIterator( v_ + j*mm_ );
3184 }
3186 //*************************************************************************************************
3187 
3188 
3189 //*************************************************************************************************
3196 template< typename Type > // Data type of the matrix
3197 inline typename DynamicMatrix<Type,true>::Iterator
3198  DynamicMatrix<Type,true>::end( size_t j )
3199 {
3200  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3201  return Iterator( v_ + j*mm_ + m_ );
3202 }
3204 //*************************************************************************************************
3205 
3206 
3207 //*************************************************************************************************
3214 template< typename Type > // Data type of the matrix
3216  DynamicMatrix<Type,true>::end( size_t j ) const
3217 {
3218  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3219  return ConstIterator( v_ + j*mm_ + m_ );
3220 }
3222 //*************************************************************************************************
3223 
3224 
3225 //*************************************************************************************************
3232 template< typename Type > // Data type of the matrix
3234  DynamicMatrix<Type,true>::cend( size_t j ) const
3235 {
3236  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3237  return ConstIterator( v_ + j*mm_ + m_ );
3238 }
3240 //*************************************************************************************************
3241 
3242 
3243 
3244 
3245 //=================================================================================================
3246 //
3247 // ASSIGNMENT OPERATORS
3248 //
3249 //=================================================================================================
3250 
3251 //*************************************************************************************************
3273 template< typename Type > // Data type of the matrix
3274 template< typename Other // Data type of the initialization array
3275  , size_t M // Number of rows of the initialization array
3276  , size_t N > // Number of columns of the initialization array
3277 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Other (&array)[M][N] )
3278 {
3279  resize( M, N, false );
3280 
3281  for( size_t j=0UL; j<N; ++j )
3282  for( size_t i=0UL; i<M; ++i )
3283  v_[i+j*mm_] = array[i][j];
3284 
3285  return *this;
3286 }
3288 //*************************************************************************************************
3289 
3290 
3291 //*************************************************************************************************
3298 template< typename Type > // Data type of the matrix
3299 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3300 {
3301  for( size_t j=0UL; j<n_; ++j )
3302  for( size_t i=0UL; i<m_; ++i )
3303  v_[i+j*mm_] = rhs;
3304 
3305  return *this;
3306 }
3308 //*************************************************************************************************
3309 
3310 
3311 //*************************************************************************************************
3321 template< typename Type > // Data type of the matrix
3322 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const DynamicMatrix& rhs )
3323 {
3324  if( &rhs == this ) return *this;
3325 
3326  resize( rhs.m_, rhs.n_, false );
3327  smpAssign( *this, ~rhs );
3328 
3329  return *this;
3330 }
3332 //*************************************************************************************************
3333 
3334 
3335 //*************************************************************************************************
3345 template< typename Type > // Data type of the matrix
3346 template< typename MT // Type of the right-hand side matrix
3347  , bool SO > // Storage order of the right-hand side matrix
3348 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Matrix<MT,SO>& rhs )
3349 {
3350  if( (~rhs).canAlias( this ) ) {
3351  DynamicMatrix tmp( ~rhs );
3352  swap( tmp );
3353  }
3354  else {
3355  resize( (~rhs).rows(), (~rhs).columns(), false );
3356  if( IsSparseMatrix<MT>::value )
3357  reset();
3358  smpAssign( *this, ~rhs );
3359  }
3360 
3361  return *this;
3362 }
3364 //*************************************************************************************************
3365 
3366 
3367 //*************************************************************************************************
3378 template< typename Type > // Data type of the matrix
3379 template< typename MT // Type of the right-hand side matrix
3380  , bool SO > // Storage order of the right-hand side matrix
3381 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=( const Matrix<MT,SO>& rhs )
3382 {
3383  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3384  throw std::invalid_argument( "Matrix sizes do not match" );
3385 
3386  if( (~rhs).canAlias( this ) ) {
3387  typename MT::ResultType tmp( ~rhs );
3388  smpAddAssign( *this, tmp );
3389  }
3390  else {
3391  smpAddAssign( *this, ~rhs );
3392  }
3393 
3394  return *this;
3395 }
3397 //*************************************************************************************************
3398 
3399 
3400 //*************************************************************************************************
3411 template< typename Type > // Data type of the matrix
3412 template< typename MT // Type of the right-hand side matrix
3413  , bool SO > // Storage order of the right-hand side matrix
3414 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=( const Matrix<MT,SO>& rhs )
3415 {
3416  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3417  throw std::invalid_argument( "Matrix sizes do not match" );
3418 
3419  if( (~rhs).canAlias( this ) ) {
3420  typename MT::ResultType tmp( ~rhs );
3421  smpSubAssign( *this, tmp );
3422  }
3423  else {
3424  smpSubAssign( *this, ~rhs );
3425  }
3426 
3427  return *this;
3428 }
3430 //*************************************************************************************************
3431 
3432 
3433 //*************************************************************************************************
3444 template< typename Type > // Data type of the matrix
3445 template< typename MT // Type of the right-hand side matrix
3446  , bool SO > // Storage order of the right-hand side matrix
3447 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=( const Matrix<MT,SO>& rhs )
3448 {
3449  if( (~rhs).rows() != n_ )
3450  throw std::invalid_argument( "Matrix sizes do not match" );
3451 
3452  DynamicMatrix tmp( *this * (~rhs) );
3453  swap( tmp );
3454 
3455  return *this;
3456 }
3458 //*************************************************************************************************
3459 
3460 
3461 //*************************************************************************************************
3469 template< typename Type > // Data type of the matrix
3470 template< typename Other > // Data type of the right-hand side scalar
3471 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3472  DynamicMatrix<Type,true>::operator*=( Other rhs )
3473 {
3474  smpAssign( *this, (*this) * rhs );
3475  return *this;
3476 }
3478 //*************************************************************************************************
3479 
3480 
3481 //*************************************************************************************************
3489 template< typename Type > // Data type of the matrix
3490 template< typename Other > // Data type of the right-hand side scalar
3491 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3492  DynamicMatrix<Type,true>::operator/=( Other rhs )
3493 {
3494  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3495 
3496  smpAssign( *this, (*this) / rhs );
3497  return *this;
3498 }
3500 //*************************************************************************************************
3501 
3502 
3503 
3504 
3505 //=================================================================================================
3506 //
3507 // UTILITY FUNCTIONS
3508 //
3509 //=================================================================================================
3510 
3511 //*************************************************************************************************
3517 template< typename Type > // Data type of the matrix
3518 inline size_t DynamicMatrix<Type,true>::rows() const
3519 {
3520  return m_;
3521 }
3523 //*************************************************************************************************
3524 
3525 
3526 //*************************************************************************************************
3532 template< typename Type > // Data type of the matrix
3533 inline size_t DynamicMatrix<Type,true>::columns() const
3534 {
3535  return n_;
3536 }
3538 //*************************************************************************************************
3539 
3540 
3541 //*************************************************************************************************
3550 template< typename Type > // Data type of the matrix
3551 inline size_t DynamicMatrix<Type,true>::spacing() const
3552 {
3553  return mm_;
3554 }
3556 //*************************************************************************************************
3557 
3558 
3559 //*************************************************************************************************
3565 template< typename Type > // Data type of the matrix
3566 inline size_t DynamicMatrix<Type,true>::capacity() const
3567 {
3568  return capacity_;
3569 }
3571 //*************************************************************************************************
3572 
3573 
3574 //*************************************************************************************************
3581 template< typename Type > // Data type of the sparse matrix
3582 inline size_t DynamicMatrix<Type,true>::capacity( size_t j ) const
3583 {
3584  UNUSED_PARAMETER( j );
3585  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3586  return mm_;
3587 }
3589 //*************************************************************************************************
3590 
3591 
3592 //*************************************************************************************************
3598 template< typename Type > // Data type of the matrix
3599 inline size_t DynamicMatrix<Type,true>::nonZeros() const
3600 {
3601  size_t nonzeros( 0UL );
3602 
3603  for( size_t j=0UL; j<n_; ++j )
3604  for( size_t i=0UL; i<m_; ++i )
3605  if( !isDefault( v_[i+j*mm_] ) )
3606  ++nonzeros;
3607 
3608  return nonzeros;
3609 }
3611 //*************************************************************************************************
3612 
3613 
3614 //*************************************************************************************************
3621 template< typename Type > // Data type of the matrix
3622 inline size_t DynamicMatrix<Type,true>::nonZeros( size_t j ) const
3623 {
3624  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3625 
3626  const size_t iend( (j+1UL)*mm_ );
3627  size_t nonzeros( 0UL );
3628 
3629  for( size_t i=j*mm_; i<iend; ++i )
3630  if( !isDefault( v_[i] ) )
3631  ++nonzeros;
3632 
3633  return nonzeros;
3634 }
3636 //*************************************************************************************************
3637 
3638 
3639 //*************************************************************************************************
3645 template< typename Type > // Data type of the matrix
3646 inline void DynamicMatrix<Type,true>::reset()
3647 {
3648  using blaze::clear;
3649 
3650  for( size_t j=0UL; j<n_; ++j )
3651  for( size_t i=0UL; i<m_; ++i )
3652  clear( v_[i+j*mm_] );
3653 }
3655 //*************************************************************************************************
3656 
3657 
3658 //*************************************************************************************************
3668 template< typename Type > // Data type of the sparse matrix
3669 inline void DynamicMatrix<Type,true>::reset( size_t j )
3670 {
3671  using blaze::clear;
3672 
3673  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3674  for( size_t i=0UL; i<m_; ++i )
3675  clear( v_[i+j*mm_] );
3676 }
3678 //*************************************************************************************************
3679 
3680 
3681 //*************************************************************************************************
3689 template< typename Type > // Data type of the matrix
3690 inline void DynamicMatrix<Type,true>::clear()
3691 {
3692  resize( 0UL, 0UL, false );
3693 }
3695 //*************************************************************************************************
3696 
3697 
3698 //*************************************************************************************************
3733 template< typename Type > // Data type of the matrix
3734 void DynamicMatrix<Type,true>::resize( size_t m, size_t n, bool preserve )
3735 {
3736  using blaze::min;
3737 
3738  if( m == m_ && n == n_ ) return;
3739 
3740  const size_t mm( adjustRows( m ) );
3741 
3742  if( preserve )
3743  {
3744  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
3745  const size_t min_m( min( m, m_ ) );
3746  const size_t min_n( min( n, n_ ) );
3747 
3748  for( size_t j=0UL; j<min_n; ++j )
3749  for( size_t i=0UL; i<min_m; ++i )
3750  v[i+j*mm] = v_[i+j*mm_];
3751 
3752  std::swap( v_, v );
3753  deallocate( v );
3754  capacity_ = mm*n;
3755  }
3756  else if( mm*n > capacity_ ) {
3757  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
3758  std::swap( v_, v );
3759  deallocate( v );
3760  capacity_ = mm*n;
3761  }
3762 
3763  if( IsVectorizable<Type>::value ) {
3764  for( size_t j=0UL; j<n; ++j )
3765  for( size_t i=m; i<mm; ++i )
3766  v_[i+j*mm] = Type();
3767  }
3768 
3769  m_ = m;
3770  mm_ = mm;
3771  n_ = n;
3772 }
3774 //*************************************************************************************************
3775 
3776 
3777 //*************************************************************************************************
3792 template< typename Type > // Data type of the matrix
3793 inline void DynamicMatrix<Type,true>::extend( size_t m, size_t n, bool preserve )
3794 {
3795  resize( m_+m, n_+n, preserve );
3796 }
3798 //*************************************************************************************************
3799 
3800 
3801 //*************************************************************************************************
3811 template< typename Type > // Data type of the matrix
3812 inline void DynamicMatrix<Type,true>::reserve( size_t elements )
3813 {
3814  if( elements > capacity_ )
3815  {
3816  // Allocating a new array
3817  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
3818 
3819  // Initializing the new array
3820  std::copy( v_, v_+capacity_, tmp );
3821 
3822  if( IsVectorizable<Type>::value ) {
3823  for( size_t i=capacity_; i<elements; ++i )
3824  tmp[i] = Type();
3825  }
3826 
3827  // Replacing the old array
3828  std::swap( tmp, v_ );
3829  deallocate( tmp );
3830  capacity_ = elements;
3831  }
3832 }
3834 //*************************************************************************************************
3835 
3836 
3837 //*************************************************************************************************
3843 template< typename Type > // Data type of the matrix
3844 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::transpose()
3845 {
3846  DynamicMatrix tmp( trans(*this) );
3847  swap( tmp );
3848  return *this;
3849 }
3851 //*************************************************************************************************
3852 
3853 
3854 //*************************************************************************************************
3861 template< typename Type > // Data type of the matrix
3862 template< typename Other > // Data type of the scalar value
3863 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( const Other& scalar )
3864 {
3865  for( size_t j=0UL; j<n_; ++j )
3866  for( size_t i=0UL; i<m_; ++i )
3867  v_[i+j*mm_] *= scalar;
3868 
3869  return *this;
3870 }
3872 //*************************************************************************************************
3873 
3874 
3875 //*************************************************************************************************
3883 template< typename Type > // Data type of the matrix
3884 inline void DynamicMatrix<Type,true>::swap( DynamicMatrix& m ) /* throw() */
3885 {
3886  std::swap( m_ , m.m_ );
3887  std::swap( mm_, m.mm_ );
3888  std::swap( n_ , m.n_ );
3889  std::swap( capacity_, m.capacity_ );
3890  std::swap( v_ , m.v_ );
3891 }
3893 //*************************************************************************************************
3894 
3895 
3896 //*************************************************************************************************
3903 template< typename Type > // Data type of the matrix
3904 inline size_t DynamicMatrix<Type,true>::adjustRows( size_t minRows ) const
3905 {
3906  if( IsVectorizable<Type>::value )
3907  return minRows + ( IT::size - ( minRows % IT::size ) ) % IT::size;
3908  else return minRows;
3909 }
3911 //*************************************************************************************************
3912 
3913 
3914 
3915 
3916 //=================================================================================================
3917 //
3918 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3919 //
3920 //=================================================================================================
3921 
3922 //*************************************************************************************************
3933 template< typename Type > // Data type of the matrix
3934 template< typename Other > // Data type of the foreign expression
3935 inline bool DynamicMatrix<Type,true>::canAlias( const Other* alias ) const
3936 {
3937  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
3938 }
3940 //*************************************************************************************************
3941 
3942 
3943 //*************************************************************************************************
3954 template< typename Type > // Data type of the matrix
3955 template< typename Other > // Data type of the foreign expression
3956 inline bool DynamicMatrix<Type,true>::isAliased( const Other* alias ) const
3957 {
3958  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
3959 }
3961 //*************************************************************************************************
3962 
3963 
3964 //*************************************************************************************************
3974 template< typename Type > // Data type of the matrix
3975 inline bool DynamicMatrix<Type,true>::isAligned() const
3976 {
3977  return true;
3978 }
3980 //*************************************************************************************************
3981 
3982 
3983 //*************************************************************************************************
3994 template< typename Type > // Data type of the matrix
3995 inline bool DynamicMatrix<Type,true>::canSMPAssign() const
3996 {
3997  return ( columns() > SMP_DMATASSIGN_THRESHOLD );
3998 }
4000 //*************************************************************************************************
4001 
4002 
4003 //*************************************************************************************************
4018 template< typename Type > // Data type of the matrix
4019 BLAZE_ALWAYS_INLINE typename DynamicMatrix<Type,true>::IntrinsicType
4020  DynamicMatrix<Type,true>::load( size_t i, size_t j ) const
4021 {
4022  using blaze::load;
4023 
4025 
4026  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4027  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4028  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4029  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4030 
4031  return load( v_+i+j*mm_ );
4032 }
4034 //*************************************************************************************************
4035 
4036 
4037 //*************************************************************************************************
4052 template< typename Type > // Data type of the matrix
4053 BLAZE_ALWAYS_INLINE typename DynamicMatrix<Type,true>::IntrinsicType
4054  DynamicMatrix<Type,true>::loadu( size_t i, size_t j ) const
4055 {
4056  using blaze::loadu;
4057 
4059 
4060  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4061  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4062  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4063 
4064  return loadu( v_+i+j*mm_ );
4065 }
4067 //*************************************************************************************************
4068 
4069 
4070 //*************************************************************************************************
4086 template< typename Type > // Data type of the matrix
4088  DynamicMatrix<Type,true>::store( size_t i, size_t j, const IntrinsicType& value )
4089 {
4090  using blaze::store;
4091 
4093 
4094  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4095  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4096  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4097  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4098 
4099  store( v_+i+j*mm_, value );
4100 }
4102 //*************************************************************************************************
4103 
4104 
4105 //*************************************************************************************************
4121 template< typename Type > // Data type of the matrix
4123  DynamicMatrix<Type,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4124 {
4125  using blaze::storeu;
4126 
4128 
4129  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4130  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4131  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4132 
4133  storeu( v_+i+j*mm_, value );
4134 }
4136 //*************************************************************************************************
4137 
4138 
4139 //*************************************************************************************************
4156 template< typename Type > // Data type of the matrix
4158  DynamicMatrix<Type,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4159 {
4160  using blaze::stream;
4161 
4163 
4164  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4165  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4166  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4167  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4168 
4169  stream( v_+i+j*mm_, value );
4170 }
4172 //*************************************************************************************************
4173 
4174 
4175 //*************************************************************************************************
4187 template< typename Type > // Data type of the matrix
4188 template< typename MT > // Type of the right-hand side dense matrix
4189 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4190  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4191 {
4192  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4193  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4194 
4195  const size_t ipos( m_ & size_t(-2) );
4196  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % 2UL ) ) == ipos, "Invalid end calculation" );
4197 
4198  for( size_t j=0UL; j<n_; ++j ) {
4199  for( size_t i=0UL; i<ipos; i+=2UL ) {
4200  v_[i +j*mm_] = (~rhs)(i ,j);
4201  v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4202  }
4203  if( ipos < m_ ) {
4204  v_[ipos+j*mm_] = (~rhs)(ipos,j);
4205  }
4206  }
4207 }
4209 //*************************************************************************************************
4210 
4211 
4212 //*************************************************************************************************
4224 template< typename Type > // Data type of the matrix
4225 template< typename MT > // Type of the right-hand side dense matrix
4226 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4227  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4228 {
4229  using blaze::store;
4230  using blaze::stream;
4231 
4233 
4234  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4235  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4236 
4237  if( useStreaming && m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
4238  {
4239  for( size_t j=0UL; j<n_; ++j )
4240  for( size_t i=0UL; i<m_; i+=IT::size )
4241  stream( v_+i+j*mm_, (~rhs).load(i,j) );
4242  }
4243  else
4244  {
4245  const size_t ipos( m_ & size_t(-IT::size*4) );
4246  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % (IT::size*4UL) ) ) == ipos, "Invalid end calculation" );
4247 
4248  for( size_t j=0UL; j<n_; ++j ) {
4249  typename MT::ConstIterator it( (~rhs).begin(j) );
4250  for( size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
4251  store( v_+i+j*mm_ , it.load() ); it += IT::size;
4252  store( v_+i+j*mm_+IT::size , it.load() ); it += IT::size;
4253  store( v_+i+j*mm_+IT::size*2UL, it.load() ); it += IT::size;
4254  store( v_+i+j*mm_+IT::size*3UL, it.load() ); it += IT::size;
4255  }
4256  for( size_t i=ipos; i<m_; i+=IT::size, it+=IT::size ) {
4257  store( v_+i+j*mm_, it.load() );
4258  }
4259  }
4260  }
4261 }
4263 //*************************************************************************************************
4264 
4265 
4266 //*************************************************************************************************
4278 template< typename Type > // Data type of the matrix
4279 template< typename MT > // Type of the right-hand side dense matrix
4280 inline void DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,false>& rhs )
4281 {
4283 
4284  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4285  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4286 
4287  const size_t block( 16UL );
4288 
4289  for( size_t jj=0UL; jj<n_; jj+=block ) {
4290  const size_t jend( min( n_, jj+block ) );
4291  for( size_t ii=0UL; ii<m_; ii+=block ) {
4292  const size_t iend( min( m_, ii+block ) );
4293  for( size_t j=jj; j<jend; ++j ) {
4294  for( size_t i=ii; i<iend; ++i ) {
4295  v_[i+j*mm_] = (~rhs)(i,j);
4296  }
4297  }
4298  }
4299  }
4300 }
4302 //*************************************************************************************************
4303 
4304 
4305 //*************************************************************************************************
4317 template< typename Type > // Data type of the matrix
4318 template< typename MT > // Type of the right-hand side sparse matrix
4319 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,true>& rhs )
4320 {
4321  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4322  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4323 
4324  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4325  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4326  v_[element->index()+j*mm_] = element->value();
4327 }
4329 //*************************************************************************************************
4330 
4331 
4332 //*************************************************************************************************
4344 template< typename Type > // Data type of the matrix
4345 template< typename MT > // Type of the right-hand side sparse matrix
4346 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,false>& rhs )
4347 {
4349 
4350  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4351  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4352 
4353  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4354  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4355  v_[i+element->index()*mm_] = element->value();
4356 }
4358 //*************************************************************************************************
4359 
4360 
4361 //*************************************************************************************************
4373 template< typename Type > // Data type of the matrix
4374 template< typename MT > // Type of the right-hand side dense matrix
4375 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4376  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4377 {
4378  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4379  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4380 
4381  for( size_t j=0UL; j<n_; ++j )
4382  {
4383  if( IsDiagonal<MT>::value )
4384  {
4385  v_[j+j*mm_] += (~rhs)(j,j);
4386  }
4387  else
4388  {
4389  const size_t ibegin( ( IsLower<MT>::value )
4390  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4391  :( 0UL ) );
4392  const size_t iend ( ( IsUpper<MT>::value )
4393  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4394  :( m_ ) );
4395  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4396 
4397  size_t i( ibegin );
4398 
4399  for( ; (i+2UL) <= iend; i+=2UL ) {
4400  v_[i +j*mm_] += (~rhs)(i ,j);
4401  v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4402  }
4403  if( i < iend ) {
4404  v_[i+j*mm_] += (~rhs)(i,j);
4405  }
4406  }
4407  }
4408 }
4410 //*************************************************************************************************
4411 
4412 
4413 //*************************************************************************************************
4425 template< typename Type > // Data type of the matrix
4426 template< typename MT > // Type of the right-hand side dense matrix
4427 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4428  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4429 {
4430  using blaze::load;
4431  using blaze::store;
4432 
4435 
4436  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4437  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4438 
4439  for( size_t j=0UL; j<n_; ++j )
4440  {
4441  const size_t ibegin( ( IsLower<MT>::value )
4442  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
4443  :( 0UL ) );
4444  const size_t iend ( ( IsUpper<MT>::value )
4445  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4446  :( m_ ) );
4447  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4448 
4449  size_t i( ibegin );
4450  typename MT::ConstIterator it( (~rhs).begin(j) + ibegin );
4451 
4452  for( ; (i+IT::size*3UL) < iend; i+=IT::size*4UL ) {
4453  store( v_+i+j*mm_ , load( v_+i+j*mm_ ) + it.load() ); it += IT::size;
4454  store( v_+i+j*mm_+IT::size , load( v_+i+j*mm_+IT::size ) + it.load() ); it += IT::size;
4455  store( v_+i+j*mm_+IT::size*2UL, load( v_+i+j*mm_+IT::size*2UL ) + it.load() ); it += IT::size;
4456  store( v_+i+j*mm_+IT::size*3UL, load( v_+i+j*mm_+IT::size*3UL ) + it.load() ); it += IT::size;
4457  }
4458  for( ; i<iend; i+=IT::size, it+=IT::size ) {
4459  store( v_+i+j*mm_, load( v_+i+j*mm_ ) + it.load() );
4460  }
4461  }
4462 }
4464 //*************************************************************************************************
4465 
4466 
4467 //*************************************************************************************************
4479 template< typename Type > // Data type of the matrix
4480 template< typename MT > // Type of the right-hand side dense matrix
4481 inline void DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,false>& rhs )
4482 {
4484 
4485  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4486  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4487 
4488  const size_t block( 16UL );
4489 
4490  for( size_t jj=0UL; jj<n_; jj+=block ) {
4491  const size_t jend( min( n_, jj+block ) );
4492  for( size_t ii=0UL; ii<m_; ii+=block )
4493  {
4494  if( IsLower<MT>::value && ii < jj ) continue;
4495  if( IsUpper<MT>::value && ii > jj ) break;
4496 
4497  for( size_t j=jj; j<jend; ++j )
4498  {
4499  const size_t ibegin( ( IsLower<MT>::value )
4500  ?( max( ( IsStrictlyLower<MT>::value ? j+1UL : j ), ii ) )
4501  :( ii ) );
4502  const size_t iend ( ( IsUpper<MT>::value )
4503  ?( min( ( IsStrictlyUpper<MT>::value ? j : j+1UL ), m_, ii+block ) )
4504  :( min( m_, ii+block ) ) );
4505  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4506 
4507  for( size_t i=ibegin; i<iend; ++i ) {
4508  v_[i+j*mm_] += (~rhs)(i,j);
4509  }
4510  }
4511  }
4512  }
4513 }
4515 //*************************************************************************************************
4516 
4517 
4518 //*************************************************************************************************
4530 template< typename Type > // Data type of the matrix
4531 template< typename MT > // Type of the right-hand side sparse matrix
4532 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,true>& rhs )
4533 {
4534  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4535  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4536 
4537  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4538  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4539  v_[element->index()+j*mm_] += element->value();
4540 }
4542 //*************************************************************************************************
4543 
4544 
4545 //*************************************************************************************************
4557 template< typename Type > // Data type of the matrix
4558 template< typename MT > // Type of the right-hand side sparse matrix
4559 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,false>& rhs )
4560 {
4562 
4563  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4564  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4565 
4566  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4567  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4568  v_[i+element->index()*mm_] += element->value();
4569 }
4571 //*************************************************************************************************
4572 
4573 
4574 //*************************************************************************************************
4586 template< typename Type > // Data type of the matrix
4587 template< typename MT > // Type of the right-hand side dense matrix
4588 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4589  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
4590 {
4591  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4592  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4593 
4594  for( size_t j=0UL; j<n_; ++j )
4595  {
4596  if( IsDiagonal<MT>::value )
4597  {
4598  v_[j+j*mm_] -= (~rhs)(j,j);
4599  }
4600  else
4601  {
4602  const size_t ibegin( ( IsLower<MT>::value )
4603  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4604  :( 0UL ) );
4605  const size_t iend ( ( IsUpper<MT>::value )
4606  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4607  :( m_ ) );
4608  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4609 
4610  size_t i( ibegin );
4611 
4612  for( ; (i+2UL) <= iend; i+=2UL ) {
4613  v_[i +j*mm_] -= (~rhs)(i ,j);
4614  v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4615  }
4616  if( i < iend ) {
4617  v_[i+j*mm_] -= (~rhs)(i,j);
4618  }
4619  }
4620  }
4621 }
4623 //*************************************************************************************************
4624 
4625 
4626 //*************************************************************************************************
4639 template< typename Type > // Data type of the matrix
4640 template< typename MT > // Type of the right-hand side dense matrix
4641 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4642  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
4643 {
4644  using blaze::load;
4645  using blaze::store;
4646 
4649 
4650  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4651  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4652 
4653  for( size_t j=0UL; j<n_; ++j )
4654  {
4655  const size_t ibegin( ( IsLower<MT>::value )
4656  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
4657  :( 0UL ) );
4658  const size_t iend ( ( IsUpper<MT>::value )
4659  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4660  :( m_ ) );
4661  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4662 
4663  size_t i( ibegin );
4664  typename MT::ConstIterator it( (~rhs).begin(j) + ibegin );
4665 
4666  for( ; (i+IT::size*3UL) < iend; i+=IT::size*4UL ) {
4667  store( v_+i+j*mm_ , load( v_+i+j*mm_ ) - it.load() ); it += IT::size;
4668  store( v_+i+j*mm_+IT::size , load( v_+i+j*mm_+IT::size ) - it.load() ); it += IT::size;
4669  store( v_+i+j*mm_+IT::size*2UL, load( v_+i+j*mm_+IT::size*2UL ) - it.load() ); it += IT::size;
4670  store( v_+i+j*mm_+IT::size*3UL, load( v_+i+j*mm_+IT::size*3UL ) - it.load() ); it += IT::size;
4671  }
4672  for( ; i<iend; i+=IT::size, it+=IT::size ) {
4673  store( v_+i+j*mm_, load( v_+i+j*mm_ ) - it.load() );
4674  }
4675  }
4676 }
4678 //*************************************************************************************************
4679 
4680 
4681 //*************************************************************************************************
4693 template< typename Type > // Data type of the matrix
4694 template< typename MT > // Type of the right-hand side dense matrix
4695 inline void DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,false>& rhs )
4696 {
4698 
4699  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4700  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4701 
4702  const size_t block( 16UL );
4703 
4704  for( size_t jj=0UL; jj<n_; jj+=block ) {
4705  const size_t jend( min( n_, jj+block ) );
4706  for( size_t ii=0UL; ii<m_; ii+=block )
4707  {
4708  if( IsLower<MT>::value && ii < jj ) continue;
4709  if( IsUpper<MT>::value && ii > jj ) break;
4710 
4711  for( size_t j=jj; j<jend; ++j )
4712  {
4713  const size_t ibegin( ( IsLower<MT>::value )
4714  ?( max( ( IsStrictlyLower<MT>::value ? j+1UL : j ), ii ) )
4715  :( ii ) );
4716  const size_t iend ( ( IsUpper<MT>::value )
4717  ?( min( ( IsStrictlyUpper<MT>::value ? j : j+1UL ), m_, ii+block ) )
4718  :( min( m_, ii+block ) ) );
4719  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4720 
4721  for( size_t i=ibegin; i<iend; ++i ) {
4722  v_[i+j*mm_] -= (~rhs)(i,j);
4723  }
4724  }
4725  }
4726  }
4727 }
4729 //*************************************************************************************************
4730 
4731 
4732 //*************************************************************************************************
4744 template< typename Type > // Data type of the matrix
4745 template< typename MT > // Type of the right-hand side sparse matrix
4746 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,true>& rhs )
4747 {
4748  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4749  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4750 
4751  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4752  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4753  v_[element->index()+j*mm_] -= element->value();
4754 }
4756 //*************************************************************************************************
4757 
4758 
4759 //*************************************************************************************************
4771 template< typename Type > // Data type of the matrix
4772 template< typename MT > // Type of the right-hand side sparse matrix
4773 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,false>& rhs )
4774 {
4776 
4777  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4778  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4779 
4780  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4781  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4782  v_[i+element->index()*mm_] -= element->value();
4783 }
4785 //*************************************************************************************************
4786 
4787 
4788 
4789 
4790 
4791 
4792 
4793 
4794 //=================================================================================================
4795 //
4796 // DYNAMICMATRIX OPERATORS
4797 //
4798 //=================================================================================================
4799 
4800 //*************************************************************************************************
4803 template< typename Type, bool SO >
4804 inline void reset( DynamicMatrix<Type,SO>& m );
4805 
4806 template< typename Type, bool SO >
4807 inline void reset( DynamicMatrix<Type,SO>& m, size_t i );
4808 
4809 template< typename Type, bool SO >
4810 inline void clear( DynamicMatrix<Type,SO>& m );
4811 
4812 template< typename Type, bool SO >
4813 inline bool isDefault( const DynamicMatrix<Type,SO>& m );
4814 
4815 template< typename Type, bool SO >
4816 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */;
4817 
4818 template< typename Type, bool SO >
4819 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */;
4821 //*************************************************************************************************
4822 
4823 
4824 //*************************************************************************************************
4831 template< typename Type // Data type of the matrix
4832  , bool SO > // Storage order
4834 {
4835  m.reset();
4836 }
4837 //*************************************************************************************************
4838 
4839 
4840 //*************************************************************************************************
4853 template< typename Type // Data type of the matrix
4854  , bool SO > // Storage order
4855 inline void reset( DynamicMatrix<Type,SO>& m, size_t i )
4856 {
4857  m.reset( i );
4858 }
4859 //*************************************************************************************************
4860 
4861 
4862 //*************************************************************************************************
4869 template< typename Type // Data type of the matrix
4870  , bool SO > // Storage order
4872 {
4873  m.clear();
4874 }
4875 //*************************************************************************************************
4876 
4877 
4878 //*************************************************************************************************
4896 template< typename Type // Data type of the matrix
4897  , bool SO > // Storage order
4898 inline bool isDefault( const DynamicMatrix<Type,SO>& m )
4899 {
4900  return ( m.rows() == 0UL && m.columns() == 0UL );
4901 }
4902 //*************************************************************************************************
4903 
4904 
4905 //*************************************************************************************************
4914 template< typename Type // Data type of the matrix
4915  , bool SO > // Storage order
4916 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */
4917 {
4918  a.swap( b );
4919 }
4920 //*************************************************************************************************
4921 
4922 
4923 //*************************************************************************************************
4932 template< typename Type // Data type of the matrix
4933  , bool SO > // Storage order
4934 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */
4935 {
4936  dst.swap( src );
4937 }
4938 //*************************************************************************************************
4939 
4940 
4941 
4942 
4943 //=================================================================================================
4944 //
4945 // HASCONSTDATAACCESS SPECIALIZATIONS
4946 //
4947 //=================================================================================================
4948 
4949 //*************************************************************************************************
4951 template< typename T, bool SO >
4952 struct HasConstDataAccess< DynamicMatrix<T,SO> > : public TrueType
4953 {
4954  enum { value = 1 };
4955  typedef TrueType Type;
4956 };
4958 //*************************************************************************************************
4959 
4960 
4961 
4962 
4963 //=================================================================================================
4964 //
4965 // HASMUTABLEDATAACCESS SPECIALIZATIONS
4966 //
4967 //=================================================================================================
4968 
4969 //*************************************************************************************************
4971 template< typename T, bool SO >
4972 struct HasMutableDataAccess< DynamicMatrix<T,SO> > : public TrueType
4973 {
4974  enum { value = 1 };
4975  typedef TrueType Type;
4976 };
4978 //*************************************************************************************************
4979 
4980 
4981 
4982 
4983 //=================================================================================================
4984 //
4985 // ISRESIZABLE SPECIALIZATIONS
4986 //
4987 //=================================================================================================
4988 
4989 //*************************************************************************************************
4991 template< typename T, bool SO >
4992 struct IsResizable< DynamicMatrix<T,SO> > : public TrueType
4993 {
4994  enum { value = 1 };
4995  typedef TrueType Type;
4996 };
4998 //*************************************************************************************************
4999 
5000 
5001 
5002 
5003 //=================================================================================================
5004 //
5005 // ADDTRAIT SPECIALIZATIONS
5006 //
5007 //=================================================================================================
5008 
5009 //*************************************************************************************************
5011 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5012 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5013 {
5014  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5015 };
5016 
5017 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5018 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5019 {
5020  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5021 };
5022 
5023 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5024 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5025 {
5026  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5027 };
5028 
5029 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5030 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5031 {
5032  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5033 };
5034 
5035 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5036 struct AddTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5037 {
5038  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5039 };
5040 
5041 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5042 struct AddTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5043 {
5044  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5045 };
5046 
5047 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5048 struct AddTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5049 {
5050  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5051 };
5052 
5053 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5054 struct AddTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5055 {
5056  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5057 };
5058 
5059 template< typename T1, bool SO, typename T2 >
5060 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5061 {
5062  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
5063 };
5064 
5065 template< typename T1, bool SO1, typename T2, bool SO2 >
5066 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5067 {
5068  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , false > Type;
5069 };
5071 //*************************************************************************************************
5072 
5073 
5074 
5075 
5076 //=================================================================================================
5077 //
5078 // SUBTRAIT SPECIALIZATIONS
5079 //
5080 //=================================================================================================
5081 
5082 //*************************************************************************************************
5084 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5085 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5086 {
5087  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5088 };
5089 
5090 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5091 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5092 {
5093  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5094 };
5095 
5096 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5097 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5098 {
5099  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5100 };
5101 
5102 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5103 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5104 {
5105  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5106 };
5107 
5108 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5109 struct SubTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5110 {
5111  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5112 };
5113 
5114 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5115 struct SubTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5116 {
5117  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5118 };
5119 
5120 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5121 struct SubTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5122 {
5123  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5124 };
5125 
5126 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5127 struct SubTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5128 {
5129  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5130 };
5131 
5132 template< typename T1, bool SO, typename T2 >
5133 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5134 {
5135  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
5136 };
5137 
5138 template< typename T1, bool SO1, typename T2, bool SO2 >
5139 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5140 {
5141  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , false > Type;
5142 };
5144 //*************************************************************************************************
5145 
5146 
5147 
5148 
5149 //=================================================================================================
5150 //
5151 // MULTTRAIT SPECIALIZATIONS
5152 //
5153 //=================================================================================================
5154 
5155 //*************************************************************************************************
5157 template< typename T1, bool SO, typename T2 >
5158 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
5159 {
5160  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5162 };
5163 
5164 template< typename T1, typename T2, bool SO >
5165 struct MultTrait< T1, DynamicMatrix<T2,SO> >
5166 {
5167  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5169 };
5170 
5171 template< typename T1, bool SO, typename T2, size_t N >
5172 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
5173 {
5174  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5175 };
5176 
5177 template< typename T1, size_t N, typename T2, bool SO >
5178 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
5179 {
5180  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5181 };
5182 
5183 template< typename T1, bool SO, typename T2, size_t N >
5184 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
5185 {
5186  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5187 };
5188 
5189 template< typename T1, size_t N, typename T2, bool SO >
5190 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
5191 {
5192  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5193 };
5194 
5195 template< typename T1, bool SO, typename T2 >
5196 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
5197 {
5198  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5199 };
5200 
5201 template< typename T1, typename T2, bool SO >
5202 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
5203 {
5204  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5205 };
5206 
5207 template< typename T1, bool SO, typename T2 >
5208 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
5209 {
5210  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5211 };
5212 
5213 template< typename T1, typename T2, bool SO >
5214 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
5215 {
5216  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5217 };
5218 
5219 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5220 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5221 {
5222  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5223 };
5224 
5225 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5226 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5227 {
5228  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5229 };
5230 
5231 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5232 struct MultTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5233 {
5234  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5235 };
5236 
5237 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5238 struct MultTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5239 {
5240  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5241 };
5242 
5243 template< typename T1, bool SO1, typename T2, bool SO2 >
5244 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5245 {
5246  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5247 };
5249 //*************************************************************************************************
5250 
5251 
5252 
5253 
5254 //=================================================================================================
5255 //
5256 // DIVTRAIT SPECIALIZATIONS
5257 //
5258 //=================================================================================================
5259 
5260 //*************************************************************************************************
5262 template< typename T1, bool SO, typename T2 >
5263 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
5264 {
5265  typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
5267 };
5269 //*************************************************************************************************
5270 
5271 
5272 
5273 
5274 //=================================================================================================
5275 //
5276 // MATHTRAIT SPECIALIZATIONS
5277 //
5278 //=================================================================================================
5279 
5280 //*************************************************************************************************
5282 template< typename T1, bool SO, typename T2 >
5283 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5284 {
5285  typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5286  typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5287 };
5289 //*************************************************************************************************
5290 
5291 
5292 
5293 
5294 //=================================================================================================
5295 //
5296 // SUBMATRIXTRAIT SPECIALIZATIONS
5297 //
5298 //=================================================================================================
5299 
5300 //*************************************************************************************************
5302 template< typename T1, bool SO >
5303 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
5304 {
5305  typedef DynamicMatrix<T1,SO> Type;
5306 };
5308 //*************************************************************************************************
5309 
5310 
5311 
5312 
5313 //=================================================================================================
5314 //
5315 // ROWTRAIT SPECIALIZATIONS
5316 //
5317 //=================================================================================================
5318 
5319 //*************************************************************************************************
5321 template< typename T1, bool SO >
5322 struct RowTrait< DynamicMatrix<T1,SO> >
5323 {
5324  typedef DynamicVector<T1,true> Type;
5325 };
5327 //*************************************************************************************************
5328 
5329 
5330 
5331 
5332 //=================================================================================================
5333 //
5334 // COLUMNTRAIT SPECIALIZATIONS
5335 //
5336 //=================================================================================================
5337 
5338 //*************************************************************************************************
5340 template< typename T1, bool SO >
5341 struct ColumnTrait< DynamicMatrix<T1,SO> >
5342 {
5343  typedef DynamicVector<T1,false> Type;
5344 };
5346 //*************************************************************************************************
5347 
5348 } // namespace blaze
5349 
5350 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: DynamicMatrix.h:720
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:427
Constraint on the data type.
Header file for mathematical functions.
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1520
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const sse_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:76
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:884
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:430
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:258
Header file for the IsSparseMatrix type trait.
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1444
Header file for the IsDiagonal type trait.
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1857
Header file for the IsSame and IsStrictlySame type traits.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DynamicMatrix.h:1238
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2665
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
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_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
DynamicMatrix()
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:468
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1754
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Header file for memory allocation and deallocation functionality.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DynamicMatrix.h:1257
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:187
EnableIf< IsBuiltin< T >, T * >::Type allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:151
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
const This & CompositeType
Data type for composite expression templates.
Definition: DynamicMatrix.h:203
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2667
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:695
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:197
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1720
Header file for the SparseMatrix base class.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: DynamicMatrix.h:1307
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1608
Header file for the DisableIf class template.
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:950
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1676
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
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:200
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#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
Header file for the IsSMPAssignable type trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: DynamicMatrix.h:191
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:196
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:226
Header file for the DenseIterator class template.
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a simple dense...
Definition: Thresholds.h:690
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:202
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:116
Header file for the IsLower type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:92
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1502
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1224
#define BLAZE_RESTRICT
Platform dependent setup of the restrict keyword.
Definition: Restrict.h:81
Header file for the default storage order for all vectors of the Blaze library.
#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
void reset()
Reset to the default initial values.
Definition: DynamicMatrix.h:1357
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:906
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:195
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:120
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:535
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
System settings for streaming (non-temporal stores)
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:841
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:198
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1271
Header file for the IsVectorizable type trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:428
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:206
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
#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
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
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
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1401
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:207
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
size_t m_
The current number of rows of the matrix.
Definition: DynamicMatrix.h:426
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:840
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const sse_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:77
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1823
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:1658
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4934
Header file for the cache size of the target architecture.
#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:2510
Header file for the column trait.
Header file for the isDefault shim.
System settings for the restrict keyword.
Constraint on the data type.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
Constraint on the data type.
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1589
Header file for the HasMutableDataAccess type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
Type & Reference
Reference to a non-constant matrix value.
Definition: DynamicMatrix.h:204
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1788
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:1695
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2666
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:209
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:937
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
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: DynamicMatrix.h:201
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:429
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
Rebind mechanism to obtain a DynamicMatrix with different data/element type.
Definition: DynamicMatrix.h:216
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: DynamicMatrix.h:208
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2518
Header file for the IsUpper type trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
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
Pointer data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:762
Header file for the IsResizable type trait.
System settings for the inline keywords.
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
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: DynamicMatrix.h:1638
DynamicMatrix< ET, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:217
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1551
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:205
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:199
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849
Header file for a safe C++ NULL pointer implementation.