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>
50 #include <blaze/math/Forward.h>
51 #include <blaze/math/Functions.h>
52 #include <blaze/math/Intrinsics.h>
53 #include <blaze/math/shims/Clear.h>
69 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Memory.h>
81 #include <blaze/util/Template.h>
82 #include <blaze/util/Types.h>
86 #include <blaze/util/Unused.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS DEFINITION
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
183 template< typename Type // Data type of the matrix
184  , size_t M // Number of rows
185  , size_t N // Number of columns
186  , bool SO = defaultStorageOrder > // Storage order
187 class HybridMatrix : public DenseMatrix< HybridMatrix<Type,M,N,SO>, SO >
188 {
189  private:
190  //**Type definitions****************************************************************************
192  //**********************************************************************************************
193 
194  //**********************************************************************************************
196  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
197  //**********************************************************************************************
198 
199  public:
200  //**Type definitions****************************************************************************
202  typedef This ResultType;
205  typedef Type ElementType;
206  typedef typename IT::Type IntrinsicType;
207  typedef const Type& ReturnType;
208  typedef const This& CompositeType;
209  typedef Type& Reference;
210  typedef const Type& ConstReference;
211  typedef Type* Pointer;
212  typedef const Type* ConstPointer;
215  //**********************************************************************************************
216 
217  //**Rebind struct definition********************************************************************
220  template< typename ET > // Data type of the other matrix
221  struct Rebind {
223  };
224  //**********************************************************************************************
225 
226  //**Compilation flags***************************************************************************
228 
232  enum { vectorizable = IsVectorizable<Type>::value };
233 
235 
238  enum { smpAssignable = 0 };
239  //**********************************************************************************************
240 
241  //**Constructors********************************************************************************
244  explicit inline HybridMatrix();
245  explicit inline HybridMatrix( size_t m, size_t n );
246  explicit inline HybridMatrix( size_t m, size_t n, const Type& init );
247  template< typename Other > explicit inline HybridMatrix( size_t m, size_t n, const Other* array );
248 
249  template< typename Other, size_t M2, size_t N2 >
250  explicit inline HybridMatrix( const Other (&array)[M2][N2] );
251 
252  inline HybridMatrix( const HybridMatrix& m );
253  template< typename MT, bool SO2 > inline HybridMatrix( const Matrix<MT,SO2>& m );
255  //**********************************************************************************************
256 
257  //**Destructor**********************************************************************************
258  // No explicitly declared destructor.
259  //**********************************************************************************************
260 
261  //**Data access functions***********************************************************************
264  inline Reference operator()( size_t i, size_t j );
265  inline ConstReference operator()( size_t i, size_t j ) const;
266  inline Pointer data ();
267  inline ConstPointer data () const;
268  inline Pointer data ( size_t i );
269  inline ConstPointer data ( size_t i ) const;
270  inline Iterator begin ( size_t i );
271  inline ConstIterator begin ( size_t i ) const;
272  inline ConstIterator cbegin( size_t i ) const;
273  inline Iterator end ( size_t i );
274  inline ConstIterator end ( size_t i ) const;
275  inline ConstIterator cend ( size_t i ) const;
277  //**********************************************************************************************
278 
279  //**Assignment operators************************************************************************
282  template< typename Other, size_t M2, size_t N2 >
283  inline HybridMatrix& operator=( const Other (&array)[M2][N2] );
284 
285  inline HybridMatrix& operator= ( const Type& set );
286  inline HybridMatrix& operator= ( const HybridMatrix& rhs );
287  template< typename MT, bool SO2 > inline HybridMatrix& operator= ( const Matrix<MT,SO2>& rhs );
288  template< typename MT, bool SO2 > inline HybridMatrix& operator+=( const Matrix<MT,SO2>& rhs );
289  template< typename MT, bool SO2 > inline HybridMatrix& operator-=( const Matrix<MT,SO2>& rhs );
290  template< typename MT, bool SO2 > inline HybridMatrix& operator*=( const Matrix<MT,SO2>& rhs );
291 
292  template< typename Other >
293  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
294  operator*=( Other rhs );
295 
296  template< typename Other >
297  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
298  operator/=( Other rhs );
300  //**********************************************************************************************
301 
302  //**Utility functions***************************************************************************
305  inline size_t rows() const;
306  inline size_t columns() const;
307  inline size_t spacing() const;
308  inline size_t capacity() const;
309  inline size_t capacity( size_t i ) const;
310  inline size_t nonZeros() const;
311  inline size_t nonZeros( size_t i ) const;
312  inline void reset();
313  inline void reset( size_t i );
314  inline void clear();
315  void resize ( size_t m, size_t n, bool preserve=true );
316  inline void extend ( size_t m, size_t n, bool preserve=true );
317  inline HybridMatrix& transpose();
318  template< typename Other > inline HybridMatrix& scale( const Other& scalar );
319  inline void swap( HybridMatrix& m ) /* throw() */;
321  //**********************************************************************************************
322 
323  //**Memory functions****************************************************************************
326  static inline void* operator new ( std::size_t size );
327  static inline void* operator new[]( std::size_t size );
328  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
329  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
330 
331  static inline void operator delete ( void* ptr );
332  static inline void operator delete[]( void* ptr );
333  static inline void operator delete ( void* ptr, const std::nothrow_t& );
334  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
336  //**********************************************************************************************
337 
338  private:
339  //**********************************************************************************************
341  template< typename MT >
343  struct VectorizedAssign {
344  enum { value = vectorizable && MT::vectorizable &&
345  IsSame<Type,typename MT::ElementType>::value &&
346  IsRowMajorMatrix<MT>::value };
347  };
349  //**********************************************************************************************
350 
351  //**********************************************************************************************
353  template< typename MT >
355  struct VectorizedAddAssign {
356  enum { value = vectorizable && MT::vectorizable &&
357  IsSame<Type,typename MT::ElementType>::value &&
358  IntrinsicTrait<Type>::addition &&
359  IsRowMajorMatrix<MT>::value };
360  };
362  //**********************************************************************************************
363 
364  //**********************************************************************************************
366  template< typename MT >
368  struct VectorizedSubAssign {
369  enum { value = vectorizable && MT::vectorizable &&
370  IsSame<Type,typename MT::ElementType>::value &&
371  IntrinsicTrait<Type>::subtraction &&
372  IsRowMajorMatrix<MT>::value };
373  };
375  //**********************************************************************************************
376 
377  public:
378  //**Expression template evaluation functions****************************************************
381  template< typename Other > inline bool canAlias ( const Other* alias ) const;
382  template< typename Other > inline bool isAliased( const Other* alias ) const;
383 
384  inline bool isAligned() const;
385 
386  inline IntrinsicType load ( size_t i, size_t j ) const;
387  inline IntrinsicType loadu ( size_t i, size_t j ) const;
388  inline void store ( size_t i, size_t j, const IntrinsicType& value );
389  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
390  inline void stream( size_t i, size_t j, const IntrinsicType& value );
391 
392  template< typename MT, bool SO2 >
393  inline typename DisableIf< VectorizedAssign<MT> >::Type
394  assign( const DenseMatrix<MT,SO2>& rhs );
395 
396  template< typename MT, bool SO2 >
397  inline typename EnableIf< VectorizedAssign<MT> >::Type
398  assign( const DenseMatrix<MT,SO2>& rhs );
399 
400  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
401  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
402 
403  template< typename MT, bool SO2 >
404  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
405  addAssign( const DenseMatrix<MT,SO2>& rhs );
406 
407  template< typename MT, bool SO2 >
408  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
409  addAssign( const DenseMatrix<MT,SO2>& rhs );
410 
411  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
412  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
413 
414  template< typename MT, bool SO2 >
415  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
416  subAssign( const DenseMatrix<MT,SO2>& rhs );
417 
418  template< typename MT, bool SO2 >
419  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
420  subAssign( const DenseMatrix<MT,SO2>& rhs );
421 
422  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
423  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
425  //**********************************************************************************************
426 
427  private:
428  //**Member variables****************************************************************************
432 
441  size_t m_;
442  size_t n_;
443 
444  //**********************************************************************************************
445 
446  //**Compile time checks*************************************************************************
452  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
453  BLAZE_STATIC_ASSERT( NN >= N );
455  //**********************************************************************************************
456 };
457 //*************************************************************************************************
458 
459 
460 
461 
462 //=================================================================================================
463 //
464 // CONSTRUCTORS
465 //
466 //=================================================================================================
467 
468 //*************************************************************************************************
473 template< typename Type // Data type of the matrix
474  , size_t M // Number of rows
475  , size_t N // Number of columns
476  , bool SO > // Storage order
478  : v_() // The statically allocated matrix elements
479  , m_( 0UL ) // The current number of rows of the matrix
480  , n_( 0UL ) // The current number of columns of the matrix
481 {
483 
484  if( IsNumeric<Type>::value ) {
485  for( size_t i=0UL; i<M*NN; ++i )
486  v_[i] = Type();
487  }
488 }
489 //*************************************************************************************************
490 
491 
492 //*************************************************************************************************
505 template< typename Type // Data type of the matrix
506  , size_t M // Number of rows
507  , size_t N // Number of columns
508  , bool SO > // Storage order
509 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n )
510  : v_() // The statically allocated matrix elements
511  , m_( m ) // The current number of rows of the matrix
512  , n_( n ) // The current number of columns of the matrix
513 {
515 
516  if( m > M )
517  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
518 
519  if( n > N )
520  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
521 
522  if( IsNumeric<Type>::value ) {
523  for( size_t i=0UL; i<M*NN; ++i )
524  v_[i] = Type();
525  }
526 }
527 //*************************************************************************************************
528 
529 
530 //*************************************************************************************************
544 template< typename Type // Data type of the matrix
545  , size_t M // Number of rows
546  , size_t N // Number of columns
547  , bool SO > // Storage order
548 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n, const Type& init )
549  : v_() // The statically allocated matrix elements
550  , m_( m ) // The current number of rows of the matrix
551  , n_( n ) // The current number of columns of the matrix
552 {
554 
555  if( m > M )
556  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
557 
558  if( n > N )
559  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
560 
561  for( size_t i=0UL; i<m; ++i ) {
562  for( size_t j=0UL; j<n; ++j )
563  v_[i*NN+j] = init;
564 
565  if( IsNumeric<Type>::value ) {
566  for( size_t j=n; j<NN; ++j )
567  v_[i*NN+j] = Type();
568  }
569  }
570 
571  if( IsNumeric<Type>::value ) {
572  for( size_t i=m; i<M; ++i )
573  for( size_t j=0UL; j<NN; ++j )
574  v_[i*NN+j] = Type();
575  }
576 }
577 //*************************************************************************************************
578 
579 
580 //*************************************************************************************************
607 template< typename Type // Data type of the matrix
608  , size_t M // Number of rows
609  , size_t N // Number of columns
610  , bool SO > // Storage order
611 template< typename Other > // Data type of the initialization array
612 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( size_t m, size_t n, const Other* array )
613  : v_() // The statically allocated matrix elements
614  , m_( m ) // The current number of rows of the matrix
615  , n_( n ) // The current number of columns of the matrix
616 {
618 
619  if( m > M )
620  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
621 
622  if( n > N )
623  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
624 
625  for( size_t i=0UL; i<m; ++i ) {
626  for( size_t j=0UL; j<n; ++j )
627  v_[i*NN+j] = array[i*n+j];
628 
629  if( IsNumeric<Type>::value ) {
630  for( size_t j=n; j<NN; ++j )
631  v_[i*NN+j] = Type();
632  }
633  }
634 
635  if( IsNumeric<Type>::value ) {
636  for( size_t i=m; i<M; ++i )
637  for( size_t j=0UL; j<NN; ++j )
638  v_[i*NN+j] = Type();
639  }
640 }
641 //*************************************************************************************************
642 
643 
644 //*************************************************************************************************
665 template< typename Type // Data type of the matrix
666  , size_t M // Number of rows
667  , size_t N // Number of columns
668  , bool SO > // Storage order
669 template< typename Other // Data type of the initialization array
670  , size_t M2 // Number of rows of the initialization array
671  , size_t N2 > // Number of columns of the initialization array
672 inline HybridMatrix<Type,M,N,SO>::HybridMatrix( const Other (&array)[M2][N2] )
673  : v_() // The statically allocated matrix elements
674  , m_( M2 ) // The current number of rows of the matrix
675  , n_( N2 ) // The current number of columns of the matrix
676 {
677  BLAZE_STATIC_ASSERT( M2 <= M );
678  BLAZE_STATIC_ASSERT( N2 <= N );
680 
681  for( size_t i=0UL; i<M2; ++i ) {
682  for( size_t j=0UL; j<N2; ++j )
683  v_[i*NN+j] = array[i][j];
684 
685  if( IsNumeric<Type>::value ) {
686  for( size_t j=N2; j<NN; ++j )
687  v_[i*NN+j] = Type();
688  }
689  }
690 
691  if( IsNumeric<Type>::value ) {
692  for( size_t i=M2; i<M; ++i )
693  for( size_t j=0UL; j<NN; ++j )
694  v_[i*NN+j] = Type();
695  }
696 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
708 template< typename Type // Data type of the matrix
709  , size_t M // Number of rows
710  , size_t N // Number of columns
711  , bool SO > // Storage order
713  : v_() // The statically allocated matrix elements
714  , m_( m.m_ ) // The current number of rows of the matrix
715  , n_( m.n_ ) // The current number of columns of the matrix
716 {
718 
719  for( size_t i=0UL; i<m_; ++i ) {
720  for( size_t j=0UL; j<n_; ++j )
721  v_[i*NN+j] = m.v_[i*NN+j];
722 
723  if( IsNumeric<Type>::value ) {
724  for( size_t j=n_; j<NN; ++j )
725  v_[i*NN+j] = Type();
726  }
727  }
728 
729  if( IsNumeric<Type>::value ) {
730  for( size_t i=m_; i<M; ++i )
731  for( size_t j=0UL; j<NN; ++j )
732  v_[i*NN+j] = Type();
733  }
734 }
735 //*************************************************************************************************
736 
737 
738 //*************************************************************************************************
744 template< typename Type // Data type of the matrix
745  , size_t M // Number of rows
746  , size_t N // Number of columns
747  , bool SO > // Storage order
748 template< typename MT // Type of the foreign matrix
749  , bool SO2 > // Storage order of the foreign matrix
751  : v_() // The statically allocated matrix elements
752  , m_( (~m).rows() ) // The current number of rows of the matrix
753  , n_( (~m).columns() ) // The current number of columns of the matrix
754 {
755  using blaze::assign;
756 
758 
759  if( (~m).rows() > M || (~m).columns() > N )
760  throw std::invalid_argument( "Invalid setup of hybrid matrix" );
761 
762  for( size_t i=0UL; i<m_; ++i ) {
763  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : n_ );
764  j<( IsNumeric<Type>::value ? NN : n_ );
765  ++j ) {
766  v_[i*NN+j] = Type();
767  }
768  }
769 
770  if( IsNumeric<Type>::value ) {
771  for( size_t i=m_; i<M; ++i )
772  for( size_t j=0UL; j<NN; ++j )
773  v_[i*NN+j] = Type();
774  }
775 
776  assign( *this, ~m );
777 }
778 //*************************************************************************************************
779 
780 
781 
782 
783 //=================================================================================================
784 //
785 // DATA ACCESS FUNCTIONS
786 //
787 //=================================================================================================
788 
789 //*************************************************************************************************
796 template< typename Type // Data type of the matrix
797  , size_t M // Number of rows
798  , size_t N // Number of columns
799  , bool SO > // Storage order
802 {
803  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
804  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
805  return v_[i*NN+j];
806 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
817 template< typename Type // Data type of the matrix
818  , size_t M // Number of rows
819  , size_t N // Number of columns
820  , bool SO > // Storage order
822  HybridMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
823 {
824  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
825  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
826  return v_[i*NN+j];
827 }
828 //*************************************************************************************************
829 
830 
831 //*************************************************************************************************
843 template< typename Type // Data type of the matrix
844  , size_t M // Number of rows
845  , size_t N // Number of columns
846  , bool SO > // Storage order
849 {
850  return v_;
851 }
852 //*************************************************************************************************
853 
854 
855 //*************************************************************************************************
867 template< typename Type // Data type of the matrix
868  , size_t M // Number of rows
869  , size_t N // Number of columns
870  , bool SO > // Storage order
873 {
874  return v_;
875 }
876 //*************************************************************************************************
877 
878 
879 //*************************************************************************************************
887 template< typename Type // Data type of the matrix
888  , size_t M // Number of rows
889  , size_t N // Number of columns
890  , bool SO > // Storage order
893 {
894  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
895  return v_ + i*NN;
896 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
908 template< typename Type // Data type of the matrix
909  , size_t M // Number of rows
910  , size_t N // Number of columns
911  , bool SO > // Storage order
914 {
915  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
916  return v_ + i*NN;
917 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
932 template< typename Type // Data type of the matrix
933  , size_t M // Number of rows
934  , size_t N // Number of columns
935  , bool SO > // Storage order
938 {
939  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
940  return Iterator( v_ + i*NN );
941 }
942 //*************************************************************************************************
943 
944 
945 //*************************************************************************************************
956 template< typename Type // Data type of the matrix
957  , size_t M // Number of rows
958  , size_t N // Number of columns
959  , bool SO > // Storage order
962 {
963  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
964  return ConstIterator( v_ + i*NN );
965 }
966 //*************************************************************************************************
967 
968 
969 //*************************************************************************************************
980 template< typename Type // Data type of the matrix
981  , size_t M // Number of rows
982  , size_t N // Number of columns
983  , bool SO > // Storage order
986 {
987  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
988  return ConstIterator( v_ + i*NN );
989 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
1004 template< typename Type // Data type of the matrix
1005  , size_t M // Number of rows
1006  , size_t N // Number of columns
1007  , bool SO > // Storage order
1010 {
1011  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1012  return Iterator( v_ + i*NN + N );
1013 }
1014 //*************************************************************************************************
1015 
1016 
1017 //*************************************************************************************************
1028 template< typename Type // Data type of the matrix
1029  , size_t M // Number of rows
1030  , size_t N // Number of columns
1031  , bool SO > // Storage order
1034 {
1035  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1036  return ConstIterator( v_ + i*NN + N );
1037 }
1038 //*************************************************************************************************
1039 
1040 
1041 //*************************************************************************************************
1052 template< typename Type // Data type of the matrix
1053  , size_t M // Number of rows
1054  , size_t N // Number of columns
1055  , bool SO > // Storage order
1058 {
1059  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1060  return ConstIterator( v_ + i*NN + N );
1061 }
1062 //*************************************************************************************************
1063 
1064 
1065 
1066 
1067 //=================================================================================================
1068 //
1069 // ASSIGNMENT OPERATORS
1070 //
1071 //=================================================================================================
1072 
1073 //*************************************************************************************************
1094 template< typename Type // Data type of the matrix
1095  , size_t M // Number of rows
1096  , size_t N // Number of columns
1097  , bool SO > // Storage order
1098 template< typename Other // Data type of the initialization array
1099  , size_t M2 // Number of rows of the initialization array
1100  , size_t N2 > // Number of columns of the initialization array
1102 {
1103  BLAZE_STATIC_ASSERT( M2 <= M );
1104  BLAZE_STATIC_ASSERT( N2 <= N );
1105 
1106  resize( M2, N2 );
1107 
1108  for( size_t i=0UL; i<M2; ++i )
1109  for( size_t j=0UL; j<N2; ++j )
1110  v_[i*NN+j] = array[i][j];
1111 
1112  return *this;
1113 }
1114 //*************************************************************************************************
1115 
1116 
1117 //*************************************************************************************************
1123 template< typename Type // Data type of the matrix
1124  , size_t M // Number of rows
1125  , size_t N // Number of columns
1126  , bool SO > // Storage order
1128 {
1129  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
1130  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
1131 
1132  for( size_t i=0UL; i<m_; ++i )
1133  for( size_t j=0UL; j<n_; ++j )
1134  v_[i*NN+j] = set;
1135 
1136  return *this;
1137 }
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1149 template< typename Type // Data type of the matrix
1150  , size_t M // Number of rows
1151  , size_t N // Number of columns
1152  , bool SO > // Storage order
1154 {
1155  using blaze::assign;
1156 
1157  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
1158  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
1159 
1160  resize( rhs.rows(), rhs.columns() );
1161  assign( *this, ~rhs );
1162 
1163  return *this;
1164 }
1165 //*************************************************************************************************
1166 
1167 
1168 //*************************************************************************************************
1179 template< typename Type // Data type of the matrix
1180  , size_t M // Number of rows
1181  , size_t N // Number of columns
1182  , bool SO > // Storage order
1183 template< typename MT // Type of the right-hand side matrix
1184  , bool SO2 > // Storage order of the right-hand side matrix
1186 {
1187  using blaze::assign;
1188 
1189  if( (~rhs).rows() > M || (~rhs).columns() > N )
1190  throw std::invalid_argument( "Invalid assignment to hybrid matrix" );
1191 
1192  if( (~rhs).canAlias( this ) ) {
1193  HybridMatrix tmp( ~rhs );
1194  swap( tmp );
1195  }
1196  else {
1197  resize( (~rhs).rows(), (~rhs).columns() );
1199  reset();
1200  assign( *this, ~rhs );
1201  }
1202 
1203  return *this;
1204 }
1205 //*************************************************************************************************
1206 
1207 
1208 //*************************************************************************************************
1218 template< typename Type // Data type of the matrix
1219  , size_t M // Number of rows
1220  , size_t N // Number of columns
1221  , bool SO > // Storage order
1222 template< typename MT // Type of the right-hand side matrix
1223  , bool SO2 > // Storage order of the right-hand side matrix
1225 {
1226  using blaze::addAssign;
1227 
1228  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1229  throw std::invalid_argument( "Matrix sizes do not match" );
1230 
1231  if( (~rhs).canAlias( this ) ) {
1232  typename MT::ResultType tmp( ~rhs );
1233  addAssign( *this, tmp );
1234  }
1235  else {
1236  addAssign( *this, ~rhs );
1237  }
1238 
1239  return *this;
1240 }
1241 //*************************************************************************************************
1242 
1243 
1244 //*************************************************************************************************
1254 template< typename Type // Data type of the matrix
1255  , size_t M // Number of rows
1256  , size_t N // Number of columns
1257  , bool SO > // Storage order
1258 template< typename MT // Type of the right-hand side matrix
1259  , bool SO2 > // Storage order of the right-hand side matrix
1261 {
1262  using blaze::subAssign;
1263 
1264  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
1265  throw std::invalid_argument( "Matrix sizes do not match" );
1266 
1267  if( (~rhs).canAlias( this ) ) {
1268  typename MT::ResultType tmp( ~rhs );
1269  subAssign( *this, tmp );
1270  }
1271  else {
1272  subAssign( *this, ~rhs );
1273  }
1274 
1275  return *this;
1276 }
1277 //*************************************************************************************************
1278 
1279 
1280 //*************************************************************************************************
1290 template< typename Type // Data type of the matrix
1291  , size_t M // Number of rows
1292  , size_t N // Number of columns
1293  , bool SO > // Storage order
1294 template< typename MT // Type of the right-hand side matrix
1295  , bool SO2 > // Storage order of the right-hand side matrix
1297 {
1298  if( n_ != (~rhs).rows() || (~rhs).columns() > N )
1299  throw std::invalid_argument( "Matrix sizes do not match" );
1300 
1301  HybridMatrix tmp( *this * (~rhs) );
1302  return this->operator=( tmp );
1303 }
1304 //*************************************************************************************************
1305 
1306 
1307 //*************************************************************************************************
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  assign( *this, (*this) * rhs );
1325  return *this;
1326 }
1327 //*************************************************************************************************
1328 
1329 
1330 //*************************************************************************************************
1339 template< typename Type // Data type of the matrix
1340  , size_t M // Number of rows
1341  , size_t N // Number of columns
1342  , bool SO > // Storage order
1343 template< typename Other > // Data type of the right-hand side scalar
1344 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,SO> >::Type&
1346 {
1347  using blaze::assign;
1348 
1349  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1350 
1351  assign( *this, (*this) / rhs );
1352  return *this;
1353 }
1354 //*************************************************************************************************
1355 
1356 
1357 
1358 
1359 //=================================================================================================
1360 //
1361 // UTILITY FUNCTIONS
1362 //
1363 //=================================================================================================
1364 
1365 //*************************************************************************************************
1370 template< typename Type // Data type of the matrix
1371  , size_t M // Number of rows
1372  , size_t N // Number of columns
1373  , bool SO > // Storage order
1374 inline size_t HybridMatrix<Type,M,N,SO>::rows() const
1375 {
1376  return m_;
1377 }
1378 //*************************************************************************************************
1379 
1380 
1381 //*************************************************************************************************
1386 template< typename Type // Data type of the matrix
1387  , size_t M // Number of rows
1388  , size_t N // Number of columns
1389  , bool SO > // Storage order
1391 {
1392  return n_;
1393 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1405 template< typename Type // Data type of the matrix
1406  , size_t M // Number of rows
1407  , size_t N // Number of columns
1408  , bool SO > // Storage order
1410 {
1411  return NN;
1412 }
1413 //*************************************************************************************************
1414 
1415 
1416 //*************************************************************************************************
1421 template< typename Type // Data type of the matrix
1422  , size_t M // Number of rows
1423  , size_t N // Number of columns
1424  , bool SO > // Storage order
1426 {
1427  return M*NN;
1428 }
1429 //*************************************************************************************************
1430 
1431 
1432 //*************************************************************************************************
1443 template< typename Type // Data type of the matrix
1444  , size_t M // Number of rows
1445  , size_t N // Number of columns
1446  , bool SO > // Storage order
1447 inline size_t HybridMatrix<Type,M,N,SO>::capacity( size_t i ) const
1448 {
1449  UNUSED_PARAMETER( i );
1450 
1451  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1452 
1453  return NN;
1454 }
1455 //*************************************************************************************************
1456 
1457 
1458 //*************************************************************************************************
1463 template< typename Type // Data type of the matrix
1464  , size_t M // Number of rows
1465  , size_t N // Number of columns
1466  , bool SO > // Storage order
1468 {
1469  size_t nonzeros( 0UL );
1470 
1471  for( size_t i=0UL; i<m_; ++i )
1472  for( size_t j=0UL; j<n_; ++j )
1473  if( !isDefault( v_[i*NN+j] ) )
1474  ++nonzeros;
1475 
1476  return nonzeros;
1477 }
1478 //*************************************************************************************************
1479 
1480 
1481 //*************************************************************************************************
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
1496 inline size_t HybridMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
1497 {
1498  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1499 
1500  const size_t jend( i*NN+n_ );
1501  size_t nonzeros( 0UL );
1502 
1503  for( size_t j=i*NN; j<jend; ++j )
1504  if( !isDefault( v_[j] ) )
1505  ++nonzeros;
1506 
1507  return nonzeros;
1508 }
1509 //*************************************************************************************************
1510 
1511 
1512 //*************************************************************************************************
1517 template< typename Type // Data type of the matrix
1518  , size_t M // Number of rows
1519  , size_t N // Number of columns
1520  , bool SO > // Storage order
1522 {
1523  using blaze::clear;
1524 
1525  for( size_t i=0UL; i<m_; ++i )
1526  for( size_t j=0UL; j<n_; ++j )
1527  clear( v_[i*NN+j] );
1528 }
1529 //*************************************************************************************************
1530 
1531 
1532 //*************************************************************************************************
1543 template< typename Type // Data type of the matrix
1544  , size_t M // Number of rows
1545  , size_t N // Number of columns
1546  , bool SO > // Storage order
1547 inline void HybridMatrix<Type,M,N,SO>::reset( size_t i )
1548 {
1549  using blaze::clear;
1550 
1551  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1552  for( size_t j=0UL; j<n_; ++j )
1553  clear( v_[i*NN+j] );
1554 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1565 template< typename Type // Data type of the matrix
1566  , size_t M // Number of rows
1567  , size_t N // Number of columns
1568  , bool SO > // Storage order
1570 {
1571  resize( 0UL, 0UL );
1572 }
1573 //*************************************************************************************************
1574 
1575 
1576 //*************************************************************************************************
1612 template< typename Type // Data type of the matrix
1613  , size_t M // Number of rows
1614  , size_t N // Number of columns
1615  , bool SO > // Storage order
1616 void HybridMatrix<Type,M,N,SO>::resize( size_t m, size_t n, bool preserve )
1617 {
1618  UNUSED_PARAMETER( preserve );
1619 
1620  if( m > M )
1621  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
1622 
1623  if( n > N )
1624  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
1625 
1626  if( IsVectorizable<Type>::value && n < n_ ) {
1627  for( size_t i=0UL; i<m; ++i )
1628  for( size_t j=n; j<n_; ++j )
1629  v_[i*NN+j] = Type();
1630  }
1631 
1632  if( IsVectorizable<Type>::value && m < m_ ) {
1633  for( size_t i=m; i<m_; ++i )
1634  for( size_t j=0UL; j<n_; ++j )
1635  v_[i*NN+j] = Type();
1636  }
1637 
1638  m_ = m;
1639  n_ = n;
1640 }
1641 //*************************************************************************************************
1642 
1643 
1644 //*************************************************************************************************
1659 template< typename Type // Data type of the matrix
1660  , size_t M // Number of rows
1661  , size_t N // Number of columns
1662  , bool SO > // Storage order
1663 inline void HybridMatrix<Type,M,N,SO>::extend( size_t m, size_t n, bool preserve )
1664 {
1665  UNUSED_PARAMETER( preserve );
1666  resize( m_+m, n_+n );
1667 }
1668 //*************************************************************************************************
1669 
1670 
1671 //*************************************************************************************************
1682 template< typename Type // Data type of the matrix
1683  , size_t M // Number of rows
1684  , size_t N // Number of columns
1685  , bool SO > // Storage order
1687 {
1688  using std::swap;
1689 
1690  if( m_ > N || n_ > M )
1691  throw std::logic_error( "Impossible transpose operation" );
1692 
1693  const size_t maxsize( max( m_, n_ ) );
1694  for( size_t i=1UL; i<maxsize; ++i )
1695  for( size_t j=0UL; j<i; ++j )
1696  swap( v_[i*NN+j], v_[j*NN+i] );
1697 
1698  if( IsVectorizable<Type>::value && m_ < n_ ) {
1699  for( size_t i=0UL; i<m_; ++i ) {
1700  for( size_t j=m_; j<n_; ++j ) {
1701  v_[i*NN+j] = Type();
1702  }
1703  }
1704  }
1705 
1706  if( IsVectorizable<Type>::value && m_ > n_ ) {
1707  for( size_t i=n_; i<m_; ++i ) {
1708  for( size_t j=0UL; j<n_; ++j ) {
1709  v_[i*NN+j] = Type();
1710  }
1711  }
1712  }
1713 
1714  swap( m_, n_ );
1715 
1716  return *this;
1717 }
1718 //*************************************************************************************************
1719 
1720 
1721 //*************************************************************************************************
1727 template< typename Type // Data type of the matrix
1728  , size_t M // Number of rows
1729  , size_t N // Number of columns
1730  , bool SO > // Storage order
1731 template< typename Other > // Data type of the scalar value
1733 {
1734  for( size_t i=0UL; i<m_; ++i )
1735  for( size_t j=0UL; j<n_; ++j )
1736  v_[i*NN+j] *= scalar;
1737 
1738  return *this;
1739 }
1740 //*************************************************************************************************
1741 
1742 
1743 //*************************************************************************************************
1750 template< typename Type // Data type of the matrix
1751  , size_t M // Number of rows
1752  , size_t N // Number of columns
1753  , bool SO > // Storage order
1754 inline void HybridMatrix<Type,M,N,SO>::swap( HybridMatrix& m ) /* throw() */
1755 {
1756  using std::swap;
1757 
1758  const size_t maxrows( max( m_, m.m_ ) );
1759  const size_t maxcols( max( n_, m.n_ ) );
1760 
1761  for( size_t i=0UL; i<maxrows; ++i ) {
1762  for( size_t j=0UL; j<maxcols; ++j ) {
1763  swap( v_[i*NN+j], m(i,j) );
1764  }
1765  }
1766 
1767  swap( m_, m.m_ );
1768  swap( n_, m.n_ );
1769 }
1770 //*************************************************************************************************
1771 
1772 
1773 
1774 
1775 //=================================================================================================
1776 //
1777 // MEMORY FUNCTIONS
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 {
1798 
1799  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
1800 
1801  return allocate<HybridMatrix>( 1UL );
1802 }
1803 //*************************************************************************************************
1804 
1805 
1806 //*************************************************************************************************
1816 template< typename Type // Data type of the matrix
1817  , size_t M // Number of rows
1818  , size_t N // Number of columns
1819  , bool SO > // Storage order
1820 inline void* HybridMatrix<Type,M,N,SO>::operator new[]( std::size_t size )
1821 {
1822  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
1823  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
1824 
1825  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
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 {
1847 
1848  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
1849 
1850  return allocate<HybridMatrix>( 1UL );
1851 }
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1865 template< typename Type // Data type of the matrix
1866  , size_t M // Number of rows
1867  , size_t N // Number of columns
1868  , bool SO > // Storage order
1869 inline void* HybridMatrix<Type,M,N,SO>::operator new[]( std::size_t size, const std::nothrow_t& )
1870 {
1871  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
1872  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
1873 
1874  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
1875 }
1876 //*************************************************************************************************
1877 
1878 
1879 //*************************************************************************************************
1885 template< typename Type // Data type of the matrix
1886  , size_t M // Number of rows
1887  , size_t N // Number of columns
1888  , bool SO > // Storage order
1889 inline void HybridMatrix<Type,M,N,SO>::operator delete( void* ptr )
1890 {
1891  deallocate( static_cast<HybridMatrix*>( ptr ) );
1892 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1902 template< typename Type // Data type of the matrix
1903  , size_t M // Number of rows
1904  , size_t N // Number of columns
1905  , bool SO > // Storage order
1906 inline void HybridMatrix<Type,M,N,SO>::operator delete[]( void* ptr )
1907 {
1908  deallocate( static_cast<HybridMatrix*>( ptr ) );
1909 }
1910 //*************************************************************************************************
1911 
1912 
1913 //*************************************************************************************************
1919 template< typename Type // Data type of the matrix
1920  , size_t M // Number of rows
1921  , size_t N // Number of columns
1922  , bool SO > // Storage order
1923 inline void HybridMatrix<Type,M,N,SO>::operator delete( void* ptr, const std::nothrow_t& )
1924 {
1925  deallocate( static_cast<HybridMatrix*>( ptr ) );
1926 }
1927 //*************************************************************************************************
1928 
1929 
1930 //*************************************************************************************************
1936 template< typename Type // Data type of the matrix
1937  , size_t M // Number of rows
1938  , size_t N // Number of columns
1939  , bool SO > // Storage order
1940 inline void HybridMatrix<Type,M,N,SO>::operator delete[]( void* ptr, const std::nothrow_t& )
1941 {
1942  deallocate( static_cast<HybridMatrix*>( ptr ) );
1943 }
1944 //*************************************************************************************************
1945 
1946 
1947 
1948 
1949 //=================================================================================================
1950 //
1951 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1952 //
1953 //=================================================================================================
1954 
1955 //*************************************************************************************************
1965 template< typename Type // Data type of the matrix
1966  , size_t M // Number of rows
1967  , size_t N // Number of columns
1968  , bool SO > // Storage order
1969 template< typename Other > // Data type of the foreign expression
1970 inline bool HybridMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
1971 {
1972  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1973 }
1974 //*************************************************************************************************
1975 
1976 
1977 //*************************************************************************************************
1987 template< typename Type // Data type of the matrix
1988  , size_t M // Number of rows
1989  , size_t N // Number of columns
1990  , bool SO > // Storage order
1991 template< typename Other > // Data type of the foreign expression
1992 inline bool HybridMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
1993 {
1994  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1995 }
1996 //*************************************************************************************************
1997 
1998 
1999 //*************************************************************************************************
2008 template< typename Type // Data type of the matrix
2009  , size_t M // Number of rows
2010  , size_t N // Number of columns
2011  , bool SO > // Storage order
2013 {
2014  return true;
2015 }
2016 //*************************************************************************************************
2017 
2018 
2019 //*************************************************************************************************
2034 template< typename Type // Data type of the matrix
2035  , size_t M // Number of rows
2036  , size_t N // Number of columns
2037  , bool SO > // Storage order
2039  HybridMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2040 {
2041  using blaze::load;
2042 
2044 
2045  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2046  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2047  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2048  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2049 
2050  return load( &v_[i*NN+j] );
2051 }
2052 //*************************************************************************************************
2053 
2054 
2055 //*************************************************************************************************
2070 template< typename Type // Data type of the matrix
2071  , size_t M // Number of rows
2072  , size_t N // Number of columns
2073  , bool SO > // Storage order
2075  HybridMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2076 {
2077  using blaze::loadu;
2078 
2080 
2081  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2082  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2083  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2084 
2085  return loadu( &v_[i*NN+j] );
2086 }
2087 //*************************************************************************************************
2088 
2089 
2090 //*************************************************************************************************
2106 template< typename Type // Data type of the matrix
2107  , size_t M // Number of rows
2108  , size_t N // Number of columns
2109  , bool SO > // Storage order
2110 inline void HybridMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2111 {
2112  using blaze::store;
2113 
2115 
2116  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2117  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2118  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2119  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2120 
2121  store( &v_[i*NN+j], value );
2122 }
2123 //*************************************************************************************************
2124 
2125 
2126 //*************************************************************************************************
2142 template< typename Type // Data type of the matrix
2143  , size_t M // Number of rows
2144  , size_t N // Number of columns
2145  , bool SO > // Storage order
2146 inline void HybridMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2147 {
2148  using blaze::storeu;
2149 
2151 
2152  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
2153  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
2154  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2155 
2156  storeu( &v_[i*NN+j], value );
2157 }
2158 //*************************************************************************************************
2159 
2160 
2161 //*************************************************************************************************
2177 template< typename Type // Data type of the matrix
2178  , size_t M // Number of rows
2179  , size_t N // Number of columns
2180  , bool SO > // Storage order
2181 inline void HybridMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2182 {
2183  using blaze::stream;
2184 
2186 
2187  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
2188  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
2189  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2190  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2191 
2192  stream( &v_[i*NN+j], value );
2193 }
2194 //*************************************************************************************************
2195 
2196 
2197 //*************************************************************************************************
2208 template< typename Type // Data type of the matrix
2209  , size_t M // Number of rows
2210  , size_t N // Number of columns
2211  , bool SO > // Storage order
2212 template< typename MT // Type of the right-hand side dense matrix
2213  , bool SO2 > // Storage order of the right-hand side dense matrix
2214 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2216 {
2217  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2218 
2219  for( size_t i=0UL; i<m_; ++i ) {
2220  for( size_t j=0UL; j<n_; ++j ) {
2221  v_[i*NN+j] = (~rhs)(i,j);
2222  }
2223  }
2224 }
2225 //*************************************************************************************************
2226 
2227 
2228 //*************************************************************************************************
2239 template< typename Type // Data type of the matrix
2240  , size_t M // Number of rows
2241  , size_t N // Number of columns
2242  , bool SO > // Storage order
2243 template< typename MT // Type of the right-hand side dense matrix
2244  , bool SO2 > // Storage order of the right-hand side dense matrix
2245 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2247 {
2248  using blaze::store;
2249 
2250  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2251 
2253 
2254  for( size_t i=0UL; i<m_; ++i ) {
2255  for( size_t j=0UL; j<n_; j+=IT::size ) {
2256  store( &v_[i*NN+j], (~rhs).load(i,j) );
2257  }
2258  }
2259 }
2260 //*************************************************************************************************
2261 
2262 
2263 //*************************************************************************************************
2274 template< typename Type // Data type of the matrix
2275  , size_t M // Number of rows
2276  , size_t N // Number of columns
2277  , bool SO > // Storage order
2278 template< typename MT > // Type of the right-hand side sparse matrix
2280 {
2281  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2282 
2283  typedef typename MT::ConstIterator RhsConstIterator;
2284 
2285  for( size_t i=0UL; i<m_; ++i )
2286  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2287  v_[i*NN+element->index()] = element->value();
2288 }
2289 //*************************************************************************************************
2290 
2291 
2292 //*************************************************************************************************
2303 template< typename Type // Data type of the matrix
2304  , size_t M // Number of rows
2305  , size_t N // Number of columns
2306  , bool SO > // Storage order
2307 template< typename MT > // Type of the right-hand side sparse matrix
2309 {
2311 
2312  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2313 
2314  typedef typename MT::ConstIterator RhsConstIterator;
2315 
2316  for( size_t j=0UL; j<n_; ++j )
2317  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2318  v_[element->index()*NN+j] = element->value();
2319 }
2320 //*************************************************************************************************
2321 
2322 
2323 //*************************************************************************************************
2334 template< typename Type // Data type of the matrix
2335  , size_t M // Number of rows
2336  , size_t N // Number of columns
2337  , bool SO > // Storage order
2338 template< typename MT // Type of the right-hand side dense matrix
2339  , bool SO2 > // Storage order of the right-hand side dense matrix
2340 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2342 {
2343  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2344 
2345  for( size_t i=0UL; i<m_; ++i ) {
2346  for( size_t j=0UL; j<n_; ++j ) {
2347  v_[i*NN+j] += (~rhs)(i,j);
2348  }
2349  }
2350 }
2351 //*************************************************************************************************
2352 
2353 
2354 //*************************************************************************************************
2365 template< typename Type // Data type of the matrix
2366  , size_t M // Number of rows
2367  , size_t N // Number of columns
2368  , bool SO > // Storage order
2369 template< typename MT // Type of the right-hand side dense matrix
2370  , bool SO2 > // Storage order of the right-hand side dense matrix
2371 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2373 {
2374  using blaze::load;
2375  using blaze::store;
2376 
2377  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2378 
2380 
2381  for( size_t i=0UL; i<m_; ++i ) {
2382  for( size_t j=0UL; j<n_; j+=IT::size ) {
2383  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2384  }
2385  }
2386 }
2387 //*************************************************************************************************
2388 
2389 
2390 //*************************************************************************************************
2401 template< typename Type // Data type of the matrix
2402  , size_t M // Number of rows
2403  , size_t N // Number of columns
2404  , bool SO > // Storage order
2405 template< typename MT > // Type of the right-hand side sparse matrix
2407 {
2408  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2409 
2410  typedef typename MT::ConstIterator RhsConstIterator;
2411 
2412  for( size_t i=0UL; i<m_; ++i )
2413  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2414  v_[i*NN+element->index()] += element->value();
2415 }
2416 //*************************************************************************************************
2417 
2418 
2419 //*************************************************************************************************
2430 template< typename Type // Data type of the matrix
2431  , size_t M // Number of rows
2432  , size_t N // Number of columns
2433  , bool SO > // Storage order
2434 template< typename MT > // Type of the right-hand side sparse matrix
2436 {
2438 
2439  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2440 
2441  typedef typename MT::ConstIterator RhsConstIterator;
2442 
2443  for( size_t j=0UL; j<n_; ++j )
2444  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2445  v_[element->index()*NN+j] += element->value();
2446 }
2447 //*************************************************************************************************
2448 
2449 
2450 //*************************************************************************************************
2461 template< typename Type // Data type of the matrix
2462  , size_t M // Number of rows
2463  , size_t N // Number of columns
2464  , bool SO > // Storage order
2465 template< typename MT // Type of the right-hand side dense matrix
2466  , bool SO2 > // Storage order of the right-hand side dense matrix
2467 inline typename DisableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2469 {
2470  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2471 
2472  for( size_t i=0UL; i<m_; ++i ) {
2473  for( size_t j=0UL; j<n_; ++j ) {
2474  v_[i*NN+j] -= (~rhs)(i,j);
2475  }
2476  }
2477 }
2478 //*************************************************************************************************
2479 
2480 
2481 //*************************************************************************************************
2492 template< typename Type // Data type of the matrix
2493  , size_t M // Number of rows
2494  , size_t N // Number of columns
2495  , bool SO > // Storage order
2496 template< typename MT // Type of the right-hand side dense matrix
2497  , bool SO2 > // Storage order of the right-hand side dense matrix
2498 inline typename EnableIf< typename HybridMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2500 {
2501  using blaze::load;
2502  using blaze::store;
2503 
2504  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2505 
2507 
2508  for( size_t i=0UL; i<m_; ++i ) {
2509  for( size_t j=0UL; j<n_; j+=IT::size ) {
2510  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
2511  }
2512  }
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 i=0UL; i<m_; ++i )
2540  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2541  v_[i*NN+element->index()] -= element->value();
2542 }
2543 //*************************************************************************************************
2544 
2545 
2546 //*************************************************************************************************
2557 template< typename Type // Data type of the matrix
2558  , size_t M // Number of rows
2559  , size_t N // Number of columns
2560  , bool SO > // Storage order
2561 template< typename MT > // Type of the right-hand side sparse matrix
2563 {
2565 
2566  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
2567 
2568  typedef typename MT::ConstIterator RhsConstIterator;
2569 
2570  for( size_t j=0UL; j<n_; ++j )
2571  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2572  v_[element->index()*NN+j] -= element->value();
2573 }
2574 //*************************************************************************************************
2575 
2576 
2577 
2578 
2579 
2580 
2581 
2582 
2583 //=================================================================================================
2584 //
2585 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2586 //
2587 //=================================================================================================
2588 
2589 //*************************************************************************************************
2597 template< typename Type // Data type of the matrix
2598  , size_t M // Number of rows
2599  , size_t N > // Number of columns
2600 class HybridMatrix<Type,M,N,true> : public DenseMatrix< HybridMatrix<Type,M,N,true>, true >
2601 {
2602  private:
2603  //**Type definitions****************************************************************************
2604  typedef IntrinsicTrait<Type> IT;
2605  //**********************************************************************************************
2606 
2607  //**********************************************************************************************
2609  enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
2610  //**********************************************************************************************
2611 
2612  public:
2613  //**Type definitions****************************************************************************
2614  typedef HybridMatrix<Type,M,N,true> This;
2615  typedef This ResultType;
2616  typedef HybridMatrix<Type,M,N,false> OppositeType;
2617  typedef HybridMatrix<Type,N,M,false> TransposeType;
2618  typedef Type ElementType;
2619  typedef typename IT::Type IntrinsicType;
2620  typedef const Type& ReturnType;
2621  typedef const This& CompositeType;
2622  typedef Type& Reference;
2623  typedef const Type& ConstReference;
2624  typedef Type* Pointer;
2625  typedef const Type* ConstPointer;
2626  typedef DenseIterator<Type> Iterator;
2627  typedef DenseIterator<const Type> ConstIterator;
2628  //**********************************************************************************************
2629 
2630  //**Rebind struct definition********************************************************************
2633  template< typename ET > // Data type of the other matrix
2634  struct Rebind {
2635  typedef HybridMatrix<ET,M,N,true> Other;
2636  };
2637  //**********************************************************************************************
2638 
2639  //**Compilation flags***************************************************************************
2641 
2645  enum { vectorizable = IsVectorizable<Type>::value };
2646 
2648 
2651  enum { smpAssignable = 0 };
2652  //**********************************************************************************************
2653 
2654  //**Constructors********************************************************************************
2657  explicit inline HybridMatrix();
2658  explicit inline HybridMatrix( size_t m, size_t n );
2659  explicit inline HybridMatrix( size_t m, size_t n, const Type& init );
2660  template< typename Other > explicit inline HybridMatrix( size_t m, size_t n, const Other* array );
2661 
2662  template< typename Other, size_t M2, size_t N2 >
2663  explicit inline HybridMatrix( const Other (&array)[M2][N2] );
2664 
2665  inline HybridMatrix( const HybridMatrix& m );
2666  template< typename MT, bool SO > inline HybridMatrix( const Matrix<MT,SO>& m );
2668  //**********************************************************************************************
2669 
2670  //**Destructor**********************************************************************************
2671  // No explicitly declared destructor.
2672  //**********************************************************************************************
2673 
2674  //**Data access functions***********************************************************************
2677  inline Reference operator()( size_t i, size_t j );
2678  inline ConstReference operator()( size_t i, size_t j ) const;
2679  inline Pointer data ();
2680  inline ConstPointer data () const;
2681  inline Pointer data ( size_t j );
2682  inline ConstPointer data ( size_t j ) const;
2683  inline Iterator begin ( size_t j );
2684  inline ConstIterator begin ( size_t j ) const;
2685  inline ConstIterator cbegin( size_t j ) const;
2686  inline Iterator end ( size_t j );
2687  inline ConstIterator end ( size_t j ) const;
2688  inline ConstIterator cend ( size_t j ) const;
2690  //**********************************************************************************************
2691 
2692  //**Assignment operators************************************************************************
2695  template< typename Other, size_t M2, size_t N2 >
2696  inline HybridMatrix& operator=( const Other (&array)[M2][N2] );
2697 
2698  inline HybridMatrix& operator= ( const Type& set );
2699  inline HybridMatrix& operator= ( const HybridMatrix& rhs );
2700  template< typename MT, bool SO > inline HybridMatrix& operator= ( const Matrix<MT,SO>& rhs );
2701  template< typename MT, bool SO > inline HybridMatrix& operator+=( const Matrix<MT,SO>& rhs );
2702  template< typename MT, bool SO > inline HybridMatrix& operator-=( const Matrix<MT,SO>& rhs );
2703  template< typename MT, bool SO > inline HybridMatrix& operator*=( const Matrix<MT,SO>& rhs );
2704 
2705  template< typename Other >
2706  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
2707  operator*=( Other rhs );
2708 
2709  template< typename Other >
2710  inline typename EnableIf< IsNumeric<Other>, HybridMatrix >::Type&
2711  operator/=( Other rhs );
2713  //**********************************************************************************************
2714 
2715  //**Utility functions***************************************************************************
2718  inline size_t rows() const;
2719  inline size_t columns() const;
2720  inline size_t spacing() const;
2721  inline size_t capacity() const;
2722  inline size_t capacity( size_t j ) const;
2723  inline size_t nonZeros() const;
2724  inline size_t nonZeros( size_t j ) const;
2725  inline void reset();
2726  inline void reset( size_t i );
2727  inline void clear();
2728  void resize ( size_t m, size_t n, bool preserve=true );
2729  inline void extend ( size_t m, size_t n, bool preserve=true );
2730  inline HybridMatrix& transpose();
2731  template< typename Other > inline HybridMatrix& scale( const Other& scalar );
2732  inline void swap( HybridMatrix& m ) /* throw() */;
2734  //**********************************************************************************************
2735 
2736  //**Memory functions****************************************************************************
2739  static inline void* operator new ( std::size_t size );
2740  static inline void* operator new[]( std::size_t size );
2741  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
2742  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
2743 
2744  static inline void operator delete ( void* ptr );
2745  static inline void operator delete[]( void* ptr );
2746  static inline void operator delete ( void* ptr, const std::nothrow_t& );
2747  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
2749  //**********************************************************************************************
2750 
2751  private:
2752  //**********************************************************************************************
2754  template< typename MT >
2755  struct VectorizedAssign {
2756  enum { value = vectorizable && MT::vectorizable &&
2757  IsSame<Type,typename MT::ElementType>::value &&
2758  IsColumnMajorMatrix<MT>::value };
2759  };
2760  //**********************************************************************************************
2761 
2762  //**********************************************************************************************
2764  template< typename MT >
2765  struct VectorizedAddAssign {
2766  enum { value = vectorizable && MT::vectorizable &&
2767  IsSame<Type,typename MT::ElementType>::value &&
2768  IntrinsicTrait<Type>::addition &&
2769  IsColumnMajorMatrix<MT>::value };
2770  };
2771  //**********************************************************************************************
2772 
2773  //**********************************************************************************************
2775  template< typename MT >
2776  struct VectorizedSubAssign {
2777  enum { value = vectorizable && MT::vectorizable &&
2778  IsSame<Type,typename MT::ElementType>::value &&
2779  IntrinsicTrait<Type>::subtraction &&
2780  IsColumnMajorMatrix<MT>::value };
2781  };
2782  //**********************************************************************************************
2783 
2784  public:
2785  //**Expression template evaluation functions****************************************************
2788  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2789  template< typename Other > inline bool isAliased( const Other* alias ) const;
2790 
2791  inline bool isAligned() const;
2792 
2793  inline IntrinsicType load ( size_t i, size_t j ) const;
2794  inline IntrinsicType loadu ( size_t i, size_t j ) const;
2795  inline void store ( size_t i, size_t j, const IntrinsicType& value );
2796  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
2797  inline void stream( size_t i, size_t j, const IntrinsicType& value );
2798 
2799  template< typename MT, bool SO >
2800  inline typename DisableIf< VectorizedAssign<MT> >::Type
2801  assign( const DenseMatrix<MT,SO>& rhs );
2802 
2803  template< typename MT, bool SO >
2804  inline typename EnableIf< VectorizedAssign<MT> >::Type
2805  assign( const DenseMatrix<MT,SO>& rhs );
2806 
2807  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2808  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2809 
2810  template< typename MT, bool SO >
2811  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2812  addAssign( const DenseMatrix<MT,SO>& rhs );
2813 
2814  template< typename MT, bool SO >
2815  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2816  addAssign( const DenseMatrix<MT,SO>& rhs );
2817 
2818  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2819  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2820 
2821  template< typename MT, bool SO >
2822  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2823  subAssign( const DenseMatrix<MT,SO>& rhs );
2824 
2825  template< typename MT, bool SO >
2826  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2827  subAssign( const DenseMatrix<MT,SO>& rhs );
2828 
2829  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2830  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2832  //**********************************************************************************************
2833 
2834  private:
2835  //**Member variables****************************************************************************
2838  AlignedArray<Type,MM*N> v_;
2839 
2841  size_t m_;
2842  size_t n_;
2843 
2844  //**********************************************************************************************
2845 
2846  //**Compile time checks*************************************************************************
2851  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
2852  BLAZE_STATIC_ASSERT( MM >= M );
2853  //**********************************************************************************************
2854 };
2856 //*************************************************************************************************
2857 
2858 
2859 
2860 
2861 //=================================================================================================
2862 //
2863 // CONSTRUCTORS
2864 //
2865 //=================================================================================================
2866 
2867 //*************************************************************************************************
2873 template< typename Type // Data type of the matrix
2874  , size_t M // Number of rows
2875  , size_t N > // Number of columns
2877  : v_() // The statically allocated matrix elements
2878  , m_( 0UL ) // The current number of rows of the matrix
2879  , n_( 0UL ) // The current number of columns of the matrix
2880 {
2881  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
2882 
2883  if( IsNumeric<Type>::value ) {
2884  for( size_t i=0UL; i<MM*N; ++i )
2885  v_[i] = Type();
2886  }
2887 }
2889 //*************************************************************************************************
2890 
2891 
2892 //*************************************************************************************************
2906 template< typename Type // Data type of the matrix
2907  , size_t M // Number of rows
2908  , size_t N > // Number of columns
2909 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n )
2910  : v_() // The statically allocated matrix elements
2911  , m_( m ) // The current number of rows of the matrix
2912  , n_( n ) // The current number of columns of the matrix
2913 {
2914  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
2915 
2916  if( m > M )
2917  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
2918 
2919  if( n > N )
2920  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
2921 
2922  if( IsNumeric<Type>::value ) {
2923  for( size_t i=0UL; i<MM*N; ++i )
2924  v_[i] = Type();
2925  }
2926 }
2928 //*************************************************************************************************
2929 
2930 
2931 //*************************************************************************************************
2946 template< typename Type // Data type of the matrix
2947  , size_t M // Number of rows
2948  , size_t N > // Number of columns
2949 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n, const Type& init )
2950  : v_() // The statically allocated matrix elements
2951  , m_( m ) // The current number of rows of the matrix
2952  , n_( n ) // The current number of columns of the matrix
2953 {
2954  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
2955 
2956  if( m > M )
2957  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
2958 
2959  if( n > N )
2960  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
2961 
2962  for( size_t j=0UL; j<n; ++j ) {
2963  for( size_t i=0UL; i<m; ++i )
2964  v_[i+j*MM] = init;
2965 
2966  if( IsNumeric<Type>::value ) {
2967  for( size_t i=m; i<MM; ++i )
2968  v_[i+j*MM] = Type();
2969  }
2970  }
2971 
2972  if( IsNumeric<Type>::value ) {
2973  for( size_t j=n; j<N; ++j )
2974  for( size_t i=0UL; i<MM; ++i )
2975  v_[i+j*MM] = Type();
2976  }
2977 }
2979 //*************************************************************************************************
2980 
2981 
2982 //*************************************************************************************************
3010 template< typename Type // Data type of the matrix
3011  , size_t M // Number of rows
3012  , size_t N > // Number of columns
3013 template< typename Other > // Data type of the initialization array
3014 inline HybridMatrix<Type,M,N,true>::HybridMatrix( size_t m, size_t n, const Other* array )
3015  : v_() // The statically allocated matrix elements
3016  , m_( m ) // The current number of rows of the matrix
3017  , n_( n ) // The current number of columns of the matrix
3018 {
3019  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3020 
3021  if( m > M )
3022  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
3023 
3024  if( n > N )
3025  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
3026 
3027  for( size_t j=0UL; j<n; ++j ) {
3028  for( size_t i=0UL; i<m; ++i )
3029  v_[i+j*MM] = array[i+j*m];
3030 
3031  if( IsNumeric<Type>::value ) {
3032  for( size_t i=m; i<MM; ++i )
3033  v_[i+j*MM] = Type();
3034  }
3035  }
3036 
3037  if( IsNumeric<Type>::value ) {
3038  for( size_t j=n; j<N; ++j )
3039  for( size_t i=0UL; i<MM; ++i )
3040  v_[i+j*MM] = Type();
3041  }
3042 }
3044 //*************************************************************************************************
3045 
3046 
3047 //*************************************************************************************************
3069 template< typename Type // Data type of the matrix
3070  , size_t M // Number of rows
3071  , size_t N > // Number of columns
3072 template< typename Other // Data type of the initialization array
3073  , size_t M2 // Number of rows of the initialization array
3074  , size_t N2 > // Number of columns of the initialization array
3075 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const Other (&array)[M2][N2] )
3076  : v_() // The statically allocated matrix elements
3077  , m_( M2 ) // The current number of rows of the matrix
3078  , n_( N2 ) // The current number of columns of the matrix
3079 {
3080  BLAZE_STATIC_ASSERT( M2 <= M );
3081  BLAZE_STATIC_ASSERT( N2 <= N );
3082  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3083 
3084  for( size_t j=0UL; j<N2; ++j ) {
3085  for( size_t i=0UL; i<M2; ++i )
3086  v_[i+j*MM] = array[i][j];
3087 
3088  if( IsNumeric<Type>::value ) {
3089  for( size_t i=M2; i<MM; ++i )
3090  v_[i+j*MM] = Type();
3091  }
3092  }
3093 
3094  if( IsNumeric<Type>::value ) {
3095  for( size_t j=N2; j<N; ++j )
3096  for( size_t i=0UL; i<MM; ++i )
3097  v_[i+j*MM] = Type();
3098  }
3099 }
3101 //*************************************************************************************************
3102 
3103 
3104 //*************************************************************************************************
3113 template< typename Type // Data type of the matrix
3114  , size_t M // Number of rows
3115  , size_t N > // Number of columns
3116 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const HybridMatrix& m )
3117  : v_() // The statically allocated matrix elements
3118  , m_( m.m_ ) // The current number of rows of the matrix
3119  , n_( m.n_ ) // The current number of columns of the matrix
3120 {
3121  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3122 
3123  for( size_t j=0UL; j<n_; ++j ) {
3124  for( size_t i=0UL; i<m_; ++i )
3125  v_[i+j*MM] = m.v_[i+j*MM];
3126 
3127  if( IsNumeric<Type>::value ) {
3128  for( size_t i=m_; i<MM; ++i )
3129  v_[i+j*MM] = Type();
3130  }
3131  }
3132 
3133  if( IsNumeric<Type>::value ) {
3134  for( size_t j=n_; j<N; ++j )
3135  for( size_t i=0UL; i<MM; ++i )
3136  v_[i+j*MM] = Type();
3137  }
3138 }
3140 //*************************************************************************************************
3141 
3142 
3143 //*************************************************************************************************
3150 template< typename Type // Data type of the matrix
3151  , size_t M // Number of rows
3152  , size_t N > // Number of columns
3153 template< typename MT // Type of the foreign matrix
3154  , bool SO2 > // Storage order of the foreign matrix
3155 inline HybridMatrix<Type,M,N,true>::HybridMatrix( const Matrix<MT,SO2>& m )
3156  : v_() // The statically allocated matrix elements
3157  , m_( (~m).rows() ) // The current number of rows of the matrix
3158  , n_( (~m).columns() ) // The current number of columns of the matrix
3159 {
3160  using blaze::assign;
3161 
3162  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3163 
3164  if( (~m).rows() > M || (~m).columns() > N )
3165  throw std::invalid_argument( "Invalid setup of hybrid matrix" );
3166 
3167  for( size_t j=0UL; j<n_; ++j ) {
3168  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
3169  i<( IsNumeric<Type>::value ? MM : m_ );
3170  ++i ) {
3171  v_[i+j*MM] = Type();
3172  }
3173  }
3174 
3175  if( IsNumeric<Type>::value ) {
3176  for( size_t j=n_; j<N; ++j )
3177  for( size_t i=0UL; i<MM; ++i )
3178  v_[i+j*MM] = Type();
3179  }
3180 
3181  assign( *this, ~m );
3182 }
3184 //*************************************************************************************************
3185 
3186 
3187 
3188 
3189 //=================================================================================================
3190 //
3191 // DATA ACCESS FUNCTIONS
3192 //
3193 //=================================================================================================
3194 
3195 //*************************************************************************************************
3203 template< typename Type // Data type of the matrix
3204  , size_t M // Number of rows
3205  , size_t N > // Number of columns
3207  HybridMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
3208 {
3209  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3210  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3211  return v_[i+j*MM];
3212 }
3214 //*************************************************************************************************
3215 
3216 
3217 //*************************************************************************************************
3225 template< typename Type // Data type of the matrix
3226  , size_t M // Number of rows
3227  , size_t N > // Number of columns
3229  HybridMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
3230 {
3231  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3232  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3233  return v_[i+j*MM];
3234 }
3236 //*************************************************************************************************
3237 
3238 
3239 //*************************************************************************************************
3251 template< typename Type // Data type of the matrix
3252  , size_t M // Number of rows
3253  , size_t N > // Number of columns
3254 inline typename HybridMatrix<Type,M,N,true>::Pointer
3256 {
3257  return v_;
3258 }
3260 //*************************************************************************************************
3261 
3262 
3263 //*************************************************************************************************
3275 template< typename Type // Data type of the matrix
3276  , size_t M // Number of rows
3277  , size_t N > // Number of columns
3278 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3280 {
3281  return v_;
3282 }
3284 //*************************************************************************************************
3285 
3286 
3287 //*************************************************************************************************
3296 template< typename Type // Data type of the matrix
3297  , size_t M // Number of rows
3298  , size_t N > // Number of columns
3299 inline typename HybridMatrix<Type,M,N,true>::Pointer
3301 {
3302  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3303  return v_ + j*MM;
3304 }
3306 //*************************************************************************************************
3307 
3308 
3309 //*************************************************************************************************
3318 template< typename Type // Data type of the matrix
3319  , size_t M // Number of rows
3320  , size_t N > // Number of columns
3321 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3322  HybridMatrix<Type,M,N,true>::data( size_t j ) const
3323 {
3324  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3325  return v_ + j*MM;
3326 }
3328 //*************************************************************************************************
3329 
3330 
3331 //*************************************************************************************************
3338 template< typename Type // Data type of the matrix
3339  , size_t M // Number of rows
3340  , size_t N > // Number of columns
3343 {
3344  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3345  return Iterator( v_ + j*MM );
3346 }
3348 //*************************************************************************************************
3349 
3350 
3351 //*************************************************************************************************
3358 template< typename Type // Data type of the matrix
3359  , size_t M // Number of rows
3360  , size_t N > // Number of columns
3362  HybridMatrix<Type,M,N,true>::begin( size_t j ) const
3363 {
3364  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3365  return ConstIterator( v_ + j*MM );
3366 }
3368 //*************************************************************************************************
3369 
3370 
3371 //*************************************************************************************************
3378 template< typename Type // Data type of the matrix
3379  , size_t M // Number of rows
3380  , size_t N > // Number of columns
3382  HybridMatrix<Type,M,N,true>::cbegin( size_t j ) const
3383 {
3384  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3385  return ConstIterator( v_ + j*MM );
3386 }
3388 //*************************************************************************************************
3389 
3390 
3391 //*************************************************************************************************
3398 template< typename Type // Data type of the matrix
3399  , size_t M // Number of rows
3400  , size_t N > // Number of columns
3403 {
3404  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3405  return Iterator( v_ + j*MM + M );
3406 }
3408 //*************************************************************************************************
3409 
3410 
3411 //*************************************************************************************************
3418 template< typename Type // Data type of the matrix
3419  , size_t M // Number of rows
3420  , size_t N > // Number of columns
3422  HybridMatrix<Type,M,N,true>::end( size_t j ) const
3423 {
3424  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3425  return ConstIterator( v_ + j*MM + M );
3426 }
3428 //*************************************************************************************************
3429 
3430 
3431 //*************************************************************************************************
3438 template< typename Type // Data type of the matrix
3439  , size_t M // Number of rows
3440  , size_t N > // Number of columns
3442  HybridMatrix<Type,M,N,true>::cend( size_t j ) const
3443 {
3444  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
3445  return ConstIterator( v_ + j*MM + M );
3446 }
3448 //*************************************************************************************************
3449 
3450 
3451 
3452 
3453 //=================================================================================================
3454 //
3455 // ASSIGNMENT OPERATORS
3456 //
3457 //=================================================================================================
3458 
3459 //*************************************************************************************************
3481 template< typename Type // Data type of the matrix
3482  , size_t M // Number of rows
3483  , size_t N > // Number of columns
3484 template< typename Other // Data type of the initialization array
3485  , size_t M2 // Number of rows of the initialization array
3486  , size_t N2 > // Number of columns of the initialization array
3487 inline HybridMatrix<Type,M,N,true>&
3488  HybridMatrix<Type,M,N,true>::operator=( const Other (&array)[M2][N2] )
3489 {
3490  BLAZE_STATIC_ASSERT( M2 <= M );
3491  BLAZE_STATIC_ASSERT( N2 <= N );
3492 
3493  resize( M2, N2 );
3494 
3495  for( size_t j=0UL; j<N2; ++j )
3496  for( size_t i=0UL; i<M2; ++i )
3497  v_[i+j*MM] = array[i][j];
3498 
3499  return *this;
3500 }
3502 //*************************************************************************************************
3503 
3504 
3505 //*************************************************************************************************
3512 template< typename Type // Data type of the matrix
3513  , size_t M // Number of rows
3514  , size_t N > // Number of columns
3515 inline HybridMatrix<Type,M,N,true>&
3516  HybridMatrix<Type,M,N,true>::operator=( const Type& set )
3517 {
3518  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
3519  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
3520 
3521  for( size_t j=0UL; j<n_; ++j )
3522  for( size_t i=0UL; i<m_; ++i )
3523  v_[i+j*MM] = set;
3524 
3525  return *this;
3526 }
3528 //*************************************************************************************************
3529 
3530 
3531 //*************************************************************************************************
3540 template< typename Type // Data type of the matrix
3541  , size_t M // Number of rows
3542  , size_t N > // Number of columns
3543 inline HybridMatrix<Type,M,N,true>&
3544  HybridMatrix<Type,M,N,true>::operator=( const HybridMatrix& rhs )
3545 {
3546  using blaze::assign;
3547 
3548  BLAZE_INTERNAL_ASSERT( m_ <= M, "Invalid number of rows detected" );
3549  BLAZE_INTERNAL_ASSERT( n_ <= N, "Invalid number of columns detected" );
3550 
3551  resize( rhs.rows(), rhs.columns() );
3552  assign( *this, ~rhs );
3553 
3554  return *this;
3555 }
3557 //*************************************************************************************************
3558 
3559 
3560 //*************************************************************************************************
3572 template< typename Type // Data type of the matrix
3573  , size_t M // Number of rows
3574  , size_t N > // Number of columns
3575 template< typename MT // Type of the right-hand side matrix
3576  , bool SO > // Storage order of the right-hand side matrix
3577 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
3578 {
3579  using blaze::assign;
3580 
3581  if( (~rhs).rows() > M || (~rhs).columns() > N )
3582  throw std::invalid_argument( "Invalid assignment to hybrid matrix" );
3583 
3584  if( (~rhs).canAlias( this ) ) {
3585  HybridMatrix tmp( ~rhs );
3586  swap( tmp );
3587  }
3588  else {
3589  resize( (~rhs).rows(), (~rhs).columns() );
3590  if( IsSparseMatrix<MT>::value )
3591  reset();
3592  assign( *this, ~rhs );
3593  }
3594 
3595  return *this;
3596 }
3598 //*************************************************************************************************
3599 
3600 
3601 //*************************************************************************************************
3612 template< typename Type // Data type of the matrix
3613  , size_t M // Number of rows
3614  , size_t N > // Number of columns
3615 template< typename MT // Type of the right-hand side matrix
3616  , bool SO > // Storage order of the right-hand side matrix
3617 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
3618 {
3619  using blaze::addAssign;
3620 
3621  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3622  throw std::invalid_argument( "Matrix sizes do not match" );
3623 
3624  if( (~rhs).canAlias( this ) ) {
3625  typename MT::ResultType tmp( ~rhs );
3626  addAssign( *this, tmp );
3627  }
3628  else {
3629  addAssign( *this, ~rhs );
3630  }
3631 
3632  return *this;
3633 }
3635 //*************************************************************************************************
3636 
3637 
3638 //*************************************************************************************************
3649 template< typename Type // Data type of the matrix
3650  , size_t M // Number of rows
3651  , size_t N > // Number of columns
3652 template< typename MT // Type of the right-hand side matrix
3653  , bool SO > // Storage order of the right-hand side matrix
3654 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
3655 {
3656  using blaze::subAssign;
3657 
3658  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ )
3659  throw std::invalid_argument( "Matrix sizes do not match" );
3660 
3661  if( (~rhs).canAlias( this ) ) {
3662  typename MT::ResultType tmp( ~rhs );
3663  subAssign( *this, tmp );
3664  }
3665  else {
3666  subAssign( *this, ~rhs );
3667  }
3668 
3669  return *this;
3670 }
3672 //*************************************************************************************************
3673 
3674 
3675 //*************************************************************************************************
3686 template< typename Type // Data type of the matrix
3687  , size_t M // Number of rows
3688  , size_t N > // Number of columns
3689 template< typename MT // Type of the right-hand side matrix
3690  , bool SO > // Storage order of the right-hand side matrix
3691 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
3692 {
3693  if( n_ != (~rhs).rows() || (~rhs).columns() > N )
3694  throw std::invalid_argument( "Matrix sizes do not match" );
3695 
3696  HybridMatrix tmp( *this * (~rhs) );
3697  return this->operator=( tmp );
3698 }
3700 //*************************************************************************************************
3701 
3702 
3703 //*************************************************************************************************
3711 template< typename Type // Data type of the matrix
3712  , size_t M // Number of rows
3713  , size_t N > // Number of columns
3714 template< typename Other > // Data type of the right-hand side scalar
3715 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3716  HybridMatrix<Type,M,N,true>::operator*=( Other rhs )
3717 {
3718  using blaze::assign;
3719 
3720  assign( *this, (*this) * rhs );
3721  return *this;
3722 }
3724 //*************************************************************************************************
3725 
3726 
3727 //*************************************************************************************************
3737 template< typename Type // Data type of the matrix
3738  , size_t M // Number of rows
3739  , size_t N > // Number of columns
3740 template< typename Other > // Data type of the right-hand side scalar
3741 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3742  HybridMatrix<Type,M,N,true>::operator/=( Other rhs )
3743 {
3744  using blaze::assign;
3745 
3746  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
3747 
3748  assign( *this, (*this) / rhs );
3749  return *this;
3750 }
3752 //*************************************************************************************************
3753 
3754 
3755 
3756 
3757 //=================================================================================================
3758 //
3759 // UTILITY FUNCTIONS
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>::rows() const
3773 {
3774  return m_;
3775 }
3777 //*************************************************************************************************
3778 
3779 
3780 //*************************************************************************************************
3786 template< typename Type // Data type of the matrix
3787  , size_t M // Number of rows
3788  , size_t N > // Number of columns
3789 inline size_t HybridMatrix<Type,M,N,true>::columns() const
3790 {
3791  return n_;
3792 }
3794 //*************************************************************************************************
3795 
3796 
3797 //*************************************************************************************************
3806 template< typename Type // Data type of the matrix
3807  , size_t M // Number of rows
3808  , size_t N > // Number of columns
3809 inline size_t HybridMatrix<Type,M,N,true>::spacing() const
3810 {
3811  return MM;
3812 }
3814 //*************************************************************************************************
3815 
3816 
3817 //*************************************************************************************************
3823 template< typename Type // Data type of the matrix
3824  , size_t M // Number of rows
3825  , size_t N > // Number of columns
3826 inline size_t HybridMatrix<Type,M,N,true>::capacity() const
3827 {
3828  return MM*N;
3829 }
3831 //*************************************************************************************************
3832 
3833 
3834 //*************************************************************************************************
3841 template< typename Type // Data type of the matrix
3842  , size_t M // Number of rows
3843  , size_t N > // Number of columns
3844 inline size_t HybridMatrix<Type,M,N,true>::capacity( size_t j ) const
3845 {
3846  UNUSED_PARAMETER( j );
3847 
3848  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3849 
3850  return MM;
3851 }
3853 //*************************************************************************************************
3854 
3855 
3856 //*************************************************************************************************
3862 template< typename Type // Data type of the matrix
3863  , size_t M // Number of rows
3864  , size_t N > // Number of columns
3865 inline size_t HybridMatrix<Type,M,N,true>::nonZeros() const
3866 {
3867  size_t nonzeros( 0UL );
3868 
3869  for( size_t j=0UL; j<n_; ++j )
3870  for( size_t i=0UL; i<m_; ++i )
3871  if( !isDefault( v_[i+j*MM] ) )
3872  ++nonzeros;
3873 
3874  return nonzeros;
3875 }
3877 //*************************************************************************************************
3878 
3879 
3880 //*************************************************************************************************
3887 template< typename Type // Data type of the matrix
3888  , size_t M // Number of rows
3889  , size_t N > // Number of columns
3890 inline size_t HybridMatrix<Type,M,N,true>::nonZeros( size_t j ) const
3891 {
3892  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3893 
3894  const size_t iend( j*MM+m_ );
3895  size_t nonzeros( 0UL );
3896 
3897  for( size_t i=j*MM; i<iend; ++i )
3898  if( !isDefault( v_[i] ) )
3899  ++nonzeros;
3900 
3901  return nonzeros;
3902 }
3904 //*************************************************************************************************
3905 
3906 
3907 //*************************************************************************************************
3913 template< typename Type // Data type of the matrix
3914  , size_t M // Number of rows
3915  , size_t N > // Number of columns
3917 {
3918  using blaze::clear;
3919 
3920  for( size_t j=0UL; j<n_; ++j )
3921  for( size_t i=0UL; i<m_; ++i )
3922  clear( v_[i+j*MM] );
3923 }
3925 //*************************************************************************************************
3926 
3927 
3928 //*************************************************************************************************
3938 template< typename Type // Data type of the matrix
3939  , size_t M // Number of rows
3940  , size_t N > // Number of columns
3941 inline void HybridMatrix<Type,M,N,true>::reset( size_t j )
3942 {
3943  using blaze::clear;
3944 
3945  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
3946  for( size_t i=0UL; i<m_; ++i )
3947  clear( v_[i+j*MM] );
3948 }
3950 //*************************************************************************************************
3951 
3952 
3953 //*************************************************************************************************
3961 template< typename Type // Data type of the matrix
3962  , size_t M // Number of rows
3963  , size_t N > // Number of columns
3965 {
3966  resize( 0UL, 0UL );
3967 }
3969 //*************************************************************************************************
3970 
3971 
3972 //*************************************************************************************************
4009 template< typename Type // Data type of the matrix
4010  , size_t M // Number of rows
4011  , size_t N > // Number of columns
4012 void HybridMatrix<Type,M,N,true>::resize( size_t m, size_t n, bool preserve )
4013 {
4014  UNUSED_PARAMETER( preserve );
4015 
4016  if( m > M )
4017  throw std::invalid_argument( "Invalid number of rows for hybrid matrix" );
4018 
4019  if( n > N )
4020  throw std::invalid_argument( "Invalid number of columns for hybrid matrix" );
4021 
4022  if( IsVectorizable<Type>::value && m < m_ ) {
4023  for( size_t j=0UL; j<n; ++j )
4024  for( size_t i=m; i<m_; ++i )
4025  v_[i+j*MM] = Type();
4026  }
4027 
4028  if( IsVectorizable<Type>::value && n < n_ ) {
4029  for( size_t j=n; j<n_; ++j )
4030  for( size_t i=0UL; i<m_; ++i )
4031  v_[i+j*MM] = Type();
4032  }
4033 
4034  m_ = m;
4035  n_ = n;
4036 }
4038 //*************************************************************************************************
4039 
4040 
4041 //*************************************************************************************************
4057 template< typename Type // Data type of the matrix
4058  , size_t M // Number of rows
4059  , size_t N > // Number of columns
4060 inline void HybridMatrix<Type,M,N,true>::extend( size_t m, size_t n, bool preserve )
4061 {
4062  UNUSED_PARAMETER( preserve );
4063  resize( m_+m, n_+n );
4064 }
4066 //*************************************************************************************************
4067 
4068 
4069 //*************************************************************************************************
4081 template< typename Type // Data type of the matrix
4082  , size_t M // Number of rows
4083  , size_t N > // Number of columns
4084 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::transpose()
4085 {
4086  using std::swap;
4087 
4088  if( m_ > N || n_ > M )
4089  throw std::logic_error( "Impossible transpose operation" );
4090 
4091  const size_t maxsize( max( m_, n_ ) );
4092  for( size_t j=1UL; j<maxsize; ++j )
4093  for( size_t i=0UL; i<j; ++i )
4094  swap( v_[i+j*MM], v_[j+i*MM] );
4095 
4096  if( IsVectorizable<Type>::value && n_ < m_ ) {
4097  for( size_t j=0UL; j<n_; ++j ) {
4098  for( size_t i=n_; i<m_; ++i ) {
4099  v_[i+j*MM] = Type();
4100  }
4101  }
4102  }
4103 
4104  if( IsVectorizable<Type>::value && n_ > m_ ) {
4105  for( size_t j=m_; j<n_; ++j )
4106  for( size_t i=0UL; i<m_; ++i )
4107  v_[i+j*MM] = Type();
4108  }
4109 
4110  swap( m_, n_ );
4111 
4112  return *this;
4113 }
4115 //*************************************************************************************************
4116 
4117 
4118 //*************************************************************************************************
4125 template< typename Type // Data type of the matrix
4126  , size_t M // Number of rows
4127  , size_t N > // Number of columns
4128 template< typename Other > // Data type of the scalar value
4129 inline HybridMatrix<Type,M,N,true>&
4130  HybridMatrix<Type,M,N,true>::scale( const Other& scalar )
4131 {
4132  for( size_t j=0UL; j<n_; ++j )
4133  for( size_t i=0UL; i<m_; ++i )
4134  v_[i+j*MM] *= scalar;
4135 
4136  return *this;
4137 }
4139 //*************************************************************************************************
4140 
4141 
4142 //*************************************************************************************************
4150 template< typename Type // Data type of the matrix
4151  , size_t M // Number of rows
4152  , size_t N > // Number of columns
4153 inline void HybridMatrix<Type,M,N,true>::swap( HybridMatrix& m ) /* throw() */
4154 {
4155  using std::swap;
4156 
4157  const size_t maxrows( max( m_, m.m_ ) );
4158  const size_t maxcols( max( n_, m.n_ ) );
4159 
4160  for( size_t j=0UL; j<maxcols; ++j ) {
4161  for( size_t i=0UL; i<maxrows; ++i ) {
4162  swap( v_[i+j*MM], m(i,j) );
4163  }
4164  }
4165 
4166  swap( m_, m.m_ );
4167  swap( n_, m.n_ );
4168 }
4170 //*************************************************************************************************
4171 
4172 
4173 
4174 
4175 //=================================================================================================
4176 //
4177 // MEMORY FUNCTIONS
4178 //
4179 //=================================================================================================
4180 
4181 //*************************************************************************************************
4192 template< typename Type // Data type of the matrix
4193  , size_t M // Number of rows
4194  , size_t N > // Number of columns
4195 inline void* HybridMatrix<Type,M,N,true>::operator new( std::size_t size )
4196 {
4198 
4199  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
4200 
4201  return allocate<HybridMatrix>( 1UL );
4202 }
4204 //*************************************************************************************************
4205 
4206 
4207 //*************************************************************************************************
4218 template< typename Type // Data type of the matrix
4219  , size_t M // Number of rows
4220  , size_t N > // Number of columns
4221 inline void* HybridMatrix<Type,M,N,true>::operator new[]( std::size_t size )
4222 {
4223  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
4224  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
4225 
4226  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
4227 }
4229 //*************************************************************************************************
4230 
4231 
4232 //*************************************************************************************************
4243 template< typename Type // Data type of the matrix
4244  , size_t M // Number of rows
4245  , size_t N > // Number of columns
4246 inline void* HybridMatrix<Type,M,N,true>::operator new( std::size_t size, const std::nothrow_t& )
4247 {
4249 
4250  BLAZE_INTERNAL_ASSERT( size == sizeof( HybridMatrix ), "Invalid number of bytes detected" );
4251 
4252  return allocate<HybridMatrix>( 1UL );
4253 }
4255 //*************************************************************************************************
4256 
4257 
4258 //*************************************************************************************************
4269 template< typename Type // Data type of the matrix
4270  , size_t M // Number of rows
4271  , size_t N > // Number of columns
4272 inline void* HybridMatrix<Type,M,N,true>::operator new[]( std::size_t size, const std::nothrow_t& )
4273 {
4274  BLAZE_INTERNAL_ASSERT( size >= sizeof( HybridMatrix ) , "Invalid number of bytes detected" );
4275  BLAZE_INTERNAL_ASSERT( size % sizeof( HybridMatrix ) == 0UL, "Invalid number of bytes detected" );
4276 
4277  return allocate<HybridMatrix>( size/sizeof(HybridMatrix) );
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 )
4294 {
4295  deallocate( static_cast<HybridMatrix*>( ptr ) );
4296 }
4298 //*************************************************************************************************
4299 
4300 
4301 //*************************************************************************************************
4308 template< typename Type // Data type of the matrix
4309  , size_t M // Number of rows
4310  , size_t N > // Number of columns
4311 inline void HybridMatrix<Type,M,N,true>::operator delete[]( void* ptr )
4312 {
4313  deallocate( static_cast<HybridMatrix*>( ptr ) );
4314 }
4316 //*************************************************************************************************
4317 
4318 
4319 //*************************************************************************************************
4326 template< typename Type // Data type of the matrix
4327  , size_t M // Number of rows
4328  , size_t N > // Number of columns
4329 inline void HybridMatrix<Type,M,N,true>::operator delete( void* ptr, const std::nothrow_t& )
4330 {
4331  deallocate( static_cast<HybridMatrix*>( ptr ) );
4332 }
4334 //*************************************************************************************************
4335 
4336 
4337 //*************************************************************************************************
4344 template< typename Type // Data type of the matrix
4345  , size_t M // Number of rows
4346  , size_t N > // Number of columns
4347 inline void HybridMatrix<Type,M,N,true>::operator delete[]( void* ptr, const std::nothrow_t& )
4348 {
4349  deallocate( static_cast<HybridMatrix*>( ptr ) );
4350 }
4352 //*************************************************************************************************
4353 
4354 
4355 
4356 
4357 //=================================================================================================
4358 //
4359 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4360 //
4361 //=================================================================================================
4362 
4363 //*************************************************************************************************
4374 template< typename Type // Data type of the matrix
4375  , size_t M // Number of rows
4376  , size_t N > // Number of columns
4377 template< typename Other > // Data type of the foreign expression
4378 inline bool HybridMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
4379 {
4380  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4381 }
4383 //*************************************************************************************************
4384 
4385 
4386 //*************************************************************************************************
4397 template< typename Type // Data type of the matrix
4398  , size_t M // Number of rows
4399  , size_t N > // Number of columns
4400 template< typename Other > // Data type of the foreign expression
4401 inline bool HybridMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
4402 {
4403  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4404 }
4406 //*************************************************************************************************
4407 
4408 
4409 //*************************************************************************************************
4419 template< typename Type // Data type of the matrix
4420  , size_t M // Number of rows
4421  , size_t N > // Number of columns
4422 inline bool HybridMatrix<Type,M,N,true>::isAligned() const
4423 {
4424  return true;
4425 }
4427 //*************************************************************************************************
4428 
4429 
4430 //*************************************************************************************************
4445 template< typename Type // Data type of the matrix
4446  , size_t M // Number of rows
4447  , size_t N > // Number of columns
4448 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4449  HybridMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
4450 {
4451  using blaze::load;
4452 
4454 
4455  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4456  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4457  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4458  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4459 
4460  return load( &v_[i+j*MM] );
4461 }
4463 //*************************************************************************************************
4464 
4465 
4466 //*************************************************************************************************
4481 template< typename Type // Data type of the matrix
4482  , size_t M // Number of rows
4483  , size_t N > // Number of columns
4484 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4485  HybridMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
4486 {
4487  using blaze::loadu;
4488 
4490 
4491  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4492  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4493  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4494 
4495  return loadu( &v_[i+j*MM] );
4496 }
4498 //*************************************************************************************************
4499 
4500 
4501 //*************************************************************************************************
4517 template< typename Type // Data type of the matrix
4518  , size_t M // Number of rows
4519  , size_t N > // Number of columns
4520 inline void HybridMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
4521 {
4522  using blaze::store;
4523 
4525 
4526  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4527  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4528  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4529  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4530 
4531  store( &v_[i+j*MM], value );
4532 }
4534 //*************************************************************************************************
4535 
4536 
4537 //*************************************************************************************************
4553 template< typename Type // Data type of the matrix
4554  , size_t M // Number of rows
4555  , size_t N > // Number of columns
4556 inline void HybridMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4557 {
4558  using blaze::storeu;
4559 
4561 
4562  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
4563  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
4564  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
4565 
4566  storeu( &v_[i+j*MM], value );
4567 }
4569 //*************************************************************************************************
4570 
4571 
4572 //*************************************************************************************************
4589 template< typename Type // Data type of the matrix
4590  , size_t M // Number of rows
4591  , size_t N > // Number of columns
4592 inline void HybridMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4593 {
4594  using blaze::stream;
4595 
4597 
4598  BLAZE_INTERNAL_ASSERT( i < m_ , "Invalid row access index" );
4599  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4600  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4601  BLAZE_INTERNAL_ASSERT( j < n_ , "Invalid column access index" );
4602 
4603  stream( &v_[i+j*MM], value );
4604 }
4606 //*************************************************************************************************
4607 
4608 
4609 //*************************************************************************************************
4621 template< typename Type // Data type of the matrix
4622  , size_t M // Number of rows
4623  , size_t N > // Number of columns
4624 template< typename MT // Type of the right-hand side dense matrix
4625  , bool SO > // Storage order of the right-hand side dense matrix
4626 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4627  HybridMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
4628 {
4629  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4630 
4631  for( size_t j=0UL; j<n_; ++j ) {
4632  for( size_t i=0UL; i<m_; ++i ) {
4633  v_[i+j*MM] = (~rhs)(i,j);
4634  }
4635  }
4636 }
4638 //*************************************************************************************************
4639 
4640 
4641 //*************************************************************************************************
4653 template< typename Type // Data type of the matrix
4654  , size_t M // Number of rows
4655  , size_t N > // Number of columns
4656 template< typename MT // Type of the right-hand side dense matrix
4657  , bool SO > // Storage order of the right-hand side dense matrix
4658 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4659  HybridMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
4660 {
4661  using blaze::store;
4662 
4663  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4664 
4666 
4667  for( size_t j=0UL; j<n_; ++j ) {
4668  for( size_t i=0UL; i<m_; i+=IT::size ) {
4669  store( &v_[i+j*MM], (~rhs).load(i,j) );
4670  }
4671  }
4672 }
4674 //*************************************************************************************************
4675 
4676 
4677 //*************************************************************************************************
4689 template< typename Type // Data type of the matrix
4690  , size_t M // Number of rows
4691  , size_t N > // Number of columns
4692 template< typename MT > // Type of the right-hand side sparse matrix
4693 inline void HybridMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
4694 {
4695  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4696 
4697  typedef typename MT::ConstIterator RhsConstIterator;
4698 
4699  for( size_t j=0UL; j<n_; ++j )
4700  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4701  v_[element->index()+j*MM] = element->value();
4702 }
4704 //*************************************************************************************************
4705 
4706 
4707 //*************************************************************************************************
4719 template< typename Type // Data type of the matrix
4720  , size_t M // Number of rows
4721  , size_t N > // Number of columns
4722 template< typename MT > // Type of the right-hand side sparse matrix
4723 inline void HybridMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
4724 {
4726 
4727  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4728 
4729  typedef typename MT::ConstIterator RhsConstIterator;
4730 
4731  for( size_t i=0UL; i<m_; ++i )
4732  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4733  v_[i+element->index()*MM] = element->value();
4734 }
4736 //*************************************************************************************************
4737 
4738 
4739 //*************************************************************************************************
4751 template< typename Type // Data type of the matrix
4752  , size_t M // Number of rows
4753  , size_t N > // Number of columns
4754 template< typename MT // Type of the right-hand side dense matrix
4755  , bool SO > // Storage order of the right-hand side dense matrix
4756 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4757  HybridMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
4758 {
4759  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4760 
4761  for( size_t j=0UL; j<n_; ++j ) {
4762  for( size_t i=0UL; i<m_; ++i ) {
4763  v_[i+j*MM] += (~rhs)(i,j);
4764  }
4765  }
4766 }
4768 //*************************************************************************************************
4769 
4770 
4771 //*************************************************************************************************
4783 template< typename Type // Data type of the matrix
4784  , size_t M // Number of rows
4785  , size_t N > // Number of columns
4786 template< typename MT // Type of the right-hand side dense matrix
4787  , bool SO > // Storage order of the right-hand side dense matrix
4788 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4789  HybridMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
4790 {
4791  using blaze::load;
4792  using blaze::store;
4793 
4794  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4795 
4797 
4798  for( size_t j=0UL; j<n_; ++j ) {
4799  for( size_t i=0UL; i<m_; i+=IT::size ) {
4800  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
4801  }
4802  }
4803 }
4805 //*************************************************************************************************
4806 
4807 
4808 //*************************************************************************************************
4820 template< typename Type // Data type of the matrix
4821  , size_t M // Number of rows
4822  , size_t N > // Number of columns
4823 template< typename MT > // Type of the right-hand side sparse matrix
4824 inline void HybridMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
4825 {
4826  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4827 
4828  typedef typename MT::ConstIterator RhsConstIterator;
4829 
4830  for( size_t j=0UL; j<n_; ++j )
4831  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4832  v_[element->index()+j*MM] += element->value();
4833 }
4835 //*************************************************************************************************
4836 
4837 
4838 //*************************************************************************************************
4850 template< typename Type // Data type of the matrix
4851  , size_t M // Number of rows
4852  , size_t N > // Number of columns
4853 template< typename MT > // Type of the right-hand side sparse matrix
4854 inline void HybridMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
4855 {
4857 
4858  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4859 
4860  typedef typename MT::ConstIterator RhsConstIterator;
4861 
4862  for( size_t i=0UL; i<m_; ++i )
4863  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4864  v_[i+element->index()*MM] += element->value();
4865 }
4867 //*************************************************************************************************
4868 
4869 
4870 //*************************************************************************************************
4882 template< typename Type // Data type of the matrix
4883  , size_t M // Number of rows
4884  , size_t N > // Number of columns
4885 template< typename MT // Type of the right-hand side dense matrix
4886  , bool SO > // Storage order of the right-hand side dense matrix
4887 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4888  HybridMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
4889 {
4890  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4891 
4892  for( size_t j=0UL; j<n_; ++j ) {
4893  for( size_t i=0UL; i<m_; ++i ) {
4894  v_[i+j*MM] -= (~rhs)(i,j);
4895  }
4896  }
4897 }
4899 //*************************************************************************************************
4900 
4901 
4902 //*************************************************************************************************
4914 template< typename Type // Data type of the matrix
4915  , size_t M // Number of rows
4916  , size_t N > // Number of columns
4917 template< typename MT // Type of the right-hand side dense matrix
4918  , bool SO > // Storage order of the right-hand side dense matrix
4919 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4920  HybridMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
4921 {
4922  using blaze::load;
4923  using blaze::store;
4924 
4925  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4926 
4928 
4929  for( size_t j=0UL; j<n_; ++j ) {
4930  for( size_t i=0UL; i<m_; i+=IT::size ) {
4931  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
4932  }
4933  }
4934 }
4936 //*************************************************************************************************
4937 
4938 
4939 //*************************************************************************************************
4951 template< typename Type // Data type of the matrix
4952  , size_t M // Number of rows
4953  , size_t N > // Number of columns
4954 template< typename MT > // Type of the right-hand side sparse matrix
4955 inline void HybridMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
4956 {
4957  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4958 
4959  typedef typename MT::ConstIterator RhsConstIterator;
4960 
4961  for( size_t j=0UL; j<n_; ++j )
4962  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4963  v_[element->index()+j*MM] -= element->value();
4964 }
4966 //*************************************************************************************************
4967 
4968 
4969 //*************************************************************************************************
4981 template< typename Type // Data type of the matrix
4982  , size_t M // Number of rows
4983  , size_t N > // Number of columns
4984 template< typename MT > // Type of the right-hand side sparse matrix
4985 inline void HybridMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
4986 {
4988 
4989  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == m_ && (~rhs).columns() == n_, "Invalid matrix size" );
4990 
4991  typedef typename MT::ConstIterator RhsConstIterator;
4992 
4993  for( size_t i=0UL; i<m_; ++i )
4994  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4995  v_[i+element->index()*MM] -= element->value();
4996 }
4998 //*************************************************************************************************
4999 
5000 
5001 
5002 
5003 
5004 
5005 
5006 
5007 //=================================================================================================
5008 //
5009 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
5010 //
5011 //=================================================================================================
5012 
5013 //*************************************************************************************************
5021 template< typename Type // Data type of the matrix
5022  , size_t M // Number of rows
5023  , bool SO > // Storage order
5024 class HybridMatrix<Type,M,0UL,SO>;
5026 //*************************************************************************************************
5027 
5028 
5029 //*************************************************************************************************
5037 template< typename Type // Data type of the matrix
5038  , size_t N // Number of columns
5039  , bool SO > // Storage order
5040 class HybridMatrix<Type,0UL,N,SO>;
5042 //*************************************************************************************************
5043 
5044 
5045 //*************************************************************************************************
5053 template< typename Type // Data type of the matrix
5054  , bool SO > // Storage order
5055 class HybridMatrix<Type,0UL,0UL,SO>;
5057 //*************************************************************************************************
5058 
5059 
5060 
5061 
5062 
5063 
5064 
5065 
5066 //=================================================================================================
5067 //
5068 // STATICMATRIX OPERATORS
5069 //
5070 //=================================================================================================
5071 
5072 //*************************************************************************************************
5075 template< typename Type, size_t M, size_t N, bool SO >
5076 inline void reset( HybridMatrix<Type,M,N,SO>& m );
5077 
5078 template< typename Type, size_t M, size_t N, bool SO >
5079 inline void reset( HybridMatrix<Type,M,N,SO>& m, size_t i );
5080 
5081 template< typename Type, size_t M, size_t N, bool SO >
5082 inline void clear( HybridMatrix<Type,M,N,SO>& m );
5083 
5084 template< typename Type, size_t M, size_t N, bool SO >
5085 inline bool isDefault( const HybridMatrix<Type,M,N,SO>& m );
5086 
5087 template< typename Type, size_t M, size_t N, bool SO >
5088 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) /* throw() */;
5089 
5090 template< typename Type, size_t M, size_t N, bool SO >
5091 inline void move( HybridMatrix<Type,M,N,SO>& dst, HybridMatrix<Type,M,N,SO>& src ) /* throw() */;
5093 //*************************************************************************************************
5094 
5095 
5096 //*************************************************************************************************
5103 template< typename Type // Data type of the matrix
5104  , size_t M // Number of rows
5105  , size_t N // Number of columns
5106  , bool SO > // Storage order
5108 {
5109  m.reset();
5110 }
5111 //*************************************************************************************************
5112 
5113 
5114 //*************************************************************************************************
5127 template< typename Type // Data type of the matrix
5128  , size_t M // Number of rows
5129  , size_t N // Number of columns
5130  , bool SO > // Storage order
5131 inline void reset( HybridMatrix<Type,M,N,SO>& m, size_t i )
5132 {
5133  m.reset( i );
5134 }
5135 //*************************************************************************************************
5136 
5137 
5138 //*************************************************************************************************
5145 template< typename Type // Data type of the matrix
5146  , size_t M // Number of rows
5147  , size_t N // Number of columns
5148  , bool SO > // Storage order
5150 {
5151  m.clear();
5152 }
5153 //*************************************************************************************************
5154 
5155 
5156 //*************************************************************************************************
5174 template< typename Type // Data type of the matrix
5175  , size_t M // Number of rows
5176  , size_t N // Number of columns
5177  , bool SO > // Storage order
5178 inline bool isDefault( const HybridMatrix<Type,M,N,SO>& m )
5179 {
5180  return ( m.rows() == 0UL && m.columns() == 0UL );
5181 }
5182 //*************************************************************************************************
5183 
5184 
5185 //*************************************************************************************************
5194 template< typename Type // Data type of the matrix
5195  , size_t M // Number of rows
5196  , size_t N // Number of columns
5197  , bool SO > // Storage order
5198 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) /* throw() */
5199 {
5200  a.swap( b );
5201 }
5202 //*************************************************************************************************
5203 
5204 
5205 //*************************************************************************************************
5214 template< typename Type // Data type of the matrix
5215  , size_t M // Number of rows
5216  , size_t N // Number of columns
5217  , bool SO > // Storage order
5218 inline void move( HybridMatrix<Type,M,N,SO>& dst, HybridMatrix<Type,M,N,SO>& src ) /* throw() */
5219 {
5220  dst = src;
5221 }
5222 //*************************************************************************************************
5223 
5224 
5225 
5226 
5227 //=================================================================================================
5228 //
5229 // ISRESIZABLE SPECIALIZATIONS
5230 //
5231 //=================================================================================================
5232 
5233 //*************************************************************************************************
5235 template< typename T, size_t M, size_t N, bool SO >
5236 struct IsResizable< HybridMatrix<T,M,N,SO> > : public TrueType
5237 {
5238  enum { value = 1 };
5239  typedef TrueType Type;
5240 };
5242 //*************************************************************************************************
5243 
5244 
5245 
5246 
5247 //=================================================================================================
5248 //
5249 // ADDTRAIT SPECIALIZATIONS
5250 //
5251 //=================================================================================================
5252 
5253 //*************************************************************************************************
5255 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5256 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5257 {
5258  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5259 };
5260 
5261 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5262 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5263 {
5264  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, false > Type;
5265 };
5266 
5267 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5268 struct AddTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5269 {
5270  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5271 };
5272 
5273 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5274 struct AddTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5275 {
5276  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, false > Type;
5277 };
5278 
5279 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5280 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5281 {
5282  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5283 };
5284 
5285 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5286 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5287 {
5288  typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5289 };
5291 //*************************************************************************************************
5292 
5293 
5294 
5295 
5296 //=================================================================================================
5297 //
5298 // SUBTRAIT SPECIALIZATIONS
5299 //
5300 //=================================================================================================
5301 
5302 //*************************************************************************************************
5304 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5305 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5306 {
5307  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5308 };
5309 
5310 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5311 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5312 {
5313  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, false > Type;
5314 };
5315 
5316 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5317 struct SubTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5318 {
5319  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5320 };
5321 
5322 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5323 struct SubTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5324 {
5325  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, false > Type;
5326 };
5327 
5328 template< typename T1, size_t M1, size_t N1, bool SO, typename T2, size_t M2, size_t N2 >
5329 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5330 {
5331  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5332 };
5333 
5334 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5335 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5336 {
5337  typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5338 };
5340 //*************************************************************************************************
5341 
5342 
5343 
5344 
5345 //=================================================================================================
5346 //
5347 // MULTTRAIT SPECIALIZATIONS
5348 //
5349 //=================================================================================================
5350 
5351 //*************************************************************************************************
5353 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5354 struct MultTrait< HybridMatrix<T1,M,N,SO>, T2 >
5355 {
5356  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5358 };
5359 
5360 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5361 struct MultTrait< T1, HybridMatrix<T2,M,N,SO> >
5362 {
5363  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5365 };
5366 
5367 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t K >
5368 struct MultTrait< HybridMatrix<T1,M,N,SO>, StaticVector<T2,K,false> >
5369 {
5370  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5371 };
5372 
5373 template< typename T1, size_t K, typename T2, size_t M, size_t N, bool SO >
5374 struct MultTrait< StaticVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5375 {
5376  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5377 };
5378 
5379 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t K >
5380 struct MultTrait< HybridMatrix<T1,M,N,SO>, HybridVector<T2,K,false> >
5381 {
5382  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5383 };
5384 
5385 template< typename T1, size_t K, typename T2, size_t M, size_t N, bool SO >
5386 struct MultTrait< HybridVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5387 {
5388  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5389 };
5390 
5391 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5392 struct MultTrait< HybridMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5393 {
5394  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5395 };
5396 
5397 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5398 struct MultTrait< DynamicVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5399 {
5400  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5401 };
5402 
5403 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5404 struct MultTrait< HybridMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5405 {
5406  typedef HybridVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5407 };
5408 
5409 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5410 struct MultTrait< CompressedVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5411 {
5412  typedef HybridVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5413 };
5414 
5415 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5416 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5417 {
5418  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5419 };
5420 
5421 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5422 struct MultTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5423 {
5424  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5425 };
5426 
5427 template< typename T1, size_t M1, size_t N1, bool SO1, typename T2, size_t M2, size_t N2, bool SO2 >
5428 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5429 {
5430  typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5431 };
5433 //*************************************************************************************************
5434 
5435 
5436 
5437 
5438 //=================================================================================================
5439 //
5440 // DIVTRAIT SPECIALIZATIONS
5441 //
5442 //=================================================================================================
5443 
5444 //*************************************************************************************************
5446 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5447 struct DivTrait< HybridMatrix<T1,M,N,SO>, T2 >
5448 {
5449  typedef HybridMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5451 };
5453 //*************************************************************************************************
5454 
5455 
5456 
5457 
5458 //=================================================================================================
5459 //
5460 // MATHTRAIT SPECIALIZATIONS
5461 //
5462 //=================================================================================================
5463 
5464 //*************************************************************************************************
5466 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5467 struct MathTrait< HybridMatrix<T1,M,N,SO>, HybridMatrix<T2,M,N,SO> >
5468 {
5469  typedef HybridMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5470  typedef HybridMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5471 };
5473 //*************************************************************************************************
5474 
5475 
5476 
5477 
5478 //=================================================================================================
5479 //
5480 // SUBMATRIXTRAIT SPECIALIZATIONS
5481 //
5482 //=================================================================================================
5483 
5484 //*************************************************************************************************
5486 template< typename T1, size_t M, size_t N, bool SO >
5487 struct SubmatrixTrait< HybridMatrix<T1,M,N,SO> >
5488 {
5489  typedef HybridMatrix<T1,M,N,SO> Type;
5490 };
5492 //*************************************************************************************************
5493 
5494 
5495 
5496 
5497 //=================================================================================================
5498 //
5499 // ROWTRAIT SPECIALIZATIONS
5500 //
5501 //=================================================================================================
5502 
5503 //*************************************************************************************************
5505 template< typename T1, size_t M, size_t N, bool SO >
5506 struct RowTrait< HybridMatrix<T1,M,N,SO> >
5507 {
5508  typedef HybridVector<T1,N,true> Type;
5509 };
5511 //*************************************************************************************************
5512 
5513 
5514 
5515 
5516 //=================================================================================================
5517 //
5518 // COLUMNTRAIT SPECIALIZATIONS
5519 //
5520 //=================================================================================================
5521 
5522 //*************************************************************************************************
5524 template< typename T1, size_t M, size_t N, bool SO >
5525 struct ColumnTrait< HybridMatrix<T1,M,N,SO> >
5526 {
5527  typedef HybridVector<T1,M,false> Type;
5528 };
5530 //*************************************************************************************************
5531 
5532 } // namespace blaze
5533 
5534 #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:2181
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:994
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:985
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1057
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
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:2110
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
#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:2075
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:1409
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the row trait.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
Header file for the IsSparseMatrix type trait.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
Header file for the IsSame and IsStrictlySame type traits.
This ResultType
Result type for expression template evaluations.
Definition: HybridMatrix.h:202
Header file for the IsColumnMajorMatrix type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2636
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: HybridMatrix.h:801
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
size_t n_
The current number of columns of the matrix.
Definition: HybridMatrix.h:442
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:1992
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:207
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2039
Header file for the SparseMatrix base class.
Type * Pointer
Pointer to a non-constant matrix value.
Definition: HybridMatrix.h:211
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: HybridMatrix.h:1616
Type & Reference
Reference to a non-constant matrix value.
Definition: HybridMatrix.h:209
Header file for the DisableIf class template.
HybridMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: HybridMatrix.h:204
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: HybridMatrix.h:212
Header file for the multiplication trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: HybridMatrix.h:1374
Header file for the clear shim.
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:2146
Compile time assertion.
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1009
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4754
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: HybridMatrix.h:1467
#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:2012
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: HybridMatrix.h:1970
Header file for the DenseMatrix base class.
Pointer data()
Low-level data access to the matrix elements.
Definition: HybridMatrix.h:848
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:226
Header file for the DenseIterator class template.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
HybridMatrix()
The default constructor for HybridMatrix.
Definition: HybridMatrix.h:477
Constraint on the data type.
HybridMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: HybridMatrix.h:203
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
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
HybridMatrix< ET, M, N, SO > Other
The type of the other HybridMatrix.
Definition: HybridMatrix.h:222
void reset()
Reset to the default initial values.
Definition: HybridMatrix.h:1521
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:535
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
Header file for the EnableIf class template.
Header file for the IsVectorizable type trait.
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: HybridMatrix.h:214
Header file for the IsNumeric type trait.
Type ElementType
Type of the matrix elements.
Definition: HybridMatrix.h:205
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:937
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
HybridMatrix & transpose()
Transposing the matrix.
Definition: HybridMatrix.h:1686
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the division trait.
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: HybridMatrix.h:1425
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
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4769
Header file for the AlignedArray implementation.
Efficient implementation of a dynamically sized matrix with static memory.The HybridMatrix class temp...
Definition: Forward.h:56
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Header file for the column trait.
Header file for the isDefault shim.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
Constraint on the data type.
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridMatrix.h:213
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
Rebind mechanism to obtain a HybridMatrix with different data/element type.
Definition: HybridMatrix.h:221
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2637
Header file for the IsRowMajorMatrix type trait.
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: HybridMatrix.h:206
const Type & ConstReference
Reference to a constant matrix value.
Definition: HybridMatrix.h:210
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
void swap(HybridMatrix &m)
Swapping the contents of two hybrid matrices.
Definition: HybridMatrix.h:1754
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
void clear()
Clearing the hybrid matrix.
Definition: HybridMatrix.h:1569
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:1390
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
HybridMatrix< Type, M, N, SO > This
Type of this HybridMatrix instance.
Definition: HybridMatrix.h:201
size_t m_
The current number of rows of the matrix.
Definition: HybridMatrix.h:441
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: HybridMatrix.h:1663
#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
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: HybridMatrix.h:191
Header file for the IsResizable type trait.
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: HybridMatrix.h:431
#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
const This & CompositeType
Data type for composite expression templates.
Definition: HybridMatrix.h:208
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849