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>
50 #include <blaze/math/Forward.h>
51 #include <blaze/math/Functions.h>
52 #include <blaze/math/Intrinsics.h>
53 #include <blaze/math/shims/Clear.h>
78 #include <blaze/system/Blocking.h>
79 #include <blaze/system/CacheSize.h>
80 #include <blaze/system/Inline.h>
82 #include <blaze/system/Restrict.h>
85 #include <blaze/util/Assert.h>
92 #include <blaze/util/DisableIf.h>
93 #include <blaze/util/EnableIf.h>
94 #include <blaze/util/Exception.h>
95 #include <blaze/util/Memory.h>
96 #include <blaze/util/Null.h>
97 #include <blaze/util/Template.h>
98 #include <blaze/util/Types.h>
102 #include <blaze/util/Unused.h>
104 
105 
106 namespace blaze {
107 
108 //=================================================================================================
109 //
110 // CLASS DEFINITION
111 //
112 //=================================================================================================
113 
114 //*************************************************************************************************
193 template< typename Type // Data type of the matrix
194  , bool SO = defaultStorageOrder > // Storage order
195 class DynamicMatrix : public DenseMatrix< DynamicMatrix<Type,SO>, SO >
196 {
197  private:
198  //**Type definitions****************************************************************************
200  //**********************************************************************************************
201 
202  public:
203  //**Type definitions****************************************************************************
205  typedef This ResultType;
208  typedef Type ElementType;
209  typedef typename IT::Type IntrinsicType;
210  typedef const Type& ReturnType;
211  typedef const This& CompositeType;
212 
213  typedef Type& Reference;
214  typedef const Type& ConstReference;
215  typedef Type* Pointer;
216  typedef const Type* ConstPointer;
217 
220  //**********************************************************************************************
221 
222  //**Rebind struct definition********************************************************************
225  template< typename ET > // Data type of the other matrix
226  struct Rebind {
228  };
229  //**********************************************************************************************
230 
231  //**Compilation flags***************************************************************************
233 
237  enum { vectorizable = IsVectorizable<Type>::value };
238 
240 
243  enum { smpAssignable = !IsSMPAssignable<Type>::value };
244  //**********************************************************************************************
245 
246  //**Constructors********************************************************************************
249  explicit inline DynamicMatrix();
250  explicit inline DynamicMatrix( size_t m, size_t n );
251  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
252  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
253 
254  template< typename Other, size_t M, size_t N >
255  explicit inline DynamicMatrix( const Other (&array)[M][N] );
256 
257  inline DynamicMatrix( const DynamicMatrix& m );
258  template< typename MT, bool SO2 > inline DynamicMatrix( const Matrix<MT,SO2>& m );
260  //**********************************************************************************************
261 
262  //**Destructor**********************************************************************************
265  inline ~DynamicMatrix();
267  //**********************************************************************************************
268 
269  //**Data access functions***********************************************************************
272  inline Reference operator()( size_t i, size_t j );
273  inline ConstReference operator()( size_t i, size_t j ) const;
274  inline Reference at( size_t i, size_t j );
275  inline ConstReference at( size_t i, size_t j ) const;
276  inline Pointer data ();
277  inline ConstPointer data () const;
278  inline Pointer data ( size_t i );
279  inline ConstPointer data ( size_t i ) const;
280  inline Iterator begin ( size_t i );
281  inline ConstIterator begin ( size_t i ) const;
282  inline ConstIterator cbegin( size_t i ) const;
283  inline Iterator end ( size_t i );
284  inline ConstIterator end ( size_t i ) const;
285  inline ConstIterator cend ( size_t i ) const;
287  //**********************************************************************************************
288 
289  //**Assignment operators************************************************************************
292  template< typename Other, size_t M, size_t N >
293  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
294 
295  inline DynamicMatrix& operator= ( const Type& rhs );
296  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
297  template< typename MT, bool SO2 > inline DynamicMatrix& operator= ( const Matrix<MT,SO2>& rhs );
298  template< typename MT, bool SO2 > inline DynamicMatrix& operator+=( const Matrix<MT,SO2>& rhs );
299  template< typename MT, bool SO2 > inline DynamicMatrix& operator-=( const Matrix<MT,SO2>& rhs );
300  template< typename MT, bool SO2 > inline DynamicMatrix& operator*=( const Matrix<MT,SO2>& rhs );
301 
302  template< typename Other >
303  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
304  operator*=( Other rhs );
305 
306  template< typename Other >
307  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
308  operator/=( Other rhs );
310  //**********************************************************************************************
311 
312  //**Utility functions***************************************************************************
315  inline size_t rows() const;
316  inline size_t columns() const;
317  inline size_t spacing() const;
318  inline size_t capacity() const;
319  inline size_t capacity( size_t i ) const;
320  inline size_t nonZeros() const;
321  inline size_t nonZeros( size_t i ) const;
322  inline void reset();
323  inline void reset( size_t i );
324  inline void clear();
325  void resize ( size_t m, size_t n, bool preserve=true );
326  inline void extend ( size_t m, size_t n, bool preserve=true );
327  inline void reserve( size_t elements );
328  inline DynamicMatrix& transpose();
329  inline DynamicMatrix& ctranspose();
330  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
331  inline void swap( DynamicMatrix& m ) /* throw() */;
333  //**********************************************************************************************
334 
335  private:
336  //**********************************************************************************************
338  template< typename MT >
340  struct VectorizedAssign {
341  enum { value = useOptimizedKernels &&
342  vectorizable && MT::vectorizable &&
343  IsSame<Type,typename MT::ElementType>::value };
344  };
346  //**********************************************************************************************
347 
348  //**********************************************************************************************
350  template< typename MT >
352  struct VectorizedAddAssign {
353  enum { value = useOptimizedKernels &&
354  vectorizable && MT::vectorizable &&
355  IsSame<Type,typename MT::ElementType>::value &&
356  IntrinsicTrait<Type>::addition &&
357  !IsDiagonal<MT>::value };
358  };
360  //**********************************************************************************************
361 
362  //**********************************************************************************************
364  template< typename MT >
366  struct VectorizedSubAssign {
367  enum { value = useOptimizedKernels &&
368  vectorizable && MT::vectorizable &&
369  IsSame<Type,typename MT::ElementType>::value &&
370  IntrinsicTrait<Type>::subtraction &&
371  !IsDiagonal<MT>::value };
372  };
374  //**********************************************************************************************
375 
376  public:
377  //**Expression template evaluation functions****************************************************
380  template< typename Other > inline bool canAlias ( const Other* alias ) const;
381  template< typename Other > inline bool isAliased( const Other* alias ) const;
382 
383  inline bool isAligned () const;
384  inline bool canSMPAssign() const;
385 
386  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
387  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
388  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
389 
390  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
391  BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const IntrinsicType& value );
392  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
393  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
394 
395  template< typename MT >
396  inline typename DisableIf< VectorizedAssign<MT> >::Type
397  assign( const DenseMatrix<MT,SO>& rhs );
398 
399  template< typename MT >
400  inline typename EnableIf< VectorizedAssign<MT> >::Type
401  assign( const DenseMatrix<MT,SO>& rhs );
402 
403  template< typename MT > inline void assign( const DenseMatrix<MT,!SO>& rhs );
404  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
405  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
406 
407  template< typename MT >
408  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
409  addAssign( const DenseMatrix<MT,SO>& rhs );
410 
411  template< typename MT >
412  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
413  addAssign( const DenseMatrix<MT,SO>& rhs );
414 
415  template< typename MT > inline void addAssign( const DenseMatrix<MT,!SO>& rhs );
416  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
417  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
418 
419  template< typename MT >
420  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
421  subAssign( const DenseMatrix<MT,SO>& rhs );
422 
423  template< typename MT >
424  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
425  subAssign( const DenseMatrix<MT,SO>& rhs );
426 
427  template< typename MT > inline void subAssign( const DenseMatrix<MT,!SO>& rhs );
428  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
429  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
431  //**********************************************************************************************
432 
433  private:
434  //**Utility functions***************************************************************************
437  inline size_t adjustColumns( size_t minColumns ) const;
439  //**********************************************************************************************
440 
441  //**Member variables****************************************************************************
444  size_t m_;
445  size_t n_;
446  size_t nn_;
447  size_t capacity_;
449 
459  //**********************************************************************************************
460 
461  //**Compile time checks*************************************************************************
468  //**********************************************************************************************
469 };
470 //*************************************************************************************************
471 
472 
473 
474 
475 //=================================================================================================
476 //
477 // CONSTRUCTORS
478 //
479 //=================================================================================================
480 
481 //*************************************************************************************************
484 template< typename Type // Data type of the matrix
485  , bool SO > // Storage order
487  : m_ ( 0UL ) // The current number of rows of the matrix
488  , n_ ( 0UL ) // The current number of columns of the matrix
489  , nn_ ( 0UL ) // The alignment adjusted number of columns
490  , capacity_( 0UL ) // The maximum capacity of the matrix
491  , v_ ( NULL ) // The matrix elements
492 {}
493 //*************************************************************************************************
494 
495 
496 //*************************************************************************************************
505 template< typename Type // Data type of the matrix
506  , bool SO > // Storage order
507 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n )
508  : m_ ( m ) // The current number of rows of the matrix
509  , n_ ( n ) // The current number of columns of the matrix
510  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
511  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
512  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
513 {
515  for( size_t i=0UL; i<m_; ++i ) {
516  for( size_t j=n_; j<nn_; ++j )
517  v_[i*nn_+j] = Type();
518  }
519  }
520 }
521 //*************************************************************************************************
522 
523 
524 //*************************************************************************************************
533 template< typename Type // Data type of the matrix
534  , bool SO > // Storage order
535 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Type& init )
536  : m_ ( m ) // The current number of rows of the matrix
537  , n_ ( n ) // The current number of columns of the matrix
538  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
539  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
540  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
541 {
542  for( size_t i=0UL; i<m; ++i ) {
543  for( size_t j=0UL; j<n_; ++j )
544  v_[i*nn_+j] = init;
545 
547  for( size_t j=n_; j<nn_; ++j )
548  v_[i*nn_+j] = Type();
549  }
550  }
551 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
578 template< typename Type // Data type of the matrix
579  , bool SO > // Storage order
580 template< typename Other > // Data type of the initialization array
581 inline DynamicMatrix<Type,SO>::DynamicMatrix( size_t m, size_t n, const Other* array )
582  : m_ ( m ) // The current number of rows of the matrix
583  , n_ ( n ) // The current number of columns of the matrix
584  , nn_ ( adjustColumns( n ) ) // The alignment adjusted number of columns
585  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
586  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
587 {
588  for( size_t i=0UL; i<m; ++i ) {
589  for( size_t j=0UL; j<n; ++j )
590  v_[i*nn_+j] = array[i*n+j];
591 
593  for( size_t j=n; j<nn_; ++j )
594  v_[i*nn_+j] = Type();
595  }
596  }
597 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
622 template< typename Type // Data type of the matrix
623  , bool SO > // Storage order
624 template< typename Other // Data type of the initialization array
625  , size_t M // Number of rows of the initialization array
626  , size_t N > // Number of columns of the initialization array
627 inline DynamicMatrix<Type,SO>::DynamicMatrix( const Other (&array)[M][N] )
628  : m_ ( M ) // The current number of rows of the matrix
629  , n_ ( N ) // The current number of columns of the matrix
630  , nn_ ( adjustColumns( N ) ) // 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  for( size_t i=0UL; i<M; ++i ) {
635  for( size_t j=0UL; j<N; ++j )
636  v_[i*nn_+j] = array[i][j];
637 
639  for( size_t j=N; j<nn_; ++j )
640  v_[i*nn_+j] = Type();
641  }
642  }
643 }
644 //*************************************************************************************************
645 
646 
647 //*************************************************************************************************
655 template< typename Type // Data type of the matrix
656  , bool SO > // Storage order
658  : m_ ( m.m_ ) // The current number of rows of the matrix
659  , n_ ( m.n_ ) // The current number of columns of the matrix
660  , nn_ ( m.nn_ ) // The alignment adjusted number of columns
661  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
662  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
663 {
664  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
665 
666  for( size_t i=0UL; i<capacity_; ++i )
667  v_[i] = m.v_[i];
668 }
669 //*************************************************************************************************
670 
671 
672 //*************************************************************************************************
677 template< typename Type // Data type of the matrix
678  , bool SO > // Storage order
679 template< typename MT // Type of the foreign matrix
680  , bool SO2 > // Storage order of the foreign matrix
682  : m_ ( (~m).rows() ) // The current number of rows of the matrix
683  , n_ ( (~m).columns() ) // The current number of columns of the matrix
684  , nn_ ( adjustColumns( n_ ) ) // The alignment adjusted number of columns
685  , capacity_( m_*nn_ ) // The maximum capacity of the matrix
686  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
687 {
688  for( size_t i=0UL; i<m_; ++i ) {
689  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : n_ );
690  j<( IsVectorizable<Type>::value ? nn_ : n_ ); ++j ) {
691  v_[i*nn_+j] = Type();
692  }
693  }
694 
695  smpAssign( *this, ~m );
696 }
697 //*************************************************************************************************
698 
699 
700 
701 
702 //=================================================================================================
703 //
704 // DESTRUCTOR
705 //
706 //=================================================================================================
707 
708 //*************************************************************************************************
711 template< typename Type // Data type of the matrix
712  , bool SO > // Storage order
714 {
715  deallocate( v_ );
716 }
717 //*************************************************************************************************
718 
719 
720 
721 
722 //=================================================================================================
723 //
724 // DATA ACCESS FUNCTIONS
725 //
726 //=================================================================================================
727 
728 //*************************************************************************************************
738 template< typename Type // Data type of the matrix
739  , bool SO > // Storage order
740 inline typename DynamicMatrix<Type,SO>::Reference
742 {
743  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
744  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
745  return v_[i*nn_+j];
746 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
760 template< typename Type // Data type of the matrix
761  , bool SO > // Storage order
763  DynamicMatrix<Type,SO>::operator()( size_t i, size_t j ) const
764 {
765  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
766  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
767  return v_[i*nn_+j];
768 }
769 //*************************************************************************************************
770 
771 
772 //*************************************************************************************************
783 template< typename Type // Data type of the matrix
784  , bool SO > // Storage order
785 inline typename DynamicMatrix<Type,SO>::Reference
786  DynamicMatrix<Type,SO>::at( size_t i, size_t j )
787 {
788  if( i >= m_ ) {
789  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
790  }
791  if( j >= n_ ) {
792  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
793  }
794  return (*this)(i,j);
795 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
810 template< typename Type // Data type of the matrix
811  , bool SO > // Storage order
813  DynamicMatrix<Type,SO>::at( size_t i, size_t j ) const
814 {
815  if( i >= m_ ) {
816  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
817  }
818  if( j >= n_ ) {
819  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
820  }
821  return (*this)(i,j);
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
838 template< typename Type // Data type of the matrix
839  , bool SO > // Storage order
841 {
842  return v_;
843 }
844 //*************************************************************************************************
845 
846 
847 //*************************************************************************************************
859 template< typename Type // Data type of the matrix
860  , bool SO > // Storage order
862 {
863  return v_;
864 }
865 //*************************************************************************************************
866 
867 
868 //*************************************************************************************************
876 template< typename Type // Data type of the matrix
877  , bool SO > // Storage order
879 {
880  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
881  return v_ + i*nn_;
882 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
894 template< typename Type // Data type of the matrix
895  , bool SO > // Storage order
897 {
898  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
899  return v_ + i*nn_;
900 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
915 template< typename Type // Data type of the matrix
916  , bool SO > // Storage order
917 inline typename DynamicMatrix<Type,SO>::Iterator
919 {
920  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
921  return Iterator( v_ + i*nn_ );
922 }
923 //*************************************************************************************************
924 
925 
926 //*************************************************************************************************
937 template< typename Type // Data type of the matrix
938  , bool SO > // Storage order
941 {
942  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
943  return ConstIterator( v_ + i*nn_ );
944 }
945 //*************************************************************************************************
946 
947 
948 //*************************************************************************************************
959 template< typename Type // Data type of the matrix
960  , bool SO > // Storage order
963 {
964  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
965  return ConstIterator( v_ + i*nn_ );
966 }
967 //*************************************************************************************************
968 
969 
970 //*************************************************************************************************
981 template< typename Type // Data type of the matrix
982  , bool SO > // Storage order
983 inline typename DynamicMatrix<Type,SO>::Iterator
985 {
986  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
987  return Iterator( v_ + i*nn_ + n_ );
988 }
989 //*************************************************************************************************
990 
991 
992 //*************************************************************************************************
1003 template< typename Type // Data type of the matrix
1004  , bool SO > // Storage order
1007 {
1008  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
1009  return ConstIterator( v_ + i*nn_ + n_ );
1010 }
1011 //*************************************************************************************************
1012 
1013 
1014 //*************************************************************************************************
1025 template< typename Type // Data type of the matrix
1026  , bool SO > // Storage order
1029 {
1030  BLAZE_USER_ASSERT( i < m_, "Invalid dense matrix row access index" );
1031  return ConstIterator( v_ + i*nn_ + n_ );
1032 }
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // ASSIGNMENT OPERATORS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1065 template< typename Type // Data type of the matrix
1066  , bool SO > // Storage order
1067 template< typename Other // Data type of the initialization array
1068  , size_t M // Number of rows of the initialization array
1069  , size_t N > // Number of columns of the initialization array
1070 inline DynamicMatrix<Type,SO>& DynamicMatrix<Type,SO>::operator=( const Other (&array)[M][N] )
1071 {
1072  resize( M, N, false );
1073 
1074  for( size_t i=0UL; i<M; ++i )
1075  for( size_t j=0UL; j<N; ++j )
1076  v_[i*nn_+j] = array[i][j];
1077 
1078  return *this;
1079 }
1080 //*************************************************************************************************
1081 
1082 
1083 //*************************************************************************************************
1089 template< typename Type // Data type of the matrix
1090  , bool SO > // Storage order
1092 {
1093  for( size_t i=0UL; i<m_; ++i )
1094  for( size_t j=0UL; j<n_; ++j )
1095  v_[i*nn_+j] = rhs;
1096 
1097  return *this;
1098 }
1099 //*************************************************************************************************
1100 
1101 
1102 //*************************************************************************************************
1111 template< typename Type // Data type of the matrix
1112  , bool SO > // Storage order
1114 {
1115  if( &rhs == this ) return *this;
1116 
1117  resize( rhs.m_, rhs.n_, false );
1118  smpAssign( *this, ~rhs );
1119 
1120  return *this;
1121 }
1122 //*************************************************************************************************
1123 
1124 
1125 //*************************************************************************************************
1134 template< typename Type // Data type of the matrix
1135  , bool SO > // Storage order
1136 template< typename MT // Type of the right-hand side matrix
1137  , bool SO2 > // Storage order of the right-hand side matrix
1139 {
1140  typedef typename TransExprTrait<This>::Type TT;
1141  typedef typename CTransExprTrait<This>::Type CT;
1142 
1143  if( IsSame<MT,TT>::value && (~rhs).isAliased( this ) ) {
1144  transpose();
1145  }
1146  else if( IsSame<MT,CT>::value && (~rhs).isAliased( this ) ) {
1147  ctranspose();
1148  }
1149  else if( (~rhs).canAlias( this ) ) {
1150  DynamicMatrix tmp( ~rhs );
1151  swap( tmp );
1152  }
1153  else {
1154  resize( (~rhs).rows(), (~rhs).columns(), false );
1156  reset();
1157  smpAssign( *this, ~rhs );
1158  }
1159 
1160  return *this;
1161 }
1162 //*************************************************************************************************
1163 
1164 
1165 //*************************************************************************************************
1175 template< typename Type // Data type of the matrix
1176  , bool SO > // Storage order
1177 template< typename MT // Type of the right-hand side matrix
1178  , bool SO2 > // Storage order of the right-hand side matrix
1180 {
1181  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
1182  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1183  }
1184 
1185  if( (~rhs).canAlias( this ) ) {
1186  const typename MT::ResultType tmp( ~rhs );
1187  smpAddAssign( *this, tmp );
1188  }
1189  else {
1190  smpAddAssign( *this, ~rhs );
1191  }
1192 
1193  return *this;
1194 }
1195 //*************************************************************************************************
1196 
1197 
1198 //*************************************************************************************************
1208 template< typename Type // Data type of the matrix
1209  , bool SO > // Storage order
1210 template< typename MT // Type of the right-hand side matrix
1211  , bool SO2 > // Storage order of the right-hand side matrix
1213 {
1214  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
1215  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1216  }
1217 
1218  if( (~rhs).canAlias( this ) ) {
1219  const typename MT::ResultType tmp( ~rhs );
1220  smpSubAssign( *this, tmp );
1221  }
1222  else {
1223  smpSubAssign( *this, ~rhs );
1224  }
1225 
1226  return *this;
1227 }
1228 //*************************************************************************************************
1229 
1230 
1231 //*************************************************************************************************
1241 template< typename Type // Data type of the matrix
1242  , bool SO > // Storage order
1243 template< typename MT // Type of the right-hand side matrix
1244  , bool SO2 > // Storage order of the right-hand side matrix
1246 {
1247  if( (~rhs).rows() != n_ ) {
1248  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1249  }
1250 
1251  DynamicMatrix tmp( *this * (~rhs) );
1252  swap( tmp );
1253 
1254  return *this;
1255 }
1256 //*************************************************************************************************
1257 
1258 
1259 //*************************************************************************************************
1266 template< typename Type // Data type of the matrix
1267  , bool SO > // Storage order
1268 template< typename Other > // Data type of the right-hand side scalar
1269 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1271 {
1272  smpAssign( *this, (*this) * rhs );
1273  return *this;
1274 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1285 template< typename Type // Data type of the matrix
1286  , bool SO > // Storage order
1287 template< typename Other > // Data type of the right-hand side scalar
1288 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,SO> >::Type&
1290 {
1291  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1292 
1293  smpAssign( *this, (*this) / rhs );
1294  return *this;
1295 }
1296 //*************************************************************************************************
1297 
1298 
1299 
1300 
1301 //=================================================================================================
1302 //
1303 // UTILITY FUNCTIONS
1304 //
1305 //=================================================================================================
1306 
1307 //*************************************************************************************************
1312 template< typename Type // Data type of the matrix
1313  , bool SO > // Storage order
1314 inline size_t DynamicMatrix<Type,SO>::rows() const
1315 {
1316  return m_;
1317 }
1318 //*************************************************************************************************
1319 
1320 
1321 //*************************************************************************************************
1326 template< typename Type // Data type of the matrix
1327  , bool SO > // Storage order
1328 inline size_t DynamicMatrix<Type,SO>::columns() const
1329 {
1330  return n_;
1331 }
1332 //*************************************************************************************************
1333 
1334 
1335 //*************************************************************************************************
1345 template< typename Type // Data type of the matrix
1346  , bool SO > // Storage order
1347 inline size_t DynamicMatrix<Type,SO>::spacing() const
1348 {
1349  return nn_;
1350 }
1351 //*************************************************************************************************
1352 
1353 
1354 //*************************************************************************************************
1359 template< typename Type // Data type of the matrix
1360  , bool SO > // Storage order
1362 {
1363  return capacity_;
1364 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1379 template< typename Type // Data type of the matrix
1380  , bool SO > // Storage order
1381 inline size_t DynamicMatrix<Type,SO>::capacity( size_t i ) const
1382 {
1383  UNUSED_PARAMETER( i );
1384  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1385  return nn_;
1386 }
1387 //*************************************************************************************************
1388 
1389 
1390 //*************************************************************************************************
1395 template< typename Type // Data type of the matrix
1396  , bool SO > // Storage order
1398 {
1399  size_t nonzeros( 0UL );
1400 
1401  for( size_t i=0UL; i<m_; ++i )
1402  for( size_t j=0UL; j<n_; ++j )
1403  if( !isDefault( v_[i*nn_+j] ) )
1404  ++nonzeros;
1405 
1406  return nonzeros;
1407 }
1408 //*************************************************************************************************
1409 
1410 
1411 //*************************************************************************************************
1422 template< typename Type // Data type of the matrix
1423  , bool SO > // Storage order
1424 inline size_t DynamicMatrix<Type,SO>::nonZeros( size_t i ) const
1425 {
1426  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1427 
1428  const size_t jend( i*nn_ + n_ );
1429  size_t nonzeros( 0UL );
1430 
1431  for( size_t j=i*nn_; j<jend; ++j )
1432  if( !isDefault( v_[j] ) )
1433  ++nonzeros;
1434 
1435  return nonzeros;
1436 }
1437 //*************************************************************************************************
1438 
1439 
1440 //*************************************************************************************************
1445 template< typename Type // Data type of the matrix
1446  , bool SO > // Storage order
1448 {
1449  using blaze::clear;
1450 
1451  for( size_t i=0UL; i<m_; ++i )
1452  for( size_t j=0UL; j<n_; ++j )
1453  clear( v_[i*nn_+j] );
1454 }
1455 //*************************************************************************************************
1456 
1457 
1458 //*************************************************************************************************
1469 template< typename Type // Data type of the matrix
1470  , bool SO > // Storage order
1471 inline void DynamicMatrix<Type,SO>::reset( size_t i )
1472 {
1473  using blaze::clear;
1474 
1475  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1476  for( size_t j=0UL; j<n_; ++j )
1477  clear( v_[i*nn_+j] );
1478 }
1479 //*************************************************************************************************
1480 
1481 
1482 //*************************************************************************************************
1489 template< typename Type // Data type of the matrix
1490  , bool SO > // Storage order
1492 {
1493  resize( 0UL, 0UL, false );
1494 }
1495 //*************************************************************************************************
1496 
1497 
1498 //*************************************************************************************************
1532 template< typename Type // Data type of the matrix
1533  , bool SO > // Storage order
1534 void DynamicMatrix<Type,SO>::resize( size_t m, size_t n, bool preserve )
1535 {
1536  using blaze::min;
1537 
1538  if( m == m_ && n == n_ ) return;
1539 
1540  const size_t nn( adjustColumns( n ) );
1541 
1542  if( preserve )
1543  {
1544  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1545  const size_t min_m( min( m, m_ ) );
1546  const size_t min_n( min( n, n_ ) );
1547 
1548  for( size_t i=0UL; i<min_m; ++i )
1549  for( size_t j=0UL; j<min_n; ++j )
1550  v[i*nn+j] = v_[i*nn_+j];
1551 
1552  std::swap( v_, v );
1553  deallocate( v );
1554  capacity_ = m*nn;
1555  }
1556  else if( m*nn > capacity_ ) {
1557  Type* BLAZE_RESTRICT v = allocate<Type>( m*nn );
1558  std::swap( v_, v );
1559  deallocate( v );
1560  capacity_ = m*nn;
1561  }
1562 
1564  for( size_t i=0UL; i<m; ++i )
1565  for( size_t j=n; j<nn; ++j )
1566  v_[i*nn+j] = Type();
1567  }
1568 
1569  m_ = m;
1570  n_ = n;
1571  nn_ = nn;
1572 }
1573 //*************************************************************************************************
1574 
1575 
1576 //*************************************************************************************************
1590 template< typename Type // Data type of the matrix
1591  , bool SO > // Storage order
1592 inline void DynamicMatrix<Type,SO>::extend( size_t m, size_t n, bool preserve )
1593 {
1594  resize( m_+m, n_+n, preserve );
1595 }
1596 //*************************************************************************************************
1597 
1598 
1599 //*************************************************************************************************
1608 template< typename Type // Data type of the matrix
1609  , bool SO > // Storage order
1610 inline void DynamicMatrix<Type,SO>::reserve( size_t elements )
1611 {
1612  if( elements > capacity_ )
1613  {
1614  // Allocating a new array
1615  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
1616 
1617  // Initializing the new array
1618  std::copy( v_, v_+capacity_, tmp );
1619 
1621  for( size_t i=capacity_; i<elements; ++i )
1622  tmp[i] = Type();
1623  }
1624 
1625  // Replacing the old array
1626  std::swap( tmp, v_ );
1627  deallocate( tmp );
1628  capacity_ = elements;
1629  }
1630 }
1631 //*************************************************************************************************
1632 
1633 
1634 //*************************************************************************************************
1639 template< typename Type // Data type of the matrix
1640  , bool SO > // Storage order
1642 {
1643  using std::swap;
1644 
1645  const size_t block( BLOCK_SIZE );
1646 
1647  if( m_ == n_ )
1648  {
1649  for( size_t ii=0UL; ii<m_; ii+=block ) {
1650  const size_t iend( min( ii+block, m_ ) );
1651  for( size_t jj=0UL; jj<=ii; jj+=block ) {
1652  for( size_t i=ii; i<iend; ++i ) {
1653  const size_t jend( min( jj+block, n_, i ) );
1654  for( size_t j=jj; j<jend; ++j ) {
1655  swap( v_[i*nn_+j], v_[j*nn_+i] );
1656  }
1657  }
1658  }
1659  }
1660  }
1661  else
1662  {
1663  DynamicMatrix tmp( trans(*this) );
1664  this->swap( tmp );
1665  }
1666 
1667  return *this;
1668 }
1669 //*************************************************************************************************
1670 
1671 
1672 //*************************************************************************************************
1677 template< typename Type // Data type of the matrix
1678  , bool SO > // Storage order
1680 {
1681  const size_t block( BLOCK_SIZE );
1682 
1683  if( m_ == n_ )
1684  {
1685  for( size_t ii=0UL; ii<m_; ii+=block ) {
1686  const size_t iend( min( ii+block, m_ ) );
1687  for( size_t jj=0UL; jj<ii; jj+=block ) {
1688  const size_t jend( min( jj+block, n_ ) );
1689  for( size_t i=ii; i<iend; ++i ) {
1690  for( size_t j=jj; j<jend; ++j ) {
1691  cswap( v_[i*nn_+j], v_[j*nn_+i] );
1692  }
1693  }
1694  }
1695  for( size_t i=ii; i<iend; ++i ) {
1696  for( size_t j=ii; j<i; ++j ) {
1697  cswap( v_[i*nn_+j], v_[j*nn_+i] );
1698  }
1699  conjugate( v_[i*nn_+i] );
1700  }
1701  }
1702  }
1703  else
1704  {
1705  DynamicMatrix tmp( ctrans(*this) );
1706  swap( tmp );
1707  }
1708 
1709  return *this;
1710 }
1711 //*************************************************************************************************
1712 
1713 
1714 //*************************************************************************************************
1720 template< typename Type // Data type of the matrix
1721  , bool SO > // Storage order
1722 template< typename Other > // Data type of the scalar value
1724 {
1725  for( size_t i=0UL; i<m_; ++i )
1726  for( size_t j=0UL; j<n_; ++j )
1727  v_[i*nn_+j] *= scalar;
1728 
1729  return *this;
1730 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1741 template< typename Type // Data type of the matrix
1742  , bool SO > // Storage order
1743 inline void DynamicMatrix<Type,SO>::swap( DynamicMatrix& m ) /* throw() */
1744 {
1745  std::swap( m_ , m.m_ );
1746  std::swap( n_ , m.n_ );
1747  std::swap( nn_, m.nn_ );
1749  std::swap( v_ , m.v_ );
1750 }
1751 //*************************************************************************************************
1752 
1753 
1754 //*************************************************************************************************
1760 template< typename Type // Data type of the matrix
1761  , bool SO > // Storage order
1762 inline size_t DynamicMatrix<Type,SO>::adjustColumns( size_t minColumns ) const
1763 {
1765  return nextMultiple<size_t>( minColumns, IT::size );
1766  else return minColumns;
1767 }
1768 //*************************************************************************************************
1769 
1770 
1771 
1772 
1773 //=================================================================================================
1774 //
1775 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1776 //
1777 //=================================================================================================
1778 
1779 //*************************************************************************************************
1789 template< typename Type // Data type of the matrix
1790  , bool SO > // Storage order
1791 template< typename Other > // Data type of the foreign expression
1792 inline bool DynamicMatrix<Type,SO>::canAlias( const Other* alias ) const
1793 {
1794  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1795 }
1796 //*************************************************************************************************
1797 
1798 
1799 //*************************************************************************************************
1809 template< typename Type // Data type of the matrix
1810  , bool SO > // Storage order
1811 template< typename Other > // Data type of the foreign expression
1812 inline bool DynamicMatrix<Type,SO>::isAliased( const Other* alias ) const
1813 {
1814  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1815 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1828 template< typename Type // Data type of the matrix
1829  , bool SO > // Storage order
1831 {
1832  return ( usePadding || columns() % IT::size == 0UL );
1833 }
1834 //*************************************************************************************************
1835 
1836 
1837 //*************************************************************************************************
1847 template< typename Type // Data type of the matrix
1848  , bool SO > // Storage order
1850 {
1851  return ( rows() > SMP_DMATASSIGN_THRESHOLD );
1852 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1871 template< typename Type // Data type of the matrix
1872  , bool SO > // Storage order
1874  DynamicMatrix<Type,SO>::load( size_t i, size_t j ) const
1875 {
1876  if( usePadding )
1877  return loada( i, j );
1878  else
1879  return loadu( i, j );
1880 }
1881 //*************************************************************************************************
1882 
1883 
1884 //*************************************************************************************************
1899 template< typename Type // Data type of the matrix
1900  , bool SO > // Storage order
1902  DynamicMatrix<Type,SO>::loada( size_t i, size_t j ) const
1903 {
1904  using blaze::loada;
1905 
1907 
1908  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1909  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1910  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1911  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
1912  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i*nn_+j ), "Invalid alignment detected" );
1913 
1914  return loada( v_+i*nn_+j );
1915 }
1916 //*************************************************************************************************
1917 
1918 
1919 //*************************************************************************************************
1934 template< typename Type // Data type of the matrix
1935  , bool SO > // Storage order
1937  DynamicMatrix<Type,SO>::loadu( size_t i, size_t j ) const
1938 {
1939  using blaze::loadu;
1940 
1942 
1943  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1944  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1945  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
1946 
1947  return loadu( v_+i*nn_+j );
1948 }
1949 //*************************************************************************************************
1950 
1951 
1952 //*************************************************************************************************
1968 template< typename Type // Data type of the matrix
1969  , bool SO > // Storage order
1971  DynamicMatrix<Type,SO>::store( size_t i, size_t j, const IntrinsicType& value )
1972 {
1973  if( usePadding )
1974  storea( i, j, value );
1975  else
1976  storeu( i, j, value );
1977 }
1978 //*************************************************************************************************
1979 
1980 
1981 //*************************************************************************************************
1997 template< typename Type // Data type of the matrix
1998  , bool SO > // Storage order
2000  DynamicMatrix<Type,SO>::storea( size_t i, size_t j, const IntrinsicType& value )
2001 {
2002  using blaze::storea;
2003 
2005 
2006  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
2007  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
2008  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
2009  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
2010  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i*nn_+j ), "Invalid alignment detected" );
2011 
2012  storea( v_+i*nn_+j, value );
2013 }
2014 //*************************************************************************************************
2015 
2016 
2017 //*************************************************************************************************
2033 template< typename Type // Data type of the matrix
2034  , bool SO > // Storage order
2036  DynamicMatrix<Type,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2037 {
2038  using blaze::storeu;
2039 
2041 
2042  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
2043  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
2044  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
2045 
2046  storeu( v_+i*nn_+j, value );
2047 }
2048 //*************************************************************************************************
2049 
2050 
2051 //*************************************************************************************************
2067 template< typename Type // Data type of the matrix
2068  , bool SO > // Storage order
2070  DynamicMatrix<Type,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2071 {
2072  using blaze::stream;
2073 
2075 
2076  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
2077  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
2078  BLAZE_INTERNAL_ASSERT( j + IT::size <= nn_, "Invalid column access index" );
2079  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
2080  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i*nn_+j ), "Invalid alignment detected" );
2081 
2082  stream( v_+i*nn_+j, value );
2083 }
2084 //*************************************************************************************************
2085 
2086 
2087 //*************************************************************************************************
2098 template< typename Type // Data type of the matrix
2099  , bool SO > // Storage order
2100 template< typename MT > // Type of the right-hand side dense matrix
2101 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2103 {
2104  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2105  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2106 
2107  const size_t jpos( n_ & size_t(-2) );
2108  BLAZE_INTERNAL_ASSERT( ( n_ - ( n_ % 2UL ) ) == jpos, "Invalid end calculation" );
2109 
2110  for( size_t i=0UL; i<m_; ++i ) {
2111  for( size_t j=0UL; j<jpos; j+=2UL ) {
2112  v_[i*nn_+j ] = (~rhs)(i,j );
2113  v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
2114  }
2115  if( jpos < n_ ) {
2116  v_[i*nn_+jpos] = (~rhs)(i,jpos);
2117  }
2118  }
2119 }
2120 //*************************************************************************************************
2121 
2122 
2123 //*************************************************************************************************
2134 template< typename Type // Data type of the matrix
2135  , bool SO > // Storage order
2136 template< typename MT > // Type of the right-hand side dense matrix
2137 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2139 {
2141 
2142  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2143  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2144 
2145  const bool remainder( !usePadding || !IsPadded<MT>::value );
2146 
2147  const size_t jpos( ( remainder )?( n_ & size_t(-IT::size) ):( n_ ) );
2148  BLAZE_INTERNAL_ASSERT( !remainder || ( n_ - ( n_ % (IT::size) ) ) == jpos, "Invalid end calculation" );
2149 
2150  if( usePadding && useStreaming &&
2151  ( m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) ) && !(~rhs).isAliased( this ) )
2152  {
2153  for( size_t i=0UL; i<m_; ++i )
2154  {
2155  size_t j( 0UL );
2156 
2157  for( ; j<jpos; j+=IT::size ) {
2158  stream( i, j, (~rhs).load(i,j) );
2159  }
2160  for( ; remainder && j<n_; ++j ) {
2161  v_[i*nn_+j] = (~rhs)(i,j);
2162  }
2163  }
2164  }
2165  else
2166  {
2167  for( size_t i=0UL; i<m_; ++i )
2168  {
2169  size_t j( 0UL );
2170  typename MT::ConstIterator it( (~rhs).begin(i) );
2171 
2172  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
2173  store( i, j , it.load() ); it += IT::size;
2174  store( i, j+IT::size , it.load() ); it += IT::size;
2175  store( i, j+IT::size*2UL, it.load() ); it += IT::size;
2176  store( i, j+IT::size*3UL, it.load() ); it += IT::size;
2177  }
2178  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
2179  store( i, j, it.load() );
2180  }
2181  for( ; remainder && j<n_; ++j, ++it ) {
2182  v_[i*nn_+j] = *it;
2183  }
2184  }
2185  }
2186 }
2187 //*************************************************************************************************
2188 
2189 
2190 //*************************************************************************************************
2201 template< typename Type // Data type of the matrix
2202  , bool SO > // Storage order
2203 template< typename MT > // Type of the right-hand side dense matrix
2205 {
2207 
2208  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2209  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2210 
2211  const size_t block( BLOCK_SIZE );
2212 
2213  for( size_t ii=0UL; ii<m_; ii+=block ) {
2214  const size_t iend( min( m_, ii+block ) );
2215  for( size_t jj=0UL; jj<n_; jj+=block ) {
2216  const size_t jend( min( n_, jj+block ) );
2217  for( size_t i=ii; i<iend; ++i ) {
2218  for( size_t j=jj; j<jend; ++j ) {
2219  v_[i*nn_+j] = (~rhs)(i,j);
2220  }
2221  }
2222  }
2223  }
2224 }
2225 //*************************************************************************************************
2226 
2227 
2228 //*************************************************************************************************
2239 template< typename Type // Data type of the matrix
2240  , bool SO > // Storage order
2241 template< typename MT > // Type of the right-hand side sparse matrix
2243 {
2244  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2245  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2246 
2247  for( size_t i=0UL; i<m_; ++i )
2248  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2249  v_[i*nn_+element->index()] = element->value();
2250 }
2251 //*************************************************************************************************
2252 
2253 
2254 //*************************************************************************************************
2265 template< typename Type // Data type of the matrix
2266  , bool SO > // Storage order
2267 template< typename MT > // Type of the right-hand side sparse matrix
2269 {
2271 
2272  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2273  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2274 
2275  for( size_t j=0UL; j<n_; ++j )
2276  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2277  v_[element->index()*nn_+j] = element->value();
2278 }
2279 //*************************************************************************************************
2280 
2281 
2282 //*************************************************************************************************
2293 template< typename Type // Data type of the matrix
2294  , bool SO > // Storage order
2295 template< typename MT > // Type of the right-hand side dense matrix
2296 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2298 {
2299  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2300  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2301 
2302  for( size_t i=0UL; i<m_; ++i )
2303  {
2304  if( IsDiagonal<MT>::value )
2305  {
2306  v_[i*nn_+i] += (~rhs)(i,i);
2307  }
2308  else
2309  {
2310  const size_t jbegin( ( IsUpper<MT>::value )
2311  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2312  :( 0UL ) );
2313  const size_t jend ( ( IsLower<MT>::value )
2314  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2315  :( n_ ) );
2316  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2317 
2318  size_t j( jbegin );
2319 
2320  for( ; (j+2UL) <= jend; j+=2UL ) {
2321  v_[i*nn_+j ] += (~rhs)(i,j );
2322  v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2323  }
2324  if( j < jend ) {
2325  v_[i*nn_+j] += (~rhs)(i,j);
2326  }
2327  }
2328  }
2329 }
2330 //*************************************************************************************************
2331 
2332 
2333 //*************************************************************************************************
2344 template< typename Type // Data type of the matrix
2345  , bool SO > // Storage order
2346 template< typename MT > // Type of the right-hand side dense matrix
2347 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2349 {
2352 
2353  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2354  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2355 
2356  const bool remainder( !usePadding || !IsPadded<MT>::value );
2357 
2358  for( size_t i=0UL; i<m_; ++i )
2359  {
2360  const size_t jbegin( ( IsUpper<MT>::value )
2361  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
2362  :( 0UL ) );
2363  const size_t jend ( ( IsLower<MT>::value )
2364  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2365  :( n_ ) );
2366  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2367 
2368  const size_t jpos( ( remainder )?( jend & size_t(-IT::size) ):( jend ) );
2369  BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (IT::size) ) ) == jpos, "Invalid end calculation" );
2370 
2371  size_t j( jbegin );
2372  typename MT::ConstIterator it( (~rhs).begin(i) + jbegin );
2373 
2374  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
2375  store( i, j , load(i,j ) + it.load() ); it += IT::size;
2376  store( i, j+IT::size , load(i,j+IT::size ) + it.load() ); it += IT::size;
2377  store( i, j+IT::size*2UL, load(i,j+IT::size*2UL) + it.load() ); it += IT::size;
2378  store( i, j+IT::size*3UL, load(i,j+IT::size*3UL) + it.load() ); it += IT::size;
2379  }
2380  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
2381  store( i, j, load(i,j) + it.load() );
2382  }
2383  for( ; remainder && j<jend; ++j, ++it ) {
2384  v_[i*nn_+j] += *it;
2385  }
2386  }
2387 }
2388 //*************************************************************************************************
2389 
2390 
2391 //*************************************************************************************************
2402 template< typename Type // Data type of the matrix
2403  , bool SO > // Storage order
2404 template< typename MT > // Type of the right-hand side dense matrix
2406 {
2408 
2409  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2410  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2411 
2412  const size_t block( BLOCK_SIZE );
2413 
2414  for( size_t ii=0UL; ii<m_; ii+=block ) {
2415  const size_t iend( min( m_, ii+block ) );
2416  for( size_t jj=0UL; jj<n_; jj+=block )
2417  {
2418  if( IsLower<MT>::value && ii < jj ) break;
2419  if( IsUpper<MT>::value && ii > jj ) continue;
2420 
2421  for( size_t i=ii; i<iend; ++i )
2422  {
2423  const size_t jbegin( ( IsUpper<MT>::value )
2424  ?( max( ( IsStrictlyUpper<MT>::value ? i+1UL : i ), jj ) )
2425  :( jj ) );
2426  const size_t jend ( ( IsLower<MT>::value )
2427  ?( min( ( IsStrictlyLower<MT>::value ? i : i+1UL ), n_, jj+block ) )
2428  :( min( n_, jj+block ) ) );
2429  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2430 
2431  for( size_t j=jbegin; j<jend; ++j ) {
2432  v_[i*nn_+j] += (~rhs)(i,j);
2433  }
2434  }
2435  }
2436  }
2437 }
2438 //*************************************************************************************************
2439 
2440 
2441 //*************************************************************************************************
2452 template< typename Type // Data type of the matrix
2453  , bool SO > // Storage order
2454 template< typename MT > // Type of the right-hand side sparse matrix
2456 {
2457  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2458  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2459 
2460  for( size_t i=0UL; i<m_; ++i )
2461  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2462  v_[i*nn_+element->index()] += element->value();
2463 }
2464 //*************************************************************************************************
2465 
2466 
2467 //*************************************************************************************************
2478 template< typename Type // Data type of the matrix
2479  , bool SO > // Storage order
2480 template< typename MT > // Type of the right-hand side sparse matrix
2482 {
2484 
2485  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2486  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2487 
2488  for( size_t j=0UL; j<n_; ++j )
2489  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2490  v_[element->index()*nn_+j] += element->value();
2491 }
2492 //*************************************************************************************************
2493 
2494 
2495 //*************************************************************************************************
2506 template< typename Type // Data type of the matrix
2507  , bool SO > // Storage order
2508 template< typename MT > // Type of the right-hand side dense matrix
2509 inline typename DisableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2511 {
2512  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2513  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2514 
2515  for( size_t i=0UL; i<m_; ++i )
2516  {
2517  if( IsDiagonal<MT>::value )
2518  {
2519  v_[i*nn_+i] -= (~rhs)(i,i);
2520  }
2521  else
2522  {
2523  const size_t jbegin( ( IsUpper<MT>::value )
2524  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2525  :( 0UL ) );
2526  const size_t jend ( ( IsLower<MT>::value )
2527  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2528  :( n_ ) );
2529  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2530 
2531  size_t j( jbegin );
2532 
2533  for( ; (j+2UL) <= jend; j+=2UL ) {
2534  v_[i*nn_+j ] -= (~rhs)(i,j );
2535  v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2536  }
2537  if( j < jend ) {
2538  v_[i*nn_+j] -= (~rhs)(i,j);
2539  }
2540  }
2541  }
2542 }
2543 //*************************************************************************************************
2544 
2545 
2546 //*************************************************************************************************
2557 template< typename Type // Data type of the matrix
2558  , bool SO > // Storage order
2559 template< typename MT > // Type of the right-hand side dense matrix
2560 inline typename EnableIf< typename DynamicMatrix<Type,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2562 {
2565 
2566  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2567  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2568 
2569  const bool remainder( !usePadding || !IsPadded<MT>::value );
2570 
2571  for( size_t i=0UL; i<m_; ++i )
2572  {
2573  const size_t jbegin( ( IsUpper<MT>::value )
2574  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
2575  :( 0UL ) );
2576  const size_t jend ( ( IsLower<MT>::value )
2577  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2578  :( n_ ) );
2579  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2580 
2581  const size_t jpos( ( remainder )?( jend & size_t(-IT::size) ):( jend ) );
2582  BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (IT::size) ) ) == jpos, "Invalid end calculation" );
2583 
2584  size_t j( jbegin );
2585  typename MT::ConstIterator it( (~rhs).begin(i) + jbegin );
2586 
2587  for( ; (j+IT::size*3UL) < jpos; j+=IT::size*4UL ) {
2588  store( i, j , load(i,j ) - it.load() ); it += IT::size;
2589  store( i, j+IT::size , load(i,j+IT::size ) - it.load() ); it += IT::size;
2590  store( i, j+IT::size*2UL, load(i,j+IT::size*2UL) - it.load() ); it += IT::size;
2591  store( i, j+IT::size*3UL, load(i,j+IT::size*3UL) - it.load() ); it += IT::size;
2592  }
2593  for( ; j<jpos; j+=IT::size, it+=IT::size ) {
2594  store( i, j, load(i,j) - it.load() );
2595  }
2596  for( ; remainder && j<jend; ++j, ++it ) {
2597  v_[i*nn_+j] -= *it;
2598  }
2599  }
2600 }
2601 //*************************************************************************************************
2602 
2603 
2604 //*************************************************************************************************
2615 template< typename Type // Data type of the matrix
2616  , bool SO > // Storage order
2617 template< typename MT > // Type of the right-hand side dense matrix
2619 {
2621 
2622  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2623  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2624 
2625  const size_t block( BLOCK_SIZE );
2626 
2627  for( size_t ii=0UL; ii<m_; ii+=block ) {
2628  const size_t iend( min( m_, ii+block ) );
2629  for( size_t jj=0UL; jj<n_; jj+=block )
2630  {
2631  if( IsLower<MT>::value && ii < jj ) break;
2632  if( IsUpper<MT>::value && ii > jj ) continue;
2633 
2634  for( size_t i=ii; i<iend; ++i )
2635  {
2636  const size_t jbegin( ( IsUpper<MT>::value )
2637  ?( max( ( IsStrictlyUpper<MT>::value ? i+1UL : i ), jj ) )
2638  :( jj ) );
2639  const size_t jend ( ( IsLower<MT>::value )
2640  ?( min( ( IsStrictlyLower<MT>::value ? i : i+1UL ), n_, jj+block ) )
2641  :( min( n_, jj+block ) ) );
2642  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2643 
2644  for( size_t j=jbegin; j<jend; ++j ) {
2645  v_[i*nn_+j] -= (~rhs)(i,j);
2646  }
2647  }
2648  }
2649  }
2650 }
2651 //*************************************************************************************************
2652 
2653 
2654 //*************************************************************************************************
2665 template< typename Type // Data type of the matrix
2666  , bool SO > // Storage order
2667 template< typename MT > // Type of the right-hand side sparse matrix
2669 {
2670  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2671  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2672 
2673  for( size_t i=0UL; i<m_; ++i )
2674  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2675  v_[i*nn_+element->index()] -= element->value();
2676 }
2677 //*************************************************************************************************
2678 
2679 
2680 //*************************************************************************************************
2691 template< typename Type // Data type of the matrix
2692  , bool SO > // Storage order
2693 template< typename MT > // Type of the right-hand side sparse matrix
2695 {
2697 
2698  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
2699  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
2700 
2701  for( size_t j=0UL; j<n_; ++j )
2702  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2703  v_[element->index()*nn_+j] -= element->value();
2704 }
2705 //*************************************************************************************************
2706 
2707 
2708 
2709 
2710 
2711 
2712 
2713 
2714 //=================================================================================================
2715 //
2716 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2717 //
2718 //=================================================================================================
2719 
2720 //*************************************************************************************************
2728 template< typename Type > // Data type of the matrix
2729 class DynamicMatrix<Type,true> : public DenseMatrix< DynamicMatrix<Type,true>, true >
2730 {
2731  private:
2732  //**Type definitions****************************************************************************
2733  typedef IntrinsicTrait<Type> IT;
2734  //**********************************************************************************************
2735 
2736  public:
2737  //**Type definitions****************************************************************************
2738  typedef DynamicMatrix<Type,true> This;
2739  typedef This ResultType;
2742  typedef Type ElementType;
2743  typedef typename IT::Type IntrinsicType;
2744  typedef const Type& ReturnType;
2745  typedef const This& CompositeType;
2746 
2747  typedef Type& Reference;
2748  typedef const Type& ConstReference;
2749  typedef Type* Pointer;
2750  typedef const Type* ConstPointer;
2751 
2754  //**********************************************************************************************
2755 
2756  //**Rebind struct definition********************************************************************
2759  template< typename ET > // Data type of the other matrix
2760  struct Rebind {
2761  typedef DynamicMatrix<ET,true> Other;
2762  };
2763  //**********************************************************************************************
2764 
2765  //**Compilation flags***************************************************************************
2767 
2771  enum { vectorizable = IsVectorizable<Type>::value };
2772 
2774 
2777  enum { smpAssignable = !IsSMPAssignable<Type>::value };
2778  //**********************************************************************************************
2779 
2780  //**Constructors********************************************************************************
2783  explicit inline DynamicMatrix();
2784  explicit inline DynamicMatrix( size_t m, size_t n );
2785  explicit inline DynamicMatrix( size_t m, size_t n, const Type& init );
2786  template< typename Other > explicit inline DynamicMatrix( size_t m, size_t n, const Other* array );
2787 
2788  template< typename Other, size_t M, size_t N >
2789  explicit inline DynamicMatrix( const Other (&array)[M][N] );
2790 
2791  inline DynamicMatrix( const DynamicMatrix& m );
2792  template< typename MT, bool SO > inline DynamicMatrix( const Matrix<MT,SO>& m );
2794  //**********************************************************************************************
2795 
2796  //**Destructor**********************************************************************************
2799  inline ~DynamicMatrix();
2801  //**********************************************************************************************
2802 
2803  //**Data access functions***********************************************************************
2806  inline Reference operator()( size_t i, size_t j );
2807  inline ConstReference operator()( size_t i, size_t j ) const;
2808  inline Reference at( size_t i, size_t j );
2809  inline ConstReference at( size_t i, size_t j ) const;
2810  inline Pointer data ();
2811  inline ConstPointer data () const;
2812  inline Pointer data ( size_t j );
2813  inline ConstPointer data ( size_t j ) const;
2814  inline Iterator begin ( size_t j );
2815  inline ConstIterator begin ( size_t j ) const;
2816  inline ConstIterator cbegin( size_t j ) const;
2817  inline Iterator end ( size_t j );
2818  inline ConstIterator end ( size_t j ) const;
2819  inline ConstIterator cend ( size_t j ) const;
2821  //**********************************************************************************************
2822 
2823  //**Assignment operators************************************************************************
2826  template< typename Other, size_t M, size_t N >
2827  inline DynamicMatrix& operator=( const Other (&array)[M][N] );
2828 
2829  inline DynamicMatrix& operator= ( const Type& rhs );
2830  inline DynamicMatrix& operator= ( const DynamicMatrix& rhs );
2831  template< typename MT, bool SO > inline DynamicMatrix& operator= ( const Matrix<MT,SO>& rhs );
2832  template< typename MT, bool SO > inline DynamicMatrix& operator+=( const Matrix<MT,SO>& rhs );
2833  template< typename MT, bool SO > inline DynamicMatrix& operator-=( const Matrix<MT,SO>& rhs );
2834  template< typename MT, bool SO > inline DynamicMatrix& operator*=( const Matrix<MT,SO>& rhs );
2835 
2836  template< typename Other >
2837  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2838  operator*=( Other rhs );
2839 
2840  template< typename Other >
2841  inline typename EnableIf< IsNumeric<Other>, DynamicMatrix >::Type&
2842  operator/=( Other rhs );
2844  //**********************************************************************************************
2845 
2846  //**Utility functions***************************************************************************
2849  inline size_t rows() const;
2850  inline size_t columns() const;
2851  inline size_t spacing() const;
2852  inline size_t capacity() const;
2853  inline size_t capacity( size_t j ) const;
2854  inline size_t nonZeros() const;
2855  inline size_t nonZeros( size_t j ) const;
2856  inline void reset();
2857  inline void reset( size_t j );
2858  inline void clear();
2859  void resize ( size_t m, size_t n, bool preserve=true );
2860  inline void extend ( size_t m, size_t n, bool preserve=true );
2861  inline void reserve( size_t elements );
2862  inline DynamicMatrix& transpose();
2863  inline DynamicMatrix& ctranspose();
2864  template< typename Other > inline DynamicMatrix& scale( const Other& scalar );
2865  inline void swap( DynamicMatrix& m ) /* throw() */;
2867  //**********************************************************************************************
2868 
2869  private:
2870  //**********************************************************************************************
2872  template< typename MT >
2873  struct VectorizedAssign {
2874  enum { value = useOptimizedKernels &&
2875  vectorizable && MT::vectorizable &&
2876  IsSame<Type,typename MT::ElementType>::value };
2877  };
2878  //**********************************************************************************************
2879 
2880  //**********************************************************************************************
2882  template< typename MT >
2883  struct VectorizedAddAssign {
2884  enum { value = useOptimizedKernels &&
2885  vectorizable && MT::vectorizable &&
2886  IsSame<Type,typename MT::ElementType>::value &&
2887  IntrinsicTrait<Type>::addition &&
2888  !IsDiagonal<MT>::value };
2889  };
2890  //**********************************************************************************************
2891 
2892  //**********************************************************************************************
2894  template< typename MT >
2895  struct VectorizedSubAssign {
2896  enum { value = useOptimizedKernels &&
2897  vectorizable && MT::vectorizable &&
2898  IsSame<Type,typename MT::ElementType>::value &&
2899  IntrinsicTrait<Type>::subtraction &&
2900  !IsDiagonal<MT>::value };
2901  };
2902  //**********************************************************************************************
2903 
2904  public:
2905  //**Expression template evaluation functions****************************************************
2908  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2909  template< typename Other > inline bool isAliased( const Other* alias ) const;
2910 
2911  inline bool isAligned () const;
2912  inline bool canSMPAssign() const;
2913 
2914  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
2915  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
2916  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
2917 
2918  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
2919  BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const IntrinsicType& value );
2920  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
2921  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
2922 
2923  template< typename MT >
2924  inline typename DisableIf< VectorizedAssign<MT> >::Type
2925  assign( const DenseMatrix<MT,true>& rhs );
2926 
2927  template< typename MT >
2928  inline typename EnableIf< VectorizedAssign<MT> >::Type
2929  assign( const DenseMatrix<MT,true>& rhs );
2930 
2931  template< typename MT > inline void assign( const DenseMatrix<MT,false>& rhs );
2932  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2933  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2934 
2935  template< typename MT >
2936  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2937  addAssign( const DenseMatrix<MT,true>& rhs );
2938 
2939  template< typename MT >
2940  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2941  addAssign( const DenseMatrix<MT,true>& rhs );
2942 
2943  template< typename MT > inline void addAssign( const DenseMatrix<MT,false>& rhs );
2944  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2945  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2946 
2947  template< typename MT >
2948  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2949  subAssign ( const DenseMatrix<MT,true>& rhs );
2950 
2951  template< typename MT >
2952  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2953  subAssign ( const DenseMatrix<MT,true>& rhs );
2954 
2955  template< typename MT > inline void subAssign( const DenseMatrix<MT,false>& rhs );
2956  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2957  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2959  //**********************************************************************************************
2960 
2961  private:
2962  //**Utility functions***************************************************************************
2965  inline size_t adjustRows( size_t minRows ) const;
2967  //**********************************************************************************************
2968 
2969  //**Member variables****************************************************************************
2972  size_t m_;
2973  size_t mm_;
2974  size_t n_;
2975  size_t capacity_;
2976  Type* BLAZE_RESTRICT v_;
2977 
2980  //**********************************************************************************************
2981 
2982  //**Compile time checks*************************************************************************
2987  //**********************************************************************************************
2988 };
2990 //*************************************************************************************************
2991 
2992 
2993 
2994 
2995 //=================================================================================================
2996 //
2997 // CONSTRUCTORS
2998 //
2999 //=================================================================================================
3000 
3001 //*************************************************************************************************
3005 template< typename Type > // Data type of the matrix
3007  : m_ ( 0UL ) // The current number of rows of the matrix
3008  , mm_ ( 0UL ) // The alignment adjusted number of rows
3009  , n_ ( 0UL ) // The current number of columns of the matrix
3010  , capacity_( 0UL ) // The maximum capacity of the matrix
3011  , v_ ( NULL ) // The matrix elements
3012 {}
3014 //*************************************************************************************************
3015 
3016 
3017 //*************************************************************************************************
3027 template< typename Type > // Data type of the matrix
3028 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n )
3029  : m_ ( m ) // The current number of rows of the matrix
3030  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
3031  , n_ ( n ) // The current number of columns of the matrix
3032  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3033  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3034 {
3035  if( IsVectorizable<Type>::value ) {
3036  for( size_t j=0UL; j<n_; ++j )
3037  for( size_t i=m_; i<mm_; ++i ) {
3038  v_[i+j*mm_] = Type();
3039  }
3040  }
3041 }
3043 //*************************************************************************************************
3044 
3045 
3046 //*************************************************************************************************
3056 template< typename Type > // Data type of the matrix
3057 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Type& init )
3058  : m_ ( m ) // The current number of rows of the matrix
3059  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
3060  , n_ ( n ) // The current number of columns of the matrix
3061  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3062  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3063 {
3064  for( size_t j=0UL; j<n_; ++j ) {
3065  for( size_t i=0UL; i<m_; ++i )
3066  v_[i+j*mm_] = init;
3067 
3068  if( IsVectorizable<Type>::value ) {
3069  for( size_t i=m_; i<mm_; ++i )
3070  v_[i+j*mm_] = Type();
3071  }
3072  }
3073 }
3075 //*************************************************************************************************
3076 
3077 
3078 //*************************************************************************************************
3102 template< typename Type > // Data type of the matrix
3103 template< typename Other > // Data type of the initialization array
3104 inline DynamicMatrix<Type,true>::DynamicMatrix( size_t m, size_t n, const Other* array )
3105  : m_ ( m ) // The current number of rows of the matrix
3106  , mm_ ( adjustRows( m ) ) // The alignment adjusted number of rows
3107  , n_ ( n ) // The current number of columns of the matrix
3108  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3109  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3110 {
3111  for( size_t j=0UL; j<n; ++j ) {
3112  for( size_t i=0UL; i<m; ++i )
3113  v_[i+j*mm_] = array[i+j*m];
3114 
3115  if( IsVectorizable<Type>::value ) {
3116  for( size_t i=m; i<mm_; ++i )
3117  v_[i+j*mm_] = Type();
3118  }
3119  }
3120 }
3122 //*************************************************************************************************
3123 
3124 
3125 //*************************************************************************************************
3147 template< typename Type > // Data type of the matrix
3148 template< typename Other // Data type of the initialization array
3149  , size_t M // Number of rows of the initialization array
3150  , size_t N > // Number of columns of the initialization array
3151 inline DynamicMatrix<Type,true>::DynamicMatrix( const Other (&array)[M][N] )
3152  : m_ ( M ) // The current number of rows of the matrix
3153  , mm_ ( adjustRows( M ) ) // The alignment adjusted number of rows
3154  , n_ ( N ) // The current number of columns of the matrix
3155  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3156  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3157 {
3158  for( size_t j=0UL; j<N; ++j ) {
3159  for( size_t i=0UL; i<M; ++i )
3160  v_[i+j*mm_] = array[i][j];
3161 
3162  if( IsVectorizable<Type>::value ) {
3163  for( size_t i=M; i<mm_; ++i )
3164  v_[i+j*mm_] = Type();
3165  }
3166  }
3167 }
3169 //*************************************************************************************************
3170 
3171 
3172 //*************************************************************************************************
3181 template< typename Type > // Data type of the matrix
3182 inline DynamicMatrix<Type,true>::DynamicMatrix( const DynamicMatrix& m )
3183  : m_ ( m.m_ ) // The current number of rows of the matrix
3184  , mm_ ( m.mm_ ) // The alignment adjusted number of rows
3185  , n_ ( m.n_ ) // The current number of columns of the matrix
3186  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3187  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3188 {
3189  BLAZE_INTERNAL_ASSERT( capacity_ <= m.capacity_, "Invalid capacity estimation" );
3190 
3191  for( size_t i=0UL; i<capacity_; ++i )
3192  v_[i] = m.v_[i];
3193 }
3195 //*************************************************************************************************
3196 
3197 
3198 //*************************************************************************************************
3204 template< typename Type > // Data type of the matrix
3205 template< typename MT // Type of the foreign matrix
3206  , bool SO > // Storage order of the foreign matrix
3207 inline DynamicMatrix<Type,true>::DynamicMatrix( const Matrix<MT,SO>& m )
3208  : m_ ( (~m).rows() ) // The current number of rows of the matrix
3209  , mm_ ( adjustRows( m_ ) ) // The alignment adjusted number of rows
3210  , n_ ( (~m).columns() ) // The current number of columns of the matrix
3211  , capacity_( mm_*n_ ) // The maximum capacity of the matrix
3212  , v_ ( allocate<Type>( capacity_ ) ) // The matrix elements
3213 {
3214  for( size_t j=0UL; j<n_; ++j ) {
3215  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
3216  i<( IsVectorizable<Type>::value ? mm_ : m_ ); ++i ) {
3217  v_[i+j*mm_] = Type();
3218  }
3219  }
3220 
3221  smpAssign( *this, ~m );
3222 }
3224 //*************************************************************************************************
3225 
3226 
3227 
3228 
3229 //=================================================================================================
3230 //
3231 // DESTRUCTOR
3232 //
3233 //=================================================================================================
3234 
3235 //*************************************************************************************************
3239 template< typename Type > // Data type of the matrix
3241 {
3242  deallocate( v_ );
3243 }
3245 //*************************************************************************************************
3246 
3247 
3248 
3249 
3250 //=================================================================================================
3251 //
3252 // DATA ACCESS FUNCTIONS
3253 //
3254 //=================================================================================================
3255 
3256 //*************************************************************************************************
3267 template< typename Type > // Data type of the matrix
3269  DynamicMatrix<Type,true>::operator()( size_t i, size_t j )
3270 {
3271  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
3272  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
3273  return v_[i+j*mm_];
3274 }
3276 //*************************************************************************************************
3277 
3278 
3279 //*************************************************************************************************
3290 template< typename Type > // Data type of the matrix
3292  DynamicMatrix<Type,true>::operator()( size_t i, size_t j ) const
3293 {
3294  BLAZE_USER_ASSERT( i<m_, "Invalid row access index" );
3295  BLAZE_USER_ASSERT( j<n_, "Invalid column access index" );
3296  return v_[i+j*mm_];
3297 }
3299 //*************************************************************************************************
3300 
3301 
3302 //*************************************************************************************************
3314 template< typename Type > // Data type of the matrix
3316  DynamicMatrix<Type,true>::at( size_t i, size_t j )
3317 {
3318  if( i >= m_ ) {
3319  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
3320  }
3321  if( j >= n_ ) {
3322  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
3323  }
3324  return (*this)(i,j);
3325 }
3327 //*************************************************************************************************
3328 
3329 
3330 //*************************************************************************************************
3342 template< typename Type > // Data type of the matrix
3344  DynamicMatrix<Type,true>::at( size_t i, size_t j ) const
3345 {
3346  if( i >= m_ ) {
3347  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
3348  }
3349  if( j >= n_ ) {
3350  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
3351  }
3352  return (*this)(i,j);
3353 }
3355 //*************************************************************************************************
3356 
3357 
3358 //*************************************************************************************************
3370 template< typename Type > // Data type of the matrix
3371 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data()
3372 {
3373  return v_;
3374 }
3376 //*************************************************************************************************
3377 
3378 
3379 //*************************************************************************************************
3391 template< typename Type > // Data type of the matrix
3392 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data() const
3393 {
3394  return v_;
3395 }
3397 //*************************************************************************************************
3398 
3399 
3400 //*************************************************************************************************
3409 template< typename Type > // Data type of the matrix
3410 inline typename DynamicMatrix<Type,true>::Pointer DynamicMatrix<Type,true>::data( size_t j )
3411 {
3412  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3413  return v_ + j*mm_;
3414 }
3416 //*************************************************************************************************
3417 
3418 
3419 //*************************************************************************************************
3428 template< typename Type > // Data type of the matrix
3429 inline typename DynamicMatrix<Type,true>::ConstPointer DynamicMatrix<Type,true>::data( size_t j ) const
3430 {
3431  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3432  return v_ + j*mm_;
3433 }
3435 //*************************************************************************************************
3436 
3437 
3438 //*************************************************************************************************
3445 template< typename Type > // Data type of the matrix
3446 inline typename DynamicMatrix<Type,true>::Iterator
3448 {
3449  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3450  return Iterator( v_ + j*mm_ );
3451 }
3453 //*************************************************************************************************
3454 
3455 
3456 //*************************************************************************************************
3463 template< typename Type > // Data type of the matrix
3465  DynamicMatrix<Type,true>::begin( size_t j ) const
3466 {
3467  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3468  return ConstIterator( v_ + j*mm_ );
3469 }
3471 //*************************************************************************************************
3472 
3473 
3474 //*************************************************************************************************
3481 template< typename Type > // Data type of the matrix
3483  DynamicMatrix<Type,true>::cbegin( size_t j ) const
3484 {
3485  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3486  return ConstIterator( v_ + j*mm_ );
3487 }
3489 //*************************************************************************************************
3490 
3491 
3492 //*************************************************************************************************
3499 template< typename Type > // Data type of the matrix
3500 inline typename DynamicMatrix<Type,true>::Iterator
3501  DynamicMatrix<Type,true>::end( size_t j )
3502 {
3503  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3504  return Iterator( v_ + j*mm_ + m_ );
3505 }
3507 //*************************************************************************************************
3508 
3509 
3510 //*************************************************************************************************
3517 template< typename Type > // Data type of the matrix
3519  DynamicMatrix<Type,true>::end( size_t j ) const
3520 {
3521  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3522  return ConstIterator( v_ + j*mm_ + m_ );
3523 }
3525 //*************************************************************************************************
3526 
3527 
3528 //*************************************************************************************************
3535 template< typename Type > // Data type of the matrix
3537  DynamicMatrix<Type,true>::cend( size_t j ) const
3538 {
3539  BLAZE_USER_ASSERT( j < n_, "Invalid dense matrix column access index" );
3540  return ConstIterator( v_ + j*mm_ + m_ );
3541 }
3543 //*************************************************************************************************
3544 
3545 
3546 
3547 
3548 //=================================================================================================
3549 //
3550 // ASSIGNMENT OPERATORS
3551 //
3552 //=================================================================================================
3553 
3554 //*************************************************************************************************
3576 template< typename Type > // Data type of the matrix
3577 template< typename Other // Data type of the initialization array
3578  , size_t M // Number of rows of the initialization array
3579  , size_t N > // Number of columns of the initialization array
3580 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Other (&array)[M][N] )
3581 {
3582  resize( M, N, false );
3583 
3584  for( size_t j=0UL; j<N; ++j )
3585  for( size_t i=0UL; i<M; ++i )
3586  v_[i+j*mm_] = array[i][j];
3587 
3588  return *this;
3589 }
3591 //*************************************************************************************************
3592 
3593 
3594 //*************************************************************************************************
3601 template< typename Type > // Data type of the matrix
3602 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Type& rhs )
3603 {
3604  for( size_t j=0UL; j<n_; ++j )
3605  for( size_t i=0UL; i<m_; ++i )
3606  v_[i+j*mm_] = rhs;
3607 
3608  return *this;
3609 }
3611 //*************************************************************************************************
3612 
3613 
3614 //*************************************************************************************************
3624 template< typename Type > // Data type of the matrix
3625 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const DynamicMatrix& rhs )
3626 {
3627  if( &rhs == this ) return *this;
3628 
3629  resize( rhs.m_, rhs.n_, false );
3630  smpAssign( *this, ~rhs );
3631 
3632  return *this;
3633 }
3635 //*************************************************************************************************
3636 
3637 
3638 //*************************************************************************************************
3648 template< typename Type > // Data type of the matrix
3649 template< typename MT // Type of the right-hand side matrix
3650  , bool SO > // Storage order of the right-hand side matrix
3651 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( const Matrix<MT,SO>& rhs )
3652 {
3653  typedef typename TransExprTrait<This>::Type TT;
3654  typedef typename CTransExprTrait<This>::Type CT;
3655 
3656  if( IsSame<MT,TT>::value && (~rhs).isAliased( this ) ) {
3657  transpose();
3658  }
3659  else if( IsSame<MT,CT>::value && (~rhs).isAliased( this ) ) {
3660  ctranspose();
3661  }
3662  else if( (~rhs).canAlias( this ) ) {
3663  DynamicMatrix tmp( ~rhs );
3664  swap( tmp );
3665  }
3666  else {
3667  resize( (~rhs).rows(), (~rhs).columns(), false );
3668  if( IsSparseMatrix<MT>::value )
3669  reset();
3670  smpAssign( *this, ~rhs );
3671  }
3672 
3673  return *this;
3674 }
3676 //*************************************************************************************************
3677 
3678 
3679 //*************************************************************************************************
3690 template< typename Type > // Data type of the matrix
3691 template< typename MT // Type of the right-hand side matrix
3692  , bool SO > // Storage order of the right-hand side matrix
3693 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=( const Matrix<MT,SO>& rhs )
3694 {
3695  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
3696  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3697  }
3698 
3699  if( (~rhs).canAlias( this ) ) {
3700  const typename MT::ResultType tmp( ~rhs );
3701  smpAddAssign( *this, tmp );
3702  }
3703  else {
3704  smpAddAssign( *this, ~rhs );
3705  }
3706 
3707  return *this;
3708 }
3710 //*************************************************************************************************
3711 
3712 
3713 //*************************************************************************************************
3724 template< typename Type > // Data type of the matrix
3725 template< typename MT // Type of the right-hand side matrix
3726  , bool SO > // Storage order of the right-hand side matrix
3727 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=( const Matrix<MT,SO>& rhs )
3728 {
3729  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
3730  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3731  }
3732 
3733  if( (~rhs).canAlias( this ) ) {
3734  const typename MT::ResultType tmp( ~rhs );
3735  smpSubAssign( *this, tmp );
3736  }
3737  else {
3738  smpSubAssign( *this, ~rhs );
3739  }
3740 
3741  return *this;
3742 }
3744 //*************************************************************************************************
3745 
3746 
3747 //*************************************************************************************************
3758 template< typename Type > // Data type of the matrix
3759 template< typename MT // Type of the right-hand side matrix
3760  , bool SO > // Storage order of the right-hand side matrix
3761 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=( const Matrix<MT,SO>& rhs )
3762 {
3763  if( (~rhs).rows() != n_ ) {
3764  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
3765  }
3766 
3767  DynamicMatrix tmp( *this * (~rhs) );
3768  swap( tmp );
3769 
3770  return *this;
3771 }
3773 //*************************************************************************************************
3774 
3775 
3776 //*************************************************************************************************
3784 template< typename Type > // Data type of the matrix
3785 template< typename Other > // Data type of the right-hand side scalar
3786 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3787  DynamicMatrix<Type,true>::operator*=( Other rhs )
3788 {
3789  smpAssign( *this, (*this) * rhs );
3790  return *this;
3791 }
3793 //*************************************************************************************************
3794 
3795 
3796 //*************************************************************************************************
3804 template< typename Type > // Data type of the matrix
3805 template< typename Other > // Data type of the right-hand side scalar
3806 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3807  DynamicMatrix<Type,true>::operator/=( Other rhs )
3808 {
3809  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3810 
3811  smpAssign( *this, (*this) / rhs );
3812  return *this;
3813 }
3815 //*************************************************************************************************
3816 
3817 
3818 
3819 
3820 //=================================================================================================
3821 //
3822 // UTILITY FUNCTIONS
3823 //
3824 //=================================================================================================
3825 
3826 //*************************************************************************************************
3832 template< typename Type > // Data type of the matrix
3833 inline size_t DynamicMatrix<Type,true>::rows() const
3834 {
3835  return m_;
3836 }
3838 //*************************************************************************************************
3839 
3840 
3841 //*************************************************************************************************
3847 template< typename Type > // Data type of the matrix
3848 inline size_t DynamicMatrix<Type,true>::columns() const
3849 {
3850  return n_;
3851 }
3853 //*************************************************************************************************
3854 
3855 
3856 //*************************************************************************************************
3865 template< typename Type > // Data type of the matrix
3866 inline size_t DynamicMatrix<Type,true>::spacing() const
3867 {
3868  return mm_;
3869 }
3871 //*************************************************************************************************
3872 
3873 
3874 //*************************************************************************************************
3880 template< typename Type > // Data type of the matrix
3881 inline size_t DynamicMatrix<Type,true>::capacity() const
3882 {
3883  return capacity_;
3884 }
3886 //*************************************************************************************************
3887 
3888 
3889 //*************************************************************************************************
3896 template< typename Type > // Data type of the matrix
3897 inline size_t DynamicMatrix<Type,true>::capacity( size_t j ) const
3898 {
3899  UNUSED_PARAMETER( j );
3900  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3901  return mm_;
3902 }
3904 //*************************************************************************************************
3905 
3906 
3907 //*************************************************************************************************
3913 template< typename Type > // Data type of the matrix
3914 inline size_t DynamicMatrix<Type,true>::nonZeros() const
3915 {
3916  size_t nonzeros( 0UL );
3917 
3918  for( size_t j=0UL; j<n_; ++j )
3919  for( size_t i=0UL; i<m_; ++i )
3920  if( !isDefault( v_[i+j*mm_] ) )
3921  ++nonzeros;
3922 
3923  return nonzeros;
3924 }
3926 //*************************************************************************************************
3927 
3928 
3929 //*************************************************************************************************
3936 template< typename Type > // Data type of the matrix
3937 inline size_t DynamicMatrix<Type,true>::nonZeros( size_t j ) const
3938 {
3939  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3940 
3941  const size_t iend( j*mm_ + m_ );
3942  size_t nonzeros( 0UL );
3943 
3944  for( size_t i=j*mm_; i<iend; ++i )
3945  if( !isDefault( v_[i] ) )
3946  ++nonzeros;
3947 
3948  return nonzeros;
3949 }
3951 //*************************************************************************************************
3952 
3953 
3954 //*************************************************************************************************
3960 template< typename Type > // Data type of the matrix
3961 inline void DynamicMatrix<Type,true>::reset()
3962 {
3963  using blaze::clear;
3964 
3965  for( size_t j=0UL; j<n_; ++j )
3966  for( size_t i=0UL; i<m_; ++i )
3967  clear( v_[i+j*mm_] );
3968 }
3970 //*************************************************************************************************
3971 
3972 
3973 //*************************************************************************************************
3983 template< typename Type > // Data type of the matrix
3984 inline void DynamicMatrix<Type,true>::reset( size_t j )
3985 {
3986  using blaze::clear;
3987 
3988  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3989  for( size_t i=0UL; i<m_; ++i )
3990  clear( v_[i+j*mm_] );
3991 }
3993 //*************************************************************************************************
3994 
3995 
3996 //*************************************************************************************************
4004 template< typename Type > // Data type of the matrix
4005 inline void DynamicMatrix<Type,true>::clear()
4006 {
4007  resize( 0UL, 0UL, false );
4008 }
4010 //*************************************************************************************************
4011 
4012 
4013 //*************************************************************************************************
4048 template< typename Type > // Data type of the matrix
4049 void DynamicMatrix<Type,true>::resize( size_t m, size_t n, bool preserve )
4050 {
4051  using blaze::min;
4052 
4053  if( m == m_ && n == n_ ) return;
4054 
4055  const size_t mm( adjustRows( m ) );
4056 
4057  if( preserve )
4058  {
4059  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
4060  const size_t min_m( min( m, m_ ) );
4061  const size_t min_n( min( n, n_ ) );
4062 
4063  for( size_t j=0UL; j<min_n; ++j )
4064  for( size_t i=0UL; i<min_m; ++i )
4065  v[i+j*mm] = v_[i+j*mm_];
4066 
4067  std::swap( v_, v );
4068  deallocate( v );
4069  capacity_ = mm*n;
4070  }
4071  else if( mm*n > capacity_ ) {
4072  Type* BLAZE_RESTRICT v = allocate<Type>( mm*n );
4073  std::swap( v_, v );
4074  deallocate( v );
4075  capacity_ = mm*n;
4076  }
4077 
4078  if( IsVectorizable<Type>::value ) {
4079  for( size_t j=0UL; j<n; ++j )
4080  for( size_t i=m; i<mm; ++i )
4081  v_[i+j*mm] = Type();
4082  }
4083 
4084  m_ = m;
4085  mm_ = mm;
4086  n_ = n;
4087 }
4089 //*************************************************************************************************
4090 
4091 
4092 //*************************************************************************************************
4107 template< typename Type > // Data type of the matrix
4108 inline void DynamicMatrix<Type,true>::extend( size_t m, size_t n, bool preserve )
4109 {
4110  resize( m_+m, n_+n, preserve );
4111 }
4113 //*************************************************************************************************
4114 
4115 
4116 //*************************************************************************************************
4126 template< typename Type > // Data type of the matrix
4127 inline void DynamicMatrix<Type,true>::reserve( size_t elements )
4128 {
4129  if( elements > capacity_ )
4130  {
4131  // Allocating a new array
4132  Type* BLAZE_RESTRICT tmp = allocate<Type>( elements );
4133 
4134  // Initializing the new array
4135  std::copy( v_, v_+capacity_, tmp );
4136 
4137  if( IsVectorizable<Type>::value ) {
4138  for( size_t i=capacity_; i<elements; ++i )
4139  tmp[i] = Type();
4140  }
4141 
4142  // Replacing the old array
4143  std::swap( tmp, v_ );
4144  deallocate( tmp );
4145  capacity_ = elements;
4146  }
4147 }
4149 //*************************************************************************************************
4150 
4151 
4152 //*************************************************************************************************
4158 template< typename Type > // Data type of the matrix
4159 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::transpose()
4160 {
4161  using std::swap;
4162 
4163  const size_t block( BLOCK_SIZE );
4164 
4165  if( m_ == n_ )
4166  {
4167  for( size_t jj=0UL; jj<n_; jj+=block ) {
4168  const size_t jend( min( jj+block, n_ ) );
4169  for( size_t ii=0UL; ii<=jj; ii+=block ) {
4170  for( size_t j=jj; j<jend; ++j ) {
4171  const size_t iend( min( ii+block, m_, j ) );
4172  for( size_t i=ii; i<iend; ++i ) {
4173  swap( v_[i+j*mm_], v_[j+i*mm_] );
4174  }
4175  }
4176  }
4177  }
4178  }
4179  else
4180  {
4181  DynamicMatrix tmp( trans(*this) );
4182  this->swap( tmp );
4183  }
4184 
4185  return *this;
4186 }
4188 //*************************************************************************************************
4189 
4190 
4191 //*************************************************************************************************
4197 template< typename Type > // Data type of the matrix
4198 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::ctranspose()
4199 {
4200  const size_t block( BLOCK_SIZE );
4201 
4202  if( m_ == n_ )
4203  {
4204  for( size_t jj=0UL; jj<n_; jj+=block ) {
4205  const size_t jend( min( jj+block, n_ ) );
4206  for( size_t ii=0UL; ii<jj; ii+=block ) {
4207  const size_t iend( min( ii+block, m_ ) );
4208  for( size_t j=jj; j<jend; ++j ) {
4209  for( size_t i=ii; i<iend; ++i ) {
4210  cswap( v_[i+j*mm_], v_[j+i*mm_] );
4211  }
4212  }
4213  }
4214  for( size_t j=jj; j<jend; ++j ) {
4215  for( size_t i=jj; i<j; ++i ) {
4216  cswap( v_[i+j*mm_], v_[j+i*mm_] );
4217  }
4218  conjugate( v_[j+j*mm_] );
4219  }
4220  }
4221  }
4222  else
4223  {
4224  DynamicMatrix tmp( ctrans(*this) );
4225  this->swap( tmp );
4226  }
4227 
4228  return *this;
4229 }
4231 //*************************************************************************************************
4232 
4233 
4234 //*************************************************************************************************
4241 template< typename Type > // Data type of the matrix
4242 template< typename Other > // Data type of the scalar value
4243 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( const Other& scalar )
4244 {
4245  for( size_t j=0UL; j<n_; ++j )
4246  for( size_t i=0UL; i<m_; ++i )
4247  v_[i+j*mm_] *= scalar;
4248 
4249  return *this;
4250 }
4252 //*************************************************************************************************
4253 
4254 
4255 //*************************************************************************************************
4263 template< typename Type > // Data type of the matrix
4264 inline void DynamicMatrix<Type,true>::swap( DynamicMatrix& m ) /* throw() */
4265 {
4266  std::swap( m_ , m.m_ );
4267  std::swap( mm_, m.mm_ );
4268  std::swap( n_ , m.n_ );
4269  std::swap( capacity_, m.capacity_ );
4270  std::swap( v_ , m.v_ );
4271 }
4273 //*************************************************************************************************
4274 
4275 
4276 //*************************************************************************************************
4283 template< typename Type > // Data type of the matrix
4284 inline size_t DynamicMatrix<Type,true>::adjustRows( size_t minRows ) const
4285 {
4286  if( usePadding && IsVectorizable<Type>::value )
4287  return nextMultiple<size_t>( minRows, IT::size );
4288  else return minRows;
4289 }
4291 //*************************************************************************************************
4292 
4293 
4294 
4295 
4296 //=================================================================================================
4297 //
4298 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4299 //
4300 //=================================================================================================
4301 
4302 //*************************************************************************************************
4313 template< typename Type > // Data type of the matrix
4314 template< typename Other > // Data type of the foreign expression
4315 inline bool DynamicMatrix<Type,true>::canAlias( const Other* alias ) const
4316 {
4317  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4318 }
4320 //*************************************************************************************************
4321 
4322 
4323 //*************************************************************************************************
4334 template< typename Type > // Data type of the matrix
4335 template< typename Other > // Data type of the foreign expression
4336 inline bool DynamicMatrix<Type,true>::isAliased( const Other* alias ) const
4337 {
4338  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4339 }
4341 //*************************************************************************************************
4342 
4343 
4344 //*************************************************************************************************
4354 template< typename Type > // Data type of the matrix
4355 inline bool DynamicMatrix<Type,true>::isAligned() const
4356 {
4357  return ( usePadding || rows() % IT::size == 0UL );
4358 }
4360 //*************************************************************************************************
4361 
4362 
4363 //*************************************************************************************************
4374 template< typename Type > // Data type of the matrix
4375 inline bool DynamicMatrix<Type,true>::canSMPAssign() const
4376 {
4377  return ( columns() > SMP_DMATASSIGN_THRESHOLD );
4378 }
4380 //*************************************************************************************************
4381 
4382 
4383 //*************************************************************************************************
4398 template< typename Type > // Data type of the matrix
4399 BLAZE_ALWAYS_INLINE typename DynamicMatrix<Type,true>::IntrinsicType
4400  DynamicMatrix<Type,true>::load( size_t i, size_t j ) const
4401 {
4402  if( usePadding )
4403  return loada( i, j );
4404  else
4405  return loadu( i, j );
4406 }
4408 //*************************************************************************************************
4409 
4410 
4411 //*************************************************************************************************
4426 template< typename Type > // Data type of the matrix
4427 BLAZE_ALWAYS_INLINE typename DynamicMatrix<Type,true>::IntrinsicType
4428  DynamicMatrix<Type,true>::loada( size_t i, size_t j ) const
4429 {
4430  using blaze::loada;
4431 
4433 
4434  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4435  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4436  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
4437  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4438  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i+j*mm_ ), "Invalid alignment detected" );
4439 
4440  return loada( v_+i+j*mm_ );
4441 }
4443 //*************************************************************************************************
4444 
4445 
4446 //*************************************************************************************************
4461 template< typename Type > // Data type of the matrix
4462 BLAZE_ALWAYS_INLINE typename DynamicMatrix<Type,true>::IntrinsicType
4463  DynamicMatrix<Type,true>::loadu( size_t i, size_t j ) const
4464 {
4465  using blaze::loadu;
4466 
4468 
4469  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4470  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4471  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4472 
4473  return loadu( v_+i+j*mm_ );
4474 }
4476 //*************************************************************************************************
4477 
4478 
4479 //*************************************************************************************************
4495 template< typename Type > // Data type of the matrix
4497  DynamicMatrix<Type,true>::store( size_t i, size_t j, const IntrinsicType& value )
4498 {
4499  if( usePadding )
4500  storea( i, j, value );
4501  else
4502  storeu( i, j, value );
4503 }
4505 //*************************************************************************************************
4506 
4507 
4508 //*************************************************************************************************
4524 template< typename Type > // Data type of the matrix
4526  DynamicMatrix<Type,true>::storea( size_t i, size_t j, const IntrinsicType& value )
4527 {
4528  using blaze::storea;
4529 
4531 
4532  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4533  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4534  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
4535  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4536  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i+j*mm_ ), "Invalid alignment detected" );
4537 
4538  storea( v_+i+j*mm_, value );
4539 }
4541 //*************************************************************************************************
4542 
4543 
4544 //*************************************************************************************************
4560 template< typename Type > // Data type of the matrix
4562  DynamicMatrix<Type,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4563 {
4564  using blaze::storeu;
4565 
4567 
4568  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4569  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4570  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4571 
4572  storeu( v_+i+j*mm_, value );
4573 }
4575 //*************************************************************************************************
4576 
4577 
4578 //*************************************************************************************************
4594 template< typename Type > // Data type of the matrix
4596  DynamicMatrix<Type,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4597 {
4598  using blaze::stream;
4599 
4601 
4602  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4603  BLAZE_INTERNAL_ASSERT( i + IT::size <= mm_, "Invalid row access index" );
4604  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
4605  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4606  BLAZE_INTERNAL_ASSERT( checkAlignment( v_+i+j*mm_ ), "Invalid alignment detected" );
4607 
4608  stream( v_+i+j*mm_, value );
4609 }
4611 //*************************************************************************************************
4612 
4613 
4614 //*************************************************************************************************
4626 template< typename Type > // Data type of the matrix
4627 template< typename MT > // Type of the right-hand side dense matrix
4628 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4629  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4630 {
4631  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4632  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4633 
4634  const size_t ipos( m_ & size_t(-2) );
4635  BLAZE_INTERNAL_ASSERT( ( m_ - ( m_ % 2UL ) ) == ipos, "Invalid end calculation" );
4636 
4637  for( size_t j=0UL; j<n_; ++j ) {
4638  for( size_t i=0UL; i<ipos; i+=2UL ) {
4639  v_[i +j*mm_] = (~rhs)(i ,j);
4640  v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4641  }
4642  if( ipos < m_ ) {
4643  v_[ipos+j*mm_] = (~rhs)(ipos,j);
4644  }
4645  }
4646 }
4648 //*************************************************************************************************
4649 
4650 
4651 //*************************************************************************************************
4663 template< typename Type > // Data type of the matrix
4664 template< typename MT > // Type of the right-hand side dense matrix
4665 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4666  DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,true>& rhs )
4667 {
4669 
4670  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4671  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4672 
4673  const bool remainder( !usePadding || !IsPadded<MT>::value );
4674 
4675  const size_t ipos( ( remainder )?( m_ & size_t(-IT::size) ):( m_ ) );
4676  BLAZE_INTERNAL_ASSERT( !remainder || ( m_ - ( m_ % (IT::size) ) ) == ipos, "Invalid end calculation" );
4677 
4678  if( usePadding && useStreaming &&
4679  ( m_*n_ > ( cacheSize / ( sizeof(Type) * 3UL ) ) ) && !(~rhs).isAliased( this ) )
4680  {
4681  for( size_t j=0UL; j<n_; ++j )
4682  {
4683  size_t i( 0UL );
4684 
4685  for( ; i<ipos; i+=IT::size ) {
4686  stream( i, j, (~rhs).load(i,j) );
4687  }
4688  for( ; remainder && i<m_; ++i ) {
4689  v_[i+j*mm_] = (~rhs)(i,j);
4690  }
4691  }
4692  }
4693  else
4694  {
4695  for( size_t j=0UL; j<n_; ++j )
4696  {
4697  size_t i( 0UL );
4698  typename MT::ConstIterator it( (~rhs).begin(j) );
4699 
4700  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
4701  store( i , j, it.load() ); it += IT::size;
4702  store( i+IT::size , j, it.load() ); it += IT::size;
4703  store( i+IT::size*2UL, j, it.load() ); it += IT::size;
4704  store( i+IT::size*3UL, j, it.load() ); it += IT::size;
4705  }
4706  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
4707  store( i, j, it.load() );
4708  }
4709  for( ; remainder && i<m_; ++i, ++it ) {
4710  v_[i+j*mm_] = *it;
4711  }
4712  }
4713  }
4714 }
4716 //*************************************************************************************************
4717 
4718 
4719 //*************************************************************************************************
4731 template< typename Type > // Data type of the matrix
4732 template< typename MT > // Type of the right-hand side dense matrix
4733 inline void DynamicMatrix<Type,true>::assign( const DenseMatrix<MT,false>& rhs )
4734 {
4736 
4737  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4738  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4739 
4740  const size_t block( BLOCK_SIZE );
4741 
4742  for( size_t jj=0UL; jj<n_; jj+=block ) {
4743  const size_t jend( min( n_, jj+block ) );
4744  for( size_t ii=0UL; ii<m_; ii+=block ) {
4745  const size_t iend( min( m_, ii+block ) );
4746  for( size_t j=jj; j<jend; ++j ) {
4747  for( size_t i=ii; i<iend; ++i ) {
4748  v_[i+j*mm_] = (~rhs)(i,j);
4749  }
4750  }
4751  }
4752  }
4753 }
4755 //*************************************************************************************************
4756 
4757 
4758 //*************************************************************************************************
4770 template< typename Type > // Data type of the matrix
4771 template< typename MT > // Type of the right-hand side sparse matrix
4772 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,true>& rhs )
4773 {
4774  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4775  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4776 
4777  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4778  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4779  v_[element->index()+j*mm_] = element->value();
4780 }
4782 //*************************************************************************************************
4783 
4784 
4785 //*************************************************************************************************
4797 template< typename Type > // Data type of the matrix
4798 template< typename MT > // Type of the right-hand side sparse matrix
4799 inline void DynamicMatrix<Type,true>::assign( const SparseMatrix<MT,false>& rhs )
4800 {
4802 
4803  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4804  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4805 
4806  for( size_t i=0UL; i<(~rhs).rows(); ++i )
4807  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4808  v_[i+element->index()*mm_] = element->value();
4809 }
4811 //*************************************************************************************************
4812 
4813 
4814 //*************************************************************************************************
4826 template< typename Type > // Data type of the matrix
4827 template< typename MT > // Type of the right-hand side dense matrix
4828 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4829  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4830 {
4831  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4832  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4833 
4834  for( size_t j=0UL; j<n_; ++j )
4835  {
4836  if( IsDiagonal<MT>::value )
4837  {
4838  v_[j+j*mm_] += (~rhs)(j,j);
4839  }
4840  else
4841  {
4842  const size_t ibegin( ( IsLower<MT>::value )
4843  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4844  :( 0UL ) );
4845  const size_t iend ( ( IsUpper<MT>::value )
4846  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4847  :( m_ ) );
4848  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4849 
4850  size_t i( ibegin );
4851 
4852  for( ; (i+2UL) <= iend; i+=2UL ) {
4853  v_[i +j*mm_] += (~rhs)(i ,j);
4854  v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4855  }
4856  if( i < iend ) {
4857  v_[i+j*mm_] += (~rhs)(i,j);
4858  }
4859  }
4860  }
4861 }
4863 //*************************************************************************************************
4864 
4865 
4866 //*************************************************************************************************
4878 template< typename Type > // Data type of the matrix
4879 template< typename MT > // Type of the right-hand side dense matrix
4880 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4881  DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,true>& rhs )
4882 {
4885 
4886  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4887  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4888 
4889  const bool remainder( !usePadding || !IsPadded<MT>::value );
4890 
4891  for( size_t j=0UL; j<n_; ++j )
4892  {
4893  const size_t ibegin( ( IsLower<MT>::value )
4894  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
4895  :( 0UL ) );
4896  const size_t iend ( ( IsUpper<MT>::value )
4897  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4898  :( m_ ) );
4899  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4900 
4901  const size_t ipos( ( remainder )?( iend & size_t(-IT::size) ):( iend ) );
4902  BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (IT::size) ) ) == ipos, "Invalid end calculation" );
4903 
4904  size_t i( ibegin );
4905  typename MT::ConstIterator it( (~rhs).begin(j) + ibegin );
4906 
4907  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
4908  store( i , j, load(i ,j) + it.load() ); it += IT::size;
4909  store( i+IT::size , j, load(i+IT::size ,j) + it.load() ); it += IT::size;
4910  store( i+IT::size*2UL, j, load(i+IT::size*2UL,j) + it.load() ); it += IT::size;
4911  store( i+IT::size*3UL, j, load(i+IT::size*3UL,j) + it.load() ); it += IT::size;
4912  }
4913  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
4914  store( i, j, load(i,j) + it.load() );
4915  }
4916  for( ; remainder && i<iend; ++i, ++it ) {
4917  v_[i+j*mm_] += *it;
4918  }
4919  }
4920 }
4922 //*************************************************************************************************
4923 
4924 
4925 //*************************************************************************************************
4937 template< typename Type > // Data type of the matrix
4938 template< typename MT > // Type of the right-hand side dense matrix
4939 inline void DynamicMatrix<Type,true>::addAssign( const DenseMatrix<MT,false>& rhs )
4940 {
4942 
4943  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4944  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4945 
4946  const size_t block( BLOCK_SIZE );
4947 
4948  for( size_t jj=0UL; jj<n_; jj+=block ) {
4949  const size_t jend( min( n_, jj+block ) );
4950  for( size_t ii=0UL; ii<m_; ii+=block )
4951  {
4952  if( IsLower<MT>::value && ii < jj ) continue;
4953  if( IsUpper<MT>::value && ii > jj ) break;
4954 
4955  for( size_t j=jj; j<jend; ++j )
4956  {
4957  const size_t ibegin( ( IsLower<MT>::value )
4958  ?( max( ( IsStrictlyLower<MT>::value ? j+1UL : j ), ii ) )
4959  :( ii ) );
4960  const size_t iend ( ( IsUpper<MT>::value )
4961  ?( min( ( IsStrictlyUpper<MT>::value ? j : j+1UL ), m_, ii+block ) )
4962  :( min( m_, ii+block ) ) );
4963  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
4964 
4965  for( size_t i=ibegin; i<iend; ++i ) {
4966  v_[i+j*mm_] += (~rhs)(i,j);
4967  }
4968  }
4969  }
4970  }
4971 }
4973 //*************************************************************************************************
4974 
4975 
4976 //*************************************************************************************************
4988 template< typename Type > // Data type of the matrix
4989 template< typename MT > // Type of the right-hand side sparse matrix
4990 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,true>& rhs )
4991 {
4992  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
4993  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
4994 
4995  for( size_t j=0UL; j<(~rhs).columns(); ++j )
4996  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4997  v_[element->index()+j*mm_] += element->value();
4998 }
5000 //*************************************************************************************************
5001 
5002 
5003 //*************************************************************************************************
5015 template< typename Type > // Data type of the matrix
5016 template< typename MT > // Type of the right-hand side sparse matrix
5017 inline void DynamicMatrix<Type,true>::addAssign( const SparseMatrix<MT,false>& rhs )
5018 {
5020 
5021  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5022  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5023 
5024  for( size_t i=0UL; i<(~rhs).rows(); ++i )
5025  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5026  v_[i+element->index()*mm_] += element->value();
5027 }
5029 //*************************************************************************************************
5030 
5031 
5032 //*************************************************************************************************
5044 template< typename Type > // Data type of the matrix
5045 template< typename MT > // Type of the right-hand side dense matrix
5046 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5047  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
5048 {
5049  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5050  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5051 
5052  for( size_t j=0UL; j<n_; ++j )
5053  {
5054  if( IsDiagonal<MT>::value )
5055  {
5056  v_[j+j*mm_] -= (~rhs)(j,j);
5057  }
5058  else
5059  {
5060  const size_t ibegin( ( IsLower<MT>::value )
5061  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
5062  :( 0UL ) );
5063  const size_t iend ( ( IsUpper<MT>::value )
5064  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5065  :( m_ ) );
5066  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5067 
5068  size_t i( ibegin );
5069 
5070  for( ; (i+2UL) <= iend; i+=2UL ) {
5071  v_[i +j*mm_] -= (~rhs)(i ,j);
5072  v_[i+1+j*mm_] -= (~rhs)(i+1,j);
5073  }
5074  if( i < iend ) {
5075  v_[i+j*mm_] -= (~rhs)(i,j);
5076  }
5077  }
5078  }
5079 }
5081 //*************************************************************************************************
5082 
5083 
5084 //*************************************************************************************************
5097 template< typename Type > // Data type of the matrix
5098 template< typename MT > // Type of the right-hand side dense matrix
5099 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5100  DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,true>& rhs )
5101 {
5104 
5105  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5106  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5107 
5108  const bool remainder( !usePadding || !IsPadded<MT>::value );
5109 
5110  for( size_t j=0UL; j<n_; ++j )
5111  {
5112  const size_t ibegin( ( IsLower<MT>::value )
5113  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
5114  :( 0UL ) );
5115  const size_t iend ( ( IsUpper<MT>::value )
5116  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5117  :( m_ ) );
5118  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5119 
5120  const size_t ipos( ( remainder )?( iend & size_t(-IT::size) ):( iend ) );
5121  BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (IT::size) ) ) == ipos, "Invalid end calculation" );
5122 
5123  size_t i( ibegin );
5124  typename MT::ConstIterator it( (~rhs).begin(j) + ibegin );
5125 
5126  for( ; (i+IT::size*3UL) < ipos; i+=IT::size*4UL ) {
5127  store( i , j, load(i ,j) - it.load() ); it += IT::size;
5128  store( i+IT::size , j, load(i+IT::size ,j) - it.load() ); it += IT::size;
5129  store( i+IT::size*2UL, j, load(i+IT::size*2UL,j) - it.load() ); it += IT::size;
5130  store( i+IT::size*3UL, j, load(i+IT::size*3UL,j) - it.load() ); it += IT::size;
5131  }
5132  for( ; i<ipos; i+=IT::size, it+=IT::size ) {
5133  store( i, j, load(i,j) - it.load() );
5134  }
5135  for( ; remainder && i<iend; ++i, ++it ) {
5136  v_[i+j*mm_] -= *it;
5137  }
5138  }
5139 }
5141 //*************************************************************************************************
5142 
5143 
5144 //*************************************************************************************************
5156 template< typename Type > // Data type of the matrix
5157 template< typename MT > // Type of the right-hand side dense matrix
5158 inline void DynamicMatrix<Type,true>::subAssign( const DenseMatrix<MT,false>& rhs )
5159 {
5161 
5162  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5163  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5164 
5165  const size_t block( BLOCK_SIZE );
5166 
5167  for( size_t jj=0UL; jj<n_; jj+=block ) {
5168  const size_t jend( min( n_, jj+block ) );
5169  for( size_t ii=0UL; ii<m_; ii+=block )
5170  {
5171  if( IsLower<MT>::value && ii < jj ) continue;
5172  if( IsUpper<MT>::value && ii > jj ) break;
5173 
5174  for( size_t j=jj; j<jend; ++j )
5175  {
5176  const size_t ibegin( ( IsLower<MT>::value )
5177  ?( max( ( IsStrictlyLower<MT>::value ? j+1UL : j ), ii ) )
5178  :( ii ) );
5179  const size_t iend ( ( IsUpper<MT>::value )
5180  ?( min( ( IsStrictlyUpper<MT>::value ? j : j+1UL ), m_, ii+block ) )
5181  :( min( m_, ii+block ) ) );
5182  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5183 
5184  for( size_t i=ibegin; i<iend; ++i ) {
5185  v_[i+j*mm_] -= (~rhs)(i,j);
5186  }
5187  }
5188  }
5189  }
5190 }
5192 //*************************************************************************************************
5193 
5194 
5195 //*************************************************************************************************
5207 template< typename Type > // Data type of the matrix
5208 template< typename MT > // Type of the right-hand side sparse matrix
5209 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,true>& rhs )
5210 {
5211  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5212  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5213 
5214  for( size_t j=0UL; j<(~rhs).columns(); ++j )
5215  for( typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5216  v_[element->index()+j*mm_] -= element->value();
5217 }
5219 //*************************************************************************************************
5220 
5221 
5222 //*************************************************************************************************
5234 template< typename Type > // Data type of the matrix
5235 template< typename MT > // Type of the right-hand side sparse matrix
5236 inline void DynamicMatrix<Type,true>::subAssign( const SparseMatrix<MT,false>& rhs )
5237 {
5239 
5240  BLAZE_INTERNAL_ASSERT( m_ == (~rhs).rows() , "Invalid number of rows" );
5241  BLAZE_INTERNAL_ASSERT( n_ == (~rhs).columns(), "Invalid number of columns" );
5242 
5243  for( size_t i=0UL; i<(~rhs).rows(); ++i )
5244  for( typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5245  v_[i+element->index()*mm_] -= element->value();
5246 }
5248 //*************************************************************************************************
5249 
5250 
5251 
5252 
5253 
5254 
5255 
5256 
5257 //=================================================================================================
5258 //
5259 // DYNAMICMATRIX OPERATORS
5260 //
5261 //=================================================================================================
5262 
5263 //*************************************************************************************************
5266 template< typename Type, bool SO >
5267 inline void reset( DynamicMatrix<Type,SO>& m );
5268 
5269 template< typename Type, bool SO >
5270 inline void reset( DynamicMatrix<Type,SO>& m, size_t i );
5271 
5272 template< typename Type, bool SO >
5273 inline void clear( DynamicMatrix<Type,SO>& m );
5274 
5275 template< typename Type, bool SO >
5276 inline bool isDefault( const DynamicMatrix<Type,SO>& m );
5277 
5278 template< typename Type, bool SO >
5279 inline bool isIntact( const DynamicMatrix<Type,SO>& m );
5280 
5281 template< typename Type, bool SO >
5282 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */;
5283 
5284 template< typename Type, bool SO >
5285 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */;
5287 //*************************************************************************************************
5288 
5289 
5290 //*************************************************************************************************
5297 template< typename Type // Data type of the matrix
5298  , bool SO > // Storage order
5300 {
5301  m.reset();
5302 }
5303 //*************************************************************************************************
5304 
5305 
5306 //*************************************************************************************************
5319 template< typename Type // Data type of the matrix
5320  , bool SO > // Storage order
5321 inline void reset( DynamicMatrix<Type,SO>& m, size_t i )
5322 {
5323  m.reset( i );
5324 }
5325 //*************************************************************************************************
5326 
5327 
5328 //*************************************************************************************************
5335 template< typename Type // Data type of the matrix
5336  , bool SO > // Storage order
5338 {
5339  m.clear();
5340 }
5341 //*************************************************************************************************
5342 
5343 
5344 //*************************************************************************************************
5362 template< typename Type // Data type of the matrix
5363  , bool SO > // Storage order
5364 inline bool isDefault( const DynamicMatrix<Type,SO>& m )
5365 {
5366  return ( m.rows() == 0UL && m.columns() == 0UL );
5367 }
5368 //*************************************************************************************************
5369 
5370 
5371 //*************************************************************************************************
5389 template< typename Type // Data type of the matrix
5390  , bool SO > // Storage order
5391 inline bool isIntact( const DynamicMatrix<Type,SO>& m )
5392 {
5393  return ( m.rows() * m.columns() <= m.capacity() );
5394 }
5395 //*************************************************************************************************
5396 
5397 
5398 //*************************************************************************************************
5407 template< typename Type // Data type of the matrix
5408  , bool SO > // Storage order
5409 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) /* throw() */
5410 {
5411  a.swap( b );
5412 }
5413 //*************************************************************************************************
5414 
5415 
5416 //*************************************************************************************************
5425 template< typename Type // Data type of the matrix
5426  , bool SO > // Storage order
5427 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) /* throw() */
5428 {
5429  dst.swap( src );
5430 }
5431 //*************************************************************************************************
5432 
5433 
5434 
5435 
5436 //=================================================================================================
5437 //
5438 // HASCONSTDATAACCESS SPECIALIZATIONS
5439 //
5440 //=================================================================================================
5441 
5442 //*************************************************************************************************
5444 template< typename T, bool SO >
5445 struct HasConstDataAccess< DynamicMatrix<T,SO> > : public IsTrue<true>
5446 {};
5448 //*************************************************************************************************
5449 
5450 
5451 
5452 
5453 //=================================================================================================
5454 //
5455 // HASMUTABLEDATAACCESS SPECIALIZATIONS
5456 //
5457 //=================================================================================================
5458 
5459 //*************************************************************************************************
5461 template< typename T, bool SO >
5462 struct HasMutableDataAccess< DynamicMatrix<T,SO> > : public IsTrue<true>
5463 {};
5465 //*************************************************************************************************
5466 
5467 
5468 
5469 
5470 //=================================================================================================
5471 //
5472 // ISALIGNED SPECIALIZATIONS
5473 //
5474 //=================================================================================================
5475 
5476 //*************************************************************************************************
5478 template< typename T, bool SO >
5479 struct IsAligned< DynamicMatrix<T,SO> > : public IsTrue<usePadding>
5480 {};
5482 //*************************************************************************************************
5483 
5484 
5485 
5486 
5487 //=================================================================================================
5488 //
5489 // ISPADDED SPECIALIZATIONS
5490 //
5491 //=================================================================================================
5492 
5493 //*************************************************************************************************
5495 template< typename T, bool SO >
5496 struct IsPadded< DynamicMatrix<T,SO> > : public IsTrue<usePadding>
5497 {};
5499 //*************************************************************************************************
5500 
5501 
5502 
5503 
5504 //=================================================================================================
5505 //
5506 // ISRESIZABLE SPECIALIZATIONS
5507 //
5508 //=================================================================================================
5509 
5510 //*************************************************************************************************
5512 template< typename T, bool SO >
5513 struct IsResizable< DynamicMatrix<T,SO> > : public IsTrue<true>
5514 {};
5516 //*************************************************************************************************
5517 
5518 
5519 
5520 
5521 //=================================================================================================
5522 //
5523 // ADDTRAIT SPECIALIZATIONS
5524 //
5525 //=================================================================================================
5526 
5527 //*************************************************************************************************
5529 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5530 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5531 {
5532  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5533 };
5534 
5535 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5536 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5537 {
5538  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5539 };
5540 
5541 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5542 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5543 {
5544  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5545 };
5546 
5547 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5548 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5549 {
5550  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5551 };
5552 
5553 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5554 struct AddTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5555 {
5556  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5557 };
5558 
5559 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5560 struct AddTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5561 {
5562  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5563 };
5564 
5565 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5566 struct AddTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5567 {
5568  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5569 };
5570 
5571 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5572 struct AddTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5573 {
5574  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5575 };
5576 
5577 template< typename T1, bool SO, typename T2 >
5578 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5579 {
5580  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, SO > Type;
5581 };
5582 
5583 template< typename T1, bool SO1, typename T2, bool SO2 >
5584 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5585 {
5586  typedef DynamicMatrix< typename AddTrait<T1,T2>::Type, false > Type;
5587 };
5589 //*************************************************************************************************
5590 
5591 
5592 
5593 
5594 //=================================================================================================
5595 //
5596 // SUBTRAIT SPECIALIZATIONS
5597 //
5598 //=================================================================================================
5599 
5600 //*************************************************************************************************
5602 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5603 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
5604 {
5605  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5606 };
5607 
5608 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5609 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5610 {
5611  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5612 };
5613 
5614 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5615 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5616 {
5617  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5618 };
5619 
5620 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5621 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5622 {
5623  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5624 };
5625 
5626 template< typename T1, bool SO, typename T2, size_t M, size_t N >
5627 struct SubTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
5628 {
5629  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5630 };
5631 
5632 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5633 struct SubTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5634 {
5635  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5636 };
5637 
5638 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5639 struct SubTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
5640 {
5641  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5642 };
5643 
5644 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5645 struct SubTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5646 {
5647  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5648 };
5649 
5650 template< typename T1, bool SO, typename T2 >
5651 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5652 {
5653  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, SO > Type;
5654 };
5655 
5656 template< typename T1, bool SO1, typename T2, bool SO2 >
5657 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5658 {
5659  typedef DynamicMatrix< typename SubTrait<T1,T2>::Type, false > Type;
5660 };
5662 //*************************************************************************************************
5663 
5664 
5665 
5666 
5667 //=================================================================================================
5668 //
5669 // MULTTRAIT SPECIALIZATIONS
5670 //
5671 //=================================================================================================
5672 
5673 //*************************************************************************************************
5675 template< typename T1, bool SO, typename T2 >
5676 struct MultTrait< DynamicMatrix<T1,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
5677 {
5678  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5679 };
5680 
5681 template< typename T1, typename T2, bool SO >
5682 struct MultTrait< T1, DynamicMatrix<T2,SO>, typename EnableIf< IsNumeric<T1> >::Type >
5683 {
5684  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
5685 };
5686 
5687 template< typename T1, bool SO, typename T2, size_t N >
5688 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
5689 {
5690  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5691 };
5692 
5693 template< typename T1, size_t N, typename T2, bool SO >
5694 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
5695 {
5696  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5697 };
5698 
5699 template< typename T1, bool SO, typename T2, size_t N >
5700 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
5701 {
5702  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5703 };
5704 
5705 template< typename T1, size_t N, typename T2, bool SO >
5706 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
5707 {
5708  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5709 };
5710 
5711 template< typename T1, bool SO, typename T2 >
5712 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
5713 {
5714  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5715 };
5716 
5717 template< typename T1, typename T2, bool SO >
5718 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
5719 {
5720  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5721 };
5722 
5723 template< typename T1, bool SO, typename T2, bool AF, bool PF >
5724 struct MultTrait< DynamicMatrix<T1,SO>, CustomVector<T2,AF,PF,false> >
5725 {
5726  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5727 };
5728 
5729 template< typename T1, bool AF, bool PF, typename T2, bool SO >
5730 struct MultTrait< CustomVector<T1,AF,PF,true>, DynamicMatrix<T2,SO> >
5731 {
5732  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5733 };
5734 
5735 template< typename T1, bool SO, typename T2 >
5736 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
5737 {
5738  typedef DynamicVector< typename MultTrait<T1,T2>::Type, false > Type;
5739 };
5740 
5741 template< typename T1, typename T2, bool SO >
5742 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
5743 {
5744  typedef DynamicVector< typename MultTrait<T1,T2>::Type, true > Type;
5745 };
5746 
5747 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5748 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5749 {
5750  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5751 };
5752 
5753 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5754 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5755 {
5756  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5757 };
5758 
5759 template< typename T1, bool SO1, typename T2, size_t M, size_t N, bool SO2 >
5760 struct MultTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5761 {
5762  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5763 };
5764 
5765 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5766 struct MultTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5767 {
5768  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5769 };
5770 
5771 template< typename T1, bool SO1, typename T2, bool SO2 >
5772 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5773 {
5774  typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5775 };
5777 //*************************************************************************************************
5778 
5779 
5780 
5781 
5782 //=================================================================================================
5783 //
5784 // DIVTRAIT SPECIALIZATIONS
5785 //
5786 //=================================================================================================
5787 
5788 //*************************************************************************************************
5790 template< typename T1, bool SO, typename T2 >
5791 struct DivTrait< DynamicMatrix<T1,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
5792 {
5793  typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
5794 };
5796 //*************************************************************************************************
5797 
5798 
5799 
5800 
5801 //=================================================================================================
5802 //
5803 // MATHTRAIT SPECIALIZATIONS
5804 //
5805 //=================================================================================================
5806 
5807 //*************************************************************************************************
5809 template< typename T1, bool SO, typename T2 >
5810 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5811 {
5812  typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5813  typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5814 };
5816 //*************************************************************************************************
5817 
5818 
5819 
5820 
5821 //=================================================================================================
5822 //
5823 // SUBMATRIXTRAIT SPECIALIZATIONS
5824 //
5825 //=================================================================================================
5826 
5827 //*************************************************************************************************
5829 template< typename T1, bool SO >
5830 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
5831 {
5832  typedef DynamicMatrix<T1,SO> Type;
5833 };
5835 //*************************************************************************************************
5836 
5837 
5838 
5839 
5840 //=================================================================================================
5841 //
5842 // ROWTRAIT SPECIALIZATIONS
5843 //
5844 //=================================================================================================
5845 
5846 //*************************************************************************************************
5848 template< typename T1, bool SO >
5849 struct RowTrait< DynamicMatrix<T1,SO> >
5850 {
5851  typedef DynamicVector<T1,true> Type;
5852 };
5854 //*************************************************************************************************
5855 
5856 
5857 
5858 
5859 //=================================================================================================
5860 //
5861 // COLUMNTRAIT SPECIALIZATIONS
5862 //
5863 //=================================================================================================
5864 
5865 //*************************************************************************************************
5867 template< typename T1, bool SO >
5868 struct ColumnTrait< DynamicMatrix<T1,SO> >
5869 {
5870  typedef DynamicVector<T1,false> Type;
5871 };
5873 //*************************************************************************************************
5874 
5875 } // namespace blaze
5876 
5877 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:118
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
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: DynamicMatrix.h:741
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:445
Header file for kernel specific block sizes.
Header file for mathematical functions.
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1610
#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 alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:962
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:448
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
Header file for the IsSparseMatrix type trait.
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1534
Header file for the IsDiagonal type trait.
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:2070
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:1328
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Optimizations.h:68
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2749
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:584
#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:486
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1937
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Header file for memory allocation and deallocation functionality.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DynamicMatrix.h:1347
void move(CustomMatrix< Type, AF, PF, SO > &dst, CustomMatrix< Type, AF, PF, SO > &src)
Moving the contents of one custom matrix to another.
Definition: CustomMatrix.h:6085
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:195
EnableIf< IsBuiltin< T >, T * >::Type allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:152
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:211
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:117
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2751
BLAZE_ALWAYS_INLINE void storea(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:2000
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:713
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:205
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1874
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:1397
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1762
DenseIterator< Type, usePadding > Iterator
Iterator over non-constant elements.
Definition: DynamicMatrix.h:218
Header file for the DisableIf class template.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:74
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:1028
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1830
DynamicMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: DynamicMatrix.h:1679
Header file for the clear shim.
BLAZE_ALWAYS_INLINE IntrinsicType loada(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1902
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:208
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const simd_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:75
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:116
Header file for the IsSMPAssignable type trait.
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:75
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: DynamicMatrix.h:199
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:204
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Header file for the DenseMatrix base class.
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:227
Header file for the DenseIterator class template.
BLAZE_ALWAYS_INLINE void conjugate(T &a)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
const CTransExprTrait< MT >::Type ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatConjExpr.h:974
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:210
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:116
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:92
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1592
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1314
#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:1447
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:984
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
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:532
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the IsPadded type trait.
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:206
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1361
Header file for the IsVectorizable type trait.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:446
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loada(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loada.h:77
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:215
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:1232
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.
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1491
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:216
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
const bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
size_t m_
The current number of rows of the matrix.
Definition: DynamicMatrix.h:444
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:918
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:2036
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:1812
const bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
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:2591
Header file for the column trait.
Header file for the isDefault shim.
System settings for the restrict keyword.
Header file for the TransExprTrait class template.
Constraint on the data type.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
Constraint on the data type.
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1743
Header file for the HasMutableDataAccess type trait.
Evaluation of the return type of a conjugate transpose expression.Via this type trait it is possible ...
Definition: CTransExprTrait.h:87
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:59
Header file for all intrinsic functionality.
Header file for the mathematical trait.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Type & Reference
Reference to a non-constant matrix value.
Definition: DynamicMatrix.h:213
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const IntrinsicType &value)
Store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1971
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:1849
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2750
Evaluation of the return type of a transpose expression.Via this type trait it is possible to evaluat...
Definition: TransExprTrait.h:87
DenseIterator< const Type, usePadding > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:219
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
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
Header file for the alignment check function.
BLAZE_ALWAYS_INLINE void cswap(T &a, T &b)
Swapping two conjugated values/objects.
Definition: Conjugate.h:197
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: DynamicMatrix.h:209
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:447
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const simd_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:74
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
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:226
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2599
Header file for the IsUpper type trait.
Header file for exception macros.
Header file for the CTransExprTrait class template.
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
Pointer data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:840
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: DynamicMatrix.h:786
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: DynamicMatrix.h:1792
DynamicMatrix< ET, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:227
DynamicMatrix & transpose()
In-place transpose of the matrix.
Definition: DynamicMatrix.h:1641
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:214
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:207
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storea(T *address, const simd_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Storea.h:78
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558
Header file for a safe C++ NULL pointer implementation.