All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HybridMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
36 #define _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <cmath>
45 #include <stdexcept>
49 #include <blaze/math/Forward.h>
50 #include <blaze/math/Functions.h>
51 #include <blaze/math/Intrinsics.h>
53 #include <blaze/math/shims/Reset.h>
67 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Memory.h>
79 #include <blaze/util/Template.h>
80 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS DEFINITION
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
181 template< typename Type // Data type of the matrix
182  , size_t M // Number of rows
183  , size_t N // Number of columns
184  , bool SO = defaultStorageOrder > // Storage order
185 class HybridMatrix : public DenseMatrix< HybridMatrix<Type,M,N,SO>, SO >
186 {
187  private:
188  //**Type definitions****************************************************************************
190  //**********************************************************************************************
191 
192  //**********************************************************************************************
194  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
195  //**********************************************************************************************
196 
197  public:
198  //**Type definitions****************************************************************************
200  typedef This ResultType;
203  typedef Type ElementType;
204  typedef typename IT::Type IntrinsicType;
205  typedef const Type& ReturnType;
206  typedef const This& CompositeType;
207  typedef Type& Reference;
208  typedef const Type& ConstReference;
209  typedef Type* Pointer;
210  typedef const Type* ConstPointer;
213  //**********************************************************************************************
214 
215  //**Compilation flags***************************************************************************
217 
221  enum { vectorizable = IsVectorizable<Type>::value };
222 
224 
227  enum { smpAssignable = 0 };
228  //**********************************************************************************************
229 
230  //**Constructors********************************************************************************
233  explicit inline HybridMatrix();
234  explicit inline HybridMatrix( size_t m, size_t n );
235  explicit inline HybridMatrix( size_t m, size_t n, const Type& init );
236  template< typename Other > explicit inline HybridMatrix( size_t m, size_t n, const Other* array );
237 
238  template< typename Other, size_t M2, size_t N2 >
239  explicit inline HybridMatrix( const Other (&array)[M2][N2] );
240 
241  inline HybridMatrix( const HybridMatrix& m );
242  template< typename MT, bool SO2 > inline HybridMatrix( const Matrix<MT,SO2>& m );
244  //**********************************************************************************************
245 
246  //**Destructor**********************************************************************************
247  // No explicitly declared destructor.
248  //**********************************************************************************************
249 
250  //**Data access functions***********************************************************************
253  inline Reference operator()( size_t i, size_t j );
254  inline ConstReference operator()( size_t i, size_t j ) const;
255  inline Pointer data ();
256  inline ConstPointer data () const;
257  inline Pointer data ( size_t i );
258  inline ConstPointer data ( size_t i ) const;
259  inline Iterator begin ( size_t i );
260  inline ConstIterator begin ( size_t i ) const;
261  inline ConstIterator cbegin( size_t i ) const;
262  inline Iterator end ( size_t i );
263  inline ConstIterator end ( size_t i ) const;
264  inline ConstIterator cend ( size_t i ) const;
266  //**********************************************************************************************
267 
268  //**Assignment operators************************************************************************
271  template< typename Other, size_t M2, size_t N2 >
272  inline HybridMatrix& operator=( const Other (&array)[M2][N2] );
273 
274  inline HybridMatrix& operator= ( const Type& set );
275  inline HybridMatrix& operator= ( const HybridMatrix& rhs );
276  template< typename MT, bool SO2 > inline HybridMatrix& operator= ( const Matrix<MT,SO2>& rhs );
277  template< typename MT, bool SO2 > inline HybridMatrix& operator+=( const Matrix<MT,SO2>& rhs );
278  template< typename MT, bool SO2 > inline HybridMatrix& operator-=( const Matrix<MT,SO2>& rhs );
279  template< typename MT, bool SO2 > inline HybridMatrix& operator*=( const Matrix<MT,SO2>& rhs );
280 
281  template< typename Other >
282  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
283  operator*=( Other rhs );
284 
285  template< typename Other >
286  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
287  operator/=( Other rhs );
289  //**********************************************************************************************
290 
291  //**Utility functions***************************************************************************
294  inline size_t rows() const;
295  inline size_t columns() const;
296  inline size_t spacing() const;
297  inline size_t capacity() const;
298  inline size_t capacity( size_t i ) const;
299  inline size_t nonZeros() const;
300  inline size_t nonZeros( size_t i ) const;
301  inline void reset();
302  inline void reset( size_t i );
303  inline void clear();
304  void resize ( size_t m, size_t n, bool preserve=true );
305  inline void extend ( size_t m, size_t n, bool preserve=true );
306  inline HybridMatrix& transpose();
307  template< typename Other > inline HybridMatrix& scale( const Other& scalar );
308  inline void swap( HybridMatrix& m ) /* throw() */;
310  //**********************************************************************************************
311 
312  //**Memory functions****************************************************************************
315  static inline void* operator new ( std::size_t size );
316  static inline void* operator new[]( std::size_t size );
317  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
318  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
319 
320  static inline void operator delete ( void* ptr );
321  static inline void operator delete[]( void* ptr );
322  static inline void operator delete ( void* ptr, const std::nothrow_t& );
323  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
325  //**********************************************************************************************
326 
327  private:
328  //**********************************************************************************************
330  template< typename MT >
332  struct VectorizedAssign {
333  enum { value = vectorizable && MT::vectorizable &&
334  IsSame<Type,typename MT::ElementType>::value &&
335  IsRowMajorMatrix<MT>::value };
336  };
338  //**********************************************************************************************
339 
340  //**********************************************************************************************
342  template< typename MT >
344  struct VectorizedAddAssign {
345  enum { value = vectorizable && MT::vectorizable &&
346  IsSame<Type,typename MT::ElementType>::value &&
347  IntrinsicTrait<Type>::addition &&
348  IsRowMajorMatrix<MT>::value };
349  };
351  //**********************************************************************************************
352 
353  //**********************************************************************************************
355  template< typename MT >
357  struct VectorizedSubAssign {
358  enum { value = vectorizable && MT::vectorizable &&
359  IsSame<Type,typename MT::ElementType>::value &&
360  IntrinsicTrait<Type>::subtraction &&
361  IsRowMajorMatrix<MT>::value };
362  };
364  //**********************************************************************************************
365 
366  public:
367  //**Expression template evaluation functions****************************************************
370  template< typename Other > inline bool canAlias ( const Other* alias ) const;
371  template< typename Other > inline bool isAliased( const Other* alias ) const;
372 
373  inline bool isAligned() const;
374 
375  inline IntrinsicType load ( size_t i, size_t j ) const;
376  inline IntrinsicType loadu ( size_t i, size_t j ) const;
377  inline void store ( size_t i, size_t j, const IntrinsicType& value );
378  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
379  inline void stream( size_t i, size_t j, const IntrinsicType& value );
380 
381  template< typename MT, bool SO2 >
382  inline typename DisableIf< VectorizedAssign<MT> >::Type
383  assign( const DenseMatrix<MT,SO2>& rhs );
384 
385  template< typename MT, bool SO2 >
386  inline typename EnableIf< VectorizedAssign<MT> >::Type
387  assign( const DenseMatrix<MT,SO2>& rhs );
388 
389  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
390  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
391 
392  template< typename MT, bool SO2 >
393  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
394  addAssign( const DenseMatrix<MT,SO2>& rhs );
395 
396  template< typename MT, bool SO2 >
397  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
398  addAssign( const DenseMatrix<MT,SO2>& rhs );
399 
400  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
401  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
402 
403  template< typename MT, bool SO2 >
404  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
405  subAssign( const DenseMatrix<MT,SO2>& rhs );
406 
407  template< typename MT, bool SO2 >
408  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
409  subAssign( const DenseMatrix<MT,SO2>& rhs );
410 
411  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
412  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
414  //**********************************************************************************************
415 
416  private:
417  //**Member variables****************************************************************************
421 
430  size_t m_;
431  size_t n_;
432 
433  //**********************************************************************************************
434 
435  //**Compile time checks*************************************************************************
441  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
442  BLAZE_STATIC_ASSERT( NN >= N );
444  //**********************************************************************************************
445 };
446 //*************************************************************************************************
447 
448 
449 
450 
451 //=================================================================================================
452 //
453 // CONSTRUCTORS
454 //
455 //=================================================================================================
456 
457 //*************************************************************************************************
462 template< typename Type // Data type of the matrix
463  , size_t M // Number of rows
464  , size_t N // Number of columns
465  , bool SO > // Storage order
467  : v_() // The statically allocated matrix elements
468  , m_( 0UL ) // The current number of rows of the matrix
469  , n_( 0UL ) // The current number of columns of the matrix
470 {
472  for( size_t i=0UL; i<M*NN; ++i )
473  v_[i] = Type();
474  }
475 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
492 template< typename Type // Data type of the matrix
493  , size_t M // Number of rows
494  , size_t N // Number of columns
495  , bool SO > // Storage order
496 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n )
497  : v_() // The statically allocated matrix elements
498  , m_( m ) // The current number of rows of the matrix
499  , n_( n ) // The current number of columns of the matrix
500 {
501  if( m > M )
502  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
503 
504  if( n > N )
505  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
506 
508  for( size_t i=0UL; i<M*NN; ++i )
509  v_[i] = Type();
510  }
511 }
512 //*************************************************************************************************
513 
514 
515 //*************************************************************************************************
529 template< typename Type // Data type of the matrix
530  , size_t M // Number of rows
531  , size_t N // Number of columns
532  , bool SO > // Storage order
533 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n, const Type& init )
534  : v_() // The statically allocated matrix elements
535  , m_( m ) // The current number of rows of the matrix
536  , n_( n ) // The current number of columns of the matrix
537 {
538  if( m > M )
539  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
540 
541  if( n > N )
542  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
543 
544  for( size_t i=0UL; i<m; ++i ) {
545  for( size_t j=0UL; j<n; ++j )
546  v_[i*NN+j] = init;
547 
549  for( size_t j=n; j<NN; ++j )
550  v_[i*NN+j] = Type();
551  }
552  }
553 
555  for( size_t i=m; i<M; ++i )
556  for( size_t j=0UL; j<NN; ++j )
557  v_[i*NN+j] = Type();
558  }
559 }
560 //*************************************************************************************************
561 
562 
563 //*************************************************************************************************
590 template< typename Type // Data type of the matrix
591  , size_t M // Number of rows
592  , size_t N // Number of columns
593  , bool SO > // Storage order
594 template< typename Other > // Data type of the initialization array
595 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n, const Other* array )
596  : v_() // The statically allocated matrix elements
597  , m_( m ) // The current number of rows of the matrix
598  , n_( n ) // The current number of columns of the matrix
599 {
600  if( m > M )
601  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
602 
603  if( n > N )
604  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
605 
606  for( size_t i=0UL; i<m; ++i ) {
607  for( size_t j=0UL; j<n; ++j )
608  v_[i*NN+j] = array[i*n+j];
609 
611  for( size_t j=n; j<NN; ++j )
612  v_[i*NN+j] = Type();
613  }
614  }
615 
617  for( size_t i=m; i<M; ++i )
618  for( size_t j=0UL; j<NN; ++j )
619  v_[i*NN+j] = Type();
620  }
621 }
622 //*************************************************************************************************
623 
624 
625 //*************************************************************************************************
646 template< typename Type // Data type of the matrix
647  , size_t M // Number of rows
648  , size_t N // Number of columns
649  , bool SO > // Storage order
650 template< typename Other // Data type of the initialization array
651  , size_t M2 // Number of rows of the initialization array
652  , size_t N2 > // Number of columns of the initialization array
653 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( const Other (&array)[M2][N2] )
654  : v_() // The statically allocated matrix elements
655  , m_( M2 ) // The current number of rows of the matrix
656  , n_( N2 ) // The current number of columns of the matrix
657 {
658  BLAZE_STATIC_ASSERT( M2 <= M );
659  BLAZE_STATIC_ASSERT( N2 <= N );
660 
661  for( size_t i=0UL; i<M2; ++i ) {
662  for( size_t j=0UL; j<N2; ++j )
663  v_[i*NN+j] = array[i][j];
664 
666  for( size_t j=N2; j<NN; ++j )
667  v_[i*NN+j] = Type();
668  }
669  }
670 
672  for( size_t i=M2; i<M; ++i )
673  for( size_t j=0UL; j<NN; ++j )
674  v_[i*NN+j] = Type();
675  }
676 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
688 template< typename Type // Data type of the matrix
689  , size_t M // Number of rows
690  , size_t N // Number of columns
691  , bool SO > // Storage order
693  : v_() // The statically allocated matrix elements
694  , m_( m.m_ ) // The current number of rows of the matrix
695  , n_( m.n_ ) // The current number of columns of the matrix
696 {
697  for( size_t i=0UL; i<m_; ++i ) {
698  for( size_t j=0UL; j<n_; ++j )
699  v_[i*NN+j] = m.v_[i*NN+j];
700 
702  for( size_t j=n_; j<NN; ++j )
703  v_[i*NN+j] = Type();
704  }
705  }
706 
708  for( size_t i=m_; i<M; ++i )
709  for( size_t j=0UL; j<NN; ++j )
710  v_[i*NN+j] = Type();
711  }
712 }
713 //*************************************************************************************************
714 
715 
716 //*************************************************************************************************
722 template< typename Type // Data type of the matrix
723  , size_t M // Number of rows
724  , size_t N // Number of columns
725  , bool SO > // Storage order
726 template< typename MT // Type of the foreign matrix
727  , bool SO2 > // Storage order of the foreign matrix
729  : v_() // The statically allocated matrix elements
730  , m_( (~m).rows() ) // The current number of rows of the matrix
731  , n_( (~m).columns() ) // The current number of columns of the matrix
732 {
733  using blaze::assign;
734 
735  if( (~m).rows() > M || (~m).columns() > N )
736  throw std::invalid_argument( "Invalid setup of hybrid matrix" );
737 
738  for( size_t i=0UL; i<m_; ++i ) {
739  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : n_ );
740  j<( IsVectorizable<Type>::value ? NN : n_ ); ++j ) {
741  v_[i*NN+j] = Type();
742  }
743  }
744 
746  for( size_t i=m_; i<M; ++i )
747  for( size_t j=0UL; j<NN; ++j )
748  v_[i*NN+j] = Type();
749  }
750 
751  assign( *this, ~m );
752 }
753 //*************************************************************************************************
754 
755 
756 
757 
758 //=================================================================================================
759 //
760 // DATA ACCESS FUNCTIONS
761 //
762 //=================================================================================================
763 
764 //*************************************************************************************************
771 template< typename Type // Data type of the matrix
772  , size_t M // Number of rows
773  , size_t N // Number of columns
774  , bool SO > // Storage order
777 {
778  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
779  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
780  return v_[i*NN+j];
781 }
782 //*************************************************************************************************
783 
784 
785 //*************************************************************************************************
792 template< typename Type // Data type of the matrix
793  , size_t M // Number of rows
794  , size_t N // Number of columns
795  , bool SO > // Storage order
797  HybridMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
798 {
799  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
800  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
801  return v_[i*NN+j];
802 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
818 template< typename Type // Data type of the matrix
819  , size_t M // Number of rows
820  , size_t N // Number of columns
821  , bool SO > // Storage order
824 {
825  return v_;
826 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
842 template< typename Type // Data type of the matrix
843  , size_t M // Number of rows
844  , size_t N // Number of columns
845  , bool SO > // Storage order
848 {
849  return v_;
850 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
862 template< typename Type // Data type of the matrix
863  , size_t M // Number of rows
864  , size_t N // Number of columns
865  , bool SO > // Storage order
868 {
869  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
870  return v_ + i*NN;
871 }
872 //*************************************************************************************************
873 
874 
875 //*************************************************************************************************
883 template< typename Type // Data type of the matrix
884  , size_t M // Number of rows
885  , size_t N // Number of columns
886  , bool SO > // Storage order
889 {
890  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
891  return v_ + i*NN;
892 }
893 //*************************************************************************************************
894 
895 
896 //*************************************************************************************************
907 template< typename Type // Data type of the matrix
908  , size_t M // Number of rows
909  , size_t N // Number of columns
910  , bool SO > // Storage order
913 {
914  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
915  return Iterator( v_ + i*NN );
916 }
917 //*************************************************************************************************
918 
919 
920 //*************************************************************************************************
931 template< typename Type // Data type of the matrix
932  , size_t M // Number of rows
933  , size_t N // Number of columns
934  , bool SO > // Storage order
937 {
938  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
939  return ConstIterator( v_ + i*NN );
940 }
941 //*************************************************************************************************
942 
943 
944 //*************************************************************************************************
955 template< typename Type // Data type of the matrix
956  , size_t M // Number of rows
957  , size_t N // Number of columns
958  , bool SO > // Storage order
961 {
962  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
963  return ConstIterator( v_ + i*NN );
964 }
965 //*************************************************************************************************
966 
967 
968 //*************************************************************************************************
979 template< typename Type // Data type of the matrix
980  , size_t M // Number of rows
981  , size_t N // Number of columns
982  , bool SO > // Storage order
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  , size_t M // Number of rows
1005  , size_t N // Number of columns
1006  , bool SO > // Storage order
1009 {
1010  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1011  return ConstIterator( v_ + i*NN + N );
1012 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1027 template< typename Type // Data type of the matrix
1028  , size_t M // Number of rows
1029  , size_t N // Number of columns
1030  , bool SO > // Storage order
1033 {
1034  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1035  return ConstIterator( v_ + i*NN + N );
1036 }
1037 //*************************************************************************************************
1038 
1039 
1040 
1041 
1042 //=================================================================================================
1043 //
1044 // ASSIGNMENT OPERATORS
1045 //
1046 //=================================================================================================
1047 
1048 //*************************************************************************************************
1069 template< typename Type // Data type of the matrix
1070  , size_t M // Number of rows
1071  , size_t N // Number of columns
1072  , bool SO > // Storage order
1073 template< typename Other // Data type of the initialization array
1074  , size_t M2 // Number of rows of the initialization array
1075  , size_t N2 > // Number of columns of the initialization array
1077 {
1078  BLAZE_STATIC_ASSERT( M2 <= M );
1079  BLAZE_STATIC_ASSERT( N2 <= N );
1080 
1081  resize( M2, N2 );
1082 
1083  for( size_t i=0UL; i<M2; ++i )
1084  for( size_t j=0UL; j<N2; ++j )
1085  v_[i*NN+j] = array[i][j];
1086 
1087  return *this;
1088 }
1089 //*************************************************************************************************
1090 
1091 
1092 //*************************************************************************************************
1098 template< typename Type // Data type of the matrix
1099  , size_t M // Number of rows
1100  , size_t N // Number of columns
1101  , bool SO > // Storage order
1103 {
1104  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
1105  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
1106 
1107  for( size_t i=0UL; i<m_; ++i )
1108  for( size_t j=0UL; j<n_; ++j )
1109  v_[i*NN+j] = set;
1110 
1111  return *this;
1112 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1124 template< typename Type // Data type of the matrix
1125  , size_t M // Number of rows
1126  , size_t N // Number of columns
1127  , bool SO > // Storage order
1129 {
1130  using blaze::assign;
1131 
1132  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
1133  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
1134 
1135  resize( rhs.rows(), rhs.columns() );
1136  assign( *this, ~rhs );
1137 
1138  return *this;
1139 }
1140 //*************************************************************************************************
1141 
1142 
1143 //*************************************************************************************************
1154 template< typename Type // Data type of the matrix
1155  , size_t M // Number of rows
1156  , size_t N // Number of columns
1157  , bool SO > // Storage order
1158 template< typename MT // Type of the right-hand side matrix
1159  , bool SO2 > // Storage order of the right-hand side matrix
1161 {
1162  using blaze::assign;
1163 
1164  if( (~rhs).rows() > M || (~rhs).columns() > N )
1165  throw std::invalid_argument( "Invalid assignment to hybrid matrix" );
1166 
1167  if( (~rhs).canAlias( this ) ) {
1168  HybridMatrix tmp( ~rhs );
1169  swap( tmp );
1170  }
1171  else {
1172  resize( (~rhs).rows(), (~rhs).columns() );
1174  reset();
1175  assign( *this, ~rhs );
1176  }
1177 
1178  return *this;
1179 }
1180 //*************************************************************************************************
1181 
1182 
1183 //*************************************************************************************************
1193 template< typename Type // Data type of the matrix
1194  , size_t M // Number of rows
1195  , size_t N // Number of columns
1196  , bool SO > // Storage order
1197 template< typename MT // Type of the right-hand side matrix
1198  , bool SO2 > // Storage order of the right-hand side matrix
1200 {
1201  using blaze::addAssign;
1202 
1203  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1204  throw std::invalid_argument( "Matrix sizes do not match" );
1205 
1206  if( (~rhs).canAlias( this ) ) {
1207  typename MT::ResultType tmp( ~rhs );
1208  addAssign( *this, tmp );
1209  }
1210  else {
1211  addAssign( *this, ~rhs );
1212  }
1213 
1214  return *this;
1215 }
1216 //*************************************************************************************************
1217 
1218 
1219 //*************************************************************************************************
1229 template< typename Type // Data type of the matrix
1230  , size_t M // Number of rows
1231  , size_t N // Number of columns
1232  , bool SO > // Storage order
1233 template< typename MT // Type of the right-hand side matrix
1234  , bool SO2 > // Storage order of the right-hand side matrix
1236 {
1237  using blaze::subAssign;
1238 
1239  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1240  throw std::invalid_argument( "Matrix sizes do not match" );
1241 
1242  if( (~rhs).canAlias( this ) ) {
1243  typename MT::ResultType tmp( ~rhs );
1244  subAssign( *this, tmp );
1245  }
1246  else {
1247  subAssign( *this, ~rhs );
1248  }
1249 
1250  return *this;
1251 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1265 template< typename Type // Data type of the matrix
1266  , size_t M // Number of rows
1267  , size_t N // Number of columns
1268  , bool SO > // Storage order
1269 template< typename MT // Type of the right-hand side matrix
1270  , bool SO2 > // Storage order of the right-hand side matrix
1272 {
1273  if( n_ != (~rhs).rows() || (~rhs).columns() > N )
1274  throw std::invalid_argument( "Matrix sizes do not match" );
1275 
1276  HybridMatrix tmp( *this * (~rhs) );
1277  return this->operator=( tmp );
1278 }
1279 //*************************************************************************************************
1280 
1281 
1282 //*************************************************************************************************
1289 template< typename Type // Data type of the matrix
1290  , size_t M // Number of rows
1291  , size_t N // Number of columns
1292  , bool SO > // Storage order
1293 template< typename Other > // Data type of the right-hand side scalar
1294 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,SO> >::Type&
1296 {
1297  using blaze::assign;
1298 
1299  assign( *this, (*this) * rhs );
1300  return *this;
1301 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1314 template< typename Type // Data type of the matrix
1315  , size_t M // Number of rows
1316  , size_t N // Number of columns
1317  , bool SO > // Storage order
1318 template< typename Other > // Data type of the right-hand side scalar
1319 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,SO> >::Type&
1321 {
1322  using blaze::assign;
1323 
1324  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1325 
1326  assign( *this, (*this) / rhs );
1327  return *this;
1328 }
1329 //*************************************************************************************************
1330 
1331 
1332 
1333 
1334 //=================================================================================================
1335 //
1336 // UTILITY FUNCTIONS
1337 //
1338 //=================================================================================================
1339 
1340 //*************************************************************************************************
1345 template< typename Type // Data type of the matrix
1346  , size_t M // Number of rows
1347  , size_t N // Number of columns
1348  , bool SO > // Storage order
1349 inline size_t HybridMatrix<Type,M,N,SO>::rows() const
1350 {
1351  return m_;
1352 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1361 template< typename Type // Data type of the matrix
1362  , size_t M // Number of rows
1363  , size_t N // Number of columns
1364  , bool SO > // Storage order
1366 {
1367  return n_;
1368 }
1369 //*************************************************************************************************
1370 
1371 
1372 //*************************************************************************************************
1380 template< typename Type // Data type of the matrix
1381  , size_t M // Number of rows
1382  , size_t N // Number of columns
1383  , bool SO > // Storage order
1385 {
1386  return NN;
1387 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1396 template< typename Type // Data type of the matrix
1397  , size_t M // Number of rows
1398  , size_t N // Number of columns
1399  , bool SO > // Storage order
1401 {
1402  return M*NN;
1403 }
1404 //*************************************************************************************************
1405 
1406 
1407 //*************************************************************************************************
1418 template< typename Type // Data type of the matrix
1419  , size_t M // Number of rows
1420  , size_t N // Number of columns
1421  , bool SO > // Storage order
1422 inline size_t HybridMatrix<Type,M,N,SO>::capacity( size_t i ) const
1423 {
1424  UNUSED_PARAMETER( i );
1425 
1426  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1427 
1428  return NN;
1429 }
1430 //*************************************************************************************************
1431 
1432 
1433 //*************************************************************************************************
1438 template< typename Type // Data type of the matrix
1439  , size_t M // Number of rows
1440  , size_t N // Number of columns
1441  , bool SO > // Storage order
1443 {
1444  size_t nonzeros( 0UL );
1445 
1446  for( size_t i=0UL; i<m_; ++i )
1447  for( size_t j=0UL; j<n_; ++j )
1448  if( !isDefault( v_[i*NN+j] ) )
1449  ++nonzeros;
1450 
1451  return nonzeros;
1452 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1467 template< typename Type // Data type of the matrix
1468  , size_t M // Number of rows
1469  , size_t N // Number of columns
1470  , bool SO > // Storage order
1471 inline size_t HybridMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
1472 {
1473  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1474 
1475  const size_t jend( i*NN+n_ );
1476  size_t nonzeros( 0UL );
1477 
1478  for( size_t j=i*NN; j<jend; ++j )
1479  if( !isDefault( v_[j] ) )
1480  ++nonzeros;
1481 
1482  return nonzeros;
1483 }
1484 //*************************************************************************************************
1485 
1486 
1487 //*************************************************************************************************
1492 template< typename Type // Data type of the matrix
1493  , size_t M // Number of rows
1494  , size_t N // Number of columns
1495  , bool SO > // Storage order
1497 {
1498  using blaze::reset;
1499 
1500  for( size_t i=0UL; i<m_; ++i )
1501  for( size_t j=0UL; j<n_; ++j )
1502  reset( v_[i*NN+j] );
1503 }
1504 //*************************************************************************************************
1505 
1506 
1507 //*************************************************************************************************
1518 template< typename Type // Data type of the matrix
1519  , size_t M // Number of rows
1520  , size_t N // Number of columns
1521  , bool SO > // Storage order
1522 inline void HybridMatrix<Type,M,N,SO>::reset( size_t i )
1523 {
1524  using blaze::reset;
1525 
1526  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1527  for( size_t j=0UL; j<n_; ++j )
1528  reset( v_[i*NN+j] );
1529 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1540 template< typename Type // Data type of the matrix
1541  , size_t M // Number of rows
1542  , size_t N // Number of columns
1543  , bool SO > // Storage order
1545 {
1546  resize( 0UL, 0UL );
1547 }
1548 //*************************************************************************************************
1549 
1550 
1551 //*************************************************************************************************
1587 template< typename Type // Data type of the matrix
1588  , size_t M // Number of rows
1589  , size_t N // Number of columns
1590  , bool SO > // Storage order
1591 void HybridMatrix<Type,M,N,SO>::resize( size_t m, size_t n, bool preserve )
1592 {
1593  UNUSED_PARAMETER( preserve );
1594 
1595  if( m > M )
1596  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
1597 
1598  if( n > N )
1599  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
1600 
1601  if( IsVectorizable<Type>::value && n < n_ ) {
1602  for( size_t i=0UL; i<m; ++i )
1603  for( size_t j=n; j<n_; ++j )
1604  v_[i*NN+j] = Type();
1605  }
1606 
1607  if( IsVectorizable<Type>::value && m < m_ ) {
1608  for( size_t i=m; i<m_; ++i )
1609  for( size_t j=0UL; j<n_; ++j )
1610  v_[i*NN+j] = Type();
1611  }
1612 
1613  m_ = m;
1614  n_ = n;
1615 }
1616 //*************************************************************************************************
1617 
1618 
1619 //*************************************************************************************************
1634 template< typename Type // Data type of the matrix
1635  , size_t M // Number of rows
1636  , size_t N // Number of columns
1637  , bool SO > // Storage order
1638 inline void HybridMatrix<Type,M,N,SO>::extend( size_t m, size_t n, bool preserve )
1639 {
1640  UNUSED_PARAMETER( preserve );
1641  resize( m_+m, n_+n );
1642 }
1643 //*************************************************************************************************
1644 
1645 
1646 //*************************************************************************************************
1657 template< typename Type // Data type of the matrix
1658  , size_t M // Number of rows
1659  , size_t N // Number of columns
1660  , bool SO > // Storage order
1662 {
1663  using std::swap;
1664 
1665  if( m_ > N || n_ > M )
1666  throw std::logic_error( "Impossible transpose operation" );
1667 
1668  const size_t maxsize( max( m_, n_ ) );
1669  for( size_t i=1UL; i<maxsize; ++i )
1670  for( size_t j=0UL; j<i; ++j )
1671  swap( v_[i*NN+j], v_[j*NN+i] );
1672 
1673  if( IsVectorizable<Type>::value && m_ < n_ ) {
1674  for( size_t i=0UL; i<m_; ++i ) {
1675  for( size_t j=m_; j<n_; ++j ) {
1676  v_[i*NN+j] = Type();
1677  }
1678  }
1679  }
1680 
1681  if( IsVectorizable<Type>::value && m_ > n_ ) {
1682  for( size_t i=n_; i<m_; ++i ) {
1683  for( size_t j=0UL; j<n_; ++j ) {
1684  v_[i*NN+j] = Type();
1685  }
1686  }
1687  }
1688 
1689  swap( m_, n_ );
1690 
1691  return *this;
1692 }
1693 //*************************************************************************************************
1694 
1695 
1696 //*************************************************************************************************
1702 template< typename Type // Data type of the matrix
1703  , size_t M // Number of rows
1704  , size_t N // Number of columns
1705  , bool SO > // Storage order
1706 template< typename Other > // Data type of the scalar value
1708 {
1709  for( size_t i=0UL; i<m_; ++i )
1710  for( size_t j=0UL; j<n_; ++j )
1711  v_[i*NN+j] *= scalar;
1712 
1713  return *this;
1714 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1725 template< typename Type // Data type of the matrix
1726  , size_t M // Number of rows
1727  , size_t N // Number of columns
1728  , bool SO > // Storage order
1729 inline void HybridMatrix<Type,M,N,SO>::swap( HybridMatrix& m ) /* throw() */
1730 {
1731  using std::swap;
1732 
1733  const size_t maxrows( max( m_, m.m_ ) );
1734  const size_t maxcols( max( n_, m.n_ ) );
1735 
1736  for( size_t i=0UL; i<maxrows; ++i ) {
1737  for( size_t j=0UL; j<maxcols; ++j ) {
1738  swap( v_[i*NN+j], m(i,j) );
1739  }
1740  }
1741 
1742  swap( m_, m.m_ );
1743  swap( n_, m.n_ );
1744 }
1745 //*************************************************************************************************
1746 
1747 
1748 
1749 
1750 //=================================================================================================
1751 //
1752 // MEMORY FUNCTIONS
1753 //
1754 //=================================================================================================
1755 
1756 //*************************************************************************************************
1766 template< typename Type // Data type of the matrix
1767  , size_t M // Number of rows
1768  , size_t N // Number of columns
1769  , bool SO > // Storage order
1770 inline void* HybridMatrix<Type,M,N,SO>::operator new( std::size_t size )
1771 {
1772  UNUSED_PARAMETER( size );
1773 
1774  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
1775 
1776  return allocate<HybridMatrix>( 1UL );
1777 }
1778 //*************************************************************************************************
1779 
1780 
1781 //*************************************************************************************************
1791 template< typename Type // Data type of the matrix
1792  , size_t M // Number of rows
1793  , size_t N // Number of columns
1794  , bool SO > // Storage order
1795 inline void* HybridMatrix<Type,M,N,SO>::operator new[]( std::size_t size )
1796 {
1797  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
1798  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
1799 
1800  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
1801 }
1802 //*************************************************************************************************
1803 
1804 
1805 //*************************************************************************************************
1815 template< typename Type // Data type of the matrix
1816  , size_t M // Number of rows
1817  , size_t N // Number of columns
1818  , bool SO > // Storage order
1819 inline void* HybridMatrix<Type,M,N,SO>::operator new( std::size_t size, const std::nothrow_t& )
1820 {
1821  UNUSED_PARAMETER( size );
1822 
1823  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
1824 
1825  return allocate<HybridMatrix>( 1UL );
1826 }
1827 //*************************************************************************************************
1828 
1829 
1830 //*************************************************************************************************
1840 template< typename Type // Data type of the matrix
1841  , size_t M // Number of rows
1842  , size_t N // Number of columns
1843  , bool SO > // Storage order
1844 inline void* HybridMatrix<Type,M,N,SO>::operator new[]( std::size_t size, const std::nothrow_t& )
1845 {
1846  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
1847  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
1848 
1849  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
1850 }
1851 //*************************************************************************************************
1852 
1853 
1854 //*************************************************************************************************
1860 template< typename Type // Data type of the matrix
1861  , size_t M // Number of rows
1862  , size_t N // Number of columns
1863  , bool SO > // Storage order
1864 inline void HybridMatrix<Type,M,N,SO>::operator delete( void* ptr )
1865 {
1866  deallocate( static_cast<HybridMatrix*>( ptr ) );
1867 }
1868 //*************************************************************************************************
1869 
1870 
1871 //*************************************************************************************************
1877 template< typename Type // Data type of the matrix
1878  , size_t M // Number of rows
1879  , size_t N // Number of columns
1880  , bool SO > // Storage order
1881 inline void HybridMatrix<Type,M,N,SO>::operator delete[]( void* ptr )
1882 {
1883  deallocate( static_cast<HybridMatrix*>( ptr ) );
1884 }
1885 //*************************************************************************************************
1886 
1887 
1888 //*************************************************************************************************
1894 template< typename Type // Data type of the matrix
1895  , size_t M // Number of rows
1896  , size_t N // Number of columns
1897  , bool SO > // Storage order
1898 inline void HybridMatrix<Type,M,N,SO>::operator delete( void* ptr, const std::nothrow_t& )
1899 {
1900  deallocate( static_cast<HybridMatrix*>( ptr ) );
1901 }
1902 //*************************************************************************************************
1903 
1904 
1905 //*************************************************************************************************
1911 template< typename Type // Data type of the matrix
1912  , size_t M // Number of rows
1913  , size_t N // Number of columns
1914  , bool SO > // Storage order
1915 inline void HybridMatrix<Type,M,N,SO>::operator delete[]( void* ptr, const std::nothrow_t& )
1916 {
1917  deallocate( static_cast<HybridMatrix*>( ptr ) );
1918 }
1919 //*************************************************************************************************
1920 
1921 
1922 
1923 
1924 //=================================================================================================
1925 //
1926 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1927 //
1928 //=================================================================================================
1929 
1930 //*************************************************************************************************
1940 template< typename Type // Data type of the matrix
1941  , size_t M // Number of rows
1942  , size_t N // Number of columns
1943  , bool SO > // Storage order
1944 template< typename Other > // Data type of the foreign expression
1945 inline bool HybridMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
1946 {
1947  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1948 }
1949 //*************************************************************************************************
1950 
1951 
1952 //*************************************************************************************************
1962 template< typename Type // Data type of the matrix
1963  , size_t M // Number of rows
1964  , size_t N // Number of columns
1965  , bool SO > // Storage order
1966 template< typename Other > // Data type of the foreign expression
1967 inline bool HybridMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
1968 {
1969  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1970 }
1971 //*************************************************************************************************
1972 
1973 
1974 //*************************************************************************************************
1983 template< typename Type // Data type of the matrix
1984  , size_t M // Number of rows
1985  , size_t N // Number of columns
1986  , bool SO > // Storage order
1988 {
1989  return true;
1990 }
1991 //*************************************************************************************************
1992 
1993 
1994 //*************************************************************************************************
2009 template< typename Type // Data type of the matrix
2010  , size_t M // Number of rows
2011  , size_t N // Number of columns
2012  , bool SO > // Storage order
2014  HybridMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2015 {
2016  using blaze::load;
2017 
2019 
2020  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2021  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2022  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2023  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2024 
2025  return load( &v_[i*NN+j] );
2026 }
2027 //*************************************************************************************************
2028 
2029 
2030 //*************************************************************************************************
2045 template< typename Type // Data type of the matrix
2046  , size_t M // Number of rows
2047  , size_t N // Number of columns
2048  , bool SO > // Storage order
2050  HybridMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2051 {
2052  using blaze::loadu;
2053 
2055 
2056  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2057  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2058  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2059 
2060  return loadu( &v_[i*NN+j] );
2061 }
2062 //*************************************************************************************************
2063 
2064 
2065 //*************************************************************************************************
2081 template< typename Type // Data type of the matrix
2082  , size_t M // Number of rows
2083  , size_t N // Number of columns
2084  , bool SO > // Storage order
2085 inline void HybridMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2086 {
2087  using blaze::store;
2088 
2090 
2091  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2092  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2093  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2094  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2095 
2096  store( &v_[i*NN+j], value );
2097 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2117 template< typename Type // Data type of the matrix
2118  , size_t M // Number of rows
2119  , size_t N // Number of columns
2120  , bool SO > // Storage order
2121 inline void HybridMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2122 {
2123  using blaze::storeu;
2124 
2126 
2127  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
2128  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
2129  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2130 
2131  storeu( &v_[i*NN+j], value );
2132 }
2133 //*************************************************************************************************
2134 
2135 
2136 //*************************************************************************************************
2152 template< typename Type // Data type of the matrix
2153  , size_t M // Number of rows
2154  , size_t N // Number of columns
2155  , bool SO > // Storage order
2156 inline void HybridMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2157 {
2158  using blaze::stream;
2159 
2161 
2162  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2163  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2164  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2165  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2166 
2167  stream( &v_[i*NN+j], value );
2168 }
2169 //*************************************************************************************************
2170 
2171 
2172 //*************************************************************************************************
2183 template< typename Type // Data type of the matrix
2184  , size_t M // Number of rows
2185  , size_t N // Number of columns
2186  , bool SO > // Storage order
2187 template< typename MT // Type of the right-hand side dense matrix
2188  , bool SO2 > // Storage order of the right-hand side dense matrix
2189 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2191 {
2192  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2193 
2194  for( size_t i=0UL; i<m_; ++i ) {
2195  for( size_t j=0UL; j<n_; ++j ) {
2196  v_[i*NN+j] = (~rhs)(i,j);
2197  }
2198  }
2199 }
2200 //*************************************************************************************************
2201 
2202 
2203 //*************************************************************************************************
2214 template< typename Type // Data type of the matrix
2215  , size_t M // Number of rows
2216  , size_t N // Number of columns
2217  , bool SO > // Storage order
2218 template< typename MT // Type of the right-hand side dense matrix
2219  , bool SO2 > // Storage order of the right-hand side dense matrix
2220 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2222 {
2223  using blaze::store;
2224 
2225  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2226 
2228 
2229  for( size_t i=0UL; i<m_; ++i ) {
2230  for( size_t j=0UL; j<n_; j+=IT::size ) {
2231  store( &v_[i*NN+j], (~rhs).load(i,j) );
2232  }
2233  }
2234 }
2235 //*************************************************************************************************
2236 
2237 
2238 //*************************************************************************************************
2249 template< typename Type // Data type of the matrix
2250  , size_t M // Number of rows
2251  , size_t N // Number of columns
2252  , bool SO > // Storage order
2253 template< typename MT > // Type of the right-hand side sparse matrix
2255 {
2256  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2257 
2258  typedef typename MT::ConstIterator RhsConstIterator;
2259 
2260  for( size_t i=0UL; i<m_; ++i )
2261  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2262  v_[i*NN+element->index()] = element->value();
2263 }
2264 //*************************************************************************************************
2265 
2266 
2267 //*************************************************************************************************
2278 template< typename Type // Data type of the matrix
2279  , size_t M // Number of rows
2280  , size_t N // Number of columns
2281  , bool SO > // Storage order
2282 template< typename MT > // Type of the right-hand side sparse matrix
2284 {
2285  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2286 
2287  typedef typename MT::ConstIterator RhsConstIterator;
2288 
2289  for( size_t j=0UL; j<n_; ++j )
2290  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2291  v_[element->index()*NN+j] = element->value();
2292 }
2293 //*************************************************************************************************
2294 
2295 
2296 //*************************************************************************************************
2307 template< typename Type // Data type of the matrix
2308  , size_t M // Number of rows
2309  , size_t N // Number of columns
2310  , bool SO > // Storage order
2311 template< typename MT // Type of the right-hand side dense matrix
2312  , bool SO2 > // Storage order of the right-hand side dense matrix
2313 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2315 {
2316  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2317 
2318  for( size_t i=0UL; i<m_; ++i ) {
2319  for( size_t j=0UL; j<n_; ++j ) {
2320  v_[i*NN+j] += (~rhs)(i,j);
2321  }
2322  }
2323 }
2324 //*************************************************************************************************
2325 
2326 
2327 //*************************************************************************************************
2338 template< typename Type // Data type of the matrix
2339  , size_t M // Number of rows
2340  , size_t N // Number of columns
2341  , bool SO > // Storage order
2342 template< typename MT // Type of the right-hand side dense matrix
2343  , bool SO2 > // Storage order of the right-hand side dense matrix
2344 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2346 {
2347  using blaze::load;
2348  using blaze::store;
2349 
2350  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2351 
2353 
2354  for( size_t i=0UL; i<m_; ++i ) {
2355  for( size_t j=0UL; j<n_; j+=IT::size ) {
2356  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2357  }
2358  }
2359 }
2360 //*************************************************************************************************
2361 
2362 
2363 //*************************************************************************************************
2374 template< typename Type // Data type of the matrix
2375  , size_t M // Number of rows
2376  , size_t N // Number of columns
2377  , bool SO > // Storage order
2378 template< typename MT > // Type of the right-hand side sparse matrix
2380 {
2381  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2382 
2383  typedef typename MT::ConstIterator RhsConstIterator;
2384 
2385  for( size_t i=0UL; i<m_; ++i )
2386  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2387  v_[i*NN+element->index()] += element->value();
2388 }
2389 //*************************************************************************************************
2390 
2391 
2392 //*************************************************************************************************
2403 template< typename Type // Data type of the matrix
2404  , size_t M // Number of rows
2405  , size_t N // Number of columns
2406  , bool SO > // Storage order
2407 template< typename MT > // Type of the right-hand side sparse matrix
2409 {
2410  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2411 
2412  typedef typename MT::ConstIterator RhsConstIterator;
2413 
2414  for( size_t j=0UL; j<n_; ++j )
2415  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2416  v_[element->index()*NN+j] += element->value();
2417 }
2418 //*************************************************************************************************
2419 
2420 
2421 //*************************************************************************************************
2432 template< typename Type // Data type of the matrix
2433  , size_t M // Number of rows
2434  , size_t N // Number of columns
2435  , bool SO > // Storage order
2436 template< typename MT // Type of the right-hand side dense matrix
2437  , bool SO2 > // Storage order of the right-hand side dense matrix
2438 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2440 {
2441  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2442 
2443  for( size_t i=0UL; i<m_; ++i ) {
2444  for( size_t j=0UL; j<n_; ++j ) {
2445  v_[i*NN+j] -= (~rhs)(i,j);
2446  }
2447  }
2448 }
2449 //*************************************************************************************************
2450 
2451 
2452 //*************************************************************************************************
2463 template< typename Type // Data type of the matrix
2464  , size_t M // Number of rows
2465  , size_t N // Number of columns
2466  , bool SO > // Storage order
2467 template< typename MT // Type of the right-hand side dense matrix
2468  , bool SO2 > // Storage order of the right-hand side dense matrix
2469 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2471 {
2472  using blaze::load;
2473  using blaze::store;
2474 
2475  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2476 
2478 
2479  for( size_t i=0UL; i<m_; ++i ) {
2480  for( size_t j=0UL; j<n_; j+=IT::size ) {
2481  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
2482  }
2483  }
2484 }
2485 //*************************************************************************************************
2486 
2487 
2488 //*************************************************************************************************
2499 template< typename Type // Data type of the matrix
2500  , size_t M // Number of rows
2501  , size_t N // Number of columns
2502  , bool SO > // Storage order
2503 template< typename MT > // Type of the right-hand side sparse matrix
2505 {
2506  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2507 
2508  typedef typename MT::ConstIterator RhsConstIterator;
2509 
2510  for( size_t i=0UL; i<m_; ++i )
2511  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2512  v_[i*NN+element->index()] -= element->value();
2513 }
2514 //*************************************************************************************************
2515 
2516 
2517 //*************************************************************************************************
2528 template< typename Type // Data type of the matrix
2529  , size_t M // Number of rows
2530  , size_t N // Number of columns
2531  , bool SO > // Storage order
2532 template< typename MT > // Type of the right-hand side sparse matrix
2534 {
2535  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2536 
2537  typedef typename MT::ConstIterator RhsConstIterator;
2538 
2539  for( size_t j=0UL; j<n_; ++j )
2540  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2541  v_[element->index()*NN+j] -= element->value();
2542 }
2543 //*************************************************************************************************
2544 
2545 
2546 
2547 
2548 
2549 
2550 
2551 
2552 //=================================================================================================
2553 //
2554 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2555 //
2556 //=================================================================================================
2557 
2558 //*************************************************************************************************
2566 template< typename Type // Data type of the matrix
2567  , size_t M // Number of rows
2568  , size_t N > // Number of columns
2569 class HybridMatrix<Type,M,N,true> : public DenseMatrix< HybridMatrix<Type,M,N,true>, true >
2570 {
2571  private:
2572  //**Type definitions****************************************************************************
2573  typedef IntrinsicTrait<Type> IT;
2574  //**********************************************************************************************
2575 
2576  //**********************************************************************************************
2578  enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
2579  //**********************************************************************************************
2580 
2581  public:
2582  //**Type definitions****************************************************************************
2583  typedef HybridMatrix<Type,M,N,true> This;
2584  typedef This ResultType;
2585  typedef HybridMatrix<Type,M,N,false> OppositeType;
2586  typedef HybridMatrix<Type,N,M,false> TransposeType;
2587  typedef Type ElementType;
2588  typedef typename IT::Type IntrinsicType;
2589  typedef const Type& ReturnType;
2590  typedef const This& CompositeType;
2591  typedef Type& Reference;
2592  typedef const Type& ConstReference;
2593  typedef Type* Pointer;
2594  typedef const Type* ConstPointer;
2595  typedef DenseIterator<Type> Iterator;
2596  typedef DenseIterator<const Type> ConstIterator;
2597  //**********************************************************************************************
2598 
2599  //**Compilation flags***************************************************************************
2601 
2605  enum { vectorizable = IsVectorizable<Type>::value };
2606 
2608 
2611  enum { smpAssignable = 0 };
2612  //**********************************************************************************************
2613 
2614  //**Constructors********************************************************************************
2617  explicit inline HybridMatrix();
2618  explicit inline HybridMatrix( size_t m, size_t n );
2619  explicit inline HybridMatrix( size_t m, size_t n, const Type& init );
2620  template< typename Other > explicit inline HybridMatrix( size_t m, size_t n, const Other* array );
2621 
2622  template< typename Other, size_t M2, size_t N2 >
2623  explicit inline HybridMatrix( const Other (&array)[M2][N2] );
2624 
2625  inline HybridMatrix( const HybridMatrix& m );
2626  template< typename MT, bool SO > inline HybridMatrix( const Matrix<MT,SO>& m );
2628  //**********************************************************************************************
2629 
2630  //**Destructor**********************************************************************************
2631  // No explicitly declared destructor.
2632  //**********************************************************************************************
2633 
2634  //**Data access functions***********************************************************************
2637  inline Reference operator()( size_t i, size_t j );
2638  inline ConstReference operator()( size_t i, size_t j ) const;
2639  inline Pointer data ();
2640  inline ConstPointer data () const;
2641  inline Pointer data ( size_t j );
2642  inline ConstPointer data ( size_t j ) const;
2643  inline Iterator begin ( size_t j );
2644  inline ConstIterator begin ( size_t j ) const;
2645  inline ConstIterator cbegin( size_t j ) const;
2646  inline Iterator end ( size_t j );
2647  inline ConstIterator end ( size_t j ) const;
2648  inline ConstIterator cend ( size_t j ) const;
2650  //**********************************************************************************************
2651 
2652  //**Assignment operators************************************************************************
2655  template< typename Other, size_t M2, size_t N2 >
2656  inline HybridMatrix& operator=( const Other (&array)[M2][N2] );
2657 
2658  inline HybridMatrix& operator= ( const Type& set );
2659  inline HybridMatrix& operator= ( const HybridMatrix& rhs );
2660  template< typename MT, bool SO > inline HybridMatrix& operator= ( const Matrix<MT,SO>& rhs );
2661  template< typename MT, bool SO > inline HybridMatrix& operator+=( const Matrix<MT,SO>& rhs );
2662  template< typename MT, bool SO > inline HybridMatrix& operator-=( const Matrix<MT,SO>& rhs );
2663  template< typename MT, bool SO > inline HybridMatrix& operator*=( const Matrix<MT,SO>& rhs );
2664 
2665  template< typename Other >
2666  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
2667  operator*=( Other rhs );
2668 
2669  template< typename Other >
2670  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
2671  operator/=( Other rhs );
2673  //**********************************************************************************************
2674 
2675  //**Utility functions***************************************************************************
2678  inline size_t rows() const;
2679  inline size_t columns() const;
2680  inline size_t spacing() const;
2681  inline size_t capacity() const;
2682  inline size_t capacity( size_t j ) const;
2683  inline size_t nonZeros() const;
2684  inline size_t nonZeros( size_t j ) const;
2685  inline void reset();
2686  inline void reset( size_t i );
2687  inline void clear();
2688  void resize ( size_t m, size_t n, bool preserve=true );
2689  inline void extend ( size_t m, size_t n, bool preserve=true );
2690  inline HybridMatrix& transpose();
2691  template< typename Other > inline HybridMatrix& scale( const Other& scalar );
2692  inline void swap( HybridMatrix& m ) /* throw() */;
2694  //**********************************************************************************************
2695 
2696  //**Memory functions****************************************************************************
2699  static inline void* operator new ( std::size_t size );
2700  static inline void* operator new[]( std::size_t size );
2701  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
2702  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
2703 
2704  static inline void operator delete ( void* ptr );
2705  static inline void operator delete[]( void* ptr );
2706  static inline void operator delete ( void* ptr, const std::nothrow_t& );
2707  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
2709  //**********************************************************************************************
2710 
2711  private:
2712  //**********************************************************************************************
2714  template< typename MT >
2715  struct VectorizedAssign {
2716  enum { value = vectorizable && MT::vectorizable &&
2717  IsSame<Type,typename MT::ElementType>::value &&
2718  IsColumnMajorMatrix<MT>::value };
2719  };
2720  //**********************************************************************************************
2721 
2722  //**********************************************************************************************
2724  template< typename MT >
2725  struct VectorizedAddAssign {
2726  enum { value = vectorizable && MT::vectorizable &&
2727  IsSame<Type,typename MT::ElementType>::value &&
2728  IntrinsicTrait<Type>::addition &&
2729  IsColumnMajorMatrix<MT>::value };
2730  };
2731  //**********************************************************************************************
2732 
2733  //**********************************************************************************************
2735  template< typename MT >
2736  struct VectorizedSubAssign {
2737  enum { value = vectorizable && MT::vectorizable &&
2738  IsSame<Type,typename MT::ElementType>::value &&
2739  IntrinsicTrait<Type>::subtraction &&
2740  IsColumnMajorMatrix<MT>::value };
2741  };
2742  //**********************************************************************************************
2743 
2744  public:
2745  //**Expression template evaluation functions****************************************************
2748  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2749  template< typename Other > inline bool isAliased( const Other* alias ) const;
2750 
2751  inline bool isAligned() const;
2752 
2753  inline IntrinsicType load ( size_t i, size_t j ) const;
2754  inline IntrinsicType loadu ( size_t i, size_t j ) const;
2755  inline void store ( size_t i, size_t j, const IntrinsicType& value );
2756  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
2757  inline void stream( size_t i, size_t j, const IntrinsicType& value );
2758 
2759  template< typename MT, bool SO >
2760  inline typename DisableIf< VectorizedAssign<MT> >::Type
2761  assign( const DenseMatrix<MT,SO>& rhs );
2762 
2763  template< typename MT, bool SO >
2764  inline typename EnableIf< VectorizedAssign<MT> >::Type
2765  assign( const DenseMatrix<MT,SO>& rhs );
2766 
2767  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2768  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2769 
2770  template< typename MT, bool SO >
2771  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2772  addAssign( const DenseMatrix<MT,SO>& rhs );
2773 
2774  template< typename MT, bool SO >
2775  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2776  addAssign( const DenseMatrix<MT,SO>& rhs );
2777 
2778  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2779  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2780 
2781  template< typename MT, bool SO >
2782  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2783  subAssign( const DenseMatrix<MT,SO>& rhs );
2784 
2785  template< typename MT, bool SO >
2786  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2787  subAssign( const DenseMatrix<MT,SO>& rhs );
2788 
2789  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2790  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2792  //**********************************************************************************************
2793 
2794  private:
2795  //**Member variables****************************************************************************
2798  AlignedArray<Type,MM*N> v_;
2799 
2801  size_t m_;
2802  size_t n_;
2803 
2804  //**********************************************************************************************
2805 
2806  //**Compile time checks*************************************************************************
2811  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
2812  BLAZE_STATIC_ASSERT( MM >= M );
2813  //**********************************************************************************************
2814 };
2816 //*************************************************************************************************
2817 
2818 
2819 
2820 
2821 //=================================================================================================
2822 //
2823 // CONSTRUCTORS
2824 //
2825 //=================================================================================================
2826 
2827 //*************************************************************************************************
2833 template< typename Type // Data type of the matrix
2834  , size_t M // Number of rows
2835  , size_t N > // Number of columns
2837  : v_() // The statically allocated matrix elements
2838  , m_( 0UL ) // The current number of rows of the matrix
2839  , n_( 0UL ) // The current number of columns of the matrix
2840 {
2841  if( IsVectorizable<Type>::value ) {
2842  for( size_t i=0UL; i<MM*N; ++i )
2843  v_[i] = Type();
2844  }
2845 }
2847 //*************************************************************************************************
2848 
2849 
2850 //*************************************************************************************************
2864 template< typename Type // Data type of the matrix
2865  , size_t M // Number of rows
2866  , size_t N > // Number of columns
2867 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n )
2868  : v_() // The statically allocated matrix elements
2869  , m_( m ) // The current number of rows of the matrix
2870  , n_( n ) // The current number of columns of the matrix
2871 {
2872  if( m > M )
2873  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
2874 
2875  if( n > N )
2876  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
2877 
2878  if( IsVectorizable<Type>::value ) {
2879  for( size_t i=0UL; i<MM*N; ++i )
2880  v_[i] = Type();
2881  }
2882 }
2884 //*************************************************************************************************
2885 
2886 
2887 //*************************************************************************************************
2902 template< typename Type // Data type of the matrix
2903  , size_t M // Number of rows
2904  , size_t N > // Number of columns
2905 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n, const Type& init )
2906  : v_() // The statically allocated matrix elements
2907  , m_( m ) // The current number of rows of the matrix
2908  , n_( n ) // The current number of columns of the matrix
2909 {
2910  if( m > M )
2911  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
2912 
2913  if( n > N )
2914  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
2915 
2916  for( size_t j=0UL; j<n; ++j ) {
2917  for( size_t i=0UL; i<m; ++i )
2918  v_[i+j*MM] = init;
2919 
2920  if( IsVectorizable<Type>::value ) {
2921  for( size_t i=m; i<MM; ++i )
2922  v_[i+j*MM] = Type();
2923  }
2924  }
2925 
2926  if( IsVectorizable<Type>::value ) {
2927  for( size_t j=n; j<N; ++j )
2928  for( size_t i=0UL; i<MM; ++i )
2929  v_[i+j*MM] = Type();
2930  }
2931 }
2933 //*************************************************************************************************
2934 
2935 
2936 //*************************************************************************************************
2964 template< typename Type // Data type of the matrix
2965  , size_t M // Number of rows
2966  , size_t N > // Number of columns
2967 template< typename Other > // Data type of the initialization array
2968 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n, const Other* array )
2969  : v_() // The statically allocated matrix elements
2970  , m_( m ) // The current number of rows of the matrix
2971  , n_( n ) // The current number of columns of the matrix
2972 {
2973  if( m > M )
2974  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
2975 
2976  if( n > N )
2977  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
2978 
2979  for( size_t j=0UL; j<n; ++j ) {
2980  for( size_t i=0UL; i<m; ++i )
2981  v_[i+j*MM] = array[i+j*m];
2982 
2983  if( IsVectorizable<Type>::value ) {
2984  for( size_t i=m; i<MM; ++i )
2985  v_[i+j*MM] = Type();
2986  }
2987  }
2988 
2989  if( IsVectorizable<Type>::value ) {
2990  for( size_t j=n; j<N; ++j )
2991  for( size_t i=0UL; i<MM; ++i )
2992  v_[i+j*MM] = Type();
2993  }
2994 }
2996 //*************************************************************************************************
2997 
2998 
2999 //*************************************************************************************************
3021 template< typename Type // Data type of the matrix
3022  , size_t M // Number of rows
3023  , size_t N > // Number of columns
3024 template< typename Other // Data type of the initialization array
3025  , size_t M2 // Number of rows of the initialization array
3026  , size_t N2 > // Number of columns of the initialization array
3027 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const Other (&array)[M2][N2] )
3028  : v_() // The statically allocated matrix elements
3029  , m_( M2 ) // The current number of rows of the matrix
3030  , n_( N2 ) // The current number of columns of the matrix
3031 {
3032  BLAZE_STATIC_ASSERT( M2 <= M );
3033  BLAZE_STATIC_ASSERT( N2 <= N );
3034 
3035  for( size_t j=0UL; j<N2; ++j ) {
3036  for( size_t i=0UL; i<M2; ++i )
3037  v_[i+j*MM] = array[i][j];
3038 
3039  if( IsVectorizable<Type>::value ) {
3040  for( size_t i=M2; i<MM; ++i )
3041  v_[i+j*MM] = Type();
3042  }
3043  }
3044 
3045  if( IsVectorizable<Type>::value ) {
3046  for( size_t j=N2; j<N; ++j )
3047  for( size_t i=0UL; i<MM; ++i )
3048  v_[i+j*MM] = Type();
3049  }
3050 }
3052 //*************************************************************************************************
3053 
3054 
3055 //*************************************************************************************************
3064 template< typename Type // Data type of the matrix
3065  , size_t M // Number of rows
3066  , size_t N > // Number of columns
3067 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const HybridMatrix& m )
3068  : v_() // The statically allocated matrix elements
3069  , m_( m.m_ ) // The current number of rows of the matrix
3070  , n_( m.n_ ) // The current number of columns of the matrix
3071 {
3072  for( size_t j=0UL; j<n_; ++j ) {
3073  for( size_t i=0UL; i<m_; ++i )
3074  v_[i+j*MM] = m.v_[i+j*MM];
3075 
3076  if( IsVectorizable<Type>::value ) {
3077  for( size_t i=m_; i<MM; ++i )
3078  v_[i+j*MM] = Type();
3079  }
3080  }
3081 
3082  if( IsVectorizable<Type>::value ) {
3083  for( size_t j=n_; j<N; ++j )
3084  for( size_t i=0UL; i<MM; ++i )
3085  v_[i+j*MM] = Type();
3086  }
3087 }
3089 //*************************************************************************************************
3090 
3091 
3092 //*************************************************************************************************
3099 template< typename Type // Data type of the matrix
3100  , size_t M // Number of rows
3101  , size_t N > // Number of columns
3102 template< typename MT // Type of the foreign matrix
3103  , bool SO2 > // Storage order of the foreign matrix
3104 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const Matrix<MT,SO2>& m )
3105  : v_() // The statically allocated matrix elements
3106  , m_( (~m).rows() ) // The current number of rows of the matrix
3107  , n_( (~m).columns() ) // The current number of columns of the matrix
3108 {
3109  using blaze::assign;
3110 
3111  if( (~m).rows() > M || (~m).columns() > N )
3112  throw std::invalid_argument( "Invalid setup of hybrid matrix" );
3113 
3114  for( size_t j=0UL; j<n_; ++j ) {
3115  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
3116  i<( IsVectorizable<Type>::value ? MM : m_ ); ++i ) {
3117  v_[i+j*MM] = Type();
3118  }
3119  }
3120 
3121  if( IsVectorizable<Type>::value ) {
3122  for( size_t j=n_; j<N; ++j )
3123  for( size_t i=0UL; i<MM; ++i )
3124  v_[i+j*MM] = Type();
3125  }
3126 
3127  assign( *this, ~m );
3128 }
3130 //*************************************************************************************************
3131 
3132 
3133 
3134 
3135 //=================================================================================================
3136 //
3137 // DATA ACCESS FUNCTIONS
3138 //
3139 //=================================================================================================
3140 
3141 //*************************************************************************************************
3149 template< typename Type // Data type of the matrix
3150  , size_t M // Number of rows
3151  , size_t N > // Number of columns
3153  HybridMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
3154 {
3155  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3156  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3157  return v_[i+j*MM];
3158 }
3160 //*************************************************************************************************
3161 
3162 
3163 //*************************************************************************************************
3171 template< typename Type // Data type of the matrix
3172  , size_t M // Number of rows
3173  , size_t N > // Number of columns
3175  HybridMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
3176 {
3177  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3178  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3179  return v_[i+j*MM];
3180 }
3182 //*************************************************************************************************
3183 
3184 
3185 //*************************************************************************************************
3197 template< typename Type // Data type of the matrix
3198  , size_t M // Number of rows
3199  , size_t N > // Number of columns
3200 inline typename HybridMatrix<Type,M,N,true>::Pointer
3202 {
3203  return v_;
3204 }
3206 //*************************************************************************************************
3207 
3208 
3209 //*************************************************************************************************
3221 template< typename Type // Data type of the matrix
3222  , size_t M // Number of rows
3223  , size_t N > // Number of columns
3224 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3226 {
3227  return v_;
3228 }
3230 //*************************************************************************************************
3231 
3232 
3233 //*************************************************************************************************
3242 template< typename Type // Data type of the matrix
3243  , size_t M // Number of rows
3244  , size_t N > // Number of columns
3245 inline typename HybridMatrix<Type,M,N,true>::Pointer
3247 {
3248  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3249  return v_ + j*MM;
3250 }
3252 //*************************************************************************************************
3253 
3254 
3255 //*************************************************************************************************
3264 template< typename Type // Data type of the matrix
3265  , size_t M // Number of rows
3266  , size_t N > // Number of columns
3267 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3268  HybridMatrix<Type,M,N,true>::data( size_t j ) const
3269 {
3270  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3271  return v_ + j*MM;
3272 }
3274 //*************************************************************************************************
3275 
3276 
3277 //*************************************************************************************************
3284 template< typename Type // Data type of the matrix
3285  , size_t M // Number of rows
3286  , size_t N > // Number of columns
3289 {
3290  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3291  return Iterator( v_ + j*MM );
3292 }
3294 //*************************************************************************************************
3295 
3296 
3297 //*************************************************************************************************
3304 template< typename Type // Data type of the matrix
3305  , size_t M // Number of rows
3306  , size_t N > // Number of columns
3308  HybridMatrix<Type,M,N,true>::begin( size_t j ) const
3309 {
3310  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3311  return ConstIterator( v_ + j*MM );
3312 }
3314 //*************************************************************************************************
3315 
3316 
3317 //*************************************************************************************************
3324 template< typename Type // Data type of the matrix
3325  , size_t M // Number of rows
3326  , size_t N > // Number of columns
3328  HybridMatrix<Type,M,N,true>::cbegin( size_t j ) const
3329 {
3330  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3331  return ConstIterator( v_ + j*MM );
3332 }
3334 //*************************************************************************************************
3335 
3336 
3337 //*************************************************************************************************
3344 template< typename Type // Data type of the matrix
3345  , size_t M // Number of rows
3346  , size_t N > // Number of columns
3349 {
3350  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3351  return Iterator( v_ + j*MM + M );
3352 }
3354 //*************************************************************************************************
3355 
3356 
3357 //*************************************************************************************************
3364 template< typename Type // Data type of the matrix
3365  , size_t M // Number of rows
3366  , size_t N > // Number of columns
3368  HybridMatrix<Type,M,N,true>::end( size_t j ) const
3369 {
3370  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3371  return ConstIterator( v_ + j*MM + M );
3372 }
3374 //*************************************************************************************************
3375 
3376 
3377 //*************************************************************************************************
3384 template< typename Type // Data type of the matrix
3385  , size_t M // Number of rows
3386  , size_t N > // Number of columns
3388  HybridMatrix<Type,M,N,true>::cend( size_t j ) const
3389 {
3390  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3391  return ConstIterator( v_ + j*MM + M );
3392 }
3394 //*************************************************************************************************
3395 
3396 
3397 
3398 
3399 //=================================================================================================
3400 //
3401 // ASSIGNMENT OPERATORS
3402 //
3403 //=================================================================================================
3404 
3405 //*************************************************************************************************
3427 template< typename Type // Data type of the matrix
3428  , size_t M // Number of rows
3429  , size_t N > // Number of columns
3430 template< typename Other // Data type of the initialization array
3431  , size_t M2 // Number of rows of the initialization array
3432  , size_t N2 > // Number of columns of the initialization array
3433 inline HybridMatrix<Type,M,N,true>&
3434  HybridMatrix<Type,M,N,true>::operator=( const Other (&array)[M2][N2] )
3435 {
3436  BLAZE_STATIC_ASSERT( M2 <= M );
3437  BLAZE_STATIC_ASSERT( N2 <= N );
3438 
3439  resize( M2, N2 );
3440 
3441  for( size_t j=0UL; j<N2; ++j )
3442  for( size_t i=0UL; i<M2; ++i )
3443  v_[i+j*MM] = array[i][j];
3444 
3445  return *this;
3446 }
3448 //*************************************************************************************************
3449 
3450 
3451 //*************************************************************************************************
3458 template< typename Type // Data type of the matrix
3459  , size_t M // Number of rows
3460  , size_t N > // Number of columns
3461 inline HybridMatrix<Type,M,N,true>&
3462  HybridMatrix<Type,M,N,true>::operator=( const Type& set )
3463 {
3464  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
3465  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
3466 
3467  for( size_t j=0UL; j<n_; ++j )
3468  for( size_t i=0UL; i<m_; ++i )
3469  v_[i+j*MM] = set;
3470 
3471  return *this;
3472 }
3474 //*************************************************************************************************
3475 
3476 
3477 //*************************************************************************************************
3486 template< typename Type // Data type of the matrix
3487  , size_t M // Number of rows
3488  , size_t N > // Number of columns
3489 inline HybridMatrix<Type,M,N,true>&
3490  HybridMatrix<Type,M,N,true>::operator=( const HybridMatrix& rhs )
3491 {
3492  using blaze::assign;
3493 
3494  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
3495  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
3496 
3497  resize( rhs.rows(), rhs.columns() );
3498  assign( *this, ~rhs );
3499 
3500  return *this;
3501 }
3503 //*************************************************************************************************
3504 
3505 
3506 //*************************************************************************************************
3518 template< typename Type // Data type of the matrix
3519  , size_t M // Number of rows
3520  , size_t N > // Number of columns
3521 template< typename MT // Type of the right-hand side matrix
3522  , bool SO > // Storage order of the right-hand side matrix
3523 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
3524 {
3525  using blaze::assign;
3526 
3527  if( (~rhs).rows() > M || (~rhs).columns() > N )
3528  throw std::invalid_argument( "Invalid assignment to hybrid matrix" );
3529 
3530  if( (~rhs).canAlias( this ) ) {
3531  HybridMatrix tmp( ~rhs );
3532  swap( tmp );
3533  }
3534  else {
3535  resize( (~rhs).rows(), (~rhs).columns() );
3536  if( IsSparseMatrix<MT>::value )
3537  reset();
3538  assign( *this, ~rhs );
3539  }
3540 
3541  return *this;
3542 }
3544 //*************************************************************************************************
3545 
3546 
3547 //*************************************************************************************************
3558 template< typename Type // Data type of the matrix
3559  , size_t M // Number of rows
3560  , size_t N > // Number of columns
3561 template< typename MT // Type of the right-hand side matrix
3562  , bool SO > // Storage order of the right-hand side matrix
3563 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
3564 {
3565  using blaze::addAssign;
3566 
3567  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3568  throw std::invalid_argument( "Matrix sizes do not match" );
3569 
3570  if( (~rhs).canAlias( this ) ) {
3571  typename MT::ResultType tmp( ~rhs );
3572  addAssign( *this, tmp );
3573  }
3574  else {
3575  addAssign( *this, ~rhs );
3576  }
3577 
3578  return *this;
3579 }
3581 //*************************************************************************************************
3582 
3583 
3584 //*************************************************************************************************
3595 template< typename Type // Data type of the matrix
3596  , size_t M // Number of rows
3597  , size_t N > // Number of columns
3598 template< typename MT // Type of the right-hand side matrix
3599  , bool SO > // Storage order of the right-hand side matrix
3600 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
3601 {
3602  using blaze::subAssign;
3603 
3604  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3605  throw std::invalid_argument( "Matrix sizes do not match" );
3606 
3607  if( (~rhs).canAlias( this ) ) {
3608  typename MT::ResultType tmp( ~rhs );
3609  subAssign( *this, tmp );
3610  }
3611  else {
3612  subAssign( *this, ~rhs );
3613  }
3614 
3615  return *this;
3616 }
3618 //*************************************************************************************************
3619 
3620 
3621 //*************************************************************************************************
3632 template< typename Type // Data type of the matrix
3633  , size_t M // Number of rows
3634  , size_t N > // Number of columns
3635 template< typename MT // Type of the right-hand side matrix
3636  , bool SO > // Storage order of the right-hand side matrix
3637 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
3638 {
3639  if( n_ != (~rhs).rows() || (~rhs).columns() > N )
3640  throw std::invalid_argument( "Matrix sizes do not match" );
3641 
3642  HybridMatrix tmp( *this * (~rhs) );
3643  return this->operator=( tmp );
3644 }
3646 //*************************************************************************************************
3647 
3648 
3649 //*************************************************************************************************
3657 template< typename Type // Data type of the matrix
3658  , size_t M // Number of rows
3659  , size_t N > // Number of columns
3660 template< typename Other > // Data type of the right-hand side scalar
3661 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3662  HybridMatrix<Type,M,N,true>::operator*=( Other rhs )
3663 {
3664  using blaze::assign;
3665 
3666  assign( *this, (*this) * rhs );
3667  return *this;
3668 }
3670 //*************************************************************************************************
3671 
3672 
3673 //*************************************************************************************************
3683 template< typename Type // Data type of the matrix
3684  , size_t M // Number of rows
3685  , size_t N > // Number of columns
3686 template< typename Other > // Data type of the right-hand side scalar
3687 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3688  HybridMatrix<Type,M,N,true>::operator/=( Other rhs )
3689 {
3690  using blaze::assign;
3691 
3692  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3693 
3694  assign( *this, (*this) / rhs );
3695  return *this;
3696 }
3698 //*************************************************************************************************
3699 
3700 
3701 
3702 
3703 //=================================================================================================
3704 //
3705 // UTILITY FUNCTIONS
3706 //
3707 //=================================================================================================
3708 
3709 //*************************************************************************************************
3715 template< typename Type // Data type of the matrix
3716  , size_t M // Number of rows
3717  , size_t N > // Number of columns
3718 inline size_t HybridMatrix<Type,M,N,true>::rows() const
3719 {
3720  return m_;
3721 }
3723 //*************************************************************************************************
3724 
3725 
3726 //*************************************************************************************************
3732 template< typename Type // Data type of the matrix
3733  , size_t M // Number of rows
3734  , size_t N > // Number of columns
3735 inline size_t HybridMatrix<Type,M,N,true>::columns() const
3736 {
3737  return n_;
3738 }
3740 //*************************************************************************************************
3741 
3742 
3743 //*************************************************************************************************
3752 template< typename Type // Data type of the matrix
3753  , size_t M // Number of rows
3754  , size_t N > // Number of columns
3755 inline size_t HybridMatrix<Type,M,N,true>::spacing() const
3756 {
3757  return MM;
3758 }
3760 //*************************************************************************************************
3761 
3762 
3763 //*************************************************************************************************
3769 template< typename Type // Data type of the matrix
3770  , size_t M // Number of rows
3771  , size_t N > // Number of columns
3772 inline size_t HybridMatrix<Type,M,N,true>::capacity() const
3773 {
3774  return MM*N;
3775 }
3777 //*************************************************************************************************
3778 
3779 
3780 //*************************************************************************************************
3787 template< typename Type // Data type of the matrix
3788  , size_t M // Number of rows
3789  , size_t N > // Number of columns
3790 inline size_t HybridMatrix<Type,M,N,true>::capacity( size_t j ) const
3791 {
3792  UNUSED_PARAMETER( j );
3793 
3794  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3795 
3796  return MM;
3797 }
3799 //*************************************************************************************************
3800 
3801 
3802 //*************************************************************************************************
3808 template< typename Type // Data type of the matrix
3809  , size_t M // Number of rows
3810  , size_t N > // Number of columns
3811 inline size_t HybridMatrix<Type,M,N,true>::nonZeros() const
3812 {
3813  size_t nonzeros( 0UL );
3814 
3815  for( size_t j=0UL; j<n_; ++j )
3816  for( size_t i=0UL; i<m_; ++i )
3817  if( !isDefault( v_[i+j*MM] ) )
3818  ++nonzeros;
3819 
3820  return nonzeros;
3821 }
3823 //*************************************************************************************************
3824 
3825 
3826 //*************************************************************************************************
3833 template< typename Type // Data type of the matrix
3834  , size_t M // Number of rows
3835  , size_t N > // Number of columns
3836 inline size_t HybridMatrix<Type,M,N,true>::nonZeros( size_t j ) const
3837 {
3838  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3839 
3840  const size_t iend( j*MM+m_ );
3841  size_t nonzeros( 0UL );
3842 
3843  for( size_t i=j*MM; i<iend; ++i )
3844  if( !isDefault( v_[i] ) )
3845  ++nonzeros;
3846 
3847  return nonzeros;
3848 }
3850 //*************************************************************************************************
3851 
3852 
3853 //*************************************************************************************************
3859 template< typename Type // Data type of the matrix
3860  , size_t M // Number of rows
3861  , size_t N > // Number of columns
3863 {
3864  using blaze::reset;
3865 
3866  for( size_t j=0UL; j<n_; ++j )
3867  for( size_t i=0UL; i<m_; ++i )
3868  reset( v_[i+j*MM] );
3869 }
3871 //*************************************************************************************************
3872 
3873 
3874 //*************************************************************************************************
3884 template< typename Type // Data type of the matrix
3885  , size_t M // Number of rows
3886  , size_t N > // Number of columns
3887 inline void HybridMatrix<Type,M,N,true>::reset( size_t j )
3888 {
3889  using blaze::reset;
3890 
3891  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3892  for( size_t i=0UL; i<m_; ++i )
3893  reset( v_[i+j*MM] );
3894 }
3896 //*************************************************************************************************
3897 
3898 
3899 //*************************************************************************************************
3907 template< typename Type // Data type of the matrix
3908  , size_t M // Number of rows
3909  , size_t N > // Number of columns
3911 {
3912  resize( 0UL, 0UL );
3913 }
3915 //*************************************************************************************************
3916 
3917 
3918 //*************************************************************************************************
3955 template< typename Type // Data type of the matrix
3956  , size_t M // Number of rows
3957  , size_t N > // Number of columns
3958 void HybridMatrix<Type,M,N,true>::resize( size_t m, size_t n, bool preserve )
3959 {
3960  UNUSED_PARAMETER( preserve );
3961 
3962  if( m > M )
3963  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
3964 
3965  if( n > N )
3966  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
3967 
3968  if( IsVectorizable<Type>::value && m < m_ ) {
3969  for( size_t j=0UL; j<n; ++j )
3970  for( size_t i=m; i<m_; ++i )
3971  v_[i+j*MM] = Type();
3972  }
3973 
3974  if( IsVectorizable<Type>::value && n < n_ ) {
3975  for( size_t j=n; j<n_; ++j )
3976  for( size_t i=0UL; i<m_; ++i )
3977  v_[i+j*MM] = Type();
3978  }
3979 
3980  m_ = m;
3981  n_ = n;
3982 }
3984 //*************************************************************************************************
3985 
3986 
3987 //*************************************************************************************************
4003 template< typename Type // Data type of the matrix
4004  , size_t M // Number of rows
4005  , size_t N > // Number of columns
4006 inline void HybridMatrix<Type,M,N,true>::extend( size_t m, size_t n, bool preserve )
4007 {
4008  UNUSED_PARAMETER( preserve );
4009  resize( m_+m, n_+n );
4010 }
4012 //*************************************************************************************************
4013 
4014 
4015 //*************************************************************************************************
4027 template< typename Type // Data type of the matrix
4028  , size_t M // Number of rows
4029  , size_t N > // Number of columns
4030 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::transpose()
4031 {
4032  using std::swap;
4033 
4034  if( m_ > N || n_ > M )
4035  throw std::logic_error( "Impossible transpose operation" );
4036 
4037  const size_t maxsize( max( m_, n_ ) );
4038  for( size_t j=1UL; j<maxsize; ++j )
4039  for( size_t i=0UL; i<j; ++i )
4040  swap( v_[i+j*MM], v_[j+i*MM] );
4041 
4042  if( IsVectorizable<Type>::value && n_ < m_ ) {
4043  for( size_t j=0UL; j<n_; ++j ) {
4044  for( size_t i=n_; i<m_; ++i ) {
4045  v_[i+j*MM] = Type();
4046  }
4047  }
4048  }
4049 
4050  if( IsVectorizable<Type>::value && n_ > m_ ) {
4051  for( size_t j=m_; j<n_; ++j )
4052  for( size_t i=0UL; i<m_; ++i )
4053  v_[i+j*MM] = Type();
4054  }
4055 
4056  swap( m_, n_ );
4057 
4058  return *this;
4059 }
4061 //*************************************************************************************************
4062 
4063 
4064 //*************************************************************************************************
4071 template< typename Type // Data type of the matrix
4072  , size_t M // Number of rows
4073  , size_t N > // Number of columns
4074 template< typename Other > // Data type of the scalar value
4075 inline HybridMatrix<Type,M,N,true>&
4076  HybridMatrix<Type,M,N,true>::scale( const Other& scalar )
4077 {
4078  for( size_t j=0UL; j<n_; ++j )
4079  for( size_t i=0UL; i<m_; ++i )
4080  v_[i+j*MM] *= scalar;
4081 
4082  return *this;
4083 }
4085 //*************************************************************************************************
4086 
4087 
4088 //*************************************************************************************************
4096 template< typename Type // Data type of the matrix
4097  , size_t M // Number of rows
4098  , size_t N > // Number of columns
4099 inline void HybridMatrix<Type,M,N,true>::swap( HybridMatrix& m ) /* throw() */
4100 {
4101  using std::swap;
4102 
4103  const size_t maxrows( max( m_, m.m_ ) );
4104  const size_t maxcols( max( n_, m.n_ ) );
4105 
4106  for( size_t j=0UL; j<maxcols; ++j ) {
4107  for( size_t i=0UL; i<maxrows; ++i ) {
4108  swap( v_[i+j*MM], m(i,j) );
4109  }
4110  }
4111 
4112  swap( m_, m.m_ );
4113  swap( n_, m.n_ );
4114 }
4116 //*************************************************************************************************
4117 
4118 
4119 
4120 
4121 //=================================================================================================
4122 //
4123 // MEMORY FUNCTIONS
4124 //
4125 //=================================================================================================
4126 
4127 //*************************************************************************************************
4138 template< typename Type // Data type of the matrix
4139  , size_t M // Number of rows
4140  , size_t N > // Number of columns
4141 inline void* HybridMatrix<Type,M,N,true>::operator new( std::size_t size )
4142 {
4143  UNUSED_PARAMETER( size );
4144 
4145  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
4146 
4147  return allocate<HybridMatrix>( 1UL );
4148 }
4150 //*************************************************************************************************
4151 
4152 
4153 //*************************************************************************************************
4164 template< typename Type // Data type of the matrix
4165  , size_t M // Number of rows
4166  , size_t N > // Number of columns
4167 inline void* HybridMatrix<Type,M,N,true>::operator new[]( std::size_t size )
4168 {
4169  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
4170  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
4171 
4172  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
4173 }
4175 //*************************************************************************************************
4176 
4177 
4178 //*************************************************************************************************
4189 template< typename Type // Data type of the matrix
4190  , size_t M // Number of rows
4191  , size_t N > // Number of columns
4192 inline void* HybridMatrix<Type,M,N,true>::operator new( std::size_t size, const std::nothrow_t& )
4193 {
4194  UNUSED_PARAMETER( size );
4195 
4196  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
4197 
4198  return allocate<HybridMatrix>( 1UL );
4199 }
4201 //*************************************************************************************************
4202 
4203 
4204 //*************************************************************************************************
4215 template< typename Type // Data type of the matrix
4216  , size_t M // Number of rows
4217  , size_t N > // Number of columns
4218 inline void* HybridMatrix<Type,M,N,true>::operator new[]( std::size_t size, const std::nothrow_t& )
4219 {
4220  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
4221  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
4222 
4223  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
4224 }
4226 //*************************************************************************************************
4227 
4228 
4229 //*************************************************************************************************
4236 template< typename Type // Data type of the matrix
4237  , size_t M // Number of rows
4238  , size_t N > // Number of columns
4239 inline void HybridMatrix<Type,M,N,true>::operator delete( void* ptr )
4240 {
4241  deallocate( static_cast<HybridMatrix*>( ptr ) );
4242 }
4244 //*************************************************************************************************
4245 
4246 
4247 //*************************************************************************************************
4254 template< typename Type // Data type of the matrix
4255  , size_t M // Number of rows
4256  , size_t N > // Number of columns
4257 inline void HybridMatrix<Type,M,N,true>::operator delete[]( void* ptr )
4258 {
4259  deallocate( static_cast<HybridMatrix*>( ptr ) );
4260 }
4262 //*************************************************************************************************
4263 
4264 
4265 //*************************************************************************************************
4272 template< typename Type // Data type of the matrix
4273  , size_t M // Number of rows
4274  , size_t N > // Number of columns
4275 inline void HybridMatrix<Type,M,N,true>::operator delete( void* ptr, const std::nothrow_t& )
4276 {
4277  deallocate( static_cast<HybridMatrix*>( ptr ) );
4278 }
4280 //*************************************************************************************************
4281 
4282 
4283 //*************************************************************************************************
4290 template< typename Type // Data type of the matrix
4291  , size_t M // Number of rows
4292  , size_t N > // Number of columns
4293 inline void HybridMatrix<Type,M,N,true>::operator delete[]( void* ptr, const std::nothrow_t& )
4294 {
4295  deallocate( static_cast<HybridMatrix*>( ptr ) );
4296 }
4298 //*************************************************************************************************
4299 
4300 
4301 
4302 
4303 //=================================================================================================
4304 //
4305 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4306 //
4307 //=================================================================================================
4308 
4309 //*************************************************************************************************
4320 template< typename Type // Data type of the matrix
4321  , size_t M // Number of rows
4322  , size_t N > // Number of columns
4323 template< typename Other > // Data type of the foreign expression
4324 inline bool HybridMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
4325 {
4326  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4327 }
4329 //*************************************************************************************************
4330 
4331 
4332 //*************************************************************************************************
4343 template< typename Type // Data type of the matrix
4344  , size_t M // Number of rows
4345  , size_t N > // Number of columns
4346 template< typename Other > // Data type of the foreign expression
4347 inline bool HybridMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
4348 {
4349  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4350 }
4352 //*************************************************************************************************
4353 
4354 
4355 //*************************************************************************************************
4365 template< typename Type // Data type of the matrix
4366  , size_t M // Number of rows
4367  , size_t N > // Number of columns
4368 inline bool HybridMatrix<Type,M,N,true>::isAligned() const
4369 {
4370  return true;
4371 }
4373 //*************************************************************************************************
4374 
4375 
4376 //*************************************************************************************************
4391 template< typename Type // Data type of the matrix
4392  , size_t M // Number of rows
4393  , size_t N > // Number of columns
4394 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4395  HybridMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
4396 {
4397  using blaze::load;
4398 
4400 
4401  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4402  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4403  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4404  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4405 
4406  return load( &v_[i+j*MM] );
4407 }
4409 //*************************************************************************************************
4410 
4411 
4412 //*************************************************************************************************
4427 template< typename Type // Data type of the matrix
4428  , size_t M // Number of rows
4429  , size_t N > // Number of columns
4430 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4431  HybridMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
4432 {
4433  using blaze::loadu;
4434 
4436 
4437  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4438  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4439  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4440 
4441  return loadu( &v_[i+j*MM] );
4442 }
4444 //*************************************************************************************************
4445 
4446 
4447 //*************************************************************************************************
4463 template< typename Type // Data type of the matrix
4464  , size_t M // Number of rows
4465  , size_t N > // Number of columns
4466 inline void HybridMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
4467 {
4468  using blaze::store;
4469 
4471 
4472  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4473  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4474  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4475  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4476 
4477  store( &v_[i+j*MM], value );
4478 }
4480 //*************************************************************************************************
4481 
4482 
4483 //*************************************************************************************************
4499 template< typename Type // Data type of the matrix
4500  , size_t M // Number of rows
4501  , size_t N > // Number of columns
4502 inline void HybridMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4503 {
4504  using blaze::storeu;
4505 
4507 
4508  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4509  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
4510  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4511 
4512  storeu( &v_[i+j*MM], value );
4513 }
4515 //*************************************************************************************************
4516 
4517 
4518 //*************************************************************************************************
4535 template< typename Type // Data type of the matrix
4536  , size_t M // Number of rows
4537  , size_t N > // Number of columns
4538 inline void HybridMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4539 {
4540  using blaze::stream;
4541 
4543 
4544  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4545  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4546  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4547  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4548 
4549  stream( &v_[i+j*MM], value );
4550 }
4552 //*************************************************************************************************
4553 
4554 
4555 //*************************************************************************************************
4567 template< typename Type // Data type of the matrix
4568  , size_t M // Number of rows
4569  , size_t N > // Number of columns
4570 template< typename MT // Type of the right-hand side dense matrix
4571  , bool SO > // Storage order of the right-hand side dense matrix
4572 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4573  HybridMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
4574 {
4575  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4576 
4577  for( size_t j=0UL; j<n_; ++j ) {
4578  for( size_t i=0UL; i<m_; ++i ) {
4579  v_[i+j*MM] = (~rhs)(i,j);
4580  }
4581  }
4582 }
4584 //*************************************************************************************************
4585 
4586 
4587 //*************************************************************************************************
4599 template< typename Type // Data type of the matrix
4600  , size_t M // Number of rows
4601  , size_t N > // Number of columns
4602 template< typename MT // Type of the right-hand side dense matrix
4603  , bool SO > // Storage order of the right-hand side dense matrix
4604 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4605  HybridMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
4606 {
4607  using blaze::store;
4608 
4609  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4610 
4612 
4613  for( size_t j=0UL; j<n_; ++j ) {
4614  for( size_t i=0UL; i<m_; i+=IT::size ) {
4615  store( &v_[i+j*MM], (~rhs).load(i,j) );
4616  }
4617  }
4618 }
4620 //*************************************************************************************************
4621 
4622 
4623 //*************************************************************************************************
4635 template< typename Type // Data type of the matrix
4636  , size_t M // Number of rows
4637  , size_t N > // Number of columns
4638 template< typename MT > // Type of the right-hand side sparse matrix
4639 inline void HybridMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
4640 {
4641  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4642 
4643  typedef typename MT::ConstIterator RhsConstIterator;
4644 
4645  for( size_t j=0UL; j<n_; ++j )
4646  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4647  v_[element->index()+j*MM] = element->value();
4648 }
4650 //*************************************************************************************************
4651 
4652 
4653 //*************************************************************************************************
4665 template< typename Type // Data type of the matrix
4666  , size_t M // Number of rows
4667  , size_t N > // Number of columns
4668 template< typename MT > // Type of the right-hand side sparse matrix
4669 inline void HybridMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
4670 {
4671  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4672 
4673  typedef typename MT::ConstIterator RhsConstIterator;
4674 
4675  for( size_t i=0UL; i<m_; ++i )
4676  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4677  v_[i+element->index()*MM] = element->value();
4678 }
4680 //*************************************************************************************************
4681 
4682 
4683 //*************************************************************************************************
4695 template< typename Type // Data type of the matrix
4696  , size_t M // Number of rows
4697  , size_t N > // Number of columns
4698 template< typename MT // Type of the right-hand side dense matrix
4699  , bool SO > // Storage order of the right-hand side dense matrix
4700 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4701  HybridMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
4702 {
4703  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4704 
4705  for( size_t j=0UL; j<n_; ++j ) {
4706  for( size_t i=0UL; i<m_; ++i ) {
4707  v_[i+j*MM] += (~rhs)(i,j);
4708  }
4709  }
4710 }
4712 //*************************************************************************************************
4713 
4714 
4715 //*************************************************************************************************
4727 template< typename Type // Data type of the matrix
4728  , size_t M // Number of rows
4729  , size_t N > // Number of columns
4730 template< typename MT // Type of the right-hand side dense matrix
4731  , bool SO > // Storage order of the right-hand side dense matrix
4732 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4733  HybridMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
4734 {
4735  using blaze::load;
4736  using blaze::store;
4737 
4738  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4739 
4741 
4742  for( size_t j=0UL; j<n_; ++j ) {
4743  for( size_t i=0UL; i<m_; i+=IT::size ) {
4744  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
4745  }
4746  }
4747 }
4749 //*************************************************************************************************
4750 
4751 
4752 //*************************************************************************************************
4764 template< typename Type // Data type of the matrix
4765  , size_t M // Number of rows
4766  , size_t N > // Number of columns
4767 template< typename MT > // Type of the right-hand side sparse matrix
4768 inline void HybridMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
4769 {
4770  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4771 
4772  typedef typename MT::ConstIterator RhsConstIterator;
4773 
4774  for( size_t j=0UL; j<n_; ++j )
4775  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4776  v_[element->index()+j*MM] += element->value();
4777 }
4779 //*************************************************************************************************
4780 
4781 
4782 //*************************************************************************************************
4794 template< typename Type // Data type of the matrix
4795  , size_t M // Number of rows
4796  , size_t N > // Number of columns
4797 template< typename MT > // Type of the right-hand side sparse matrix
4798 inline void HybridMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
4799 {
4800  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4801 
4802  typedef typename MT::ConstIterator RhsConstIterator;
4803 
4804  for( size_t i=0UL; i<m_; ++i )
4805  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4806  v_[i+element->index()*MM] += element->value();
4807 }
4809 //*************************************************************************************************
4810 
4811 
4812 //*************************************************************************************************
4824 template< typename Type // Data type of the matrix
4825  , size_t M // Number of rows
4826  , size_t N > // Number of columns
4827 template< typename MT // Type of the right-hand side dense matrix
4828  , bool SO > // Storage order of the right-hand side dense matrix
4829 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4830  HybridMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
4831 {
4832  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4833 
4834  for( size_t j=0UL; j<n_; ++j ) {
4835  for( size_t i=0UL; i<m_; ++i ) {
4836  v_[i+j*MM] -= (~rhs)(i,j);
4837  }
4838  }
4839 }
4841 //*************************************************************************************************
4842 
4843 
4844 //*************************************************************************************************
4856 template< typename Type // Data type of the matrix
4857  , size_t M // Number of rows
4858  , size_t N > // Number of columns
4859 template< typename MT // Type of the right-hand side dense matrix
4860  , bool SO > // Storage order of the right-hand side dense matrix
4861 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4862  HybridMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
4863 {
4864  using blaze::load;
4865  using blaze::store;
4866 
4867  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4868 
4870 
4871  for( size_t j=0UL; j<n_; ++j ) {
4872  for( size_t i=0UL; i<m_; i+=IT::size ) {
4873  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
4874  }
4875  }
4876 }
4878 //*************************************************************************************************
4879 
4880 
4881 //*************************************************************************************************
4893 template< typename Type // Data type of the matrix
4894  , size_t M // Number of rows
4895  , size_t N > // Number of columns
4896 template< typename MT > // Type of the right-hand side sparse matrix
4897 inline void HybridMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
4898 {
4899  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4900 
4901  typedef typename MT::ConstIterator RhsConstIterator;
4902 
4903  for( size_t j=0UL; j<n_; ++j )
4904  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4905  v_[element->index()+j*MM] -= element->value();
4906 }
4908 //*************************************************************************************************
4909 
4910 
4911 //*************************************************************************************************
4923 template< typename Type // Data type of the matrix
4924  , size_t M // Number of rows
4925  , size_t N > // Number of columns
4926 template< typename MT > // Type of the right-hand side sparse matrix
4927 inline void HybridMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
4928 {
4929  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4930 
4931  typedef typename MT::ConstIterator RhsConstIterator;
4932 
4933  for( size_t i=0UL; i<m_; ++i )
4934  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4935  v_[i+element->index()*MM] -= element->value();
4936 }
4938 //*************************************************************************************************
4939 
4940 
4941 
4942 
4943 
4944 
4945 
4946 
4947 //=================================================================================================
4948 //
4949 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
4950 //
4951 //=================================================================================================
4952 
4953 //*************************************************************************************************
4961 template< typename Type // Data type of the matrix
4962  , size_t M // Number of rows
4963  , bool SO > // Storage order
4964 class HybridMatrix<Type,M,0UL,SO>;
4966 //*************************************************************************************************
4967 
4968 
4969 //*************************************************************************************************
4977 template< typename Type // Data type of the matrix
4978  , size_t N // Number of columns
4979  , bool SO > // Storage order
4980 class HybridMatrix<Type,0UL,N,SO>;
4982 //*************************************************************************************************
4983 
4984 
4985 //*************************************************************************************************
4993 template< typename Type // Data type of the matrix
4994  , bool SO > // Storage order
4995 class HybridMatrix<Type,0UL,0UL,SO>;
4997 //*************************************************************************************************
4998 
4999 
5000 
5001 
5002 
5003 
5004 
5005 
5006 //=================================================================================================
5007 //
5008 // STATICMATRIX OPERATORS
5009 //
5010 //=================================================================================================
5011 
5012 //*************************************************************************************************
5015 template< typename Type, size_t M, size_t N, bool SO >
5016 inline void reset( HybridMatrix<Type,M,N,SO>& m );
5017 
5018 template< typename Type, size_t M, size_t N, bool SO >
5019 inline void clear( HybridMatrix<Type,M,N,SO>& m );
5020 
5021 template< typename Type, size_t M, size_t N, bool SO >
5022 inline bool isDefault( const HybridMatrix<Type,M,N,SO>& m );
5023 
5024 template< typename Type, size_t M, size_t N, bool SO >
5025 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) /* throw() */;
5027 //*************************************************************************************************
5028 
5029 
5030 //*************************************************************************************************
5037 template< typename Type // Data type of the matrix
5038  , size_t M // Number of rows
5039  , size_t N // Number of columns
5040  , bool SO > // Storage order
5042 {
5043  m.reset();
5044 }
5045 //*************************************************************************************************
5046 
5047 
5048 //*************************************************************************************************
5057 template< typename Type // Data type of the matrix
5058  , size_t M // Number of rows
5059  , size_t N // Number of columns
5060  , bool SO > // Storage order
5062 {
5063  m.reset();
5064 }
5065 //*************************************************************************************************
5066 
5067 
5068 //*************************************************************************************************
5075 template< typename Type // Data type of the matrix
5076  , size_t M // Number of rows
5077  , size_t N // Number of columns
5078  , bool SO > // Storage order
5079 inline bool isDefault( const HybridMatrix<Type,M,N,SO>& m )
5080 {
5081  if( SO == rowMajor ) {
5082  for( size_t i=0UL; i<m.rows(); ++i )
5083  for( size_t j=0UL; j<m.columns(); ++j )
5084  if( !isDefault( m(i,j) ) ) return false;
5085  }
5086  else {
5087  for( size_t j=0UL; j<m.columns(); ++j )
5088  for( size_t i=0UL; i<m.rows(); ++i )
5089  if( !isDefault( m(i,j) ) ) return false;
5090  }
5091 
5092  return true;
5093 }
5094 //*************************************************************************************************
5095 
5096 
5097 //*************************************************************************************************
5106 template< typename Type // Data type of the matrix
5107  , size_t M // Number of rows
5108  , size_t N // Number of columns
5109  , bool SO > // Storage order
5110 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) /* throw() */
5111 {
5112  a.swap( b );
5113 }
5114 //*************************************************************************************************
5115 
5116 
5117 
5118 
5119 //=================================================================================================
5120 //
5121 // ADDTRAIT SPECIALIZATIONS
5122 //
5123 //=================================================================================================
5124 
5125 //*************************************************************************************************
5127 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5128 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5129 {
5130  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5131 };
5132 
5133 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5134 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5135 {
5136  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, false > Type;
5137 };
5138 
5139 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5140 struct AddTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5141 {
5142  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5143 };
5144 
5145 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5146 struct AddTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5147 {
5148  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, false > Type;
5149 };
5150 
5151 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5152 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5153 {
5154  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5155 };
5156 
5157 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5158 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5159 {
5160  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5161 };
5163 //*************************************************************************************************
5164 
5165 
5166 
5167 
5168 //=================================================================================================
5169 //
5170 // SUBTRAIT SPECIALIZATIONS
5171 //
5172 //=================================================================================================
5173 
5174 //*************************************************************************************************
5176 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5177 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5178 {
5179  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5180 };
5181 
5182 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5183 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5184 {
5185  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, false > Type;
5186 };
5187 
5188 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5189 struct SubTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5190 {
5191  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5192 };
5193 
5194 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5195 struct SubTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5196 {
5197  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, false > Type;
5198 };
5199 
5200 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5201 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5202 {
5203  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5204 };
5205 
5206 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5207 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5208 {
5209  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5210 };
5212 //*************************************************************************************************
5213 
5214 
5215 
5216 
5217 //=================================================================================================
5218 //
5219 // MULTTRAIT SPECIALIZATIONS
5220 //
5221 //=================================================================================================
5222 
5223 //*************************************************************************************************
5225 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5226 struct MultTrait< HybridMatrix<T1,M,N,SO>, T2 >
5227 {
5228  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5230 };
5231 
5232 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5233 struct MultTrait< T1, HybridMatrix<T2,M,N,SO> >
5234 {
5235  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5237 };
5238 
5239 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t K >
5240 struct MultTrait< HybridMatrix<T1,M,N,SO>, StaticVector<T2,K,false> >
5241 {
5242  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5243 };
5244 
5245 template< typename T1, size_t K, typename T2, size_t M, size_t N, bool SO >
5246 struct MultTrait< StaticVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5247 {
5248  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5249 };
5250 
5251 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t K >
5252 struct MultTrait< HybridMatrix<T1,M,N,SO>, HybridVector<T2,K,false> >
5253 {
5254  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5255 };
5256 
5257 template< typename T1, size_t K, typename T2, size_t M, size_t N, bool SO >
5258 struct MultTrait< HybridVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5259 {
5260  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5261 };
5262 
5263 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5264 struct MultTrait< HybridMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5265 {
5266  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5267 };
5268 
5269 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5270 struct MultTrait< DynamicVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5271 {
5272  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5273 };
5274 
5275 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5276 struct MultTrait< HybridMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5277 {
5278  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5279 };
5280 
5281 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5282 struct MultTrait< CompressedVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5283 {
5284  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5285 };
5286 
5287 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5288 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5289 {
5290  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5291 };
5292 
5293 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5294 struct MultTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5295 {
5296  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5297 };
5298 
5299 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5300 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5301 {
5302  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5303 };
5305 //*************************************************************************************************
5306 
5307 
5308 
5309 
5310 //=================================================================================================
5311 //
5312 // DIVTRAIT SPECIALIZATIONS
5313 //
5314 //=================================================================================================
5315 
5316 //*************************************************************************************************
5318 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5319 struct DivTrait< HybridMatrix<T1,M,N,SO>, T2 >
5320 {
5321  typedef HybridMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5323 };
5325 //*************************************************************************************************
5326 
5327 
5328 
5329 
5330 //=================================================================================================
5331 //
5332 // MATHTRAIT SPECIALIZATIONS
5333 //
5334 //=================================================================================================
5335 
5336 //*************************************************************************************************
5338 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5339 struct MathTrait< HybridMatrix<T1,M,N,SO>, HybridMatrix<T2,M,N,SO> >
5340 {
5341  typedef HybridMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5342  typedef HybridMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5343 };
5345 //*************************************************************************************************
5346 
5347 
5348 
5349 
5350 //=================================================================================================
5351 //
5352 // SUBMATRIXTRAIT SPECIALIZATIONS
5353 //
5354 //=================================================================================================
5355 
5356 //*************************************************************************************************
5358 template< typename T1, size_t M, size_t N, bool SO >
5359 struct SubmatrixTrait< HybridMatrix<T1,M,N,SO> >
5360 {
5361  typedef HybridMatrix<T1,M,N,SO> Type;
5362 };
5364 //*************************************************************************************************
5365 
5366 
5367 
5368 
5369 //=================================================================================================
5370 //
5371 // ROWTRAIT SPECIALIZATIONS
5372 //
5373 //=================================================================================================
5374 
5375 //*************************************************************************************************
5377 template< typename T1, size_t M, size_t N, bool SO >
5378 struct RowTrait< HybridMatrix<T1,M,N,SO> >
5379 {
5380  typedef HybridVector<T1,N,true> Type;
5381 };
5383 //*************************************************************************************************
5384 
5385 
5386 
5387 
5388 //=================================================================================================
5389 //
5390 // COLUMNTRAIT SPECIALIZATIONS
5391 //
5392 //=================================================================================================
5393 
5394 //*************************************************************************************************
5396 template< typename T1, size_t M, size_t N, bool SO >
5397 struct ColumnTrait< HybridMatrix<T1,M,N,SO> >
5398 {
5399  typedef HybridVector<T1,M,false> Type;
5400 };
5402 //*************************************************************************************************
5403 
5404 } // namespace blaze
5405 
5406 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2156
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:960
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1032
Constraint on the data type.
Header file for mathematical functions.
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2085
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#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
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2050
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: HybridMatrix.h:1384
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
Header file for the row trait.
Header file for the IsSparseMatrix type trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
This ResultType
Result type for expression template evaluations.
Definition: HybridMatrix.h:200
Header file for the IsColumnMajorMatrix type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2555
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: HybridMatrix.h:776
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
#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
size_t n_
The current number of columns of the matrix.
Definition: HybridMatrix.h:431
Header file for memory allocation and deallocation functionality.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: HybridMatrix.h:1967
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridMatrix.h:205
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2014
Header file for the SparseMatrix base class.
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:115
Type * Pointer
Pointer to a non-constant matrix value.
Definition: HybridMatrix.h:209
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: HybridMatrix.h:1591
Type & Reference
Reference to a non-constant matrix value.
Definition: HybridMatrix.h:207
Header file for the DisableIf class template.
HybridMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: HybridMatrix.h:202
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: HybridMatrix.h:210
Header file for the multiplication trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: HybridMatrix.h:1349
Header file for nested template disabiguation.
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2121
Compile time assertion.
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:984
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4605
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: HybridMatrix.h:1442
#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
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: HybridMatrix.h:1987
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: HybridMatrix.h:1945
Header file for the DenseMatrix base class.
Pointer data()
Low-level data access to the matrix elements.
Definition: HybridMatrix.h:823
Header file for the DenseIterator class template.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
HybridMatrix()
The default constructor for HybridMatrix.
Definition: HybridMatrix.h:466
Constraint on the data type.
HybridMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: HybridMatrix.h:201
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: HybridMatrix.h:1496
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
Header file for the EnableIf class template.
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
Header file for the IsVectorizable type trait.
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: HybridMatrix.h:212
Header file for the IsNumeric type trait.
Type ElementType
Type of the matrix elements.
Definition: HybridMatrix.h:203
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:912
EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
HybridMatrix & transpose()
Transposing the matrix.
Definition: HybridMatrix.h:1661
Header file for the addition trait.
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4671
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: HybridMatrix.h:1400
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
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Header file for the reset shim.
Header file for the AlignedArray implementation.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
Efficient implementation of a dynamically sized matrix with static memory.The HybridMatrix class temp...
Definition: Forward.h:49
#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:2411
Header file for the column trait.
Header file for the isDefault shim.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
Constraint on the data type.
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridMatrix.h:211
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2556
Header file for the IsRowMajorMatrix type trait.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: HybridMatrix.h:204
const Type & ConstReference
Reference to a constant matrix value.
Definition: HybridMatrix.h:208
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
void swap(HybridMatrix &m)
Swapping the contents of two hybrid matrices.
Definition: HybridMatrix.h:1729
Header file for basic type definitions.
void clear()
Clearing the hybrid matrix.
Definition: HybridMatrix.h:1544
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
size_t columns() const
Returns the current number of columns of the matrix.
Definition: HybridMatrix.h:1365
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
HybridMatrix< Type, M, N, SO > This
Type of this HybridMatrix instance.
Definition: HybridMatrix.h:199
size_t m_
The current number of rows of the matrix.
Definition: HybridMatrix.h:430
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: HybridMatrix.h:1638
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: HybridMatrix.h:189
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:154
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: HybridMatrix.h:420
#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
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209
const This & CompositeType
Data type for composite expression templates.
Definition: HybridMatrix.h:206