All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
49 #include <blaze/math/Forward.h>
50 #include <blaze/math/Functions.h>
51 #include <blaze/math/Intrinsics.h>
52 #include <blaze/math/shims/Clear.h>
65 #include <blaze/system/CacheSize.h>
66 #include <blaze/system/Restrict.h>
68 #include <blaze/system/Streaming.h>
70 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Memory.h>
80 #include <blaze/util/Null.h>
81 #include <blaze/util/Template.h>
82 #include <blaze/util/Types.h>
86 #include <blaze/util/Unused.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS DEFINITION
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
176 template< typename Type // Data type of the matrix
177  , bool SO = defaultStorageOrder > // Storage order
178 class DynamicMatrix : public DenseMatrix< DynamicMatrix<Type,SO>, SO >
179 {
180  private:
181  //**Type definitions****************************************************************************
183  //**********************************************************************************************
184 
185  public:
186  //**Type definitions****************************************************************************
188  typedef This ResultType;
191  typedef Type ElementType;
192  typedef typename IT::Type IntrinsicType;
193  typedef const Type& ReturnType;
194  typedef const This& CompositeType;
195  typedef Type& Reference;
196  typedef const Type& ConstReference;
197  typedef Type* Pointer;
198  typedef const Type* ConstPointer;
201  //**********************************************************************************************
202 
203  //**Rebind struct definition********************************************************************
206  template< typename ET > // Data type of the other matrix
207  struct Rebind {
209  };
210  //**********************************************************************************************
211 
212  //**Compilation flags***************************************************************************
214 
218  enum { vectorizable = IsVectorizable<Type>::value };
219 
221 
224  enum { smpAssignable = !IsSMPAssignable<Type>::value };
225  //**********************************************************************************************
226 
227  //**Constructors********************************************************************************
230  explicit inline DynamicMatrix();
231  explicit inline DynamicMatrix( size_t m, size_t n );
232  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
233  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
234 
235  template< typename Other, size_t M, size_t N >
236  explicit inline DynamicMatrix( const Other (&array)[M][N] );
237 
238  inline DynamicMatrix( const DynamicMatrix& m );
239  template< typename MT, bool SO2 > inline DynamicMatrix( const Matrix<MT,SO2>& m );
241  //**********************************************************************************************
242 
243  //**Destructor**********************************************************************************
246  inline ~DynamicMatrix();
248  //**********************************************************************************************
249 
250  //**Data access functions***********************************************************************
253  inline Reference operator()( size_t i, size_t j );
254  inline ConstReference operator()( size_t i, size_t j ) const;
255  inline Pointer data ();
256  inline ConstPointer data () const;
257  inline Pointer data ( size_t i );
258  inline ConstPointer data ( size_t i ) const;
259  inline Iterator begin ( size_t i );
260  inline ConstIterator begin ( size_t i ) const;
261  inline ConstIterator cbegin( size_t i ) const;
262  inline Iterator end ( size_t i );
263  inline ConstIterator end ( size_t i ) const;
264  inline ConstIterator cend ( size_t i ) const;
266  //**********************************************************************************************
267 
268  //**Assignment operators************************************************************************
271  template< typename Other, size_t M, size_t N >
272  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
273 
274  inline DynamicMatrix& operator= ( Type set );
275  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
276  template< typename MT, bool SO2 > inline DynamicMatrix& operator= ( const Matrix<MT,SO2>& rhs );
277  template< typename MT, bool SO2 > inline DynamicMatrix& operator+=( const Matrix<MT,SO2>& rhs );
278  template< typename MT, bool SO2 > inline DynamicMatrix& operator-=( const Matrix<MT,SO2>& rhs );
279  template< typename MT, bool SO2 > inline DynamicMatrix& operator*=( const Matrix<MT,SO2>& rhs );
280 
281  template< typename Other >
282  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
283  operator*=( Other rhs );
284 
285  template< typename Other >
286  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
287  operator/=( Other rhs );
289  //**********************************************************************************************
290 
291  //**Utility functions***************************************************************************
294  inline size_t rows() const;
295  inline size_t columns() const;
296  inline size_t spacing() const;
297  inline size_t capacity() const;
298  inline size_t capacity( size_t i ) const;
299  inline size_t nonZeros() const;
300  inline size_t nonZeros( size_t i ) const;
301  inline void reset();
302  inline void reset( size_t i );
303  inline void clear();
304  void resize ( size_t m, size_t n, bool preserve=true );
305  inline void extend ( size_t m, size_t n, bool preserve=true );
306  inline void reserve( size_t elements );
307  inline DynamicMatrix& transpose();
308  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
309  inline void swap( DynamicMatrix& m ) /* throw() */;
311  //**********************************************************************************************
312 
313  private:
314  //**********************************************************************************************
316  template< typename MT >
318  struct VectorizedAssign {
319  enum { value = vectorizable && MT::vectorizable &&
320  IsSame<Type,typename MT::ElementType>::value };
321  };
323  //**********************************************************************************************
324 
325  //**********************************************************************************************
327  template< typename MT >
329  struct VectorizedAddAssign {
330  enum { value = vectorizable && MT::vectorizable &&
331  IsSame<Type,typename MT::ElementType>::value &&
332  IntrinsicTrait<Type>::addition };
333  };
335  //**********************************************************************************************
336 
337  //**********************************************************************************************
339  template< typename MT >
341  struct VectorizedSubAssign {
342  enum { value = vectorizable && MT::vectorizable &&
343  IsSame<Type,typename MT::ElementType>::value &&
344  IntrinsicTrait<Type>::subtraction };
345  };
347  //**********************************************************************************************
348 
349  public:
350  //**Expression template evaluation functions****************************************************
353  template< typename Other > inline bool canAlias ( const Other* alias ) const;
354  template< typename Other > inline bool isAliased( const Other* alias ) const;
355 
356  inline bool isAligned () const;
357  inline bool canSMPAssign() const;
358 
359  inline IntrinsicType load ( size_t i, size_t j ) const;
360  inline IntrinsicType loadu ( size_t i, size_t j ) const;
361  inline void store ( size_t i, size_t j, const IntrinsicType& value );
362  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
363  inline void stream( size_t i, size_t j, const IntrinsicType& value );
364 
365  template< typename MT >
366  inline typename DisableIf< VectorizedAssign<MT> >::Type
367  assign( const DenseMatrix<MT,SO>& rhs );
368 
369  template< typename MT >
370  inline typename EnableIf< VectorizedAssign<MT> >::Type
371  assign( const DenseMatrix<MT,SO>& rhs );
372 
373  template< typename MT > inline void assign( const DenseMatrix<MT,!SO>& rhs );
374  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
375  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
376 
377  template< typename MT >
378  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
379  addAssign( const DenseMatrix<MT,SO>& rhs );
380 
381  template< typename MT >
382  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
383  addAssign( const DenseMatrix<MT,SO>& rhs );
384 
385  template< typename MT > inline void addAssign( const DenseMatrix<MT,!SO>& rhs );
386  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
387  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
388 
389  template< typename MT >
390  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
391  subAssign( const DenseMatrix<MT,SO>& rhs );
392 
393  template< typename MT >
394  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
395  subAssign( const DenseMatrix<MT,SO>& rhs );
396 
397  template< typename MT > inline void subAssign( const DenseMatrix<MT,!SO>& rhs );
398  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
399  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
401  //**********************************************************************************************
402 
403  private:
404  //**Utility functions***************************************************************************
407  inline size_t adjustColumns( size_t minColumns ) const;
409  //**********************************************************************************************
410 
411  //**Member variables****************************************************************************
414  size_t m_;
415  size_t n_;
416  size_t nn_;
417  size_t capacity_;
419 
429  //**********************************************************************************************
430 
431  //**Compile time checks*************************************************************************
438  //**********************************************************************************************
439 };
440 //*************************************************************************************************
441 
442 
443 
444 
445 //=================================================================================================
446 //
447 // CONSTRUCTORS
448 //
449 //=================================================================================================
450 
451 //*************************************************************************************************
454 template< typename Type // Data type of the matrix
455  , bool SO > // Storage order
457  : m_ ( 0UL ) // The current number of rows of the matrix
458  , n_ ( 0UL ) // The current number of columns of the matrix
459  , nn_ ( 0UL ) // The alignment adjusted number of columns
460  , capacity_( 0UL ) // The maximum capacity of the matrix
461  , v_ ( NULL ) // The matrix elements
462 {}
463 //*************************************************************************************************
464 
465 
466 //*************************************************************************************************
475 template< typename Type // Data type of the matrix
476  , bool SO > // Storage order
477 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n )
478  : m_ ( m ) // The current number of rows of the matrix
479  , n_ ( n ) // The current number of columns of the matrix
480  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
481  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
482  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
483 {
485  for( size_t i=0UL; i<m_; ++i ) {
486  for( size_t j=n_; j<nn_; ++j )
487  v_[i*nn_+j] = Type();
488  }
489  }
490 }
491 //*************************************************************************************************
492 
493 
494 //*************************************************************************************************
503 template< typename Type // Data type of the matrix
504  , bool SO > // Storage order
505 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Type& init )
506  : m_ ( m ) // The current number of rows of the matrix
507  , n_ ( n ) // The current number of columns of the matrix
508  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
509  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
510  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
511 {
512  for( size_t i=0UL; i<m; ++i ) {
513  for( size_t j=0UL; j<n_; ++j )
514  v_[i*nn_+j] = init;
515 
517  for( size_t j=n_; j<nn_; ++j )
518  v_[i*nn_+j] = Type();
519  }
520  }
521 }
522 //*************************************************************************************************
523 
524 
525 //*************************************************************************************************
548 template< typename Type // Data type of the matrix
549  , bool SO > // Storage order
550 template< typename Other > // Data type of the initialization array
551 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Other* array )
552  : m_ ( m ) // The current number of rows of the matrix
553  , n_ ( n ) // The current number of columns of the matrix
554  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
555  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
556  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
557 {
558  for( size_t i=0UL; i<m; ++i ) {
559  for( size_t j=0UL; j<n; ++j )
560  v_[i*nn_+j] = array[i*n+j];
561 
563  for( size_t j=n; j<nn_; ++j )
564  v_[i*nn_+j] = Type();
565  }
566  }
567 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
592 template< typename Type // Data type of the matrix
593  , bool SO > // Storage order
594 template< typename Other // Data type of the initialization array
595  , size_t M // Number of rows of the initialization array
596  , size_t N > // Number of columns of the initialization array
597 inline DynamicMatrix<Type,SO>::DynamicMatrix( const Other (&array)[M][N] )
598  : m_ ( M ) // The current number of rows of the matrix
599  , n_ ( N ) // The current number of columns of the matrix
600  , nn_ ( adjustColumns( N ) ) // The alignment adjusted number of columns
601  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
602  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
603 {
604  for( size_t i=0UL; i<M; ++i ) {
605  for( size_t j=0UL; j<N; ++j )
606  v_[i*nn_+j] = array[i][j];
607 
609  for( size_t j=N; j<nn_; ++j )
610  v_[i*nn_+j] = Type();
611  }
612  }
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
625 template< typename Type // Data type of the matrix
626  , bool SO > // Storage order
628  : m_ ( m.m_ ) // The current number of rows of the matrix
629  , n_ ( m.n_ ) // The current number of columns of the matrix
630  , nn_ ( m.nn_ ) // The alignment adjusted number of columns
631  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
632  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
633 {
634  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
635 
636  for( size_t i=0UL; i<capacity_; ++i )
637  v_[i] = m.v_[i];
638 }
639 //*************************************************************************************************
640 
641 
642 //*************************************************************************************************
647 template< typename Type // Data type of the matrix
648  , bool SO > // Storage order
649 template< typename MT // Type of the foreign matrix
650  , bool SO2 > // Storage order of the foreign matrix
652  : m_ ( (~m).rows() ) // The current number of rows of the matrix
653  , n_ ( (~m).columns() ) // The current number of columns of the matrix
654  , nn_ ( adjustColumns( n_ ) ) // The alignment adjusted number of columns
655  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
656  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
657 {
658  for( size_t i=0UL; i<m_; ++i ) {
659  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : n_ );
660  j<( IsVectorizable<Type>::value ? nn_ : n_ ); ++j ) {
661  v_[i*nn_+j] = Type();
662  }
663  }
664 
665  smpAssign( *this, ~m );
666 }
667 //*************************************************************************************************
668 
669 
670 
671 
672 //=================================================================================================
673 //
674 // DESTRUCTOR
675 //
676 //=================================================================================================
677 
678 //*************************************************************************************************
681 template< typename Type // Data type of the matrix
682  , bool SO > // Storage order
684 {
685  deallocate( v_ );
686 }
687 //*************************************************************************************************
688 
689 
690 
691 
692 //=================================================================================================
693 //
694 // DATA ACCESS FUNCTIONS
695 //
696 //=================================================================================================
697 
698 //*************************************************************************************************
705 template< typename Type // Data type of the matrix
706  , bool SO > // Storage order
707 inline typename DynamicMatrix<Type,SO>::Reference
709 {
710  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
711  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
712  return v_[i*nn_+j];
713 }
714 //*************************************************************************************************
715 
716 
717 //*************************************************************************************************
724 template< typename Type // Data type of the matrix
725  , bool SO > // Storage order
727  DynamicMatrix<Type,SO>::operator()( size_t i, size_t j ) const
728 {
729  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
730  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
731  return v_[i*nn_+j];
732 }
733 //*************************************************************************************************
734 
735 
736 //*************************************************************************************************
748 template< typename Type // Data type of the matrix
749  , bool SO > // Storage order
751 {
752  return v_;
753 }
754 //*************************************************************************************************
755 
756 
757 //*************************************************************************************************
769 template< typename Type // Data type of the matrix
770  , bool SO > // Storage order
772 {
773  return v_;
774 }
775 //*************************************************************************************************
776 
777 
778 //*************************************************************************************************
786 template< typename Type // Data type of the matrix
787  , bool SO > // Storage order
789 {
790  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
791  return v_ + i*nn_;
792 }
793 //*************************************************************************************************
794 
795 
796 //*************************************************************************************************
804 template< typename Type // Data type of the matrix
805  , bool SO > // Storage order
807 {
808  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
809  return v_ + i*nn_;
810 }
811 //*************************************************************************************************
812 
813 
814 //*************************************************************************************************
825 template< typename Type // Data type of the matrix
826  , bool SO > // Storage order
827 inline typename DynamicMatrix<Type,SO>::Iterator
829 {
830  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
831  return Iterator( v_ + i*nn_ );
832 }
833 //*************************************************************************************************
834 
835 
836 //*************************************************************************************************
847 template< typename Type // Data type of the matrix
848  , bool SO > // Storage order
851 {
852  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
853  return ConstIterator( v_ + i*nn_ );
854 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
869 template< typename Type // Data type of the matrix
870  , bool SO > // Storage order
873 {
874  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
875  return ConstIterator( v_ + i*nn_ );
876 }
877 //*************************************************************************************************
878 
879 
880 //*************************************************************************************************
891 template< typename Type // Data type of the matrix
892  , bool SO > // Storage order
893 inline typename DynamicMatrix<Type,SO>::Iterator
895 {
896  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
897  return Iterator( v_ + i*nn_ + n_ );
898 }
899 //*************************************************************************************************
900 
901 
902 //*************************************************************************************************
913 template< typename Type // Data type of the matrix
914  , bool SO > // Storage order
916  DynamicMatrix<Type,SO>::end( size_t i ) const
917 {
918  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
919  return ConstIterator( v_ + i*nn_ + n_ );
920 }
921 //*************************************************************************************************
922 
923 
924 //*************************************************************************************************
935 template< typename Type // Data type of the matrix
936  , bool SO > // Storage order
939 {
940  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
941  return ConstIterator( v_ + i*nn_ + n_ );
942 }
943 //*************************************************************************************************
944 
945 
946 
947 
948 //=================================================================================================
949 //
950 // ASSIGNMENT OPERATORS
951 //
952 //=================================================================================================
953 
954 //*************************************************************************************************
975 template< typename Type // Data type of the matrix
976  , bool SO > // Storage order
977 template< typename Other // Data type of the initialization array
978  , size_t M // Number of rows of the initialization array
979  , size_t N > // Number of columns of the initialization array
980 inline DynamicMatrix<Type,SO>& DynamicMatrix<Type,SO>::operator=( const Other (&array)[M][N] )
981 {
982  resize( M, N, false );
983 
984  for( size_t i=0UL; i<M; ++i )
985  for( size_t j=0UL; j<N; ++j )
986  v_[i*nn_+j] = array[i][j];
987 
988  return *this;
989 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
999 template< typename Type // Data type of the matrix
1000  , bool SO > // Storage order
1002 {
1003  for( size_t i=0UL; i<m_; ++i )
1004  for( size_t j=0UL; j<n_; ++j )
1005  v_[i*nn_+j] = rhs;
1006 
1007  return *this;
1008 }
1009 //*************************************************************************************************
1010 
1011 
1012 //*************************************************************************************************
1021 template< typename Type // Data type of the matrix
1022  , bool SO > // Storage order
1024 {
1025  if( &rhs == this ) return *this;
1026 
1027  resize( rhs.m_, rhs.n_, false );
1028  smpAssign( *this, ~rhs );
1029 
1030  return *this;
1031 }
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1044 template< typename Type // Data type of the matrix
1045  , bool SO > // Storage order
1046 template< typename MT // Type of the right-hand side matrix
1047  , bool SO2 > // Storage order of the right-hand side matrix
1049 {
1050  if( (~rhs).canAlias( this ) ) {
1051  DynamicMatrix tmp( ~rhs );
1052  swap( tmp );
1053  }
1054  else {
1055  resize( (~rhs).rows(), (~rhs).columns(), false );
1057  reset();
1058  smpAssign( *this, ~rhs );
1059  }
1060 
1061  return *this;
1062 }
1063 //*************************************************************************************************
1064 
1065 
1066 //*************************************************************************************************
1076 template< typename Type // Data type of the matrix
1077  , bool SO > // Storage order
1078 template< typename MT // Type of the right-hand side matrix
1079  , bool SO2 > // Storage order of the right-hand side matrix
1081 {
1082  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1083  throw std::invalid_argument( "Matrix sizes do not match" );
1084 
1085  if( (~rhs).canAlias( this ) ) {
1086  typename MT::ResultType tmp( ~rhs );
1087  smpAddAssign( *this, tmp );
1088  }
1089  else {
1090  smpAddAssign( *this, ~rhs );
1091  }
1092 
1093  return *this;
1094 }
1095 //*************************************************************************************************
1096 
1097 
1098 //*************************************************************************************************
1108 template< typename Type // Data type of the matrix
1109  , bool SO > // Storage order
1110 template< typename MT // Type of the right-hand side matrix
1111  , bool SO2 > // Storage order of the right-hand side matrix
1113 {
1114  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1115  throw std::invalid_argument( "Matrix sizes do not match" );
1116 
1117  if( (~rhs).canAlias( this ) ) {
1118  typename MT::ResultType tmp( ~rhs );
1119  smpSubAssign( *this, tmp );
1120  }
1121  else {
1122  smpSubAssign( *this, ~rhs );
1123  }
1124 
1125  return *this;
1126 }
1127 //*************************************************************************************************
1128 
1129 
1130 //*************************************************************************************************
1140 template< typename Type // Data type of the matrix
1141  , bool SO > // Storage order
1142 template< typename MT // Type of the right-hand side matrix
1143  , bool SO2 > // Storage order of the right-hand side matrix
1145 {
1146  if( (~rhs).rows() != n_ )
1147  throw std::invalid_argument( "Matrix sizes do not match" );
1148 
1149  DynamicMatrix tmp( *this * (~rhs) );
1150  swap( tmp );
1151 
1152  return *this;
1153 }
1154 //*************************************************************************************************
1155 
1156 
1157 //*************************************************************************************************
1164 template< typename Type // Data type of the matrix
1165  , bool SO > // Storage order
1166 template< typename Other > // Data type of the right-hand side scalar
1167 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1169 {
1170  smpAssign( *this, (*this) * rhs );
1171  return *this;
1172 }
1173 //*************************************************************************************************
1174 
1175 
1176 //*************************************************************************************************
1183 template< typename Type // Data type of the matrix
1184  , bool SO > // Storage order
1185 template< typename Other > // Data type of the right-hand side scalar
1186 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1188 {
1189  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1190 
1191  smpAssign( *this, (*this) / rhs );
1192  return *this;
1193 }
1194 //*************************************************************************************************
1195 
1196 
1197 
1198 
1199 //=================================================================================================
1200 //
1201 // UTILITY FUNCTIONS
1202 //
1203 //=================================================================================================
1204 
1205 //*************************************************************************************************
1210 template< typename Type // Data type of the matrix
1211  , bool SO > // Storage order
1212 inline size_t DynamicMatrix<Type,SO>::rows() const
1213 {
1214  return m_;
1215 }
1216 //*************************************************************************************************
1217 
1218 
1219 //*************************************************************************************************
1224 template< typename Type // Data type of the matrix
1225  , bool SO > // Storage order
1226 inline size_t DynamicMatrix<Type,SO>::columns() const
1227 {
1228  return n_;
1229 }
1230 //*************************************************************************************************
1231 
1232 
1233 //*************************************************************************************************
1243 template< typename Type // Data type of the matrix
1244  , bool SO > // Storage order
1245 inline size_t DynamicMatrix<Type,SO>::spacing() const
1246 {
1247  return nn_;
1248 }
1249 //*************************************************************************************************
1250 
1251 
1252 //*************************************************************************************************
1257 template< typename Type // Data type of the matrix
1258  , bool SO > // Storage order
1260 {
1261  return capacity_;
1262 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1277 template< typename Type // Data type of the sparse matrix
1278  , bool SO > // Storage order
1279 inline size_t DynamicMatrix<Type,SO>::capacity( size_t i ) const
1280 {
1281  UNUSED_PARAMETER( i );
1282  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1283  return nn_;
1284 }
1285 //*************************************************************************************************
1286 
1287 
1288 //*************************************************************************************************
1293 template< typename Type // Data type of the matrix
1294  , bool SO > // Storage order
1296 {
1297  size_t nonzeros( 0UL );
1298 
1299  for( size_t i=0UL; i<m_; ++i )
1300  for( size_t j=0UL; j<n_; ++j )
1301  if( !isDefault( v_[i*nn_+j] ) )
1302  ++nonzeros;
1303 
1304  return nonzeros;
1305 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1320 template< typename Type // Data type of the matrix
1321  , bool SO > // Storage order
1322 inline size_t DynamicMatrix<Type,SO>::nonZeros( size_t i ) const
1323 {
1324  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1325 
1326  const size_t jend( (i+1UL)*nn_ );
1327  size_t nonzeros( 0UL );
1328 
1329  for( size_t j=i*nn_; j<jend; ++j )
1330  if( !isDefault( v_[j] ) )
1331  ++nonzeros;
1332 
1333  return nonzeros;
1334 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1343 template< typename Type // Data type of the matrix
1344  , bool SO > // Storage order
1346 {
1347  using blaze::clear;
1348 
1349  for( size_t i=0UL; i<m_; ++i )
1350  for( size_t j=0UL; j<n_; ++j )
1351  clear( v_[i*nn_+j] );
1352 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1367 template< typename Type // Data type of the sparse matrix
1368  , bool SO > // Storage order
1369 inline void DynamicMatrix<Type,SO>::reset( size_t i )
1370 {
1371  using blaze::clear;
1372 
1373  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1374  for( size_t j=0UL; j<n_; ++j )
1375  clear( v_[i*nn_+j] );
1376 }
1377 //*************************************************************************************************
1378 
1379 
1380 //*************************************************************************************************
1387 template< typename Type // Data type of the matrix
1388  , bool SO > // Storage order
1390 {
1391  resize( 0UL, 0UL, false );
1392 }
1393 //*************************************************************************************************
1394 
1395 
1396 //*************************************************************************************************
1430 template< typename Type // Data type of the matrix
1431  , bool SO > // Storage order
1432 void DynamicMatrix<Type,SO>::resize( size_t m, size_t n, bool preserve )
1433 {
1434  using blaze::min;
1435 
1436  if( m == m_ && n == n_ ) return;
1437 
1438  const size_t nn( adjustColumns( n ) );
1439 
1440  if( preserve )
1441  {
1442  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1443  const size_t min_m( min( m, m_ ) );
1444  const size_t min_n( min( n, n_ ) );
1445 
1446  for( size_t i=0UL; i<min_m; ++i )
1447  for( size_t j=0UL; j<min_n; ++j )
1448  v[i*nn+j] = v_[i*nn_+j];
1449 
1450  std::swap( v_, v );
1451  deallocate( v );
1452  capacity_ = m*nn;
1453  }
1454  else if( m*nn > capacity_ ) {
1455  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1456  std::swap( v_, v );
1457  deallocate( v );
1458  capacity_ = m*nn;
1459  }
1460 
1462  for( size_t i=0UL; i<m; ++i )
1463  for( size_t j=n; j<nn; ++j )
1464  v_[i*nn+j] = Type();
1465  }
1466 
1467  m_ = m;
1468  n_ = n;
1469  nn_ = nn;
1470 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1488 template< typename Type // Data type of the matrix
1489  , bool SO > // Storage order
1490 inline void DynamicMatrix<Type,SO>::extend( size_t m, size_t n, bool preserve )
1491 {
1492  resize( m_+m, n_+n, preserve );
1493 }
1494 //*************************************************************************************************
1495 
1496 
1497 //*************************************************************************************************
1506 template< typename Type // Data type of the matrix
1507  , bool SO > // Storage order
1508 inline void DynamicMatrix<Type,SO>::reserve( size_t elements )
1509 {
1510  if( elements > capacity_ )
1511  {
1512  // Allocating a new array
1513  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
1514 
1515  // Initializing the new array
1516  std::copy( v_, v_+capacity_, tmp );
1517 
1519  for( size_t i=capacity_; i<elements; ++i )
1520  tmp[i] = Type();
1521  }
1522 
1523  // Replacing the old array
1524  std::swap( tmp, v_ );
1525  deallocate( tmp );
1526  capacity_ = elements;
1527  }
1528 }
1529 //*************************************************************************************************
1530 
1531 
1532 //*************************************************************************************************
1537 template< typename Type // Data type of the matrix
1538  , bool SO > // Storage order
1540 {
1541  DynamicMatrix tmp( trans(*this) );
1542  swap( tmp );
1543  return *this;
1544 }
1545 //*************************************************************************************************
1546 
1547 
1548 //*************************************************************************************************
1554 template< typename Type // Data type of the matrix
1555  , bool SO > // Storage order
1556 template< typename Other > // Data type of the scalar value
1558 {
1559  for( size_t i=0UL; i<m_; ++i )
1560  for( size_t j=0UL; j<n_; ++j )
1561  v_[i*nn_+j] *= scalar;
1562 
1563  return *this;
1564 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1575 template< typename Type // Data type of the matrix
1576  , bool SO > // Storage order
1577 inline void DynamicMatrix<Type,SO>::swap( DynamicMatrix& m ) /* throw() */
1578 {
1579  std::swap( m_ , m.m_ );
1580  std::swap( n_ , m.n_ );
1581  std::swap( nn_, m.nn_ );
1583  std::swap( v_ , m.v_ );
1584 }
1585 //*************************************************************************************************
1586 
1587 
1588 //*************************************************************************************************
1594 template< typename Type // Data type of the matrix
1595  , bool SO > // Storage order
1596 inline size_t DynamicMatrix<Type,SO>::adjustColumns( size_t minColumns ) const
1597 {
1599  return minColumns + ( IT::size - ( minColumns % IT::size ) ) % IT::size;
1600  else return minColumns;
1601 }
1602 //*************************************************************************************************
1603 
1604 
1605 
1606 
1607 //=================================================================================================
1608 //
1609 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1610 //
1611 //=================================================================================================
1612 
1613 //*************************************************************************************************
1623 template< typename Type // Data type of the matrix
1624  , bool SO > // Storage order
1625 template< typename Other > // Data type of the foreign expression
1626 inline bool DynamicMatrix<Type,SO>::canAlias( const Other* alias ) const
1627 {
1628  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1629 }
1630 //*************************************************************************************************
1631 
1632 
1633 //*************************************************************************************************
1643 template< typename Type // Data type of the matrix
1644  , bool SO > // Storage order
1645 template< typename Other > // Data type of the foreign expression
1646 inline bool DynamicMatrix<Type,SO>::isAliased( const Other* alias ) const
1647 {
1648  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 //*************************************************************************************************
1662 template< typename Type // Data type of the matrix
1663  , bool SO > // Storage order
1665 {
1666  return true;
1667 }
1668 //*************************************************************************************************
1669 
1670 
1671 //*************************************************************************************************
1681 template< typename Type // Data type of the matrix
1682  , bool SO > // Storage order
1684 {
1685  return ( rows() > SMP_DMATASSIGN_THRESHOLD );
1686 }
1687 //*************************************************************************************************
1688 
1689 
1690 //*************************************************************************************************
1705 template< typename Type // Data type of the matrix
1706  , bool SO > // Storage order
1708  DynamicMatrix<Type,SO>::load( size_t i, size_t j ) const
1709 {
1710  using blaze::load;
1711 
1713 
1714  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1715  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1716  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1717  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1718 
1719  return load( v_+i*nn_+j );
1720 }
1721 //*************************************************************************************************
1722 
1723 
1724 //*************************************************************************************************
1739 template< typename Type // Data type of the matrix
1740  , bool SO > // Storage order
1742  DynamicMatrix<Type,SO>::loadu( size_t i, size_t j ) const
1743 {
1744  using blaze::loadu;
1745 
1747 
1748  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1749  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1750  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1751 
1752  return loadu( v_+i*nn_+j );
1753 }
1754 //*************************************************************************************************
1755 
1756 
1757 //*************************************************************************************************
1773 template< typename Type // Data type of the matrix
1774  , bool SO > // Storage order
1775 inline void DynamicMatrix<Type,SO>::store( size_t i, size_t j, const IntrinsicType& value )
1776 {
1777  using blaze::store;
1778 
1780 
1781  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1782  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1783  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1784  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1785 
1786  store( v_+i*nn_+j, value );
1787 }
1788 //*************************************************************************************************
1789 
1790 
1791 //*************************************************************************************************
1807 template< typename Type // Data type of the matrix
1808  , bool SO > // Storage order
1809 inline void DynamicMatrix<Type,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
1810 {
1811  using blaze::storeu;
1812 
1814 
1815  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1816  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1817  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1818 
1819  storeu( v_+i*nn_+j, value );
1820 }
1821 //*************************************************************************************************
1822 
1823 
1824 //*************************************************************************************************
1840 template< typename Type // Data type of the matrix
1841  , bool SO > // Storage order
1842 inline void DynamicMatrix<Type,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
1843 {
1844  using blaze::stream;
1845 
1847 
1848  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
1849  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
1850  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1851  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
1852 
1853  stream( v_+i*nn_+j, value );
1854 }
1855 //*************************************************************************************************
1856 
1857 
1858 //*************************************************************************************************
1869 template< typename Type // Data type of the matrix
1870  , bool SO > // Storage order
1871 template< typename MT > // Type of the right-hand side dense matrix
1872 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
1874 {
1875  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1876  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1877 
1878  const size_t jend( n_ & size_t(-2) );
1879  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % 2UL ) ) == jend, "Invalid end calculation" );
1880 
1881  for( size_t i=0UL; i<m_; ++i ) {
1882  for( size_t j=0UL; j<jend; j+=2UL ) {
1883  v_[i*nn_+j ] = (~rhs)(i,j );
1884  v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1885  }
1886  if( jend < n_ ) {
1887  v_[i*nn_+jend] = (~rhs)(i,jend);
1888  }
1889  }
1890 }
1891 //*************************************************************************************************
1892 
1893 
1894 //*************************************************************************************************
1905 template< typename Type // Data type of the matrix
1906  , bool SO > // Storage order
1907 template< typename MT > // Type of the right-hand side dense matrix
1908 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
1910 {
1911  using blaze::store;
1912  using blaze::stream;
1913 
1914  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1915  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1916 
1918 
1919  if( useStreaming && m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
1920  {
1921  for( size_t i=0UL; i<m_; ++i )
1922  for( size_t j=0UL; j<n_; j+=IT::size )
1923  stream( v_+i*nn_+j, (~rhs).load(i,j) );
1924  }
1925  else
1926  {
1927  const size_t jend( n_ & size_t(-IT::size*4) );
1928  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
1929 
1930  for( size_t i=0UL; i<m_; ++i ) {
1931  typename MT::ConstIterator it( (~rhs).begin(i) );
1932  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1933  store( v_+i*nn_+j , it.load() ); it += IT::size;
1934  store( v_+i*nn_+j+IT::size , it.load() ); it += IT::size;
1935  store( v_+i*nn_+j+IT::size*2UL, it.load() ); it += IT::size;
1936  store( v_+i*nn_+j+IT::size*3UL, it.load() ); it += IT::size;
1937  }
1938  for( size_t j=jend; j<n_; j+=IT::size, it+=IT::size ) {
1939  store( v_+i*nn_+j, it.load() );
1940  }
1941  }
1942  }
1943 }
1944 //*************************************************************************************************
1945 
1946 
1947 //*************************************************************************************************
1958 template< typename Type // Data type of the matrix
1959  , bool SO > // Storage order
1960 template< typename MT > // Type of the right-hand side dense matrix
1962 {
1964 
1965  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
1966  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
1967 
1968  const size_t block( 16UL );
1969 
1970  for( size_t ii=0UL; ii<m_; ii+=block ) {
1971  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
1972  for( size_t jj=0UL; jj<n_; jj+=block ) {
1973  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
1974  for( size_t i=ii; i<iend; ++i ) {
1975  for( size_t j=jj; j<jend; ++j ) {
1976  v_[i*nn_+j] = (~rhs)(i,j);
1977  }
1978  }
1979  }
1980  }
1981 }
1982 //*************************************************************************************************
1983 
1984 
1985 //*************************************************************************************************
1996 template< typename Type // Data type of the matrix
1997  , bool SO > // Storage order
1998 template< typename MT > // Type of the right-hand side sparse matrix
2000 {
2001  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2002  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2003 
2004  for( size_t i=0UL; i<m_; ++i )
2005  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2006  v_[i*nn_+element->index()] = element->value();
2007 }
2008 //*************************************************************************************************
2009 
2010 
2011 //*************************************************************************************************
2022 template< typename Type // Data type of the matrix
2023  , bool SO > // Storage order
2024 template< typename MT > // Type of the right-hand side sparse matrix
2026 {
2028 
2029  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2030  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2031 
2032  for( size_t j=0UL; j<n_; ++j )
2033  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2034  v_[element->index()*nn_+j] = element->value();
2035 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2050 template< typename Type // Data type of the matrix
2051  , bool SO > // Storage order
2052 template< typename MT > // Type of the right-hand side dense matrix
2053 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2055 {
2056  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2057  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2058 
2059  const size_t jend( n_ & size_t(-2) );
2060  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % 2UL ) ) == jend, "Invalid end calculation" );
2061 
2062  for( size_t i=0UL; i<m_; ++i ) {
2063  for( size_t j=0UL; j<jend; j+=2UL ) {
2064  v_[i*nn_+j ] += (~rhs)(i,j );
2065  v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2066  }
2067  if( jend < n_ ) {
2068  v_[i*nn_+jend] += (~rhs)(i,jend);
2069  }
2070  }
2071 }
2072 //*************************************************************************************************
2073 
2074 
2075 //*************************************************************************************************
2086 template< typename Type // Data type of the matrix
2087  , bool SO > // Storage order
2088 template< typename MT > // Type of the right-hand side dense matrix
2089 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2091 {
2092  using blaze::load;
2093  using blaze::store;
2094 
2095  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2096  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2097 
2099 
2100  const size_t jend( n_ & size_t(-IT::size*4) );
2101  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
2102 
2103  for( size_t i=0UL; i<m_; ++i ) {
2104  typename MT::ConstIterator it( (~rhs).begin(i) );
2105  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2106  store( v_+i*nn_+j , load( v_+i*nn_+j ) + it.load() ); it += IT::size;
2107  store( v_+i*nn_+j+IT::size , load( v_+i*nn_+j+IT::size ) + it.load() ); it += IT::size;
2108  store( v_+i*nn_+j+IT::size*2UL, load( v_+i*nn_+j+IT::size*2UL ) + it.load() ); it += IT::size;
2109  store( v_+i*nn_+j+IT::size*3UL, load( v_+i*nn_+j+IT::size*3UL ) + it.load() ); it += IT::size;
2110  }
2111  for( size_t j=jend; j<n_; j+=IT::size, it+=IT::size ) {
2112  store( v_+i*nn_+j, load( v_+i*nn_+j ) + it.load() );
2113  }
2114  }
2115 }
2116 //*************************************************************************************************
2117 
2118 
2119 //*************************************************************************************************
2130 template< typename Type // Data type of the matrix
2131  , bool SO > // Storage order
2132 template< typename MT > // Type of the right-hand side dense matrix
2134 {
2136 
2137  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2138  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2139 
2140  const size_t block( 16UL );
2141 
2142  for( size_t ii=0UL; ii<m_; ii+=block ) {
2143  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2144  for( size_t jj=0UL; jj<n_; jj+=block ) {
2145  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2146  for( size_t i=ii; i<iend; ++i ) {
2147  for( size_t j=jj; j<jend; ++j ) {
2148  v_[i*nn_+j] += (~rhs)(i,j);
2149  }
2150  }
2151  }
2152  }
2153 }
2154 //*************************************************************************************************
2155 
2156 
2157 //*************************************************************************************************
2168 template< typename Type // Data type of the matrix
2169  , bool SO > // Storage order
2170 template< typename MT > // Type of the right-hand side sparse matrix
2172 {
2173  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2174  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2175 
2176  for( size_t i=0UL; i<m_; ++i )
2177  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2178  v_[i*nn_+element->index()] += element->value();
2179 }
2180 //*************************************************************************************************
2181 
2182 
2183 //*************************************************************************************************
2194 template< typename Type // Data type of the matrix
2195  , bool SO > // Storage order
2196 template< typename MT > // Type of the right-hand side sparse matrix
2198 {
2200 
2201  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2202  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2203 
2204  for( size_t j=0UL; j<n_; ++j )
2205  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2206  v_[element->index()*nn_+j] += element->value();
2207 }
2208 //*************************************************************************************************
2209 
2210 
2211 //*************************************************************************************************
2222 template< typename Type // Data type of the matrix
2223  , bool SO > // Storage order
2224 template< typename MT > // Type of the right-hand side dense matrix
2225 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2227 {
2228  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2229  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2230 
2231  const size_t jend( n_ & size_t(-2) );
2232  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % 2UL ) ) == jend, "Invalid end calculation" );
2233 
2234  for( size_t i=0UL; i<m_; ++i ) {
2235  for( size_t j=0UL; j<jend; j+=2UL ) {
2236  v_[i*nn_+j ] -= (~rhs)(i,j );
2237  v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2238  }
2239  if( jend < n_ ) {
2240  v_[i*nn_+jend] -= (~rhs)(i,jend);
2241  }
2242  }
2243 }
2244 //*************************************************************************************************
2245 
2246 
2247 //*************************************************************************************************
2258 template< typename Type // Data type of the matrix
2259  , bool SO > // Storage order
2260 template< typename MT > // Type of the right-hand side dense matrix
2261 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2263 {
2264  using blaze::load;
2265  using blaze::store;
2266 
2267  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2268  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2269 
2271 
2272  const size_t jend( n_ & size_t(-IT::size*4) );
2273  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % (IT::size*4UL) ) ) == jend, "Invalid end calculation" );
2274 
2275  for( size_t i=0UL; i<m_; ++i ) {
2276  typename MT::ConstIterator it( (~rhs).begin(i) );
2277  for( size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2278  store( v_+i*nn_+j , load( v_+i*nn_+j ) - it.load() ); it += IT::size;
2279  store( v_+i*nn_+j+IT::size , load( v_+i*nn_+j+IT::size ) - it.load() ); it += IT::size;
2280  store( v_+i*nn_+j+IT::size*2UL, load( v_+i*nn_+j+IT::size*2UL ) - it.load() ); it += IT::size;
2281  store( v_+i*nn_+j+IT::size*3UL, load( v_+i*nn_+j+IT::size*3UL ) - it.load() ); it += IT::size;
2282  }
2283  for( size_t j=jend; j<n_; j+=IT::size, it+=IT::size ) {
2284  store( v_+i*nn_+j, load( v_+i*nn_+j ) - it.load() );
2285  }
2286  }
2287 }
2288 //*************************************************************************************************
2289 
2290 
2291 //*************************************************************************************************
2302 template< typename Type // Data type of the matrix
2303  , bool SO > // Storage order
2304 template< typename MT > // Type of the right-hand side dense matrix
2306 {
2308 
2309  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2310  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2311 
2312  const size_t block( 16UL );
2313 
2314  for( size_t ii=0UL; ii<m_; ii+=block ) {
2315  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2316  for( size_t jj=0UL; jj<n_; jj+=block ) {
2317  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2318  for( size_t i=ii; i<iend; ++i ) {
2319  for( size_t j=jj; j<jend; ++j ) {
2320  v_[i*nn_+j] -= (~rhs)(i,j);
2321  }
2322  }
2323  }
2324  }
2325 }
2326 //*************************************************************************************************
2327 
2328 
2329 //*************************************************************************************************
2340 template< typename Type // Data type of the matrix
2341  , bool SO > // Storage order
2342 template< typename MT > // Type of the right-hand side sparse matrix
2344 {
2345  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2346  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2347 
2348  for( size_t i=0UL; i<m_; ++i )
2349  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2350  v_[i*nn_+element->index()] -= element->value();
2351 }
2352 //*************************************************************************************************
2353 
2354 
2355 //*************************************************************************************************
2366 template< typename Type // Data type of the matrix
2367  , bool SO > // Storage order
2368 template< typename MT > // Type of the right-hand side sparse matrix
2370 {
2372 
2373  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2374  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2375 
2376  for( size_t j=0UL; j<n_; ++j )
2377  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2378  v_[element->index()*nn_+j] -= element->value();
2379 }
2380 //*************************************************************************************************
2381 
2382 
2383 
2384 
2385 
2386 
2387 
2388 
2389 //=================================================================================================
2390 //
2391 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2392 //
2393 //=================================================================================================
2394 
2395 //*************************************************************************************************
2403 template< typename Type > // Data type of the matrix
2404 class DynamicMatrix<Type,true> : public DenseMatrix< DynamicMatrix<Type,true>, true >
2405 {
2406  private:
2407  //**Type definitions****************************************************************************
2408  typedef IntrinsicTrait<Type> IT;
2409  //**********************************************************************************************
2410 
2411  public:
2412  //**Type definitions****************************************************************************
2413  typedef DynamicMatrix<Type,true> This;
2414  typedef This ResultType;
2417  typedef Type ElementType;
2418  typedef typename IT::Type IntrinsicType;
2419  typedef const Type& ReturnType;
2420  typedef const This& CompositeType;
2421  typedef Type& Reference;
2422  typedef const Type& ConstReference;
2423  typedef Type* Pointer;
2424  typedef const Type* ConstPointer;
2425  typedef DenseIterator<Type> Iterator;
2427  //**********************************************************************************************
2428 
2429  //**Rebind struct definition********************************************************************
2432  template< typename ET > // Data type of the other matrix
2433  struct Rebind {
2434  typedef DynamicMatrix<ET,true> Other;
2435  };
2436  //**********************************************************************************************
2437 
2438  //**Compilation flags***************************************************************************
2440 
2444  enum { vectorizable = IsVectorizable<Type>::value };
2445 
2447 
2450  enum { smpAssignable = !IsSMPAssignable<Type>::value };
2451  //**********************************************************************************************
2452 
2453  //**Constructors********************************************************************************
2456  explicit inline DynamicMatrix();
2457  explicit inline DynamicMatrix( size_t m, size_t n );
2458  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
2459  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
2460 
2461  template< typename Other, size_t M, size_t N >
2462  explicit inline DynamicMatrix( const Other (&array)[M][N] );
2463 
2464  inline DynamicMatrix( const DynamicMatrix& m );
2465  template< typename MT, bool SO > inline DynamicMatrix( const Matrix<MT,SO>& m );
2467  //**********************************************************************************************
2468 
2469  //**Destructor**********************************************************************************
2472  inline ~DynamicMatrix();
2474  //**********************************************************************************************
2475 
2476  //**Data access functions***********************************************************************
2479  inline Reference operator()( size_t i, size_t j );
2480  inline ConstReference operator()( size_t i, size_t j ) const;
2481  inline Pointer data ();
2482  inline ConstPointer data () const;
2483  inline Pointer data ( size_t j );
2484  inline ConstPointer data ( size_t j ) const;
2485  inline Iterator begin ( size_t j );
2486  inline ConstIterator begin ( size_t j ) const;
2487  inline ConstIterator cbegin( size_t j ) const;
2488  inline Iterator end ( size_t j );
2489  inline ConstIterator end ( size_t j ) const;
2490  inline ConstIterator cend ( size_t j ) const;
2492  //**********************************************************************************************
2493 
2494  //**Assignment operators************************************************************************
2497  template< typename Other, size_t M, size_t N >
2498  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
2499 
2500  inline DynamicMatrix& operator= ( Type set );
2501  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
2502  template< typename MT, bool SO > inline DynamicMatrix& operator= ( const Matrix<MT,SO>& rhs );
2503  template< typename MT, bool SO > inline DynamicMatrix& operator+=( const Matrix<MT,SO>& rhs );
2504  template< typename MT, bool SO > inline DynamicMatrix& operator-=( const Matrix<MT,SO>& rhs );
2505  template< typename MT, bool SO > inline DynamicMatrix& operator*=( const Matrix<MT,SO>& rhs );
2506 
2507  template< typename Other >
2508  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2509  operator*=( Other rhs );
2510 
2511  template< typename Other >
2512  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2513  operator/=( Other rhs );
2515  //**********************************************************************************************
2516 
2517  //**Utility functions***************************************************************************
2520  inline size_t rows() const;
2521  inline size_t columns() const;
2522  inline size_t spacing() const;
2523  inline size_t capacity() const;
2524  inline size_t capacity( size_t j ) const;
2525  inline size_t nonZeros() const;
2526  inline size_t nonZeros( size_t j ) const;
2527  inline void reset();
2528  inline void reset( size_t j );
2529  inline void clear();
2530  void resize ( size_t m, size_t n, bool preserve=true );
2531  inline void extend ( size_t m, size_t n, bool preserve=true );
2532  inline void reserve( size_t elements );
2533  inline DynamicMatrix& transpose();
2534  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
2535  inline void swap( DynamicMatrix& m ) /* throw() */;
2537  //**********************************************************************************************
2538 
2539  private:
2540  //**********************************************************************************************
2542  template< typename MT >
2543  struct VectorizedAssign {
2544  enum { value = vectorizable && MT::vectorizable &&
2545  IsSame<Type,typename MT::ElementType>::value };
2546  };
2547  //**********************************************************************************************
2548 
2549  //**********************************************************************************************
2551  template< typename MT >
2552  struct VectorizedAddAssign {
2553  enum { value = vectorizable && MT::vectorizable &&
2554  IsSame<Type,typename MT::ElementType>::value &&
2555  IntrinsicTrait<Type>::addition };
2556  };
2557  //**********************************************************************************************
2558 
2559  //**********************************************************************************************
2561  template< typename MT >
2562  struct VectorizedSubAssign {
2563  enum { value = vectorizable && MT::vectorizable &&
2564  IsSame<Type,typename MT::ElementType>::value &&
2565  IntrinsicTrait<Type>::subtraction };
2566  };
2567  //**********************************************************************************************
2568 
2569  public:
2570  //**Expression template evaluation functions****************************************************
2573  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2574  template< typename Other > inline bool isAliased( const Other* alias ) const;
2575 
2576  inline bool isAligned () const;
2577  inline bool canSMPAssign() const;
2578 
2579  inline IntrinsicType load ( size_t i, size_t j ) const;
2580  inline IntrinsicType loadu ( size_t i, size_t j ) const;
2581  inline void store ( size_t i, size_t j, const IntrinsicType& value );
2582  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
2583  inline void stream( size_t i, size_t j, const IntrinsicType& value );
2584 
2585  template< typename MT >
2586  inline typename DisableIf< VectorizedAssign<MT> >::Type
2587  assign( const DenseMatrix<MT,true>& rhs );
2588 
2589  template< typename MT >
2590  inline typename EnableIf< VectorizedAssign<MT> >::Type
2591  assign( const DenseMatrix<MT,true>& rhs );
2592 
2593  template< typename MT > inline void assign( const DenseMatrix<MT,false>& rhs );
2594  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2595  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2596 
2597  template< typename MT >
2598  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2599  addAssign( const DenseMatrix<MT,true>& rhs );
2600 
2601  template< typename MT >
2602  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2603  addAssign( const DenseMatrix<MT,true>& rhs );
2604 
2605  template< typename MT > inline void addAssign( const DenseMatrix<MT,false>& rhs );
2606  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2607  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2608 
2609  template< typename MT >
2610  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2611  subAssign ( const DenseMatrix<MT,true>& rhs );
2612 
2613  template< typename MT >
2614  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2615  subAssign ( const DenseMatrix<MT,true>& rhs );
2616 
2617  template< typename MT > inline void subAssign( const DenseMatrix<MT,false>& rhs );
2618  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2619  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2621  //**********************************************************************************************
2622 
2623  private:
2624  //**Utility functions***************************************************************************
2627  inline size_t adjustRows( size_t minRows ) const;
2629  //**********************************************************************************************
2630 
2631  //**Member variables****************************************************************************
2634  size_t m_;
2635  size_t mm_;
2636  size_t n_;
2637  size_t capacity_;
2638  Type* BLAZE_RESTRICT v_;
2639 
2649  //**********************************************************************************************
2650 
2651  //**Compile time checks*************************************************************************
2656  //**********************************************************************************************
2657 };
2659 //*************************************************************************************************
2660 
2661 
2662 
2663 
2664 //=================================================================================================
2665 //
2666 // CONSTRUCTORS
2667 //
2668 //=================================================================================================
2669 
2670 //*************************************************************************************************
2674 template< typename Type > // Data type of the matrix
2676  : m_ ( 0UL ) // The current number of rows of the matrix
2677  , mm_ ( 0UL ) // The alignment adjusted number of rows
2678  , n_ ( 0UL ) // The current number of columns of the matrix
2679  , capacity_( 0UL ) // The maximum capacity of the matrix
2680  , v_ ( NULL ) // The matrix elements
2681 {}
2683 //*************************************************************************************************
2684 
2685 
2686 //*************************************************************************************************
2696 template< typename Type > // Data type of the matrix
2697 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n )
2698  : m_ ( m ) // The current number of rows of the matrix
2699  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2700  , n_ ( n ) // The current number of columns of the matrix
2701  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2702  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2703 {
2704  if( IsVectorizable<Type>::value ) {
2705  for( size_t j=0UL; j<n_; ++j )
2706  for( size_t i=m_; i<mm_; ++i ) {
2707  v_[i+j*mm_] = Type();
2708  }
2709  }
2710 }
2712 //*************************************************************************************************
2713 
2714 
2715 //*************************************************************************************************
2725 template< typename Type > // Data type of the matrix
2726 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Type& init )
2727  : m_ ( m ) // The current number of rows of the matrix
2728  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2729  , n_ ( n ) // The current number of columns of the matrix
2730  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2731  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2732 {
2733  for( size_t j=0UL; j<n_; ++j ) {
2734  for( size_t i=0UL; i<m_; ++i )
2735  v_[i+j*mm_] = init;
2736 
2737  if( IsVectorizable<Type>::value ) {
2738  for( size_t i=m_; i<mm_; ++i )
2739  v_[i+j*mm_] = Type();
2740  }
2741  }
2742 }
2744 //*************************************************************************************************
2745 
2746 
2747 //*************************************************************************************************
2771 template< typename Type > // Data type of the matrix
2772 template< typename Other > // Data type of the initialization array
2773 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Other* array )
2774  : m_ ( m ) // The current number of rows of the matrix
2775  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
2776  , n_ ( n ) // The current number of columns of the matrix
2777  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2778  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2779 {
2780  for( size_t j=0UL; j<n; ++j ) {
2781  for( size_t i=0UL; i<m; ++i )
2782  v_[i+j*mm_] = array[i+j*m];
2783 
2784  if( IsVectorizable<Type>::value ) {
2785  for( size_t i=m; i<mm_; ++i )
2786  v_[i+j*mm_] = Type();
2787  }
2788  }
2789 }
2791 //*************************************************************************************************
2792 
2793 
2794 //*************************************************************************************************
2816 template< typename Type > // Data type of the matrix
2817 template< typename Other // Data type of the initialization array
2818  , size_t M // Number of rows of the initialization array
2819  , size_t N > // Number of columns of the initialization array
2820 inline DynamicMatrix<Type,true>::DynamicMatrix( const Other (&array)[M][N] )
2821  : m_ ( M ) // The current number of rows of the matrix
2822  , mm_ ( adjustRows( M ) ) // The alignment adjusted number of rows
2823  , n_ ( N ) // The current number of columns of the matrix
2824  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2825  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2826 {
2827  for( size_t j=0UL; j<N; ++j ) {
2828  for( size_t i=0UL; i<M; ++i )
2829  v_[i+j*mm_] = array[i][j];
2830 
2831  if( IsVectorizable<Type>::value ) {
2832  for( size_t i=M; i<mm_; ++i )
2833  v_[i+j*mm_] = Type();
2834  }
2835  }
2836 }
2838 //*************************************************************************************************
2839 
2840 
2841 //*************************************************************************************************
2850 template< typename Type > // Data type of the matrix
2851 inline DynamicMatrix<Type,true>::DynamicMatrix( const DynamicMatrix& m )
2852  : m_ ( m.m_ ) // The current number of rows of the matrix
2853  , mm_ ( m.mm_ ) // The alignment adjusted number of rows
2854  , n_ ( m.n_ ) // The current number of columns of the matrix
2855  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2856  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2857 {
2858  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
2859 
2860  for( size_t i=0UL; i<capacity_; ++i )
2861  v_[i] = m.v_[i];
2862 }
2864 //*************************************************************************************************
2865 
2866 
2867 //*************************************************************************************************
2873 template< typename Type > // Data type of the matrix
2874 template< typename MT // Type of the foreign matrix
2875  , bool SO > // Storage order of the foreign matrix
2876 inline DynamicMatrix<Type,true>::DynamicMatrix( const Matrix<MT,SO>& m )
2877  : m_ ( (~m).rows() ) // The current number of rows of the matrix
2878  , mm_ ( adjustRows( m_ ) ) // The alignment adjusted number of rows
2879  , n_ ( (~m).columns() ) // The current number of columns of the matrix
2880  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
2881  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
2882 {
2883  for( size_t j=0UL; j<n_; ++j ) {
2884  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
2885  i<( IsVectorizable<Type>::value ? mm_ : m_ ); ++i ) {
2886  v_[i+j*mm_] = Type();
2887  }
2888  }
2889 
2890  smpAssign( *this, ~m );
2891 }
2893 //*************************************************************************************************
2894 
2895 
2896 
2897 
2898 //=================================================================================================
2899 //
2900 // DESTRUCTOR
2901 //
2902 //=================================================================================================
2903 
2904 //*************************************************************************************************
2908 template< typename Type > // Data type of the matrix
2910 {
2911  deallocate( v_ );
2912 }
2914 //*************************************************************************************************
2915 
2916 
2917 
2918 
2919 //=================================================================================================
2920 //
2921 // DATA ACCESS FUNCTIONS
2922 //
2923 //=================================================================================================
2924 
2925 //*************************************************************************************************
2933 template< typename Type > // Data type of the matrix
2935  DynamicMatrix<Type,true>::operator()( size_t i, size_t j )
2936 {
2937  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
2938  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
2939  return v_[i+j*mm_];
2940 }
2942 //*************************************************************************************************
2943 
2944 
2945 //*************************************************************************************************
2953 template< typename Type > // Data type of the matrix
2955  DynamicMatrix<Type,true>::operator()( size_t i, size_t j ) const
2956 {
2957  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
2958  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
2959  return v_[i+j*mm_];
2960 }
2962 //*************************************************************************************************
2963 
2964 
2965 //*************************************************************************************************
2977 template< typename Type > // Data type of the matrix
2978 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data()
2979 {
2980  return v_;
2981 }
2983 //*************************************************************************************************
2984 
2985 
2986 //*************************************************************************************************
2998 template< typename Type > // Data type of the matrix
2999 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data() const
3000 {
3001  return v_;
3002 }
3004 //*************************************************************************************************
3005 
3006 
3007 //*************************************************************************************************
3016 template< typename Type > // Data type of the matrix
3017 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data( size_t j )
3018 {
3019  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3020  return v_ + j*mm_;
3021 }
3023 //*************************************************************************************************
3024 
3025 
3026 //*************************************************************************************************
3035 template< typename Type > // Data type of the matrix
3036 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data( size_t j ) const
3037 {
3038  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3039  return v_ + j*mm_;
3040 }
3042 //*************************************************************************************************
3043 
3044 
3045 //*************************************************************************************************
3052 template< typename Type > // Data type of the matrix
3053 inline typename DynamicMatrix<Type,true>::Iterator
3055 {
3056  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3057  return Iterator( v_ + j*mm_ );
3058 }
3060 //*************************************************************************************************
3061 
3062 
3063 //*************************************************************************************************
3070 template< typename Type > // Data type of the matrix
3072  DynamicMatrix<Type,true>::begin( size_t j ) const
3073 {
3074  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3075  return ConstIterator( v_ + j*mm_ );
3076 }
3078 //*************************************************************************************************
3079 
3080 
3081 //*************************************************************************************************
3088 template< typename Type > // Data type of the matrix
3090  DynamicMatrix<Type,true>::cbegin( size_t j ) const
3091 {
3092  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3093  return ConstIterator( v_ + j*mm_ );
3094 }
3096 //*************************************************************************************************
3097 
3098 
3099 //*************************************************************************************************
3106 template< typename Type > // Data type of the matrix
3107 inline typename DynamicMatrix<Type,true>::Iterator
3108  DynamicMatrix<Type,true>::end( size_t j )
3109 {
3110  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3111  return Iterator( v_ + j*mm_ + m_ );
3112 }
3114 //*************************************************************************************************
3115 
3116 
3117 //*************************************************************************************************
3124 template< typename Type > // Data type of the matrix
3126  DynamicMatrix<Type,true>::end( size_t j ) const
3127 {
3128  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3129  return ConstIterator( v_ + j*mm_ + m_ );
3130 }
3132 //*************************************************************************************************
3133 
3134 
3135 //*************************************************************************************************
3142 template< typename Type > // Data type of the matrix
3144  DynamicMatrix<Type,true>::cend( size_t j ) const
3145 {
3146  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3147  return ConstIterator( v_ + j*mm_ + m_ );
3148 }
3150 //*************************************************************************************************
3151 
3152 
3153 
3154 
3155 //=================================================================================================
3156 //
3157 // ASSIGNMENT OPERATORS
3158 //
3159 //=================================================================================================
3160 
3161 //*************************************************************************************************
3183 template< typename Type > // Data type of the matrix
3184 template< typename Other // Data type of the initialization array
3185  , size_t M // Number of rows of the initialization array
3186  , size_t N > // Number of columns of the initialization array
3187 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Other (&array)[M][N] )
3188 {
3189  resize( M, N, false );
3190 
3191  for( size_t j=0UL; j<N; ++j )
3192  for( size_t i=0UL; i<M; ++i )
3193  v_[i+j*mm_] = array[i][j];
3194 
3195  return *this;
3196 }
3198 //*************************************************************************************************
3199 
3200 
3201 //*************************************************************************************************
3208 template< typename Type > // Data type of the matrix
3209 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3210 {
3211  for( size_t j=0UL; j<n_; ++j )
3212  for( size_t i=0UL; i<m_; ++i )
3213  v_[i+j*mm_] = rhs;
3214 
3215  return *this;
3216 }
3218 //*************************************************************************************************
3219 
3220 
3221 //*************************************************************************************************
3231 template< typename Type > // Data type of the matrix
3232 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const DynamicMatrix& rhs )
3233 {
3234  if( &rhs == this ) return *this;
3235 
3236  resize( rhs.m_, rhs.n_, false );
3237  smpAssign( *this, ~rhs );
3238 
3239  return *this;
3240 }
3242 //*************************************************************************************************
3243 
3244 
3245 //*************************************************************************************************
3255 template< typename Type > // Data type of the matrix
3256 template< typename MT // Type of the right-hand side matrix
3257  , bool SO > // Storage order of the right-hand side matrix
3258 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Matrix<MT,SO>& rhs )
3259 {
3260  if( (~rhs).canAlias( this ) ) {
3261  DynamicMatrix tmp( ~rhs );
3262  swap( tmp );
3263  }
3264  else {
3265  resize( (~rhs).rows(), (~rhs).columns(), false );
3266  if( IsSparseMatrix<MT>::value )
3267  reset();
3268  smpAssign( *this, ~rhs );
3269  }
3270 
3271  return *this;
3272 }
3274 //*************************************************************************************************
3275 
3276 
3277 //*************************************************************************************************
3288 template< typename Type > // Data type of the matrix
3289 template< typename MT // Type of the right-hand side matrix
3290  , bool SO > // Storage order of the right-hand side matrix
3291 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=( const Matrix<MT,SO>& rhs )
3292 {
3293  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3294  throw std::invalid_argument( "Matrix sizes do not match" );
3295 
3296  if( (~rhs).canAlias( this ) ) {
3297  typename MT::ResultType tmp( ~rhs );
3298  smpAddAssign( *this, tmp );
3299  }
3300  else {
3301  smpAddAssign( *this, ~rhs );
3302  }
3303 
3304  return *this;
3305 }
3307 //*************************************************************************************************
3308 
3309 
3310 //*************************************************************************************************
3321 template< typename Type > // Data type of the matrix
3322 template< typename MT // Type of the right-hand side matrix
3323  , bool SO > // Storage order of the right-hand side matrix
3324 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=( const Matrix<MT,SO>& rhs )
3325 {
3326  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3327  throw std::invalid_argument( "Matrix sizes do not match" );
3328 
3329  if( (~rhs).canAlias( this ) ) {
3330  typename MT::ResultType tmp( ~rhs );
3331  smpSubAssign( *this, tmp );
3332  }
3333  else {
3334  smpSubAssign( *this, ~rhs );
3335  }
3336 
3337  return *this;
3338 }
3340 //*************************************************************************************************
3341 
3342 
3343 //*************************************************************************************************
3354 template< typename Type > // Data type of the matrix
3355 template< typename MT // Type of the right-hand side matrix
3356  , bool SO > // Storage order of the right-hand side matrix
3357 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=( const Matrix<MT,SO>& rhs )
3358 {
3359  if( (~rhs).rows() != n_ )
3360  throw std::invalid_argument( "Matrix sizes do not match" );
3361 
3362  DynamicMatrix tmp( *this * (~rhs) );
3363  swap( tmp );
3364 
3365  return *this;
3366 }
3368 //*************************************************************************************************
3369 
3370 
3371 //*************************************************************************************************
3379 template< typename Type > // Data type of the matrix
3380 template< typename Other > // Data type of the right-hand side scalar
3381 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3382  DynamicMatrix<Type,true>::operator*=( Other rhs )
3383 {
3384  smpAssign( *this, (*this) * rhs );
3385  return *this;
3386 }
3388 //*************************************************************************************************
3389 
3390 
3391 //*************************************************************************************************
3399 template< typename Type > // Data type of the matrix
3400 template< typename Other > // Data type of the right-hand side scalar
3401 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3402  DynamicMatrix<Type,true>::operator/=( Other rhs )
3403 {
3404  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3405 
3406  smpAssign( *this, (*this) / rhs );
3407  return *this;
3408 }
3410 //*************************************************************************************************
3411 
3412 
3413 
3414 
3415 //=================================================================================================
3416 //
3417 // UTILITY FUNCTIONS
3418 //
3419 //=================================================================================================
3420 
3421 //*************************************************************************************************
3427 template< typename Type > // Data type of the matrix
3428 inline size_t DynamicMatrix<Type,true>::rows() const
3429 {
3430  return m_;
3431 }
3433 //*************************************************************************************************
3434 
3435 
3436 //*************************************************************************************************
3442 template< typename Type > // Data type of the matrix
3443 inline size_t DynamicMatrix<Type,true>::columns() const
3444 {
3445  return n_;
3446 }
3448 //*************************************************************************************************
3449 
3450 
3451 //*************************************************************************************************
3460 template< typename Type > // Data type of the matrix
3461 inline size_t DynamicMatrix<Type,true>::spacing() const
3462 {
3463  return mm_;
3464 }
3466 //*************************************************************************************************
3467 
3468 
3469 //*************************************************************************************************
3475 template< typename Type > // Data type of the matrix
3476 inline size_t DynamicMatrix<Type,true>::capacity() const
3477 {
3478  return capacity_;
3479 }
3481 //*************************************************************************************************
3482 
3483 
3484 //*************************************************************************************************
3491 template< typename Type > // Data type of the sparse matrix
3492 inline size_t DynamicMatrix<Type,true>::capacity( size_t j ) const
3493 {
3494  UNUSED_PARAMETER( j );
3495  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3496  return mm_;
3497 }
3499 //*************************************************************************************************
3500 
3501 
3502 //*************************************************************************************************
3508 template< typename Type > // Data type of the matrix
3509 inline size_t DynamicMatrix<Type,true>::nonZeros() const
3510 {
3511  size_t nonzeros( 0UL );
3512 
3513  for( size_t j=0UL; j<n_; ++j )
3514  for( size_t i=0UL; i<m_; ++i )
3515  if( !isDefault( v_[i+j*mm_] ) )
3516  ++nonzeros;
3517 
3518  return nonzeros;
3519 }
3521 //*************************************************************************************************
3522 
3523 
3524 //*************************************************************************************************
3531 template< typename Type > // Data type of the matrix
3532 inline size_t DynamicMatrix<Type,true>::nonZeros( size_t j ) const
3533 {
3534  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3535 
3536  const size_t iend( (j+1UL)*mm_ );
3537  size_t nonzeros( 0UL );
3538 
3539  for( size_t i=j*mm_; i<iend; ++i )
3540  if( !isDefault( v_[i] ) )
3541  ++nonzeros;
3542 
3543  return nonzeros;
3544 }
3546 //*************************************************************************************************
3547 
3548 
3549 //*************************************************************************************************
3555 template< typename Type > // Data type of the matrix
3556 inline void DynamicMatrix<Type,true>::reset()
3557 {
3558  using blaze::clear;
3559 
3560  for( size_t j=0UL; j<n_; ++j )
3561  for( size_t i=0UL; i<m_; ++i )
3562  clear( v_[i+j*mm_] );
3563 }
3565 //*************************************************************************************************
3566 
3567 
3568 //*************************************************************************************************
3578 template< typename Type > // Data type of the sparse matrix
3579 inline void DynamicMatrix<Type,true>::reset( size_t j )
3580 {
3581  using blaze::clear;
3582 
3583  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3584  for( size_t i=0UL; i<m_; ++i )
3585  clear( v_[i+j*mm_] );
3586 }
3588 //*************************************************************************************************
3589 
3590 
3591 //*************************************************************************************************
3599 template< typename Type > // Data type of the matrix
3600 inline void DynamicMatrix<Type,true>::clear()
3601 {
3602  resize( 0UL, 0UL, false );
3603 }
3605 //*************************************************************************************************
3606 
3607 
3608 //*************************************************************************************************
3643 template< typename Type > // Data type of the matrix
3644 void DynamicMatrix<Type,true>::resize( size_t m, size_t n, bool preserve )
3645 {
3646  using blaze::min;
3647 
3648  if( m == m_ && n == n_ ) return;
3649 
3650  const size_t mm( adjustRows( m ) );
3651 
3652  if( preserve )
3653  {
3654  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
3655  const size_t min_m( min( m, m_ ) );
3656  const size_t min_n( min( n, n_ ) );
3657 
3658  for( size_t j=0UL; j<min_n; ++j )
3659  for( size_t i=0UL; i<min_m; ++i )
3660  v[i+j*mm] = v_[i+j*mm_];
3661 
3662  std::swap( v_, v );
3663  deallocate( v );
3664  capacity_ = mm*n;
3665  }
3666  else if( mm*n > capacity_ ) {
3667  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
3668  std::swap( v_, v );
3669  deallocate( v );
3670  capacity_ = mm*n;
3671  }
3672 
3673  if( IsVectorizable<Type>::value ) {
3674  for( size_t j=0UL; j<n; ++j )
3675  for( size_t i=m; i<mm; ++i )
3676  v_[i+j*mm] = Type();
3677  }
3678 
3679  m_ = m;
3680  mm_ = mm;
3681  n_ = n;
3682 }
3684 //*************************************************************************************************
3685 
3686 
3687 //*************************************************************************************************
3702 template< typename Type > // Data type of the matrix
3703 inline void DynamicMatrix<Type,true>::extend( size_t m, size_t n, bool preserve )
3704 {
3705  resize( m_+m, n_+n, preserve );
3706 }
3708 //*************************************************************************************************
3709 
3710 
3711 //*************************************************************************************************
3721 template< typename Type > // Data type of the matrix
3722 inline void DynamicMatrix<Type,true>::reserve( size_t elements )
3723 {
3724  if( elements > capacity_ )
3725  {
3726  // Allocating a new array
3727  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
3728 
3729  // Initializing the new array
3730  std::copy( v_, v_+capacity_, tmp );
3731 
3732  if( IsVectorizable<Type>::value ) {
3733  for( size_t i=capacity_; i<elements; ++i )
3734  tmp[i] = Type();
3735  }
3736 
3737  // Replacing the old array
3738  std::swap( tmp, v_ );
3739  deallocate( tmp );
3740  capacity_ = elements;
3741  }
3742 }
3744 //*************************************************************************************************
3745 
3746 
3747 //*************************************************************************************************
3753 template< typename Type > // Data type of the matrix
3754 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::transpose()
3755 {
3756  DynamicMatrix tmp( trans(*this) );
3757  swap( tmp );
3758  return *this;
3759 }
3761 //*************************************************************************************************
3762 
3763 
3764 //*************************************************************************************************
3771 template< typename Type > // Data type of the matrix
3772 template< typename Other > // Data type of the scalar value
3773 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( const Other& scalar )
3774 {
3775  for( size_t j=0UL; j<n_; ++j )
3776  for( size_t i=0UL; i<m_; ++i )
3777  v_[i+j*mm_] *= scalar;
3778 
3779  return *this;
3780 }
3782 //*************************************************************************************************
3783 
3784 
3785 //*************************************************************************************************
3793 template< typename Type > // Data type of the matrix
3794 inline void DynamicMatrix<Type,true>::swap( DynamicMatrix& m ) /* throw() */
3795 {
3796  std::swap( m_ , m.m_ );
3797  std::swap( mm_, m.mm_ );
3798  std::swap( n_ , m.n_ );
3799  std::swap( capacity_, m.capacity_ );
3800  std::swap( v_ , m.v_ );
3801 }
3803 //*************************************************************************************************
3804 
3805 
3806 //*************************************************************************************************
3813 template< typename Type > // Data type of the matrix
3814 inline size_t DynamicMatrix<Type,true>::adjustRows( size_t minRows ) const
3815 {
3816  if( IsVectorizable<Type>::value )
3817  return minRows + ( IT::size - ( minRows % IT::size ) ) % IT::size;
3818  else return minRows;
3819 }
3821 //*************************************************************************************************
3822 
3823 
3824 
3825 
3826 //=================================================================================================
3827 //
3828 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
3829 //
3830 //=================================================================================================
3831 
3832 //*************************************************************************************************
3843 template< typename Type > // Data type of the matrix
3844 template< typename Other > // Data type of the foreign expression
3845 inline bool DynamicMatrix<Type,true>::canAlias( const Other* alias ) const
3846 {
3847  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
3848 }
3850 //*************************************************************************************************
3851 
3852 
3853 //*************************************************************************************************
3864 template< typename Type > // Data type of the matrix
3865 template< typename Other > // Data type of the foreign expression
3866 inline bool DynamicMatrix<Type,true>::isAliased( const Other* alias ) const
3867 {
3868  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
3869 }
3871 //*************************************************************************************************
3872 
3873 
3874 //*************************************************************************************************
3884 template< typename Type > // Data type of the matrix
3885 inline bool DynamicMatrix<Type,true>::isAligned() const
3886 {
3887  return true;
3888 }
3890 //*************************************************************************************************
3891 
3892 
3893 //*************************************************************************************************
3904 template< typename Type > // Data type of the matrix
3905 inline bool DynamicMatrix<Type,true>::canSMPAssign() const
3906 {
3907  return ( columns() > SMP_DMATASSIGN_THRESHOLD );
3908 }
3910 //*************************************************************************************************
3911 
3912 
3913 //*************************************************************************************************
3928 template< typename Type > // Data type of the matrix
3929 inline typename DynamicMatrix<Type,true>::IntrinsicType
3930  DynamicMatrix<Type,true>::load( size_t i, size_t j ) const
3931 {
3932  using blaze::load;
3933 
3935 
3936  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
3937  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
3938  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
3939  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
3940 
3941  return load( v_+i+j*mm_ );
3942 }
3944 //*************************************************************************************************
3945 
3946 
3947 //*************************************************************************************************
3962 template< typename Type > // Data type of the matrix
3963 inline typename DynamicMatrix<Type,true>::IntrinsicType
3964  DynamicMatrix<Type,true>::loadu( size_t i, size_t j ) const
3965 {
3966  using blaze::loadu;
3967 
3969 
3970  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
3971  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
3972  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
3973 
3974  return loadu( v_+i+j*mm_ );
3975 }
3977 //*************************************************************************************************
3978 
3979 
3980 //*************************************************************************************************
3996 template< typename Type > // Data type of the matrix
3997 inline void DynamicMatrix<Type,true>::store( size_t i, size_t j, const IntrinsicType& value )
3998 {
3999  using blaze::store;
4000 
4002 
4003  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4004  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4005  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4006  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4007 
4008  store( v_+i+j*mm_, value );
4009 }
4011 //*************************************************************************************************
4012 
4013 
4014 //*************************************************************************************************
4030 template< typename Type > // Data type of the matrix
4031 inline void DynamicMatrix<Type,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4032 {
4033  using blaze::storeu;
4034 
4036 
4037  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4038  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4039  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4040 
4041  storeu( v_+i+j*mm_, value );
4042 }
4044 //*************************************************************************************************
4045 
4046 
4047 //*************************************************************************************************
4064 template< typename Type > // Data type of the matrix
4065 inline void DynamicMatrix<Type,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4066 {
4067  using blaze::stream;
4068 
4070 
4071  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4072  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4073  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4074  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4075 
4076  stream( v_+i+j*mm_, value );
4077 }
4079 //*************************************************************************************************
4080 
4081 
4082 //*************************************************************************************************
4094 template< typename Type > // Data type of the matrix
4095 template< typename MT > // Type of the right-hand side dense matrix
4096 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4097  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4098 {
4099  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4100  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4101 
4102  const size_t iend( m_ & size_t(-2) );
4103  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % 2UL ) ) == iend, "Invalid end calculation" );
4104 
4105  for( size_t j=0UL; j<n_; ++j ) {
4106  for( size_t i=0UL; i<iend; i+=2UL ) {
4107  v_[i +j*mm_] = (~rhs)(i ,j);
4108  v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4109  }
4110  if( iend < m_ ) {
4111  v_[iend+j*mm_] = (~rhs)(iend,j);
4112  }
4113  }
4114 }
4116 //*************************************************************************************************
4117 
4118 
4119 //*************************************************************************************************
4131 template< typename Type > // Data type of the matrix
4132 template< typename MT > // Type of the right-hand side dense matrix
4133 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4134  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4135 {
4136  using blaze::store;
4137  using blaze::stream;
4138 
4139  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4140  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4141 
4143 
4144  if( useStreaming && m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) && !(~rhs).isAliased( this ) )
4145  {
4146  for( size_t j=0UL; j<n_; ++j )
4147  for( size_t i=0UL; i<m_; i+=IT::size )
4148  stream( v_+i+j*mm_, (~rhs).load(i,j) );
4149  }
4150  else
4151  {
4152  const size_t iend( m_ & size_t(-IT::size*4) );
4153  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
4154 
4155  for( size_t j=0UL; j<n_; ++j ) {
4156  typename MT::ConstIterator it( (~rhs).begin(j) );
4157  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4158  store( v_+i+j*mm_ , it.load() ); it += IT::size;
4159  store( v_+i+j*mm_+IT::size , it.load() ); it += IT::size;
4160  store( v_+i+j*mm_+IT::size*2UL, it.load() ); it += IT::size;
4161  store( v_+i+j*mm_+IT::size*3UL, it.load() ); it += IT::size;
4162  }
4163  for( size_t i=iend; i<m_; i+=IT::size, it+=IT::size ) {
4164  store( v_+i+j*mm_, it.load() );
4165  }
4166  }
4167  }
4168 }
4170 //*************************************************************************************************
4171 
4172 
4173 //*************************************************************************************************
4185 template< typename Type > // Data type of the matrix
4186 template< typename MT > // Type of the right-hand side dense matrix
4187 inline void DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,false>& rhs )
4188 {
4190 
4191  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4192  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4193 
4194  const size_t block( 16UL );
4195 
4196  for( size_t jj=0UL; jj<n_; jj+=block ) {
4197  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4198  for( size_t ii=0UL; ii<m_; ii+=block ) {
4199  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4200  for( size_t j=jj; j<jend; ++j ) {
4201  for( size_t i=ii; i<iend; ++i ) {
4202  v_[i+j*mm_] = (~rhs)(i,j);
4203  }
4204  }
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 sparse matrix
4226 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,true>& rhs )
4227 {
4228  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4229  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4230 
4231  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4232  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4233  v_[element->index()+j*mm_] = element->value();
4234 }
4236 //*************************************************************************************************
4237 
4238 
4239 //*************************************************************************************************
4251 template< typename Type > // Data type of the matrix
4252 template< typename MT > // Type of the right-hand side sparse matrix
4253 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,false>& rhs )
4254 {
4256 
4257  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4258  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4259 
4260  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4261  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4262  v_[i+element->index()*mm_] = element->value();
4263 }
4265 //*************************************************************************************************
4266 
4267 
4268 //*************************************************************************************************
4280 template< typename Type > // Data type of the matrix
4281 template< typename MT > // Type of the right-hand side dense matrix
4282 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4283  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4284 {
4285  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4286  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4287 
4288  const size_t iend( m_ & size_t(-2) );
4289  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % 2UL ) ) == iend, "Invalid end calculation" );
4290 
4291  for( size_t j=0UL; j<n_; ++j ) {
4292  for( size_t i=0UL; i<iend; i+=2UL ) {
4293  v_[i +j*mm_] += (~rhs)(i ,j);
4294  v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4295  }
4296  if( iend < m_ ) {
4297  v_[iend+j*mm_] += (~rhs)(iend,j);
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 dense matrix
4319 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4320  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4321 {
4322  using blaze::load;
4323  using blaze::store;
4324 
4325  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4326  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4327 
4329 
4330  const size_t iend( m_ & size_t(-IT::size*4) );
4331  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
4332 
4333  for( size_t j=0UL; j<n_; ++j ) {
4334  typename MT::ConstIterator it( (~rhs).begin(j) );
4335  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4336  store( v_+i+j*mm_ , load( v_+i+j*mm_ ) + it.load() ); it += IT::size;
4337  store( v_+i+j*mm_+IT::size , load( v_+i+j*mm_+IT::size ) + it.load() ); it += IT::size;
4338  store( v_+i+j*mm_+IT::size*2UL, load( v_+i+j*mm_+IT::size*2UL ) + it.load() ); it += IT::size;
4339  store( v_+i+j*mm_+IT::size*3UL, load( v_+i+j*mm_+IT::size*3UL ) + it.load() ); it += IT::size;
4340  }
4341  for( size_t i=iend; i<m_; i+=IT::size, it+=IT::size ) {
4342  store( v_+i+j*mm_, load( v_+i+j*mm_ ) + it.load() );
4343  }
4344  }
4345 }
4347 //*************************************************************************************************
4348 
4349 
4350 //*************************************************************************************************
4362 template< typename Type > // Data type of the matrix
4363 template< typename MT > // Type of the right-hand side dense matrix
4364 inline void DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,false>& rhs )
4365 {
4367 
4368  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4369  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4370 
4371  const size_t block( 16UL );
4372 
4373  for( size_t jj=0UL; jj<n_; jj+=block ) {
4374  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4375  for( size_t ii=0UL; ii<m_; ii+=block ) {
4376  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4377  for( size_t j=jj; j<jend; ++j ) {
4378  for( size_t i=ii; i<iend; ++i ) {
4379  v_[i+j*mm_] += (~rhs)(i,j);
4380  }
4381  }
4382  }
4383  }
4384 }
4386 //*************************************************************************************************
4387 
4388 
4389 //*************************************************************************************************
4401 template< typename Type > // Data type of the matrix
4402 template< typename MT > // Type of the right-hand side sparse matrix
4403 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,true>& rhs )
4404 {
4405  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4406  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4407 
4408  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4409  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4410  v_[element->index()+j*mm_] += element->value();
4411 }
4413 //*************************************************************************************************
4414 
4415 
4416 //*************************************************************************************************
4428 template< typename Type > // Data type of the matrix
4429 template< typename MT > // Type of the right-hand side sparse matrix
4430 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,false>& rhs )
4431 {
4433 
4434  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4435  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4436 
4437  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4438  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4439  v_[i+element->index()*mm_] += element->value();
4440 }
4442 //*************************************************************************************************
4443 
4444 
4445 //*************************************************************************************************
4457 template< typename Type > // Data type of the matrix
4458 template< typename MT > // Type of the right-hand side dense matrix
4459 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4460  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
4461 {
4462  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4463  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4464 
4465  const size_t iend( m_ & size_t(-2) );
4466  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % 2UL ) ) == iend, "Invalid end calculation" );
4467 
4468  for( size_t j=0UL; j<n_; ++j ) {
4469  for( size_t i=0UL; i<iend; i+=2UL ) {
4470  v_[i +j*mm_] -= (~rhs)(i ,j);
4471  v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4472  }
4473  if( iend < m_ ) {
4474  v_[iend+j*mm_] -= (~rhs)(iend,j);
4475  }
4476  }
4477 }
4479 //*************************************************************************************************
4480 
4481 
4482 //*************************************************************************************************
4495 template< typename Type > // Data type of the matrix
4496 template< typename MT > // Type of the right-hand side dense matrix
4497 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4498  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
4499 {
4500  using blaze::load;
4501  using blaze::store;
4502 
4503  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4504  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4505 
4507 
4508  const size_t iend( m_ & size_t(-IT::size*4) );
4509  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % (IT::size*4UL) ) ) == iend, "Invalid end calculation" );
4510 
4511  for( size_t j=0UL; j<n_; ++j ) {
4512  typename MT::ConstIterator it( (~rhs).begin(j) );
4513  for( size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4514  store( v_+i+j*mm_ , load( v_+i+j*mm_ ) - it.load() ); it += IT::size;
4515  store( v_+i+j*mm_+IT::size , load( v_+i+j*mm_+IT::size ) - it.load() ); it += IT::size;
4516  store( v_+i+j*mm_+IT::size*2UL, load( v_+i+j*mm_+IT::size*2UL ) - it.load() ); it += IT::size;
4517  store( v_+i+j*mm_+IT::size*3UL, load( v_+i+j*mm_+IT::size*3UL ) - it.load() ); it += IT::size;
4518  }
4519  for( size_t i=iend; i<m_; i+=IT::size, it+=IT::size ) {
4520  store( v_+i+j*mm_, load( v_+i+j*mm_ ) - it.load() );
4521  }
4522  }
4523 }
4525 //*************************************************************************************************
4526 
4527 
4528 //*************************************************************************************************
4540 template< typename Type > // Data type of the matrix
4541 template< typename MT > // Type of the right-hand side dense matrix
4542 inline void DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,false>& rhs )
4543 {
4545 
4546  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4547  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4548 
4549  const size_t block( 16UL );
4550 
4551  for( size_t jj=0UL; jj<n_; jj+=block ) {
4552  const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4553  for( size_t ii=0UL; ii<m_; ii+=block ) {
4554  const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4555  for( size_t j=jj; j<jend; ++j ) {
4556  for( size_t i=ii; i<iend; ++i ) {
4557  v_[i+j*mm_] -= (~rhs)(i,j);
4558  }
4559  }
4560  }
4561  }
4562 }
4564 //*************************************************************************************************
4565 
4566 
4567 //*************************************************************************************************
4579 template< typename Type > // Data type of the matrix
4580 template< typename MT > // Type of the right-hand side sparse matrix
4581 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,true>& rhs )
4582 {
4583  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4584  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4585 
4586  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4587  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4588  v_[element->index()+j*mm_] -= element->value();
4589 }
4591 //*************************************************************************************************
4592 
4593 
4594 //*************************************************************************************************
4606 template< typename Type > // Data type of the matrix
4607 template< typename MT > // Type of the right-hand side sparse matrix
4608 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,false>& rhs )
4609 {
4611 
4612  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4613  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4614 
4615  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4616  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4617  v_[i+element->index()*mm_] -= element->value();
4618 }
4620 //*************************************************************************************************
4621 
4622 
4623 
4624 
4625 
4626 
4627 
4628 
4629 //=================================================================================================
4630 //
4631 // DYNAMICMATRIX OPERATORS
4632 //
4633 //=================================================================================================
4634 
4635 //*************************************************************************************************
4638 template< typename Type, bool SO >
4639 inline void reset( DynamicMatrix<Type,SO>& m );
4640 
4641 template< typename Type, bool SO >
4642 inline void reset( DynamicMatrix<Type,SO>& m, size_t i );
4643 
4644 template< typename Type, bool SO >
4645 inline void clear( DynamicMatrix<Type,SO>& m );
4646 
4647 template< typename Type, bool SO >
4648 inline bool isDefault( const DynamicMatrix<Type,SO>& m );
4649 
4650 template< typename Type, bool SO >
4651 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */;
4652 
4653 template< typename Type, bool SO >
4654 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */;
4656 //*************************************************************************************************
4657 
4658 
4659 //*************************************************************************************************
4666 template< typename Type // Data type of the matrix
4667  , bool SO > // Storage order
4669 {
4670  m.reset();
4671 }
4672 //*************************************************************************************************
4673 
4674 
4675 //*************************************************************************************************
4688 template< typename Type // Data type of the matrix
4689  , bool SO > // Storage order
4690 inline void reset( DynamicMatrix<Type,SO>& m, size_t i )
4691 {
4692  m.reset( i );
4693 }
4694 //*************************************************************************************************
4695 
4696 
4697 //*************************************************************************************************
4704 template< typename Type // Data type of the matrix
4705  , bool SO > // Storage order
4707 {
4708  m.clear();
4709 }
4710 //*************************************************************************************************
4711 
4712 
4713 //*************************************************************************************************
4731 template< typename Type // Data type of the matrix
4732  , bool SO > // Storage order
4733 inline bool isDefault( const DynamicMatrix<Type,SO>& m )
4734 {
4735  return ( m.rows() == 0UL && m.columns() == 0UL );
4736 }
4737 //*************************************************************************************************
4738 
4739 
4740 //*************************************************************************************************
4749 template< typename Type // Data type of the matrix
4750  , bool SO > // Storage order
4751 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */
4752 {
4753  a.swap( b );
4754 }
4755 //*************************************************************************************************
4756 
4757 
4758 //*************************************************************************************************
4767 template< typename Type // Data type of the matrix
4768  , bool SO > // Storage order
4769 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */
4770 {
4771  dst.swap( src );
4772 }
4773 //*************************************************************************************************
4774 
4775 
4776 
4777 
4778 //=================================================================================================
4779 //
4780 // ISRESIZABLE SPECIALIZATIONS
4781 //
4782 //=================================================================================================
4783 
4784 //*************************************************************************************************
4786 template< typename T, bool SO >
4787 struct IsResizable< DynamicMatrix<T,SO> > : public TrueType
4788 {
4789  enum { value = 1 };
4790  typedef TrueType Type;
4791 };
4793 //*************************************************************************************************
4794 
4795 
4796 
4797 
4798 //=================================================================================================
4799 //
4800 // ADDTRAIT SPECIALIZATIONS
4801 //
4802 //=================================================================================================
4803 
4804 //*************************************************************************************************
4806 template< typename T1, bool SO, typename T2, size_t M, size_t N >
4807 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4808 {
4809  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4810 };
4811 
4812 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
4813 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4814 {
4815  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
4816 };
4817 
4818 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
4819 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4820 {
4821  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4822 };
4823 
4824 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
4825 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4826 {
4827  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
4828 };
4829 
4830 template< typename T1, bool SO, typename T2, size_t M, size_t N >
4831 struct AddTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4832 {
4833  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4834 };
4835 
4836 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
4837 struct AddTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4838 {
4839  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
4840 };
4841 
4842 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
4843 struct AddTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4844 {
4845  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4846 };
4847 
4848 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
4849 struct AddTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4850 {
4851  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
4852 };
4853 
4854 template< typename T1, bool SO, typename T2 >
4855 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4856 {
4857  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4858 };
4859 
4860 template< typename T1, bool SO1, typename T2, bool SO2 >
4861 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4862 {
4863  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , false > Type;
4864 };
4866 //*************************************************************************************************
4867 
4868 
4869 
4870 
4871 //=================================================================================================
4872 //
4873 // SUBTRAIT SPECIALIZATIONS
4874 //
4875 //=================================================================================================
4876 
4877 //*************************************************************************************************
4879 template< typename T1, bool SO, typename T2, size_t M, size_t N >
4880 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4881 {
4882  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4883 };
4884 
4885 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
4886 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4887 {
4888  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
4889 };
4890 
4891 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
4892 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4893 {
4894  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4895 };
4896 
4897 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
4898 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4899 {
4900  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
4901 };
4902 
4903 template< typename T1, bool SO, typename T2, size_t M, size_t N >
4904 struct SubTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4905 {
4906  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4907 };
4908 
4909 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
4910 struct SubTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4911 {
4912  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
4913 };
4914 
4915 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
4916 struct SubTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4917 {
4918  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4919 };
4920 
4921 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
4922 struct SubTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4923 {
4924  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
4925 };
4926 
4927 template< typename T1, bool SO, typename T2 >
4928 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4929 {
4930  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4931 };
4932 
4933 template< typename T1, bool SO1, typename T2, bool SO2 >
4934 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4935 {
4936  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , false > Type;
4937 };
4939 //*************************************************************************************************
4940 
4941 
4942 
4943 
4944 //=================================================================================================
4945 //
4946 // MULTTRAIT SPECIALIZATIONS
4947 //
4948 //=================================================================================================
4949 
4950 //*************************************************************************************************
4952 template< typename T1, bool SO, typename T2 >
4953 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
4954 {
4955  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4957 };
4958 
4959 template< typename T1, typename T2, bool SO >
4960 struct MultTrait< T1, DynamicMatrix<T2,SO> >
4961 {
4962  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4964 };
4965 
4966 template< typename T1, bool SO, typename T2, size_t N >
4967 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
4968 {
4969  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
4970 };
4971 
4972 template< typename T1, size_t N, typename T2, bool SO >
4973 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
4974 {
4975  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
4976 };
4977 
4978 template< typename T1, bool SO, typename T2, size_t N >
4979 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
4980 {
4981  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
4982 };
4983 
4984 template< typename T1, size_t N, typename T2, bool SO >
4985 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
4986 {
4987  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
4988 };
4989 
4990 template< typename T1, bool SO, typename T2 >
4991 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
4992 {
4993  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
4994 };
4995 
4996 template< typename T1, typename T2, bool SO >
4997 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
4998 {
4999  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5000 };
5001 
5002 template< typename T1, bool SO, typename T2 >
5003 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
5004 {
5005  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5006 };
5007 
5008 template< typename T1, typename T2, bool SO >
5009 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
5010 {
5011  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5012 };
5013 
5014 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5015 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5016 {
5017  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5018 };
5019 
5020 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5021 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5022 {
5023  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5024 };
5025 
5026 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5027 struct MultTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5028 {
5029  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5030 };
5031 
5032 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5033 struct MultTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5034 {
5035  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5036 };
5037 
5038 template< typename T1, bool SO1, typename T2, bool SO2 >
5039 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5040 {
5041  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5042 };
5044 //*************************************************************************************************
5045 
5046 
5047 
5048 
5049 //=================================================================================================
5050 //
5051 // DIVTRAIT SPECIALIZATIONS
5052 //
5053 //=================================================================================================
5054 
5055 //*************************************************************************************************
5057 template< typename T1, bool SO, typename T2 >
5058 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
5059 {
5060  typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
5062 };
5064 //*************************************************************************************************
5065 
5066 
5067 
5068 
5069 //=================================================================================================
5070 //
5071 // MATHTRAIT SPECIALIZATIONS
5072 //
5073 //=================================================================================================
5074 
5075 //*************************************************************************************************
5077 template< typename T1, bool SO, typename T2 >
5078 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5079 {
5080  typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5081  typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5082 };
5084 //*************************************************************************************************
5085 
5086 
5087 
5088 
5089 //=================================================================================================
5090 //
5091 // SUBMATRIXTRAIT SPECIALIZATIONS
5092 //
5093 //=================================================================================================
5094 
5095 //*************************************************************************************************
5097 template< typename T1, bool SO >
5098 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
5099 {
5100  typedef DynamicMatrix<T1,SO> Type;
5101 };
5103 //*************************************************************************************************
5104 
5105 
5106 
5107 
5108 //=================================================================================================
5109 //
5110 // ROWTRAIT SPECIALIZATIONS
5111 //
5112 //=================================================================================================
5113 
5114 //*************************************************************************************************
5116 template< typename T1, bool SO >
5117 struct RowTrait< DynamicMatrix<T1,SO> >
5118 {
5119  typedef DynamicVector<T1,true> Type;
5120 };
5122 //*************************************************************************************************
5123 
5124 
5125 
5126 
5127 //=================================================================================================
5128 //
5129 // COLUMNTRAIT SPECIALIZATIONS
5130 //
5131 //=================================================================================================
5132 
5133 //*************************************************************************************************
5135 template< typename T1, bool SO >
5136 struct ColumnTrait< DynamicMatrix<T1,SO> >
5137 {
5138  typedef DynamicVector<T1,false> Type;
5139 };
5141 //*************************************************************************************************
5142 
5143 } // namespace blaze
5144 
5145 #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:708
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:415
Constraint on the data type.
Header file for mathematical functions.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1508
#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.
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:258
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:872
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:418
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.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1432
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
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:1226
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1809
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2636
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#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:456
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:1245
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:178
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:194
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2638
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:683
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:188
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:1295
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1596
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:938
Header file for the multiplication trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1664
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1742
Header file for the clear shim.
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:4754
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:191
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
#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.
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: DynamicMatrix.h:182
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:187
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
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.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
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:193
Constraint on the data type.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1490
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1212
#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:1345
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:894
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 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:2480
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:189
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1259
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:416
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1775
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:197
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:1389
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:198
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:414
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:828
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:1646
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4769
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:2481
Header file for the column trait.
Header file for the isDefault shim.
System settings for the restrict keyword.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1577
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1708
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
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:195
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:1683
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2637
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:200
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
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:192
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:417
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
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:207
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: DynamicMatrix.h:199
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2489
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
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
Pointer data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:750
Header file for the IsResizable type trait.
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:1626
DynamicMatrix< ET, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:208
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1539
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:196
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:190
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.
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:1842