StaticMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_STATICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_STATICMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <cmath>
45 #include <stdexcept>
51 #include <blaze/math/Forward.h>
52 #include <blaze/math/Intrinsics.h>
53 #include <blaze/math/shims/Clear.h>
76 #include <blaze/system/Inline.h>
79 #include <blaze/util/Assert.h>
87 #include <blaze/util/DisableIf.h>
88 #include <blaze/util/EnableIf.h>
89 #include <blaze/util/Memory.h>
90 #include <blaze/util/mpl/SizeT.h>
92 #include <blaze/util/Template.h>
93 #include <blaze/util/Types.h>
97 #include <blaze/util/Unused.h>
98 
99 
100 namespace blaze {
101 
102 //=================================================================================================
103 //
104 // CLASS DEFINITION
105 //
106 //=================================================================================================
107 
108 //*************************************************************************************************
190 template< typename Type // Data type of the matrix
191  , size_t M // Number of rows
192  , size_t N // Number of columns
193  , bool SO = defaultStorageOrder > // Storage order
194 class StaticMatrix : public DenseMatrix< StaticMatrix<Type,M,N,SO>, SO >
195 {
196  private:
197  //**Type definitions****************************************************************************
199  //**********************************************************************************************
200 
201  //**********************************************************************************************
203  static const size_t NN = N + ( IT::size - ( N % IT::size ) ) % IT::size;
204  //**********************************************************************************************
205 
206  public:
207  //**Type definitions****************************************************************************
209  typedef This ResultType;
212  typedef Type ElementType;
213  typedef typename IT::Type IntrinsicType;
214  typedef const Type& ReturnType;
215  typedef const This& CompositeType;
216  typedef Type& Reference;
217  typedef const Type& ConstReference;
218  typedef Type* Pointer;
219  typedef const Type* ConstPointer;
222  //**********************************************************************************************
223 
224  //**Rebind struct definition********************************************************************
227  template< typename ET > // Data type of the other matrix
228  struct Rebind {
230  };
231  //**********************************************************************************************
232 
233  //**Compilation flags***************************************************************************
235 
239  enum { vectorizable = IsVectorizable<Type>::value };
240 
242 
245  enum { smpAssignable = 0 };
246  //**********************************************************************************************
247 
248  //**Constructors********************************************************************************
251  explicit inline StaticMatrix();
252  explicit inline StaticMatrix( const Type& init );
253 
254  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
255  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
256 
257  inline StaticMatrix( const StaticMatrix& m );
258  template< typename Other, bool SO2 > inline StaticMatrix( const StaticMatrix<Other,M,N,SO2>& m );
259  template< typename MT , bool SO2 > inline StaticMatrix( const Matrix<MT,SO2>& m );
260 
261  inline StaticMatrix( const Type& v1, const Type& v2 );
262  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
263  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
264  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
265  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
266  const Type& v6 );
267  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
268  const Type& v6, const Type& v7 );
269  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
270  const Type& v6, const Type& v7, const Type& v8 );
271  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
272  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
273  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
274  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
276  //**********************************************************************************************
277 
278  //**Destructor**********************************************************************************
279  // No explicitly declared destructor.
280  //**********************************************************************************************
281 
282  //**Data access functions***********************************************************************
285  inline Reference operator()( size_t i, size_t j );
286  inline ConstReference operator()( size_t i, size_t j ) const;
287  inline Pointer data ();
288  inline ConstPointer data () const;
289  inline Pointer data ( size_t i );
290  inline ConstPointer data ( size_t i ) const;
291  inline Iterator begin ( size_t i );
292  inline ConstIterator begin ( size_t i ) const;
293  inline ConstIterator cbegin( size_t i ) const;
294  inline Iterator end ( size_t i );
295  inline ConstIterator end ( size_t i ) const;
296  inline ConstIterator cend ( size_t i ) const;
298  //**********************************************************************************************
299 
300  //**Assignment operators************************************************************************
303  template< typename Other >
304  inline StaticMatrix& operator=( const Other (&array)[M][N] );
305 
306  inline StaticMatrix& operator= ( const Type& set );
307  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
308  template< typename Other, bool SO2 > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO2>& rhs );
309  template< typename MT , bool SO2 > inline StaticMatrix& operator= ( const Matrix<MT,SO2>& rhs );
310  template< typename MT , bool SO2 > inline StaticMatrix& operator+=( const Matrix<MT,SO2>& rhs );
311  template< typename MT , bool SO2 > inline StaticMatrix& operator-=( const Matrix<MT,SO2>& rhs );
312  template< typename MT , bool SO2 > inline StaticMatrix& operator*=( const Matrix<MT,SO2>& rhs );
313 
314  template< typename Other >
315  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
316  operator*=( Other rhs );
317 
318  template< typename Other >
319  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
320  operator/=( Other rhs );
322  //**********************************************************************************************
323 
324  //**Utility functions***************************************************************************
327  inline size_t rows() const;
328  inline size_t columns() const;
329  inline size_t spacing() const;
330  inline size_t capacity() const;
331  inline size_t capacity( size_t i ) const;
332  inline size_t nonZeros() const;
333  inline size_t nonZeros( size_t i ) const;
334  inline void reset();
335  inline void reset( size_t i );
336  inline StaticMatrix& transpose();
337  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
338  inline void swap( StaticMatrix& m ) /* throw() */;
340  //**********************************************************************************************
341 
342  //**Memory functions****************************************************************************
345  static inline void* operator new ( std::size_t size );
346  static inline void* operator new[]( std::size_t size );
347  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
348  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
349 
350  static inline void operator delete ( void* ptr );
351  static inline void operator delete[]( void* ptr );
352  static inline void operator delete ( void* ptr, const std::nothrow_t& );
353  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
355  //**********************************************************************************************
356 
357  private:
358  //**********************************************************************************************
360  template< typename MT >
362  struct VectorizedAssign {
363  enum { value = vectorizable && MT::vectorizable &&
364  IsSame<Type,typename MT::ElementType>::value &&
365  IsRowMajorMatrix<MT>::value };
366  };
368  //**********************************************************************************************
369 
370  //**********************************************************************************************
372  template< typename MT >
374  struct VectorizedAddAssign {
375  enum { value = vectorizable && MT::vectorizable &&
376  IsSame<Type,typename MT::ElementType>::value &&
377  IntrinsicTrait<Type>::addition &&
378  IsRowMajorMatrix<MT>::value &&
379  !IsDiagonal<MT>::value };
380  };
382  //**********************************************************************************************
383 
384  //**********************************************************************************************
386  template< typename MT >
388  struct VectorizedSubAssign {
389  enum { value = vectorizable && MT::vectorizable &&
390  IsSame<Type,typename MT::ElementType>::value &&
391  IntrinsicTrait<Type>::subtraction &&
392  IsRowMajorMatrix<MT>::value &&
393  !IsDiagonal<MT>::value };
394  };
396  //**********************************************************************************************
397 
398  public:
399  //**Expression template evaluation functions****************************************************
402  template< typename Other > inline bool canAlias ( const Other* alias ) const;
403  template< typename Other > inline bool isAliased( const Other* alias ) const;
404 
405  inline bool isAligned() const;
406 
407  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
408  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
409 
410  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
411  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
412  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
413 
414  template< typename MT, bool SO2 >
415  inline typename DisableIf< VectorizedAssign<MT> >::Type
416  assign( const DenseMatrix<MT,SO2>& rhs );
417 
418  template< typename MT, bool SO2 >
419  inline typename EnableIf< VectorizedAssign<MT> >::Type
420  assign( const DenseMatrix<MT,SO2>& rhs );
421 
422  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
423  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
424 
425  template< typename MT, bool SO2 >
426  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
427  addAssign( const DenseMatrix<MT,SO2>& rhs );
428 
429  template< typename MT, bool SO2 >
430  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
431  addAssign( const DenseMatrix<MT,SO2>& rhs );
432 
433  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
434  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
435 
436  template< typename MT, bool SO2 >
437  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
438  subAssign( const DenseMatrix<MT,SO2>& rhs );
439 
440  template< typename MT, bool SO2 >
441  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
442  subAssign( const DenseMatrix<MT,SO2>& rhs );
443 
444  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
445  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
447  //**********************************************************************************************
448 
449  private:
450  //**Member variables****************************************************************************
454 
464  //**********************************************************************************************
465 
466  //**Compile time checks*************************************************************************
472  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
473  BLAZE_STATIC_ASSERT( NN >= N );
475  //**********************************************************************************************
476 };
477 //*************************************************************************************************
478 
479 
480 
481 
482 //=================================================================================================
483 //
484 // CONSTRUCTORS
485 //
486 //=================================================================================================
487 
488 //*************************************************************************************************
493 template< typename Type // Data type of the matrix
494  , size_t M // Number of rows
495  , size_t N // Number of columns
496  , bool SO > // Storage order
498  : v_() // The statically allocated matrix elements
499 {
501 
502  if( IsNumeric<Type>::value ) {
503  for( size_t i=0UL; i<M*NN; ++i )
504  v_[i] = Type();
505  }
506 }
507 //*************************************************************************************************
508 
509 
510 //*************************************************************************************************
515 template< typename Type // Data type of the matrix
516  , size_t M // Number of rows
517  , size_t N // Number of columns
518  , bool SO > // Storage order
519 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& init )
520  : v_() // The statically allocated matrix elements
521 {
523 
524  for( size_t i=0UL; i<M; ++i ) {
525  for( size_t j=0UL; j<N; ++j )
526  v_[i*NN+j] = init;
527 
528  for( size_t j=N; j<NN; ++j )
529  v_[i*NN+j] = Type();
530  }
531 }
532 //*************************************************************************************************
533 
534 
535 //*************************************************************************************************
561 template< typename Type // Data type of the matrix
562  , size_t M // Number of rows
563  , size_t N // Number of columns
564  , bool SO > // Storage order
565 template< typename Other > // Data type of the initialization array
566 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( size_t m, size_t n, const Other* array )
567  : v_() // The statically allocated matrix elements
568 {
570 
571  if( m > M || n > N )
572  throw std::invalid_argument( "Invalid setup of static matrix" );
573 
574  for( size_t i=0UL; i<m; ++i ) {
575  for( size_t j=0UL; j<n; ++j )
576  v_[i*NN+j] = array[i*n+j];
577 
578  if( IsNumeric<Type>::value ) {
579  for( size_t j=n; j<NN; ++j )
580  v_[i*NN+j] = Type();
581  }
582  }
583 
584  if( IsNumeric<Type>::value ) {
585  for( size_t i=m; i<M; ++i ) {
586  for( size_t j=0UL; j<NN; ++j )
587  v_[i*NN+j] = Type();
588  }
589  }
590 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
614 template< typename Type // Data type of the matrix
615  , size_t M // Number of rows
616  , size_t N // Number of columns
617  , bool SO > // Storage order
618 template< typename Other > // Data type of the initialization array
619 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Other (&array)[M][N] )
620  : v_() // The statically allocated matrix elements
621 {
623 
624  for( size_t i=0UL; i<M; ++i ) {
625  for( size_t j=0UL; j<N; ++j )
626  v_[i*NN+j] = array[i][j];
627 
628  for( size_t j=N; j<NN; ++j )
629  v_[i*NN+j] = Type();
630  }
631 }
632 //*************************************************************************************************
633 
634 
635 //*************************************************************************************************
642 template< typename Type // Data type of the matrix
643  , size_t M // Number of rows
644  , size_t N // Number of columns
645  , bool SO > // Storage order
647  : v_() // The statically allocated matrix elements
648 {
650 
651  for( size_t i=0UL; i<M*NN; ++i )
652  v_[i] = m.v_[i];
653 }
654 //*************************************************************************************************
655 
656 
657 //*************************************************************************************************
662 template< typename Type // Data type of the matrix
663  , size_t M // Number of rows
664  , size_t N // Number of columns
665  , bool SO > // Storage order
666 template< typename Other // Data type of the foreign matrix
667  , bool SO2 > // Storage order of the foreign matrix
669  : v_() // The statically allocated matrix elements
670 {
672 
673  for( size_t i=0UL; i<M; ++i ) {
674  for( size_t j=0UL; j<N; ++j )
675  v_[i*NN+j] = m(i,j);
676 
677  for( size_t j=N; j<NN; ++j )
678  v_[i*NN+j] = Type();
679  }
680 }
681 //*************************************************************************************************
682 
683 
684 //*************************************************************************************************
694 template< typename Type // Data type of the matrix
695  , size_t M // Number of rows
696  , size_t N // Number of columns
697  , bool SO > // Storage order
698 template< typename MT // Type of the foreign matrix
699  , bool SO2 > // Storage order of the foreign matrix
701  : v_() // The statically allocated matrix elements
702 {
703  using blaze::assign;
704 
706 
707  if( (~m).rows() != M || (~m).columns() != N )
708  throw std::invalid_argument( "Invalid setup of static matrix" );
709 
710  for( size_t i=0UL; i<M; ++i ) {
711  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : N ); j<NN; ++j ) {
712  v_[i*NN+j] = Type();
713  }
714  }
715 
716  assign( *this, ~m );
717 }
718 //*************************************************************************************************
719 
720 
721 //*************************************************************************************************
738 template< typename Type // Data type of the matrix
739  , size_t M // Number of rows
740  , size_t N // Number of columns
741  , bool SO > // Storage order
742 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2 )
743  : v_() // The statically allocated matrix elements
744 {
745  BLAZE_STATIC_ASSERT( M*N == 2UL );
747 
748  // Initialization of a 1x2 matrix
749  if( M == 1UL ) {
750  v_[0UL] = v1;
751  v_[1UL] = v2;
752  }
753 
754  // Initialization of a 2x1 matrix
755  else {
756  v_[0UL] = v1;
757  v_[ NN] = v2;
758  }
759 
760  for( size_t i=0UL; i<M; ++i ) {
761  for( size_t j=N; j<NN; ++j )
762  v_[i*NN+j] = Type();
763  }
764 }
765 //*************************************************************************************************
766 
767 
768 //*************************************************************************************************
786 template< typename Type // Data type of the matrix
787  , size_t M // Number of rows
788  , size_t N // Number of columns
789  , bool SO > // Storage order
790 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
791  : v_() // The statically allocated matrix elements
792 {
793  BLAZE_STATIC_ASSERT( M*N == 3UL );
795 
796  // Initialization of a 1x3 matrix
797  if( M == 1UL ) {
798  v_[0UL] = v1;
799  v_[1UL] = v2;
800  v_[2UL] = v3;
801  }
802 
803  // Initialization of a 3x1 matrix
804  else {
805  v_[ 0UL] = v1;
806  v_[ NN] = v2;
807  v_[2UL*NN] = v3;
808  }
809 
810  for( size_t i=0UL; i<M; ++i ) {
811  for( size_t j=N; j<NN; ++j )
812  v_[i*NN+j] = Type();
813  }
814 }
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
839 template< typename Type // Data type of the matrix
840  , size_t M // Number of rows
841  , size_t N // Number of columns
842  , bool SO > // Storage order
843 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2,
844  const Type& v3, const Type& v4 )
845  : v_() // The statically allocated matrix elements
846 {
847  BLAZE_STATIC_ASSERT( M*N == 4UL );
849 
850  // Initialization of a 1x4 matrix
851  if( M == 1UL ) {
852  v_[0UL] = v1;
853  v_[1UL] = v2;
854  v_[2UL] = v3;
855  v_[3UL] = v4;
856  }
857 
858  // Initialization of a 2x2 matrix
859  else if( M == 2UL ) {
860  v_[ 0UL] = v1;
861  v_[ 1UL] = v2;
862  v_[NN ] = v3;
863  v_[NN+1UL] = v4;
864  }
865 
866  // Initialization of a 4x1 matrix
867  else {
868  v_[ 0UL] = v1;
869  v_[ NN] = v2;
870  v_[2UL*NN] = v3;
871  v_[3UL*NN] = v4;
872  }
873 
874  for( size_t i=0UL; i<M; ++i ) {
875  for( size_t j=N; j<NN; ++j )
876  v_[i*NN+j] = Type();
877  }
878 }
879 //*************************************************************************************************
880 
881 
882 //*************************************************************************************************
902 template< typename Type // Data type of the matrix
903  , size_t M // Number of rows
904  , size_t N // Number of columns
905  , bool SO > // Storage order
906 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
907  const Type& v4, const Type& v5 )
908  : v_() // The statically allocated matrix elements
909 {
910  BLAZE_STATIC_ASSERT( M*N == 5UL );
912 
913  // Initialization of a 1x5 matrix
914  if( M == 1UL ) {
915  v_[0UL] = v1;
916  v_[1UL] = v2;
917  v_[2UL] = v3;
918  v_[3UL] = v4;
919  v_[4UL] = v5;
920  }
921 
922  // Initialization of a 5x1 matrix
923  else {
924  v_[ 0UL] = v1;
925  v_[ NN] = v2;
926  v_[2UL*NN] = v3;
927  v_[3UL*NN] = v4;
928  v_[4UL*NN] = v5;
929  }
930 
931  for( size_t i=0UL; i<M; ++i ) {
932  for( size_t j=N; j<NN; ++j )
933  v_[i*NN+j] = Type();
934  }
935 }
936 //*************************************************************************************************
937 
938 
939 //*************************************************************************************************
963 template< typename Type // Data type of the matrix
964  , size_t M // Number of rows
965  , size_t N // Number of columns
966  , bool SO > // Storage order
967 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
968  const Type& v4, const Type& v5, const Type& v6 )
969  : v_() // The statically allocated matrix elements
970 {
971  BLAZE_STATIC_ASSERT( M*N == 6UL );
973 
974  // Initialization of a 1x6 matrix
975  if( M == 1UL ) {
976  v_[0UL] = v1;
977  v_[1UL] = v2;
978  v_[2UL] = v3;
979  v_[3UL] = v4;
980  v_[4UL] = v5;
981  v_[5UL] = v6;
982  }
983 
984  // Initialization of a 2x3 matrix
985  else if( M == 2UL ) {
986  v_[ 0UL] = v1;
987  v_[ 1UL] = v2;
988  v_[ 2UL] = v3;
989  v_[NN ] = v4;
990  v_[NN+1UL] = v5;
991  v_[NN+2UL] = v6;
992  }
993 
994  // Initialization of a 3x2 matrix
995  else if( M == 3UL ) {
996  v_[ 0UL] = v1;
997  v_[ 1UL] = v2;
998  v_[ NN ] = v3;
999  v_[ NN+1UL] = v4;
1000  v_[2UL*NN ] = v5;
1001  v_[2UL*NN+1UL] = v6;
1002  }
1003 
1004  // Initialization of a 6x1 matrix
1005  else {
1006  v_[ 0UL] = v1;
1007  v_[ NN] = v2;
1008  v_[2UL*NN] = v3;
1009  v_[3UL*NN] = v4;
1010  v_[4UL*NN] = v5;
1011  v_[5UL*NN] = v6;
1012  }
1013 
1014  for( size_t i=0UL; i<M; ++i ) {
1015  for( size_t j=N; j<NN; ++j )
1016  v_[i*NN+j] = Type();
1017  }
1018 }
1019 //*************************************************************************************************
1020 
1021 
1022 //*************************************************************************************************
1044 template< typename Type // Data type of the matrix
1045  , size_t M // Number of rows
1046  , size_t N // Number of columns
1047  , bool SO > // Storage order
1048 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1049  const Type& v4, const Type& v5, const Type& v6,
1050  const Type& v7 )
1051  : v_() // The statically allocated matrix elements
1052 {
1053  BLAZE_STATIC_ASSERT( M*N == 7UL );
1055 
1056  // Initialization of a 1x7 matrix
1057  if( M == 1UL ) {
1058  v_[0UL] = v1;
1059  v_[1UL] = v2;
1060  v_[2UL] = v3;
1061  v_[3UL] = v4;
1062  v_[4UL] = v5;
1063  v_[5UL] = v6;
1064  v_[6UL] = v7;
1065  }
1066 
1067  // Initialization of a 7x1 matrix
1068  else {
1069  v_[ 0UL] = v1;
1070  v_[ NN] = v2;
1071  v_[2UL*NN] = v3;
1072  v_[3UL*NN] = v4;
1073  v_[4UL*NN] = v5;
1074  v_[5UL*NN] = v6;
1075  v_[6UL*NN] = v7;
1076  }
1077 
1078  for( size_t i=0UL; i<M; ++i ) {
1079  for( size_t j=N; j<NN; ++j )
1080  v_[i*NN+j] = Type();
1081  }
1082 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1111 template< typename Type // Data type of the matrix
1112  , size_t M // Number of rows
1113  , size_t N // Number of columns
1114  , bool SO > // Storage order
1115 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1116  const Type& v4, const Type& v5, const Type& v6,
1117  const Type& v7, const Type& v8 )
1118  : v_() // The statically allocated matrix elements
1119 {
1120  BLAZE_STATIC_ASSERT( M*N == 8UL );
1122 
1123  // Initialization of a 1x8 matrix
1124  if( M == 1UL ) {
1125  v_[0UL] = v1;
1126  v_[1UL] = v2;
1127  v_[2UL] = v3;
1128  v_[3UL] = v4;
1129  v_[4UL] = v5;
1130  v_[5UL] = v6;
1131  v_[6UL] = v7;
1132  v_[7UL] = v8;
1133  }
1134 
1135  // Initialization of a 2x4 matrix
1136  else if( M == 2UL ) {
1137  v_[ 0UL] = v1;
1138  v_[ 1UL] = v2;
1139  v_[ 2UL] = v3;
1140  v_[ 3UL] = v4;
1141  v_[NN ] = v5;
1142  v_[NN+1UL] = v6;
1143  v_[NN+2UL] = v7;
1144  v_[NN+3UL] = v8;
1145  }
1146 
1147  // Initialization of a 4x2 matrix
1148  else if( M == 4UL ) {
1149  v_[ 0UL] = v1;
1150  v_[ 1UL] = v2;
1151  v_[ NN ] = v3;
1152  v_[ NN+1UL] = v4;
1153  v_[2UL*NN ] = v5;
1154  v_[2UL*NN+1UL] = v6;
1155  v_[3UL*NN ] = v7;
1156  v_[3UL*NN+1UL] = v8;
1157  }
1158 
1159  // Initialization of a 8x1 matrix
1160  else {
1161  v_[ 0UL] = v1;
1162  v_[ NN] = v2;
1163  v_[2UL*NN] = v3;
1164  v_[3UL*NN] = v4;
1165  v_[4UL*NN] = v5;
1166  v_[5UL*NN] = v6;
1167  v_[6UL*NN] = v7;
1168  v_[7UL*NN] = v8;
1169  }
1170 
1171  for( size_t i=0UL; i<M; ++i ) {
1172  for( size_t j=N; j<NN; ++j )
1173  v_[i*NN+j] = Type();
1174  }
1175 }
1176 //*************************************************************************************************
1177 
1178 
1179 //*************************************************************************************************
1206 template< typename Type // Data type of the matrix
1207  , size_t M // Number of rows
1208  , size_t N // Number of columns
1209  , bool SO > // Storage order
1210 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1211  const Type& v4, const Type& v5, const Type& v6,
1212  const Type& v7, const Type& v8, const Type& v9 )
1213  : v_() // The statically allocated matrix elements
1214 {
1215  BLAZE_STATIC_ASSERT( M*N == 9UL );
1217 
1218  // Initialization of a 1x9 matrix
1219  if( M == 1UL ) {
1220  v_[0UL] = v1;
1221  v_[1UL] = v2;
1222  v_[2UL] = v3;
1223  v_[3UL] = v4;
1224  v_[4UL] = v5;
1225  v_[5UL] = v6;
1226  v_[6UL] = v7;
1227  v_[7UL] = v8;
1228  v_[8UL] = v9;
1229  }
1230 
1231  // Initialization of a 3x3 matrix
1232  else if( M == 3UL ) {
1233  v_[ 0UL] = v1;
1234  v_[ 1UL] = v2;
1235  v_[ 2UL] = v3;
1236  v_[ NN ] = v4;
1237  v_[ NN+1UL] = v5;
1238  v_[ NN+2UL] = v6;
1239  v_[2UL*NN ] = v7;
1240  v_[2UL*NN+1UL] = v8;
1241  v_[2UL*NN+2UL] = v9;
1242  }
1243 
1244  // Initialization of a 9x1 matrix
1245  else {
1246  v_[ 0UL] = v1;
1247  v_[ NN] = v2;
1248  v_[2UL*NN] = v3;
1249  v_[3UL*NN] = v4;
1250  v_[4UL*NN] = v5;
1251  v_[5UL*NN] = v6;
1252  v_[6UL*NN] = v7;
1253  v_[7UL*NN] = v8;
1254  v_[8UL*NN] = v9;
1255  }
1256 
1257  for( size_t i=0UL; i<M; ++i ) {
1258  for( size_t j=N; j<NN; ++j )
1259  v_[i*NN+j] = Type();
1260  }
1261 }
1262 //*************************************************************************************************
1263 
1264 
1265 //*************************************************************************************************
1293 template< typename Type // Data type of the matrix
1294  , size_t M // Number of rows
1295  , size_t N // Number of columns
1296  , bool SO > // Storage order
1297 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1298  const Type& v4, const Type& v5, const Type& v6,
1299  const Type& v7, const Type& v8, const Type& v9,
1300  const Type& v10 )
1301  : v_() // The statically allocated matrix elements
1302 {
1303  BLAZE_STATIC_ASSERT( M*N == 10UL );
1305 
1306  // Initialization of a 1x10 matrix
1307  if( M == 1UL ) {
1308  v_[0UL] = v1;
1309  v_[1UL] = v2;
1310  v_[2UL] = v3;
1311  v_[3UL] = v4;
1312  v_[4UL] = v5;
1313  v_[5UL] = v6;
1314  v_[6UL] = v7;
1315  v_[7UL] = v8;
1316  v_[8UL] = v9;
1317  v_[9UL] = v10;
1318  }
1319 
1320  // Initialization of a 2x5 matrix
1321  else if( M == 2UL ) {
1322  v_[ 0UL] = v1;
1323  v_[ 1UL] = v2;
1324  v_[ 2UL] = v3;
1325  v_[ 3UL] = v4;
1326  v_[ 4UL] = v5;
1327  v_[NN ] = v6;
1328  v_[NN+1UL] = v7;
1329  v_[NN+2UL] = v8;
1330  v_[NN+3UL] = v9;
1331  v_[NN+4UL] = v10;
1332  }
1333 
1334  // Initialization of a 5x2 matrix
1335  else if( M == 5UL ) {
1336  v_[ 0UL] = v1;
1337  v_[ 1UL] = v2;
1338  v_[ NN ] = v3;
1339  v_[ NN+1UL] = v4;
1340  v_[2UL*NN ] = v5;
1341  v_[2UL*NN+1UL] = v6;
1342  v_[3UL*NN ] = v7;
1343  v_[3UL*NN+1UL] = v8;
1344  v_[4UL*NN ] = v9;
1345  v_[4UL*NN+1UL] = v10;
1346  }
1347 
1348  // Initialization of a 10x1 matrix
1349  else {
1350  v_[ 0UL] = v1;
1351  v_[ NN] = v2;
1352  v_[2UL*NN] = v3;
1353  v_[3UL*NN] = v4;
1354  v_[4UL*NN] = v5;
1355  v_[5UL*NN] = v6;
1356  v_[6UL*NN] = v7;
1357  v_[7UL*NN] = v8;
1358  v_[8UL*NN] = v9;
1359  v_[9UL*NN] = v10;
1360  }
1361 
1362  for( size_t i=0UL; i<M; ++i ) {
1363  for( size_t j=N; j<NN; ++j )
1364  v_[i*NN+j] = Type();
1365  }
1366 }
1367 //*************************************************************************************************
1368 
1369 
1370 
1371 
1372 //=================================================================================================
1373 //
1374 // DATA ACCESS FUNCTIONS
1375 //
1376 //=================================================================================================
1377 
1378 //*************************************************************************************************
1385 template< typename Type // Data type of the matrix
1386  , size_t M // Number of rows
1387  , size_t N // Number of columns
1388  , bool SO > // Storage order
1391 {
1392  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1393  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1394  return v_[i*NN+j];
1395 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1406 template< typename Type // Data type of the matrix
1407  , size_t M // Number of rows
1408  , size_t N // Number of columns
1409  , bool SO > // Storage order
1411  StaticMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
1412 {
1413  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1414  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1415  return v_[i*NN+j];
1416 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1432 template< typename Type // Data type of the matrix
1433  , size_t M // Number of rows
1434  , size_t N // Number of columns
1435  , bool SO > // Storage order
1436 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1438 {
1439  return v_;
1440 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
1456 template< typename Type // Data type of the matrix
1457  , size_t M // Number of rows
1458  , size_t N // Number of columns
1459  , bool SO > // Storage order
1462 {
1463  return v_;
1464 }
1465 //*************************************************************************************************
1466 
1467 
1468 //*************************************************************************************************
1476 template< typename Type // Data type of the matrix
1477  , size_t M // Number of rows
1478  , size_t N // Number of columns
1479  , bool SO > // Storage order
1480 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1482 {
1483  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1484  return v_ + i*NN;
1485 }
1486 //*************************************************************************************************
1487 
1488 
1489 //*************************************************************************************************
1497 template< typename Type // Data type of the matrix
1498  , size_t M // Number of rows
1499  , size_t N // Number of columns
1500  , bool SO > // Storage order
1503 {
1504  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1505  return v_ + i*NN;
1506 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1521 template< typename Type // Data type of the matrix
1522  , size_t M // Number of rows
1523  , size_t N // Number of columns
1524  , bool SO > // Storage order
1527 {
1528  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1529  return Iterator( v_ + i*NN );
1530 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1545 template< typename Type // Data type of the matrix
1546  , size_t M // Number of rows
1547  , size_t N // Number of columns
1548  , bool SO > // Storage order
1551 {
1552  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1553  return ConstIterator( v_ + i*NN );
1554 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1569 template< typename Type // Data type of the matrix
1570  , size_t M // Number of rows
1571  , size_t N // Number of columns
1572  , bool SO > // Storage order
1575 {
1576  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1577  return ConstIterator( v_ + i*NN );
1578 }
1579 //*************************************************************************************************
1580 
1581 
1582 //*************************************************************************************************
1593 template< typename Type // Data type of the matrix
1594  , size_t M // Number of rows
1595  , size_t N // Number of columns
1596  , bool SO > // Storage order
1599 {
1600  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1601  return Iterator( v_ + i*NN + N );
1602 }
1603 //*************************************************************************************************
1604 
1605 
1606 //*************************************************************************************************
1617 template< typename Type // Data type of the matrix
1618  , size_t M // Number of rows
1619  , size_t N // Number of columns
1620  , bool SO > // Storage order
1623 {
1624  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1625  return ConstIterator( v_ + i*NN + N );
1626 }
1627 //*************************************************************************************************
1628 
1629 
1630 //*************************************************************************************************
1641 template< typename Type // Data type of the matrix
1642  , size_t M // Number of rows
1643  , size_t N // Number of columns
1644  , bool SO > // Storage order
1647 {
1648  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1649  return ConstIterator( v_ + i*NN + N );
1650 }
1651 //*************************************************************************************************
1652 
1653 
1654 
1655 
1656 //=================================================================================================
1657 //
1658 // ASSIGNMENT OPERATORS
1659 //
1660 //=================================================================================================
1661 
1662 //*************************************************************************************************
1683 template< typename Type // Data type of the matrix
1684  , size_t M // Number of rows
1685  , size_t N // Number of columns
1686  , bool SO > // Storage order
1687 template< typename Other > // Data type of the initialization array
1689 {
1690  for( size_t i=0UL; i<M; ++i )
1691  for( size_t j=0UL; j<N; ++j )
1692  v_[i*NN+j] = array[i][j];
1693 
1694  return *this;
1695 }
1696 //*************************************************************************************************
1697 
1698 
1699 //*************************************************************************************************
1705 template< typename Type // Data type of the matrix
1706  , size_t M // Number of rows
1707  , size_t N // Number of columns
1708  , bool SO > // Storage order
1710 {
1711  for( size_t i=0UL; i<M; ++i )
1712  for( size_t j=0UL; j<N; ++j )
1713  v_[i*NN+j] = set;
1714 
1715  return *this;
1716 }
1717 //*************************************************************************************************
1718 
1719 
1720 //*************************************************************************************************
1728 template< typename Type // Data type of the matrix
1729  , size_t M // Number of rows
1730  , size_t N // Number of columns
1731  , bool SO > // Storage order
1733 {
1734  using blaze::assign;
1735 
1736  assign( *this, ~rhs );
1737  return *this;
1738 }
1739 //*************************************************************************************************
1740 
1741 
1742 //*************************************************************************************************
1748 template< typename Type // Data type of the matrix
1749  , size_t M // Number of rows
1750  , size_t N // Number of columns
1751  , bool SO > // Storage order
1752 template< typename Other // Data type of the foreign matrix
1753  , bool SO2 > // Storage order of the foreign matrix
1756 {
1757  using blaze::assign;
1758 
1759  assign( *this, ~rhs );
1760  return *this;
1761 }
1762 //*************************************************************************************************
1763 
1764 
1765 //*************************************************************************************************
1776 template< typename Type // Data type of the matrix
1777  , size_t M // Number of rows
1778  , size_t N // Number of columns
1779  , bool SO > // Storage order
1780 template< typename MT // Type of the right-hand side matrix
1781  , bool SO2 > // Storage order of the right-hand side matrix
1783 {
1784  using blaze::assign;
1785 
1786  if( (~rhs).rows() != M || (~rhs).columns() != N )
1787  throw std::invalid_argument( "Invalid assignment to static matrix" );
1788 
1789  if( (~rhs).canAlias( this ) ) {
1790  StaticMatrix tmp( ~rhs );
1791  swap( tmp );
1792  }
1793  else {
1795  reset();
1796  assign( *this, ~rhs );
1797  }
1798 
1799  return *this;
1800 }
1801 //*************************************************************************************************
1802 
1803 
1804 //*************************************************************************************************
1814 template< typename Type // Data type of the matrix
1815  , size_t M // Number of rows
1816  , size_t N // Number of columns
1817  , bool SO > // Storage order
1818 template< typename MT // Type of the right-hand side matrix
1819  , bool SO2 > // Storage order of the right-hand side matrix
1821 {
1822  using blaze::addAssign;
1823 
1824  if( (~rhs).rows() != M || (~rhs).columns() != N )
1825  throw std::invalid_argument( "Matrix sizes do not match" );
1826 
1827  if( (~rhs).canAlias( this ) ) {
1828  typename MT::ResultType tmp( ~rhs );
1829  addAssign( *this, tmp );
1830  }
1831  else {
1832  addAssign( *this, ~rhs );
1833  }
1834 
1835  return *this;
1836 }
1837 //*************************************************************************************************
1838 
1839 
1840 //*************************************************************************************************
1850 template< typename Type // Data type of the matrix
1851  , size_t M // Number of rows
1852  , size_t N // Number of columns
1853  , bool SO > // Storage order
1854 template< typename MT // Type of the right-hand side matrix
1855  , bool SO2 > // Storage order of the right-hand side matrix
1857 {
1858  using blaze::subAssign;
1859 
1860  if( (~rhs).rows() != M || (~rhs).columns() != N )
1861  throw std::invalid_argument( "Matrix sizes do not match" );
1862 
1863  if( (~rhs).canAlias( this ) ) {
1864  typename MT::ResultType tmp( ~rhs );
1865  subAssign( *this, tmp );
1866  }
1867  else {
1868  subAssign( *this, ~rhs );
1869  }
1870 
1871  return *this;
1872 }
1873 //*************************************************************************************************
1874 
1875 
1876 //*************************************************************************************************
1886 template< typename Type // Data type of the matrix
1887  , size_t M // Number of rows
1888  , size_t N // Number of columns
1889  , bool SO > // Storage order
1890 template< typename MT // Type of the right-hand side matrix
1891  , bool SO2 > // Storage order of the right-hand side matrix
1893 {
1894  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
1895  throw std::invalid_argument( "Matrix sizes do not match" );
1896 
1897  StaticMatrix tmp( *this * (~rhs) );
1898  return this->operator=( tmp );
1899 }
1900 //*************************************************************************************************
1901 
1902 
1903 //*************************************************************************************************
1910 template< typename Type // Data type of the matrix
1911  , size_t M // Number of rows
1912  , size_t N // Number of columns
1913  , bool SO > // Storage order
1914 template< typename Other > // Data type of the right-hand side scalar
1915 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1917 {
1918  using blaze::assign;
1919 
1920  assign( *this, (*this) * rhs );
1921  return *this;
1922 }
1923 //*************************************************************************************************
1924 
1925 
1926 //*************************************************************************************************
1935 template< typename Type // Data type of the matrix
1936  , size_t M // Number of rows
1937  , size_t N // Number of columns
1938  , bool SO > // Storage order
1939 template< typename Other > // Data type of the right-hand side scalar
1940 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1942 {
1943  using blaze::assign;
1944 
1945  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1946 
1947  assign( *this, (*this) / rhs );
1948  return *this;
1949 }
1950 //*************************************************************************************************
1951 
1952 
1953 
1954 
1955 //=================================================================================================
1956 //
1957 // UTILITY FUNCTIONS
1958 //
1959 //=================================================================================================
1960 
1961 //*************************************************************************************************
1966 template< typename Type // Data type of the matrix
1967  , size_t M // Number of rows
1968  , size_t N // Number of columns
1969  , bool SO > // Storage order
1970 inline size_t StaticMatrix<Type,M,N,SO>::rows() const
1971 {
1972  return M;
1973 }
1974 //*************************************************************************************************
1975 
1976 
1977 //*************************************************************************************************
1982 template< typename Type // Data type of the matrix
1983  , size_t M // Number of rows
1984  , size_t N // Number of columns
1985  , bool SO > // Storage order
1987 {
1988  return N;
1989 }
1990 //*************************************************************************************************
1991 
1992 
1993 //*************************************************************************************************
2001 template< typename Type // Data type of the matrix
2002  , size_t M // Number of rows
2003  , size_t N // Number of columns
2004  , bool SO > // Storage order
2006 {
2007  return NN;
2008 }
2009 //*************************************************************************************************
2010 
2011 
2012 //*************************************************************************************************
2017 template< typename Type // Data type of the matrix
2018  , size_t M // Number of rows
2019  , size_t N // Number of columns
2020  , bool SO > // Storage order
2022 {
2023  return M*NN;
2024 }
2025 //*************************************************************************************************
2026 
2027 
2028 //*************************************************************************************************
2039 template< typename Type // Data type of the matrix
2040  , size_t M // Number of rows
2041  , size_t N // Number of columns
2042  , bool SO > // Storage order
2043 inline size_t StaticMatrix<Type,M,N,SO>::capacity( size_t i ) const
2044 {
2045  UNUSED_PARAMETER( i );
2046 
2047  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2048 
2049  return NN;
2050 }
2051 //*************************************************************************************************
2052 
2053 
2054 //*************************************************************************************************
2059 template< typename Type // Data type of the matrix
2060  , size_t M // Number of rows
2061  , size_t N // Number of columns
2062  , bool SO > // Storage order
2064 {
2065  size_t nonzeros( 0UL );
2066 
2067  for( size_t i=0UL; i<M; ++i )
2068  for( size_t j=0UL; j<N; ++j )
2069  if( !isDefault( v_[i*NN+j] ) )
2070  ++nonzeros;
2071 
2072  return nonzeros;
2073 }
2074 //*************************************************************************************************
2075 
2076 
2077 //*************************************************************************************************
2088 template< typename Type // Data type of the matrix
2089  , size_t M // Number of rows
2090  , size_t N // Number of columns
2091  , bool SO > // Storage order
2092 inline size_t StaticMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
2093 {
2094  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2095 
2096  const size_t jend( (i+1UL)*NN );
2097  size_t nonzeros( 0UL );
2098 
2099  for( size_t j=i*NN; j<jend; ++j )
2100  if( !isDefault( v_[j] ) )
2101  ++nonzeros;
2102 
2103  return nonzeros;
2104 }
2105 //*************************************************************************************************
2106 
2107 
2108 //*************************************************************************************************
2113 template< typename Type // Data type of the matrix
2114  , size_t M // Number of rows
2115  , size_t N // Number of columns
2116  , bool SO > // Storage order
2118 {
2119  using blaze::clear;
2120 
2121  for( size_t i=0UL; i<M; ++i )
2122  for( size_t j=0UL; j<N; ++j )
2123  clear( v_[i*NN+j] );
2124 }
2125 //*************************************************************************************************
2126 
2127 
2128 //*************************************************************************************************
2139 template< typename Type // Data type of the matrix
2140  , size_t M // Number of rows
2141  , size_t N // Number of columns
2142  , bool SO > // Storage order
2143 inline void StaticMatrix<Type,M,N,SO>::reset( size_t i )
2144 {
2145  using blaze::clear;
2146 
2147  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2148  for( size_t j=0UL; j<N; ++j )
2149  clear( v_[i*NN+j] );
2150 }
2151 //*************************************************************************************************
2152 
2153 
2154 //*************************************************************************************************
2162 template< typename Type // Data type of the matrix
2163  , size_t M // Number of rows
2164  , size_t N // Number of columns
2165  , bool SO > // Storage order
2167 {
2168  using std::swap;
2169 
2170  BLAZE_STATIC_ASSERT( M == N );
2171 
2172  for( size_t i=1UL; i<M; ++i )
2173  for( size_t j=0UL; j<i; ++j )
2174  swap( v_[i*NN+j], v_[j*NN+i] );
2175 
2176  return *this;
2177 }
2178 //*************************************************************************************************
2179 
2180 
2181 //*************************************************************************************************
2187 template< typename Type // Data type of the matrix
2188  , size_t M // Number of rows
2189  , size_t N // Number of columns
2190  , bool SO > // Storage order
2191 template< typename Other > // Data type of the scalar value
2193 {
2194  for( size_t i=0UL; i<M; ++i )
2195  for( size_t j=0UL; j<N; ++j )
2196  v_[i*NN+j] *= scalar;
2197 
2198  return *this;
2199 }
2200 //*************************************************************************************************
2201 
2202 
2203 //*************************************************************************************************
2210 template< typename Type // Data type of the matrix
2211  , size_t M // Number of rows
2212  , size_t N // Number of columns
2213  , bool SO > // Storage order
2214 inline void StaticMatrix<Type,M,N,SO>::swap( StaticMatrix& m ) /* throw() */
2215 {
2216  using std::swap;
2217 
2218  for( size_t i=0UL; i<M; ++i ) {
2219  for( size_t j=0UL; j<N; ++j ) {
2220  swap( v_[i*NN+j], m(i,j) );
2221  }
2222  }
2223 }
2224 //*************************************************************************************************
2225 
2226 
2227 
2228 
2229 //=================================================================================================
2230 //
2231 // MEMORY FUNCTIONS
2232 //
2233 //=================================================================================================
2234 
2235 //*************************************************************************************************
2245 template< typename Type // Data type of the matrix
2246  , size_t M // Number of rows
2247  , size_t N // Number of columns
2248  , bool SO > // Storage order
2249 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size )
2250 {
2252 
2253  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2254 
2255  return allocate<StaticMatrix>( 1UL );
2256 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2270 template< typename Type // Data type of the matrix
2271  , size_t M // Number of rows
2272  , size_t N // Number of columns
2273  , bool SO > // Storage order
2274 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size )
2275 {
2276  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2277  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2278 
2279  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2280 }
2281 //*************************************************************************************************
2282 
2283 
2284 //*************************************************************************************************
2294 template< typename Type // Data type of the matrix
2295  , size_t M // Number of rows
2296  , size_t N // Number of columns
2297  , bool SO > // Storage order
2298 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size, const std::nothrow_t& )
2299 {
2300  UNUSED_PARAMETER( size );
2301 
2302  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2303 
2304  return allocate<StaticMatrix>( 1UL );
2305 }
2306 //*************************************************************************************************
2307 
2308 
2309 //*************************************************************************************************
2319 template< typename Type // Data type of the matrix
2320  , size_t M // Number of rows
2321  , size_t N // Number of columns
2322  , bool SO > // Storage order
2323 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size, const std::nothrow_t& )
2324 {
2325  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2326  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2327 
2328  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2329 }
2330 //*************************************************************************************************
2331 
2332 
2333 //*************************************************************************************************
2339 template< typename Type // Data type of the matrix
2340  , size_t M // Number of rows
2341  , size_t N // Number of columns
2342  , bool SO > // Storage order
2343 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr )
2344 {
2345  deallocate( static_cast<StaticMatrix*>( ptr ) );
2346 }
2347 //*************************************************************************************************
2348 
2349 
2350 //*************************************************************************************************
2356 template< typename Type // Data type of the matrix
2357  , size_t M // Number of rows
2358  , size_t N // Number of columns
2359  , bool SO > // Storage order
2360 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr )
2361 {
2362  deallocate( static_cast<StaticMatrix*>( ptr ) );
2363 }
2364 //*************************************************************************************************
2365 
2366 
2367 //*************************************************************************************************
2373 template< typename Type // Data type of the matrix
2374  , size_t M // Number of rows
2375  , size_t N // Number of columns
2376  , bool SO > // Storage order
2377 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr, const std::nothrow_t& )
2378 {
2379  deallocate( static_cast<StaticMatrix*>( ptr ) );
2380 }
2381 //*************************************************************************************************
2382 
2383 
2384 //*************************************************************************************************
2390 template< typename Type // Data type of the matrix
2391  , size_t M // Number of rows
2392  , size_t N // Number of columns
2393  , bool SO > // Storage order
2394 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr, const std::nothrow_t& )
2395 {
2396  deallocate( static_cast<StaticMatrix*>( ptr ) );
2397 }
2398 //*************************************************************************************************
2399 
2400 
2401 
2402 
2403 //=================================================================================================
2404 //
2405 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2406 //
2407 //=================================================================================================
2408 
2409 //*************************************************************************************************
2419 template< typename Type // Data type of the matrix
2420  , size_t M // Number of rows
2421  , size_t N // Number of columns
2422  , bool SO > // Storage order
2423 template< typename Other > // Data type of the foreign expression
2424 inline bool StaticMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
2425 {
2426  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2427 }
2428 //*************************************************************************************************
2429 
2430 
2431 //*************************************************************************************************
2441 template< typename Type // Data type of the matrix
2442  , size_t M // Number of rows
2443  , size_t N // Number of columns
2444  , bool SO > // Storage order
2445 template< typename Other > // Data type of the foreign expression
2446 inline bool StaticMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
2447 {
2448  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2449 }
2450 //*************************************************************************************************
2451 
2452 
2453 //*************************************************************************************************
2462 template< typename Type // Data type of the matrix
2463  , size_t M // Number of rows
2464  , size_t N // Number of columns
2465  , bool SO > // Storage order
2467 {
2468  return true;
2469 }
2470 //*************************************************************************************************
2471 
2472 
2473 //*************************************************************************************************
2488 template< typename Type // Data type of the matrix
2489  , size_t M // Number of rows
2490  , size_t N // Number of columns
2491  , bool SO > // Storage order
2493  StaticMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2494 {
2495  using blaze::load;
2496 
2498 
2499  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2500  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2501  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2502  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2503 
2504  return load( &v_[i*NN+j] );
2505 }
2506 //*************************************************************************************************
2507 
2508 
2509 //*************************************************************************************************
2524 template< typename Type // Data type of the matrix
2525  , size_t M // Number of rows
2526  , size_t N // Number of columns
2527  , bool SO > // Storage order
2529  StaticMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2530 {
2531  using blaze::loadu;
2532 
2534 
2535  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2536  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2537  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2538 
2539  return loadu( &v_[i*NN+j] );
2540 }
2541 //*************************************************************************************************
2542 
2543 
2544 //*************************************************************************************************
2560 template< typename Type // Data type of the matrix
2561  , size_t M // Number of rows
2562  , size_t N // Number of columns
2563  , bool SO > // Storage order
2565  StaticMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2566 {
2567  using blaze::store;
2568 
2570 
2571  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2572  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2573  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2574  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2575 
2576  store( &v_[i*NN+j], value );
2577 }
2578 //*************************************************************************************************
2579 
2580 
2581 //*************************************************************************************************
2597 template< typename Type // Data type of the matrix
2598  , size_t M // Number of rows
2599  , size_t N // Number of columns
2600  , bool SO > // Storage order
2602  StaticMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2603 {
2604  using blaze::storeu;
2605 
2607 
2608  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2609  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2610  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2611 
2612  storeu( &v_[i*NN+j], value );
2613 }
2614 //*************************************************************************************************
2615 
2616 
2617 //*************************************************************************************************
2633 template< typename Type // Data type of the matrix
2634  , size_t M // Number of rows
2635  , size_t N // Number of columns
2636  , bool SO > // Storage order
2638  StaticMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2639 {
2640  using blaze::stream;
2641 
2643 
2644  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2645  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2646  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2647  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2648 
2649  stream( &v_[i*NN+j], value );
2650 }
2651 //*************************************************************************************************
2652 
2653 
2654 //*************************************************************************************************
2665 template< typename Type // Data type of the matrix
2666  , size_t M // Number of rows
2667  , size_t N // Number of columns
2668  , bool SO > // Storage order
2669 template< typename MT // Type of the right-hand side dense matrix
2670  , bool SO2 > // Storage order of the right-hand side dense matrix
2671 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2673 {
2674  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2675 
2676  for( size_t i=0UL; i<M; ++i ) {
2677  for( size_t j=0UL; j<N; ++j ) {
2678  v_[i*NN+j] = (~rhs)(i,j);
2679  }
2680  }
2681 }
2682 //*************************************************************************************************
2683 
2684 
2685 //*************************************************************************************************
2696 template< typename Type // Data type of the matrix
2697  , size_t M // Number of rows
2698  , size_t N // Number of columns
2699  , bool SO > // Storage order
2700 template< typename MT // Type of the right-hand side dense matrix
2701  , bool SO2 > // Storage order of the right-hand side dense matrix
2702 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2704 {
2705  using blaze::store;
2706 
2708 
2709  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2710 
2711  for( size_t i=0UL; i<M; ++i ) {
2712  for( size_t j=0UL; j<N; j+=IT::size ) {
2713  store( &v_[i*NN+j], (~rhs).load(i,j) );
2714  }
2715  }
2716 }
2717 //*************************************************************************************************
2718 
2719 
2720 //*************************************************************************************************
2731 template< typename Type // Data type of the matrix
2732  , size_t M // Number of rows
2733  , size_t N // Number of columns
2734  , bool SO > // Storage order
2735 template< typename MT > // Type of the right-hand side sparse matrix
2737 {
2738  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2739 
2740  typedef typename MT::ConstIterator RhsConstIterator;
2741 
2742  for( size_t i=0UL; i<M; ++i )
2743  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2744  v_[i*NN+element->index()] = element->value();
2745 }
2746 //*************************************************************************************************
2747 
2748 
2749 //*************************************************************************************************
2760 template< typename Type // Data type of the matrix
2761  , size_t M // Number of rows
2762  , size_t N // Number of columns
2763  , bool SO > // Storage order
2764 template< typename MT > // Type of the right-hand side sparse matrix
2766 {
2768 
2769  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2770 
2771  typedef typename MT::ConstIterator RhsConstIterator;
2772 
2773  for( size_t j=0UL; j<N; ++j )
2774  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2775  v_[element->index()*NN+j] = element->value();
2776 }
2777 //*************************************************************************************************
2778 
2779 
2780 //*************************************************************************************************
2791 template< typename Type // Data type of the matrix
2792  , size_t M // Number of rows
2793  , size_t N // Number of columns
2794  , bool SO > // Storage order
2795 template< typename MT // Type of the right-hand side dense matrix
2796  , bool SO2 > // Storage order of the right-hand side dense matrix
2797 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2799 {
2800  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2801 
2802  for( size_t i=0UL; i<M; ++i )
2803  {
2804  if( IsDiagonal<MT>::value )
2805  {
2806  v_[i*NN+i] += (~rhs)(i,i);
2807  }
2808  else
2809  {
2810  const size_t jbegin( ( IsUpper<MT>::value )
2811  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2812  :( 0UL ) );
2813  const size_t jend ( ( IsLower<MT>::value )
2814  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2815  :( N ) );
2816  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2817 
2818  for( size_t j=jbegin; j<jend; ++j ) {
2819  v_[i*NN+j] += (~rhs)(i,j);
2820  }
2821  }
2822  }
2823 }
2824 //*************************************************************************************************
2825 
2826 
2827 //*************************************************************************************************
2838 template< typename Type // Data type of the matrix
2839  , size_t M // Number of rows
2840  , size_t N // Number of columns
2841  , bool SO > // Storage order
2842 template< typename MT // Type of the right-hand side dense matrix
2843  , bool SO2 > // Storage order of the right-hand side dense matrix
2844 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2846 {
2847  using blaze::load;
2848  using blaze::store;
2849 
2852 
2853  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2854 
2855  for( size_t i=0UL; i<M; ++i )
2856  {
2857  const size_t jbegin( ( IsUpper<MT>::value )
2858  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
2859  :( 0UL ) );
2860  const size_t jend ( ( IsLower<MT>::value )
2861  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2862  :( N ) );
2863  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2864 
2865  for( size_t j=jbegin; j<jend; j+=IT::size ) {
2866  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2867  }
2868  }
2869 }
2870 //*************************************************************************************************
2871 
2872 
2873 //*************************************************************************************************
2884 template< typename Type // Data type of the matrix
2885  , size_t M // Number of rows
2886  , size_t N // Number of columns
2887  , bool SO > // Storage order
2888 template< typename MT > // Type of the right-hand side sparse matrix
2890 {
2891  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2892 
2893  typedef typename MT::ConstIterator RhsConstIterator;
2894 
2895  for( size_t i=0UL; i<M; ++i )
2896  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2897  v_[i*NN+element->index()] += element->value();
2898 }
2899 //*************************************************************************************************
2900 
2901 
2902 //*************************************************************************************************
2913 template< typename Type // Data type of the matrix
2914  , size_t M // Number of rows
2915  , size_t N // Number of columns
2916  , bool SO > // Storage order
2917 template< typename MT > // Type of the right-hand side sparse matrix
2919 {
2921 
2922  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2923 
2924  typedef typename MT::ConstIterator RhsConstIterator;
2925 
2926  for( size_t j=0UL; j<N; ++j )
2927  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2928  v_[element->index()*NN+j] += element->value();
2929 }
2930 //*************************************************************************************************
2931 
2932 
2933 //*************************************************************************************************
2944 template< typename Type // Data type of the matrix
2945  , size_t M // Number of rows
2946  , size_t N // Number of columns
2947  , bool SO > // Storage order
2948 template< typename MT // Type of the right-hand side dense matrix
2949  , bool SO2 > // Storage order of the right-hand side dense matrix
2950 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2952 {
2953  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2954 
2955  for( size_t i=0UL; i<M; ++i )
2956  {
2957  if( IsDiagonal<MT>::value )
2958  {
2959  v_[i*NN+i] -= (~rhs)(i,i);
2960  }
2961  else
2962  {
2963  const size_t jbegin( ( IsUpper<MT>::value )
2964  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
2965  :( 0UL ) );
2966  const size_t jend ( ( IsLower<MT>::value )
2967  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
2968  :( N ) );
2969  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
2970 
2971  for( size_t j=jbegin; j<jend; ++j ) {
2972  v_[i*NN+j] -= (~rhs)(i,j);
2973  }
2974  }
2975  }
2976 }
2977 //*************************************************************************************************
2978 
2979 
2980 //*************************************************************************************************
2991 template< typename Type // Data type of the matrix
2992  , size_t M // Number of rows
2993  , size_t N // Number of columns
2994  , bool SO > // Storage order
2995 template< typename MT // Type of the right-hand side dense matrix
2996  , bool SO2 > // Storage order of the right-hand side dense matrix
2997 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2999 {
3000  using blaze::load;
3001  using blaze::store;
3002 
3005 
3006  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3007 
3008  for( size_t i=0UL; i<M; ++i )
3009  {
3010  const size_t jbegin( ( IsUpper<MT>::value )
3011  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
3012  :( 0UL ) );
3013  const size_t jend ( ( IsLower<MT>::value )
3014  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
3015  :( N ) );
3016  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
3017 
3018  for( size_t j=jbegin; j<jend; j+=IT::size ) {
3019  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
3020  }
3021  }
3022 }
3023 //*************************************************************************************************
3024 
3025 
3026 //*************************************************************************************************
3037 template< typename Type // Data type of the matrix
3038  , size_t M // Number of rows
3039  , size_t N // Number of columns
3040  , bool SO > // Storage order
3041 template< typename MT > // Type of the right-hand side sparse matrix
3043 {
3044  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3045 
3046  typedef typename MT::ConstIterator RhsConstIterator;
3047 
3048  for( size_t i=0UL; i<M; ++i )
3049  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3050  v_[i*NN+element->index()] -= element->value();
3051 }
3052 //*************************************************************************************************
3053 
3054 
3055 //*************************************************************************************************
3066 template< typename Type // Data type of the matrix
3067  , size_t M // Number of rows
3068  , size_t N // Number of columns
3069  , bool SO > // Storage order
3070 template< typename MT > // Type of the right-hand side sparse matrix
3072 {
3074 
3075  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3076 
3077  typedef typename MT::ConstIterator RhsConstIterator;
3078 
3079  for( size_t j=0UL; j<N; ++j )
3080  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
3081  v_[element->index()*NN+j] -= element->value();
3082 }
3083 //*************************************************************************************************
3084 
3085 
3086 
3087 
3088 
3089 
3090 
3091 
3092 //=================================================================================================
3093 //
3094 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
3095 //
3096 //=================================================================================================
3097 
3098 //*************************************************************************************************
3106 template< typename Type // Data type of the matrix
3107  , size_t M // Number of rows
3108  , size_t N > // Number of columns
3109 class StaticMatrix<Type,M,N,true> : public DenseMatrix< StaticMatrix<Type,M,N,true>, true >
3110 {
3111  private:
3112  //**Type definitions****************************************************************************
3113  typedef IntrinsicTrait<Type> IT;
3114  //**********************************************************************************************
3115 
3116  //**********************************************************************************************
3118  static const size_t MM = M + ( IT::size - ( M % IT::size ) ) % IT::size;
3119  //**********************************************************************************************
3120 
3121  public:
3122  //**Type definitions****************************************************************************
3124  typedef This ResultType;
3127  typedef Type ElementType;
3128  typedef typename IT::Type IntrinsicType;
3129  typedef const Type& ReturnType;
3130  typedef const This& CompositeType;
3131  typedef Type& Reference;
3132  typedef const Type& ConstReference;
3133  typedef Type* Pointer;
3134  typedef const Type* ConstPointer;
3135  typedef DenseIterator<Type> Iterator;
3137  //**********************************************************************************************
3138 
3139  //**Rebind struct definition********************************************************************
3142  template< typename ET > // Data type of the other matrix
3143  struct Rebind {
3145  };
3146  //**********************************************************************************************
3147 
3148  //**Compilation flags***************************************************************************
3150 
3154  enum { vectorizable = IsVectorizable<Type>::value };
3155 
3157 
3160  enum { smpAssignable = 0 };
3161  //**********************************************************************************************
3162 
3163  //**Constructors********************************************************************************
3166  explicit inline StaticMatrix();
3167  explicit inline StaticMatrix( const Type& init );
3168 
3169  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
3170  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
3171 
3172  inline StaticMatrix( const StaticMatrix& m );
3173  template< typename Other, bool SO > inline StaticMatrix( const StaticMatrix<Other,M,N,SO>& m );
3174  template< typename MT , bool SO > inline StaticMatrix( const Matrix<MT,SO>& m );
3175 
3176  inline StaticMatrix( const Type& v1, const Type& v2 );
3177  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
3178  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
3179  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
3180  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3181  const Type& v6 );
3182  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3183  const Type& v6, const Type& v7 );
3184  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3185  const Type& v6, const Type& v7, const Type& v8 );
3186  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3187  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
3188  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3189  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
3191  //**********************************************************************************************
3192 
3193  //**Destructor**********************************************************************************
3194  // No explicitly declared destructor.
3195  //**********************************************************************************************
3196 
3197  //**Data access functions***********************************************************************
3200  inline Reference operator()( size_t i, size_t j );
3201  inline ConstReference operator()( size_t i, size_t j ) const;
3202  inline Pointer data ();
3203  inline ConstPointer data () const;
3204  inline Pointer data ( size_t j );
3205  inline ConstPointer data ( size_t j ) const;
3206  inline Iterator begin ( size_t j );
3207  inline ConstIterator begin ( size_t j ) const;
3208  inline ConstIterator cbegin( size_t j ) const;
3209  inline Iterator end ( size_t j );
3210  inline ConstIterator end ( size_t j ) const;
3211  inline ConstIterator cend ( size_t j ) const;
3213  //**********************************************************************************************
3214 
3215  //**Assignment operators************************************************************************
3218  template< typename Other >
3219  inline StaticMatrix& operator=( const Other (&array)[M][N] );
3220 
3221  inline StaticMatrix& operator= ( const Type& set );
3222  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
3223  template< typename Other, bool SO > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO>& rhs );
3224  template< typename MT , bool SO > inline StaticMatrix& operator= ( const Matrix<MT,SO>& rhs );
3225  template< typename MT , bool SO > inline StaticMatrix& operator+=( const Matrix<MT,SO>& rhs );
3226  template< typename MT , bool SO > inline StaticMatrix& operator-=( const Matrix<MT,SO>& rhs );
3227  template< typename MT , bool SO > inline StaticMatrix& operator*=( const Matrix<MT,SO>& rhs );
3228 
3229  template< typename Other >
3230  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3231  operator*=( Other rhs );
3232 
3233  template< typename Other >
3234  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3235  operator/=( Other rhs );
3237  //**********************************************************************************************
3238 
3239  //**Utility functions***************************************************************************
3242  inline size_t rows() const;
3243  inline size_t columns() const;
3244  inline size_t spacing() const;
3245  inline size_t capacity() const;
3246  inline size_t capacity( size_t j ) const;
3247  inline size_t nonZeros() const;
3248  inline size_t nonZeros( size_t j ) const;
3249  inline void reset();
3250  inline void reset( size_t i );
3251  inline StaticMatrix& transpose();
3252  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
3253  inline void swap( StaticMatrix& m ) /* throw() */;
3255  //**********************************************************************************************
3256 
3257  //**Memory functions****************************************************************************
3260  static inline void* operator new ( std::size_t size );
3261  static inline void* operator new[]( std::size_t size );
3262  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
3263  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
3264 
3265  static inline void operator delete ( void* ptr );
3266  static inline void operator delete[]( void* ptr );
3267  static inline void operator delete ( void* ptr, const std::nothrow_t& );
3268  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
3270  //**********************************************************************************************
3271 
3272  private:
3273  //**********************************************************************************************
3275  template< typename MT >
3276  struct VectorizedAssign {
3277  enum { value = vectorizable && MT::vectorizable &&
3278  IsSame<Type,typename MT::ElementType>::value &&
3279  IsColumnMajorMatrix<MT>::value };
3280  };
3281  //**********************************************************************************************
3282 
3283  //**********************************************************************************************
3285  template< typename MT >
3286  struct VectorizedAddAssign {
3287  enum { value = vectorizable && MT::vectorizable &&
3288  IsSame<Type,typename MT::ElementType>::value &&
3289  IntrinsicTrait<Type>::addition &&
3290  IsColumnMajorMatrix<MT>::value &&
3291  !IsDiagonal<MT>::value };
3292  };
3293  //**********************************************************************************************
3294 
3295  //**********************************************************************************************
3297  template< typename MT >
3298  struct VectorizedSubAssign {
3299  enum { value = vectorizable && MT::vectorizable &&
3300  IsSame<Type,typename MT::ElementType>::value &&
3301  IntrinsicTrait<Type>::subtraction &&
3302  IsColumnMajorMatrix<MT>::value &&
3303  !IsDiagonal<MT>::value };
3304  };
3305  //**********************************************************************************************
3306 
3307  public:
3308  //**Expression template evaluation functions****************************************************
3311  template< typename Other > inline bool canAlias ( const Other* alias ) const;
3312  template< typename Other > inline bool isAliased( const Other* alias ) const;
3313 
3314  inline bool isAligned() const;
3315 
3316  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
3317  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
3318 
3319  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
3320  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
3321  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
3322 
3323  template< typename MT, bool SO >
3324  inline typename DisableIf< VectorizedAssign<MT> >::Type
3325  assign( const DenseMatrix<MT,SO>& rhs );
3326 
3327  template< typename MT, bool SO >
3328  inline typename EnableIf< VectorizedAssign<MT> >::Type
3329  assign( const DenseMatrix<MT,SO>& rhs );
3330 
3331  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
3332  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
3333 
3334  template< typename MT, bool SO >
3335  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
3336  addAssign( const DenseMatrix<MT,SO>& rhs );
3337 
3338  template< typename MT, bool SO >
3339  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
3340  addAssign( const DenseMatrix<MT,SO>& rhs );
3341 
3342  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
3343  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
3344 
3345  template< typename MT, bool SO >
3346  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
3347  subAssign( const DenseMatrix<MT,SO>& rhs );
3348 
3349  template< typename MT, bool SO >
3350  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
3351  subAssign( const DenseMatrix<MT,SO>& rhs );
3352 
3353  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
3354  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
3356  //**********************************************************************************************
3357 
3358  private:
3359  //**Member variables****************************************************************************
3362  AlignedArray<Type,MM*N> v_;
3363 
3366  //**********************************************************************************************
3367 
3368  //**Compile time checks*************************************************************************
3373  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
3374  BLAZE_STATIC_ASSERT( MM >= M );
3375  //**********************************************************************************************
3376 };
3378 //*************************************************************************************************
3379 
3380 
3381 
3382 
3383 //=================================================================================================
3384 //
3385 // CONSTRUCTORS
3386 //
3387 //=================================================================================================
3388 
3389 //*************************************************************************************************
3395 template< typename Type // Data type of the matrix
3396  , size_t M // Number of rows
3397  , size_t N > // Number of columns
3399  : v_() // The statically allocated matrix elements
3400 {
3401  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3402 
3403  if( IsNumeric<Type>::value ) {
3404  for( size_t i=0UL; i<MM*N; ++i )
3405  v_[i] = Type();
3406  }
3407 }
3409 //*************************************************************************************************
3410 
3411 
3412 //*************************************************************************************************
3418 template< typename Type // Data type of the matrix
3419  , size_t M // Number of rows
3420  , size_t N > // Number of columns
3421 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& init )
3422  : v_() // The statically allocated matrix elements
3423 {
3424  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3425 
3426  for( size_t j=0UL; j<N; ++j ) {
3427  for( size_t i=0UL; i<M; ++i )
3428  v_[i+j*MM] = init;
3429 
3430  for( size_t i=M; i<MM; ++i )
3431  v_[i+j*MM] = Type();
3432  }
3433 }
3435 //*************************************************************************************************
3436 
3437 
3438 //*************************************************************************************************
3465 template< typename Type // Data type of the matrix
3466  , size_t M // Number of rows
3467  , size_t N > // Number of columns
3468 template< typename Other > // Data type of the initialization array
3469 inline StaticMatrix<Type,M,N,true>::StaticMatrix( size_t m, size_t n, const Other* array )
3470  : v_() // The statically allocated matrix elements
3471 {
3472  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3473 
3474  if( m > M || n > N )
3475  throw std::invalid_argument( "Invalid setup of static matrix" );
3476 
3477  for( size_t j=0UL; j<n; ++j ) {
3478  for( size_t i=0UL; i<m; ++i )
3479  v_[i+j*MM] = array[i+j*m];
3480 
3481  if( IsNumeric<Type>::value ) {
3482  for( size_t i=m; i<MM; ++i )
3483  v_[i+j*MM] = Type();
3484  }
3485  }
3486 
3487  if( IsNumeric<Type>::value ) {
3488  for( size_t j=n; j<N; ++j ) {
3489  for( size_t i=0UL; i<M; ++i )
3490  v_[i+j*MM] = Type();
3491  }
3492  }
3493 }
3495 //*************************************************************************************************
3496 
3497 
3498 //*************************************************************************************************
3519 template< typename Type // Data type of the matrix
3520  , size_t M // Number of rows
3521  , size_t N > // Number of columns
3522 template< typename Other > // Data type of the initialization array
3523 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Other (&array)[M][N] )
3524  : v_() // The statically allocated matrix elements
3525 {
3526  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3527 
3528  for( size_t j=0UL; j<N; ++j ) {
3529  for( size_t i=0UL; i<M; ++i )
3530  v_[i+j*MM] = array[i][j];
3531 
3532  for( size_t i=M; i<MM; ++i )
3533  v_[i+j*MM] = Type();
3534  }
3535 }
3537 //*************************************************************************************************
3538 
3539 
3540 //*************************************************************************************************
3548 template< typename Type // Data type of the matrix
3549  , size_t M // Number of rows
3550  , size_t N > // Number of columns
3551 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix& m )
3552  : v_() // The statically allocated matrix elements
3553 {
3554  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3555 
3556  for( size_t i=0UL; i<MM*N; ++i )
3557  v_[i] = m.v_[i];
3558 }
3560 //*************************************************************************************************
3561 
3562 
3563 //*************************************************************************************************
3569 template< typename Type // Data type of the matrix
3570  , size_t M // Number of rows
3571  , size_t N > // Number of columns
3572 template< typename Other // Data type of the foreign matrix
3573  , bool SO > // Storage order of the foreign matrix
3574 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix<Other,M,N,SO>& m )
3575  : v_() // The statically allocated matrix elements
3576 {
3577  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3578 
3579  for( size_t j=0UL; j<N; ++j ) {
3580  for( size_t i=0UL; i<M; ++i )
3581  v_[i+j*MM] = m(i,j);
3582 
3583  for( size_t i=M; i<MM; ++i )
3584  v_[i+j*MM] = Type();
3585  }
3586 }
3588 //*************************************************************************************************
3589 
3590 
3591 //*************************************************************************************************
3602 template< typename Type // Data type of the matrix
3603  , size_t M // Number of rows
3604  , size_t N > // Number of columns
3605 template< typename MT // Type of the foreign matrix
3606  , bool SO > // Storage order of the foreign matrix
3607 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Matrix<MT,SO>& m )
3608  : v_() // The statically allocated matrix elements
3609 {
3610  using blaze::assign;
3611 
3612  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3613 
3614  if( (~m).rows() != M || (~m).columns() != N )
3615  throw std::invalid_argument( "Invalid setup of static matrix" );
3616 
3617  for( size_t j=0UL; j<N; ++j ) {
3618  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : M ); i<MM; ++i ) {
3619  v_[i+j*MM] = Type();
3620  }
3621  }
3622 
3623  assign( *this, ~m );
3624 }
3626 //*************************************************************************************************
3627 
3628 
3629 //*************************************************************************************************
3647 template< typename Type // Data type of the matrix
3648  , size_t M // Number of rows
3649  , size_t N > // Number of columns
3650 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2 )
3651  : v_() // The statically allocated matrix elements
3652 {
3653  BLAZE_STATIC_ASSERT( M*N == 2UL );
3654  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3655 
3656  // Initialization of a 2x1 matrix
3657  if( N == 1UL ) {
3658  v_[0UL] = v1;
3659  v_[1UL] = v2;
3660  }
3661 
3662  // Initialization of a 1x2 matrix
3663  else {
3664  v_[0UL] = v1;
3665  v_[ MM] = v2;
3666  }
3667 
3668  for( size_t j=0UL; j<N; ++j )
3669  for( size_t i=M; i<MM; ++i ) {
3670  v_[i+j*MM] = Type();
3671  }
3672 }
3674 //*************************************************************************************************
3675 
3676 
3677 //*************************************************************************************************
3696 template< typename Type // Data type of the matrix
3697  , size_t M // Number of rows
3698  , size_t N > // Number of columns
3699 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
3700  : v_() // The statically allocated matrix elements
3701 {
3702  BLAZE_STATIC_ASSERT( M*N == 3UL );
3703  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3704 
3705  // Initialization of a 3x1 matrix
3706  if( N == 1UL ) {
3707  v_[0UL] = v1;
3708  v_[1UL] = v2;
3709  v_[2UL] = v3;
3710  }
3711 
3712  // Initialization of a 1x3 matrix
3713  else {
3714  v_[ 0UL] = v1;
3715  v_[ MM] = v2;
3716  v_[2UL*MM] = v3;
3717  }
3718 
3719  for( size_t j=0UL; j<N; ++j )
3720  for( size_t i=M; i<MM; ++i ) {
3721  v_[i+j*MM] = Type();
3722  }
3723 }
3725 //*************************************************************************************************
3726 
3727 
3728 //*************************************************************************************************
3750 template< typename Type // Data type of the matrix
3751  , size_t M // Number of rows
3752  , size_t N > // Number of columns
3753 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3754  const Type& v4 )
3755  : v_() // The statically allocated matrix elements
3756 {
3757  BLAZE_STATIC_ASSERT( M*N == 4UL );
3758  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3759 
3760  // Initialization of a 4x1 matrix
3761  if( N == 1UL ) {
3762  v_[0UL] = v1;
3763  v_[1UL] = v2;
3764  v_[2UL] = v3;
3765  v_[3UL] = v4;
3766  }
3767 
3768  // Initialization of a 2x2 matrix
3769  else if( N == 2UL ) {
3770  v_[ 0UL] = v1;
3771  v_[ 1UL] = v2;
3772  v_[MM ] = v3;
3773  v_[MM+1UL] = v4;
3774  }
3775 
3776  // Initialization of a 1x4 matrix
3777  else {
3778  v_[ 0UL] = v1;
3779  v_[ MM] = v2;
3780  v_[2UL*MM] = v3;
3781  v_[3UL*MM] = v4;
3782  }
3783 
3784  for( size_t j=0UL; j<N; ++j )
3785  for( size_t i=M; i<MM; ++i ) {
3786  v_[i+j*MM] = Type();
3787  }
3788 }
3790 //*************************************************************************************************
3791 
3792 
3793 //*************************************************************************************************
3814 template< typename Type // Data type of the matrix
3815  , size_t M // Number of rows
3816  , size_t N > // Number of columns
3817 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3818  const Type& v4, const Type& v5 )
3819  : v_() // The statically allocated matrix elements
3820 {
3821  BLAZE_STATIC_ASSERT( M*N == 5UL );
3822  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3823 
3824  // Initialization of a 5x1 matrix
3825  if( N == 1UL ) {
3826  v_[0UL] = v1;
3827  v_[1UL] = v2;
3828  v_[2UL] = v3;
3829  v_[3UL] = v4;
3830  v_[4UL] = v5;
3831  }
3832 
3833  // Initialization of a 1x5 matrix
3834  else {
3835  v_[ 0UL] = v1;
3836  v_[ MM] = v2;
3837  v_[2UL*MM] = v3;
3838  v_[3UL*MM] = v4;
3839  v_[4UL*MM] = v5;
3840  }
3841 
3842  for( size_t j=0UL; j<N; ++j )
3843  for( size_t i=M; i<MM; ++i ) {
3844  v_[i+j*MM] = Type();
3845  }
3846 }
3848 //*************************************************************************************************
3849 
3850 
3851 //*************************************************************************************************
3876 template< typename Type // Data type of the matrix
3877  , size_t M // Number of rows
3878  , size_t N > // Number of columns
3879 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3880  const Type& v4, const Type& v5, const Type& v6 )
3881  : v_() // The statically allocated matrix elements
3882 {
3883  BLAZE_STATIC_ASSERT( M*N == 6UL );
3884  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3885 
3886  // Initialization of a 6x1 matrix
3887  if( N == 1UL ) {
3888  v_[0UL] = v1;
3889  v_[1UL] = v2;
3890  v_[2UL] = v3;
3891  v_[3UL] = v4;
3892  v_[4UL] = v5;
3893  v_[5UL] = v6;
3894  }
3895 
3896  // Initialization of a 3x2 matrix
3897  else if( N == 2UL ) {
3898  v_[ 0UL] = v1;
3899  v_[ 1UL] = v2;
3900  v_[ 2UL] = v3;
3901  v_[MM ] = v4;
3902  v_[MM+1UL] = v5;
3903  v_[MM+2UL] = v6;
3904  }
3905 
3906  // Initialization of a 2x3 matrix
3907  else if( N == 3UL ) {
3908  v_[ 0UL] = v1;
3909  v_[ 1UL] = v2;
3910  v_[ MM ] = v3;
3911  v_[ MM+1UL] = v4;
3912  v_[2UL*MM ] = v5;
3913  v_[2UL*MM+1UL] = v6;
3914  }
3915 
3916  // Initialization of a 1x6 matrix
3917  else {
3918  v_[ 0UL] = v1;
3919  v_[ MM] = v2;
3920  v_[2UL*MM] = v3;
3921  v_[3UL*MM] = v4;
3922  v_[4UL*MM] = v5;
3923  v_[5UL*MM] = v6;
3924  }
3925 
3926  for( size_t j=0UL; j<N; ++j )
3927  for( size_t i=M; i<MM; ++i ) {
3928  v_[i+j*MM] = Type();
3929  }
3930 }
3932 //*************************************************************************************************
3933 
3934 
3935 //*************************************************************************************************
3958 template< typename Type // Data type of the matrix
3959  , size_t M // Number of rows
3960  , size_t N > // Number of columns
3961 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3962  const Type& v4, const Type& v5, const Type& v6,
3963  const Type& v7 )
3964  : v_() // The statically allocated matrix elements
3965 {
3966  BLAZE_STATIC_ASSERT( M*N == 7UL );
3967  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3968 
3969  // Initialization of a 7x1 matrix
3970  if( N == 1UL ) {
3971  v_[0UL] = v1;
3972  v_[1UL] = v2;
3973  v_[2UL] = v3;
3974  v_[3UL] = v4;
3975  v_[4UL] = v5;
3976  v_[5UL] = v6;
3977  v_[6UL] = v7;
3978  }
3979 
3980  // Initialization of a 1x7 matrix
3981  else {
3982  v_[ 0UL] = v1;
3983  v_[ MM] = v2;
3984  v_[2UL*MM] = v3;
3985  v_[3UL*MM] = v4;
3986  v_[4UL*MM] = v5;
3987  v_[5UL*MM] = v6;
3988  v_[6UL*MM] = v7;
3989  }
3990 
3991  for( size_t j=0UL; j<N; ++j )
3992  for( size_t i=M; i<MM; ++i ) {
3993  v_[i+j*MM] = Type();
3994  }
3995 }
3997 //*************************************************************************************************
3998 
3999 
4000 //*************************************************************************************************
4027 template< typename Type // Data type of the matrix
4028  , size_t M // Number of rows
4029  , size_t N > // Number of columns
4030 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4031  const Type& v4, const Type& v5, const Type& v6,
4032  const Type& v7, const Type& v8 )
4033  : v_() // The statically allocated matrix elements
4034 {
4035  BLAZE_STATIC_ASSERT( M*N == 8UL );
4036  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4037 
4038  // Initialization of a 8x1 matrix
4039  if( N == 1UL ) {
4040  v_[0UL] = v1;
4041  v_[1UL] = v2;
4042  v_[2UL] = v3;
4043  v_[3UL] = v4;
4044  v_[4UL] = v5;
4045  v_[5UL] = v6;
4046  v_[6UL] = v7;
4047  v_[7UL] = v8;
4048  }
4049 
4050  // Initialization of a 4x2 matrix
4051  else if( N == 2UL ) {
4052  v_[ 0UL] = v1;
4053  v_[ 1UL] = v2;
4054  v_[ 2UL] = v3;
4055  v_[ 3UL] = v4;
4056  v_[MM ] = v5;
4057  v_[MM+1UL] = v6;
4058  v_[MM+2UL] = v7;
4059  v_[MM+3UL] = v8;
4060  }
4061 
4062  // Initialization of a 2x4 matrix
4063  else if( N == 4UL ) {
4064  v_[ 0UL] = v1;
4065  v_[ 1UL] = v2;
4066  v_[ MM ] = v3;
4067  v_[ MM+1UL] = v4;
4068  v_[2UL*MM ] = v5;
4069  v_[2UL*MM+1UL] = v6;
4070  v_[3UL*MM ] = v7;
4071  v_[3UL*MM+1UL] = v8;
4072  }
4073 
4074  // Initialization of a 1x8 matrix
4075  else {
4076  v_[ 0UL] = v1;
4077  v_[ MM] = v2;
4078  v_[2UL*MM] = v3;
4079  v_[3UL*MM] = v4;
4080  v_[4UL*MM] = v5;
4081  v_[5UL*MM] = v6;
4082  v_[6UL*MM] = v7;
4083  v_[7UL*MM] = v8;
4084  }
4085 
4086  for( size_t j=0UL; j<N; ++j )
4087  for( size_t i=M; i<MM; ++i ) {
4088  v_[i+j*MM] = Type();
4089  }
4090 }
4092 //*************************************************************************************************
4093 
4094 
4095 //*************************************************************************************************
4123 template< typename Type // Data type of the matrix
4124  , size_t M // Number of rows
4125  , size_t N > // Number of columns
4126 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4127  const Type& v4, const Type& v5, const Type& v6,
4128  const Type& v7, const Type& v8, const Type& v9 )
4129  : v_() // The statically allocated matrix elements
4130 {
4131  BLAZE_STATIC_ASSERT( M*N == 9UL );
4132  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4133 
4134  // Initialization of a 9x1 matrix
4135  if( N == 1 ) {
4136  v_[0UL] = v1;
4137  v_[1UL] = v2;
4138  v_[2UL] = v3;
4139  v_[3UL] = v4;
4140  v_[4UL] = v5;
4141  v_[5UL] = v6;
4142  v_[6UL] = v7;
4143  v_[7UL] = v8;
4144  v_[8UL] = v9;
4145  }
4146 
4147  // Initialization of a 3x3 matrix
4148  else if( N == 3UL ) {
4149  v_[ 0UL] = v1;
4150  v_[ 1UL] = v2;
4151  v_[ 2UL] = v3;
4152  v_[ MM ] = v4;
4153  v_[ MM+1UL] = v5;
4154  v_[ MM+2UL] = v6;
4155  v_[2UL*MM ] = v7;
4156  v_[2UL*MM+1UL] = v8;
4157  v_[2UL*MM+2UL] = v9;
4158  }
4159 
4160  // Initialization of a 1x9 matrix
4161  else {
4162  v_[ 0UL] = v1;
4163  v_[ MM] = v2;
4164  v_[2UL*MM] = v3;
4165  v_[3UL*MM] = v4;
4166  v_[4UL*MM] = v5;
4167  v_[5UL*MM] = v6;
4168  v_[6UL*MM] = v7;
4169  v_[7UL*MM] = v8;
4170  v_[8UL*MM] = v9;
4171  }
4172 
4173  for( size_t j=0UL; j<N; ++j )
4174  for( size_t i=M; i<MM; ++i ) {
4175  v_[i+j*MM] = Type();
4176  }
4177 }
4179 //*************************************************************************************************
4180 
4181 
4182 //*************************************************************************************************
4211 template< typename Type // Data type of the matrix
4212  , size_t M // Number of rows
4213  , size_t N > // Number of columns
4214 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4215  const Type& v4, const Type& v5, const Type& v6,
4216  const Type& v7, const Type& v8, const Type& v9,
4217  const Type& v10 )
4218  : v_() // The statically allocated matrix elements
4219 {
4220  BLAZE_STATIC_ASSERT( M*N == 10UL );
4221  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4222 
4223  // Initialization of a 10x1 matrix
4224  if( N == 1UL ) {
4225  v_[0UL] = v1;
4226  v_[1UL] = v2;
4227  v_[2UL] = v3;
4228  v_[3UL] = v4;
4229  v_[4UL] = v5;
4230  v_[5UL] = v6;
4231  v_[6UL] = v7;
4232  v_[7UL] = v8;
4233  v_[8UL] = v9;
4234  v_[9UL] = v10;
4235  }
4236 
4237  // Initialization of a 5x2 matrix
4238  else if( N == 2UL ) {
4239  v_[ 0UL] = v1;
4240  v_[ 1UL] = v2;
4241  v_[ 2UL] = v3;
4242  v_[ 3UL] = v4;
4243  v_[ 4UL] = v5;
4244  v_[MM ] = v6;
4245  v_[MM+1UL] = v7;
4246  v_[MM+2UL] = v8;
4247  v_[MM+3UL] = v9;
4248  v_[MM+4UL] = v10;
4249  }
4250 
4251  // Initialization of a 2x5 matrix
4252  else if( N == 5UL ) {
4253  v_[ 0UL] = v1;
4254  v_[ 1UL] = v2;
4255  v_[ MM ] = v3;
4256  v_[ MM+1UL] = v4;
4257  v_[2UL*MM ] = v5;
4258  v_[2UL*MM+1UL] = v6;
4259  v_[3UL*MM ] = v7;
4260  v_[3UL*MM+1UL] = v8;
4261  v_[4UL*MM ] = v9;
4262  v_[4UL*MM+1UL] = v10;
4263  }
4264 
4265  // Initialization of a 1x10 matrix
4266  else {
4267  v_[ 0UL] = v1;
4268  v_[ MM] = v2;
4269  v_[2UL*MM] = v3;
4270  v_[3UL*MM] = v4;
4271  v_[4UL*MM] = v5;
4272  v_[5UL*MM] = v6;
4273  v_[6UL*MM] = v7;
4274  v_[7UL*MM] = v8;
4275  v_[8UL*MM] = v9;
4276  v_[9UL*MM] = v10;
4277  }
4278 
4279  for( size_t j=0UL; j<N; ++j )
4280  for( size_t i=M; i<MM; ++i ) {
4281  v_[i+j*MM] = Type();
4282  }
4283 }
4285 //*************************************************************************************************
4286 
4287 
4288 
4289 
4290 //=================================================================================================
4291 //
4292 // DATA ACCESS FUNCTIONS
4293 //
4294 //=================================================================================================
4295 
4296 //*************************************************************************************************
4304 template< typename Type // Data type of the matrix
4305  , size_t M // Number of rows
4306  , size_t N > // Number of columns
4308  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
4309 {
4310  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4311  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4312  return v_[i+j*MM];
4313 }
4315 //*************************************************************************************************
4316 
4317 
4318 //*************************************************************************************************
4326 template< typename Type // Data type of the matrix
4327  , size_t M // Number of rows
4328  , size_t N > // Number of columns
4330  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
4331 {
4332  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4333  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4334  return v_[i+j*MM];
4335 }
4337 //*************************************************************************************************
4338 
4339 
4340 //*************************************************************************************************
4352 template< typename Type // Data type of the matrix
4353  , size_t M // Number of rows
4354  , size_t N > // Number of columns
4355 inline typename StaticMatrix<Type,M,N,true>::Pointer
4357 {
4358  return v_;
4359 }
4361 //*************************************************************************************************
4362 
4363 
4364 //*************************************************************************************************
4376 template< typename Type // Data type of the matrix
4377  , size_t M // Number of rows
4378  , size_t N > // Number of columns
4379 inline typename StaticMatrix<Type,M,N,true>::ConstPointer
4381 {
4382  return v_;
4383 }
4385 //*************************************************************************************************
4386 
4387 
4388 //*************************************************************************************************
4397 template< typename Type // Data type of the matrix
4398  , size_t M // Number of rows
4399  , size_t N > // Number of columns
4400 inline typename StaticMatrix<Type,M,N,true>::Pointer
4402 {
4403  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4404  return v_ + j*MM;
4405 }
4407 //*************************************************************************************************
4408 
4409 
4410 //*************************************************************************************************
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 typename StaticMatrix<Type,M,N,true>::ConstPointer
4423  StaticMatrix<Type,M,N,true>::data( size_t j ) const
4424 {
4425  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4426  return v_ + j*MM;
4427 }
4429 //*************************************************************************************************
4430 
4431 
4432 //*************************************************************************************************
4439 template< typename Type // Data type of the matrix
4440  , size_t M // Number of rows
4441  , size_t N > // Number of columns
4444 {
4445  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4446  return Iterator( v_ + j*MM );
4447 }
4449 //*************************************************************************************************
4450 
4451 
4452 //*************************************************************************************************
4459 template< typename Type // Data type of the matrix
4460  , size_t M // Number of rows
4461  , size_t N > // Number of columns
4463  StaticMatrix<Type,M,N,true>::begin( size_t j ) const
4464 {
4465  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4466  return ConstIterator( v_ + j*MM );
4467 }
4469 //*************************************************************************************************
4470 
4471 
4472 //*************************************************************************************************
4479 template< typename Type // Data type of the matrix
4480  , size_t M // Number of rows
4481  , size_t N > // Number of columns
4483  StaticMatrix<Type,M,N,true>::cbegin( size_t j ) const
4484 {
4485  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4486  return ConstIterator( v_ + j*MM );
4487 }
4489 //*************************************************************************************************
4490 
4491 
4492 //*************************************************************************************************
4499 template< typename Type // Data type of the matrix
4500  , size_t M // Number of rows
4501  , size_t N > // Number of columns
4504 {
4505  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4506  return Iterator( v_ + j*MM + M );
4507 }
4509 //*************************************************************************************************
4510 
4511 
4512 //*************************************************************************************************
4519 template< typename Type // Data type of the matrix
4520  , size_t M // Number of rows
4521  , size_t N > // Number of columns
4523  StaticMatrix<Type,M,N,true>::end( size_t j ) const
4524 {
4525  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4526  return ConstIterator( v_ + j*MM + M );
4527 }
4529 //*************************************************************************************************
4530 
4531 
4532 //*************************************************************************************************
4539 template< typename Type // Data type of the matrix
4540  , size_t M // Number of rows
4541  , size_t N > // Number of columns
4543  StaticMatrix<Type,M,N,true>::cend( size_t j ) const
4544 {
4545  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4546  return ConstIterator( v_ + j*MM + M );
4547 }
4549 //*************************************************************************************************
4550 
4551 
4552 
4553 
4554 //=================================================================================================
4555 //
4556 // ASSIGNMENT OPERATORS
4557 //
4558 //=================================================================================================
4559 
4560 //*************************************************************************************************
4582 template< typename Type // Data type of the matrix
4583  , size_t M // Number of rows
4584  , size_t N > // Number of columns
4585 template< typename Other > // Data type of the initialization array
4586 inline StaticMatrix<Type,M,N,true>&
4587  StaticMatrix<Type,M,N,true>::operator=( const Other (&array)[M][N] )
4588 {
4589  for( size_t j=0UL; j<N; ++j )
4590  for( size_t i=0UL; i<M; ++i )
4591  v_[i+j*MM] = array[i][j];
4592 
4593  return *this;
4594 }
4596 //*************************************************************************************************
4597 
4598 
4599 //*************************************************************************************************
4606 template< typename Type // Data type of the matrix
4607  , size_t M // Number of rows
4608  , size_t N > // Number of columns
4609 inline StaticMatrix<Type,M,N,true>&
4610  StaticMatrix<Type,M,N,true>::operator=( const Type& set )
4611 {
4612  for( size_t j=0UL; j<N; ++j )
4613  for( size_t i=0UL; i<M; ++i )
4614  v_[i+j*MM] = set;
4615 
4616  return *this;
4617 }
4619 //*************************************************************************************************
4620 
4621 
4622 //*************************************************************************************************
4631 template< typename Type // Data type of the matrix
4632  , size_t M // Number of rows
4633  , size_t N > // Number of columns
4634 inline StaticMatrix<Type,M,N,true>&
4635  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix& rhs )
4636 {
4637  using blaze::assign;
4638 
4639  assign( *this, ~rhs );
4640  return *this;
4641 }
4643 //*************************************************************************************************
4644 
4645 
4646 //*************************************************************************************************
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 Other // Data type of the foreign matrix
4657  , bool SO > // Storage order of the foreign matrix
4658 inline StaticMatrix<Type,M,N,true>&
4659  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix<Other,M,N,SO>& rhs )
4660 {
4661  using blaze::assign;
4662 
4663  assign( *this, ~rhs );
4664  return *this;
4665 }
4667 //*************************************************************************************************
4668 
4669 
4670 //*************************************************************************************************
4682 template< typename Type // Data type of the matrix
4683  , size_t M // Number of rows
4684  , size_t N > // Number of columns
4685 template< typename MT // Type of the right-hand side matrix
4686  , bool SO > // Storage order of the right-hand side matrix
4687 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
4688 {
4689  using blaze::assign;
4690 
4691  if( (~rhs).rows() != M || (~rhs).columns() != N )
4692  throw std::invalid_argument( "Invalid assignment to static matrix" );
4693 
4694  if( (~rhs).canAlias( this ) ) {
4695  StaticMatrix tmp( ~rhs );
4696  swap( tmp );
4697  }
4698  else {
4699  if( IsSparseMatrix<MT>::value )
4700  reset();
4701  assign( *this, ~rhs );
4702  }
4703 
4704  return *this;
4705 }
4707 //*************************************************************************************************
4708 
4709 
4710 //*************************************************************************************************
4721 template< typename Type // Data type of the matrix
4722  , size_t M // Number of rows
4723  , size_t N > // Number of columns
4724 template< typename MT // Type of the right-hand side matrix
4725  , bool SO > // Storage order of the right-hand side matrix
4726 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
4727 {
4728  using blaze::addAssign;
4729 
4730  if( (~rhs).rows() != M || (~rhs).columns() != N )
4731  throw std::invalid_argument( "Matrix sizes do not match" );
4732 
4733  if( (~rhs).canAlias( this ) ) {
4734  typename MT::ResultType tmp( ~rhs );
4735  addAssign( *this, tmp );
4736  }
4737  else {
4738  addAssign( *this, ~rhs );
4739  }
4740 
4741  return *this;
4742 }
4744 //*************************************************************************************************
4745 
4746 
4747 //*************************************************************************************************
4758 template< typename Type // Data type of the matrix
4759  , size_t M // Number of rows
4760  , size_t N > // Number of columns
4761 template< typename MT // Type of the right-hand side matrix
4762  , bool SO > // Storage order of the right-hand side matrix
4763 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
4764 {
4765  using blaze::subAssign;
4766 
4767  if( (~rhs).rows() != M || (~rhs).columns() != N )
4768  throw std::invalid_argument( "Matrix sizes do not match" );
4769 
4770  if( (~rhs).canAlias( this ) ) {
4771  typename MT::ResultType tmp( ~rhs );
4772  subAssign( *this, tmp );
4773  }
4774  else {
4775  subAssign( *this, ~rhs );
4776  }
4777 
4778  return *this;
4779 }
4781 //*************************************************************************************************
4782 
4783 
4784 //*************************************************************************************************
4795 template< typename Type // Data type of the matrix
4796  , size_t M // Number of rows
4797  , size_t N > // Number of columns
4798 template< typename MT // Type of the right-hand side matrix
4799  , bool SO > // Storage order of the right-hand side matrix
4800 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
4801 {
4802  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
4803  throw std::invalid_argument( "Matrix sizes do not match" );
4804 
4805  StaticMatrix tmp( *this * (~rhs) );
4806  return this->operator=( tmp );
4807 }
4809 //*************************************************************************************************
4810 
4811 
4812 //*************************************************************************************************
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 Other > // Data type of the right-hand side scalar
4824 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4825  StaticMatrix<Type,M,N,true>::operator*=( Other rhs )
4826 {
4827  using blaze::assign;
4828 
4829  assign( *this, (*this) * rhs );
4830  return *this;
4831 }
4833 //*************************************************************************************************
4834 
4835 
4836 //*************************************************************************************************
4846 template< typename Type // Data type of the matrix
4847  , size_t M // Number of rows
4848  , size_t N > // Number of columns
4849 template< typename Other > // Data type of the right-hand side scalar
4850 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4851  StaticMatrix<Type,M,N,true>::operator/=( Other rhs )
4852 {
4853  using blaze::assign;
4854 
4855  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4856 
4857  assign( *this, (*this) / rhs );
4858  return *this;
4859 }
4861 //*************************************************************************************************
4862 
4863 
4864 
4865 
4866 //=================================================================================================
4867 //
4868 // UTILITY FUNCTIONS
4869 //
4870 //=================================================================================================
4871 
4872 //*************************************************************************************************
4878 template< typename Type // Data type of the matrix
4879  , size_t M // Number of rows
4880  , size_t N > // Number of columns
4881 inline size_t StaticMatrix<Type,M,N,true>::rows() const
4882 {
4883  return M;
4884 }
4886 //*************************************************************************************************
4887 
4888 
4889 //*************************************************************************************************
4895 template< typename Type // Data type of the matrix
4896  , size_t M // Number of rows
4897  , size_t N > // Number of columns
4898 inline size_t StaticMatrix<Type,M,N,true>::columns() const
4899 {
4900  return N;
4901 }
4903 //*************************************************************************************************
4904 
4905 
4906 //*************************************************************************************************
4915 template< typename Type // Data type of the matrix
4916  , size_t M // Number of rows
4917  , size_t N > // Number of columns
4918 inline size_t StaticMatrix<Type,M,N,true>::spacing() const
4919 {
4920  return MM;
4921 }
4923 //*************************************************************************************************
4924 
4925 
4926 //*************************************************************************************************
4932 template< typename Type // Data type of the matrix
4933  , size_t M // Number of rows
4934  , size_t N > // Number of columns
4935 inline size_t StaticMatrix<Type,M,N,true>::capacity() const
4936 {
4937  return MM*N;
4938 }
4940 //*************************************************************************************************
4941 
4942 
4943 //*************************************************************************************************
4950 template< typename Type // Data type of the matrix
4951  , size_t M // Number of rows
4952  , size_t N > // Number of columns
4953 inline size_t StaticMatrix<Type,M,N,true>::capacity( size_t j ) const
4954 {
4955  UNUSED_PARAMETER( j );
4956 
4957  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4958 
4959  return MM;
4960 }
4962 //*************************************************************************************************
4963 
4964 
4965 //*************************************************************************************************
4971 template< typename Type // Data type of the matrix
4972  , size_t M // Number of rows
4973  , size_t N > // Number of columns
4974 inline size_t StaticMatrix<Type,M,N,true>::nonZeros() const
4975 {
4976  size_t nonzeros( 0UL );
4977 
4978  for( size_t j=0UL; j<N; ++j )
4979  for( size_t i=0UL; i<M; ++i )
4980  if( !isDefault( v_[i+j*MM] ) )
4981  ++nonzeros;
4982 
4983  return nonzeros;
4984 }
4986 //*************************************************************************************************
4987 
4988 
4989 //*************************************************************************************************
4996 template< typename Type // Data type of the matrix
4997  , size_t M // Number of rows
4998  , size_t N > // Number of columns
4999 inline size_t StaticMatrix<Type,M,N,true>::nonZeros( size_t j ) const
5000 {
5001  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5002 
5003  const size_t iend( (j+1UL)*MM );
5004  size_t nonzeros( 0UL );
5005 
5006  for( size_t i=j*MM; i<iend; ++i )
5007  if( !isDefault( v_[i] ) )
5008  ++nonzeros;
5009 
5010  return nonzeros;
5011 }
5013 //*************************************************************************************************
5014 
5015 
5016 //*************************************************************************************************
5022 template< typename Type // Data type of the matrix
5023  , size_t M // Number of rows
5024  , size_t N > // Number of columns
5026 {
5027  using blaze::clear;
5028 
5029  for( size_t j=0UL; j<N; ++j )
5030  for( size_t i=0UL; i<M; ++i )
5031  clear( v_[i+j*MM] );
5032 }
5034 //*************************************************************************************************
5035 
5036 
5037 //*************************************************************************************************
5047 template< typename Type // Data type of the matrix
5048  , size_t M // Number of rows
5049  , size_t N > // Number of columns
5050 inline void StaticMatrix<Type,M,N,true>::reset( size_t j )
5051 {
5052  using blaze::clear;
5053 
5054  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5055  for( size_t i=0UL; i<M; ++i )
5056  clear( v_[i+j*MM] );
5057 }
5059 //*************************************************************************************************
5060 
5061 
5062 //*************************************************************************************************
5071 template< typename Type // Data type of the matrix
5072  , size_t M // Number of rows
5073  , size_t N > // Number of columns
5074 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::transpose()
5075 {
5076  using std::swap;
5077 
5078  BLAZE_STATIC_ASSERT( M == N );
5079 
5080  for( size_t j=1UL; j<N; ++j )
5081  for( size_t i=0UL; i<j; ++i )
5082  swap( v_[i+j*MM], v_[j+i*MM] );
5083 
5084  return *this;
5085 }
5087 //*************************************************************************************************
5088 
5089 
5090 //*************************************************************************************************
5097 template< typename Type // Data type of the matrix
5098  , size_t M // Number of rows
5099  , size_t N > // Number of columns
5100 template< typename Other > // Data type of the scalar value
5101 inline StaticMatrix<Type,M,N,true>&
5102  StaticMatrix<Type,M,N,true>::scale( const Other& scalar )
5103 {
5104  for( size_t j=0UL; j<N; ++j )
5105  for( size_t i=0UL; i<M; ++i )
5106  v_[i+j*MM] *= scalar;
5107 
5108  return *this;
5109 }
5111 //*************************************************************************************************
5112 
5113 
5114 //*************************************************************************************************
5122 template< typename Type // Data type of the matrix
5123  , size_t M // Number of rows
5124  , size_t N > // Number of columns
5125 inline void StaticMatrix<Type,M,N,true>::swap( StaticMatrix& m ) /* throw() */
5126 {
5127  using std::swap;
5128 
5129  for( size_t j=0UL; j<N; ++j ) {
5130  for( size_t i=0UL; i<M; ++i ) {
5131  swap( v_[i+j*MM], m(i,j) );
5132  }
5133  }
5134 }
5136 //*************************************************************************************************
5137 
5138 
5139 
5140 
5141 //=================================================================================================
5142 //
5143 // MEMORY FUNCTIONS
5144 //
5145 //=================================================================================================
5146 
5147 //*************************************************************************************************
5158 template< typename Type // Data type of the matrix
5159  , size_t M // Number of rows
5160  , size_t N > // Number of columns
5161 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size )
5162 {
5163  UNUSED_PARAMETER( size );
5164 
5165  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5166 
5167  return allocate<StaticMatrix>( 1UL );
5168 }
5170 //*************************************************************************************************
5171 
5172 
5173 //*************************************************************************************************
5184 template< typename Type // Data type of the matrix
5185  , size_t M // Number of rows
5186  , size_t N > // Number of columns
5187 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size )
5188 {
5189  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5190  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5191 
5192  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5193 }
5195 //*************************************************************************************************
5196 
5197 
5198 //*************************************************************************************************
5209 template< typename Type // Data type of the matrix
5210  , size_t M // Number of rows
5211  , size_t N > // Number of columns
5212 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size, const std::nothrow_t& )
5213 {
5214  UNUSED_PARAMETER( size );
5215 
5216  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5217 
5218  return allocate<StaticMatrix>( 1UL );
5219 }
5221 //*************************************************************************************************
5222 
5223 
5224 //*************************************************************************************************
5235 template< typename Type // Data type of the matrix
5236  , size_t M // Number of rows
5237  , size_t N > // Number of columns
5238 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size, const std::nothrow_t& )
5239 {
5240  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5241  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5242 
5243  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5244 }
5246 //*************************************************************************************************
5247 
5248 
5249 //*************************************************************************************************
5256 template< typename Type // Data type of the matrix
5257  , size_t M // Number of rows
5258  , size_t N > // Number of columns
5259 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr )
5260 {
5261  deallocate( static_cast<StaticMatrix*>( ptr ) );
5262 }
5264 //*************************************************************************************************
5265 
5266 
5267 //*************************************************************************************************
5274 template< typename Type // Data type of the matrix
5275  , size_t M // Number of rows
5276  , size_t N > // Number of columns
5277 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr )
5278 {
5279  deallocate( static_cast<StaticMatrix*>( ptr ) );
5280 }
5282 //*************************************************************************************************
5283 
5284 
5285 //*************************************************************************************************
5292 template< typename Type // Data type of the matrix
5293  , size_t M // Number of rows
5294  , size_t N > // Number of columns
5295 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr, const std::nothrow_t& )
5296 {
5297  deallocate( static_cast<StaticMatrix*>( ptr ) );
5298 }
5300 //*************************************************************************************************
5301 
5302 
5303 //*************************************************************************************************
5310 template< typename Type // Data type of the matrix
5311  , size_t M // Number of rows
5312  , size_t N > // Number of columns
5313 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr, const std::nothrow_t& )
5314 {
5315  deallocate( static_cast<StaticMatrix*>( ptr ) );
5316 }
5318 //*************************************************************************************************
5319 
5320 
5321 
5322 
5323 //=================================================================================================
5324 //
5325 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5326 //
5327 //=================================================================================================
5328 
5329 //*************************************************************************************************
5340 template< typename Type // Data type of the matrix
5341  , size_t M // Number of rows
5342  , size_t N > // Number of columns
5343 template< typename Other > // Data type of the foreign expression
5344 inline bool StaticMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
5345 {
5346  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5347 }
5349 //*************************************************************************************************
5350 
5351 
5352 //*************************************************************************************************
5363 template< typename Type // Data type of the matrix
5364  , size_t M // Number of rows
5365  , size_t N > // Number of columns
5366 template< typename Other > // Data type of the foreign expression
5367 inline bool StaticMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
5368 {
5369  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5370 }
5372 //*************************************************************************************************
5373 
5374 
5375 //*************************************************************************************************
5385 template< typename Type // Data type of the matrix
5386  , size_t M // Number of rows
5387  , size_t N > // Number of columns
5388 inline bool StaticMatrix<Type,M,N,true>::isAligned() const
5389 {
5390  return true;
5391 }
5393 //*************************************************************************************************
5394 
5395 
5396 //*************************************************************************************************
5411 template< typename Type // Data type of the matrix
5412  , size_t M // Number of rows
5413  , size_t N > // Number of columns
5414 BLAZE_ALWAYS_INLINE typename StaticMatrix<Type,M,N,true>::IntrinsicType
5415  StaticMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
5416 {
5417  using blaze::load;
5418 
5420 
5421  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5422  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5423  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5424  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5425 
5426  return load( &v_[i+j*MM] );
5427 }
5429 //*************************************************************************************************
5430 
5431 
5432 //*************************************************************************************************
5447 template< typename Type // Data type of the matrix
5448  , size_t M // Number of rows
5449  , size_t N > // Number of columns
5450 BLAZE_ALWAYS_INLINE typename StaticMatrix<Type,M,N,true>::IntrinsicType
5451  StaticMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
5452 {
5453  using blaze::loadu;
5454 
5456 
5457  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5458  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5459  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5460 
5461  return loadu( &v_[i+j*MM] );
5462 }
5464 //*************************************************************************************************
5465 
5466 
5467 //*************************************************************************************************
5483 template< typename Type // Data type of the matrix
5484  , size_t M // Number of rows
5485  , size_t N > // Number of columns
5487  StaticMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
5488 {
5489  using blaze::store;
5490 
5492 
5493  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5494  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5495  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5496  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5497 
5498  store( &v_[i+j*MM], value );
5499 }
5501 //*************************************************************************************************
5502 
5503 
5504 //*************************************************************************************************
5520 template< typename Type // Data type of the matrix
5521  , size_t M // Number of rows
5522  , size_t N > // Number of columns
5524  StaticMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
5525 {
5526  using blaze::storeu;
5527 
5529 
5530  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5531  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
5532  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5533 
5534  storeu( &v_[i+j*MM], value );
5535 }
5537 //*************************************************************************************************
5538 
5539 
5540 //*************************************************************************************************
5557 template< typename Type // Data type of the matrix
5558  , size_t M // Number of rows
5559  , size_t N > // Number of columns
5561  StaticMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
5562 {
5563  using blaze::stream;
5564 
5566 
5567  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5568  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5569  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5570  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5571 
5572  stream( &v_[i+j*MM], value );
5573 }
5575 //*************************************************************************************************
5576 
5577 
5578 //*************************************************************************************************
5590 template< typename Type // Data type of the matrix
5591  , size_t M // Number of rows
5592  , size_t N > // Number of columns
5593 template< typename MT // Type of the right-hand side dense matrix
5594  , bool SO > // Storage order of the right-hand side dense matrix
5595 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5596  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5597 {
5598  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5599 
5600  for( size_t j=0UL; j<N; ++j ) {
5601  for( size_t i=0UL; i<M; ++i ) {
5602  v_[i+j*MM] = (~rhs)(i,j);
5603  }
5604  }
5605 }
5607 //*************************************************************************************************
5608 
5609 
5610 //*************************************************************************************************
5622 template< typename Type // Data type of the matrix
5623  , size_t M // Number of rows
5624  , size_t N > // Number of columns
5625 template< typename MT // Type of the right-hand side dense matrix
5626  , bool SO > // Storage order of the right-hand side dense matrix
5627 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5628  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5629 {
5630  using blaze::store;
5631 
5633 
5634  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5635 
5636  for( size_t j=0UL; j<N; ++j ) {
5637  for( size_t i=0UL; i<M; i+=IT::size ) {
5638  store( &v_[i+j*MM], (~rhs).load(i,j) );
5639  }
5640  }
5641 }
5643 //*************************************************************************************************
5644 
5645 
5646 //*************************************************************************************************
5658 template< typename Type // Data type of the matrix
5659  , size_t M // Number of rows
5660  , size_t N > // Number of columns
5661 template< typename MT > // Type of the right-hand side sparse matrix
5662 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
5663 {
5664  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5665 
5666  typedef typename MT::ConstIterator RhsConstIterator;
5667 
5668  for( size_t j=0UL; j<N; ++j )
5669  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5670  v_[element->index()+j*MM] = element->value();
5671 }
5673 //*************************************************************************************************
5674 
5675 
5676 //*************************************************************************************************
5688 template< typename Type // Data type of the matrix
5689  , size_t M // Number of rows
5690  , size_t N > // Number of columns
5691 template< typename MT > // Type of the right-hand side sparse matrix
5692 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
5693 {
5695 
5696  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5697 
5698  typedef typename MT::ConstIterator RhsConstIterator;
5699 
5700  for( size_t i=0UL; i<M; ++i )
5701  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5702  v_[i+element->index()*MM] = element->value();
5703 }
5705 //*************************************************************************************************
5706 
5707 
5708 //*************************************************************************************************
5720 template< typename Type // Data type of the matrix
5721  , size_t M // Number of rows
5722  , size_t N > // Number of columns
5723 template< typename MT // Type of the right-hand side dense matrix
5724  , bool SO > // Storage order of the right-hand side dense matrix
5725 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5726  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5727 {
5728  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5729 
5730  for( size_t j=0UL; j<N; ++j )
5731  {
5732  if( IsDiagonal<MT>::value )
5733  {
5734  v_[j+j*MM] += (~rhs)(j,j);
5735  }
5736  else
5737  {
5738  const size_t ibegin( ( IsLower<MT>::value )
5739  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
5740  :( 0UL ) );
5741  const size_t iend ( ( IsUpper<MT>::value )
5742  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5743  :( M ) );
5744  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5745 
5746  for( size_t i=ibegin; i<iend; ++i ) {
5747  v_[i+j*MM] += (~rhs)(i,j);
5748  }
5749  }
5750  }
5751 }
5753 //*************************************************************************************************
5754 
5755 
5756 //*************************************************************************************************
5768 template< typename Type // Data type of the matrix
5769  , size_t M // Number of rows
5770  , size_t N > // Number of columns
5771 template< typename MT // Type of the right-hand side dense matrix
5772  , bool SO > // Storage order of the right-hand side dense matrix
5773 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5774  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5775 {
5776  using blaze::load;
5777  using blaze::store;
5778 
5781 
5782  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5783 
5784  for( size_t j=0UL; j<N; ++j )
5785  {
5786  const size_t ibegin( ( IsLower<MT>::value )
5787  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
5788  :( 0UL ) );
5789  const size_t iend ( ( IsUpper<MT>::value )
5790  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5791  :( M ) );
5792  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5793 
5794  for( size_t i=ibegin; i<iend; i+=IT::size ) {
5795  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
5796  }
5797  }
5798 }
5800 //*************************************************************************************************
5801 
5802 
5803 //*************************************************************************************************
5815 template< typename Type // Data type of the matrix
5816  , size_t M // Number of rows
5817  , size_t N > // Number of columns
5818 template< typename MT > // Type of the right-hand side sparse matrix
5819 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
5820 {
5821  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5822 
5823  typedef typename MT::ConstIterator RhsConstIterator;
5824 
5825  for( size_t j=0UL; j<N; ++j )
5826  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5827  v_[element->index()+j*MM] += element->value();
5828 }
5830 //*************************************************************************************************
5831 
5832 
5833 //*************************************************************************************************
5845 template< typename Type // Data type of the matrix
5846  , size_t M // Number of rows
5847  , size_t N > // Number of columns
5848 template< typename MT > // Type of the right-hand side sparse matrix
5849 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
5850 {
5852 
5853  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5854 
5855  typedef typename MT::ConstIterator RhsConstIterator;
5856 
5857  for( size_t i=0UL; i<M; ++i )
5858  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5859  v_[i+element->index()*MM] += element->value();
5860 }
5862 //*************************************************************************************************
5863 
5864 
5865 //*************************************************************************************************
5877 template< typename Type // Data type of the matrix
5878  , size_t M // Number of rows
5879  , size_t N > // Number of columns
5880 template< typename MT // Type of the right-hand side dense matrix
5881  , bool SO > // Storage order of the right-hand side dense matrix
5882 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5883  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5884 {
5885  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5886 
5887  for( size_t j=0UL; j<N; ++j )
5888  {
5889  if( IsDiagonal<MT>::value )
5890  {
5891  v_[j+j*MM] -= (~rhs)(j,j);
5892  }
5893  else
5894  {
5895  const size_t ibegin( ( IsLower<MT>::value )
5896  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
5897  :( 0UL ) );
5898  const size_t iend ( ( IsUpper<MT>::value )
5899  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5900  :( M ) );
5901  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5902 
5903  for( size_t i=ibegin; i<iend; ++i ) {
5904  v_[i+j*MM] -= (~rhs)(i,j);
5905  }
5906  }
5907  }
5908 }
5910 //*************************************************************************************************
5911 
5912 
5913 //*************************************************************************************************
5925 template< typename Type // Data type of the matrix
5926  , size_t M // Number of rows
5927  , size_t N > // Number of columns
5928 template< typename MT // Type of the right-hand side dense matrix
5929  , bool SO > // Storage order of the right-hand side dense matrix
5930 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5931  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5932 {
5933  using blaze::load;
5934  using blaze::store;
5935 
5938 
5939  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5940 
5941  for( size_t j=0UL; j<N; ++j )
5942  {
5943  const size_t ibegin( ( IsLower<MT>::value )
5944  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
5945  :( 0UL ) );
5946  const size_t iend ( ( IsUpper<MT>::value )
5947  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5948  :( M ) );
5949  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
5950 
5951  for( size_t i=ibegin; i<iend; i+=IT::size ) {
5952  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
5953  }
5954  }
5955 }
5957 //*************************************************************************************************
5958 
5959 
5960 //*************************************************************************************************
5972 template< typename Type // Data type of the matrix
5973  , size_t M // Number of rows
5974  , size_t N > // Number of columns
5975 template< typename MT > // Type of the right-hand side sparse matrix
5976 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
5977 {
5978  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5979 
5980  typedef typename MT::ConstIterator RhsConstIterator;
5981 
5982  for( size_t j=0UL; j<N; ++j )
5983  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5984  v_[element->index()+j*MM] -= element->value();
5985 }
5987 //*************************************************************************************************
5988 
5989 
5990 //*************************************************************************************************
6002 template< typename Type // Data type of the matrix
6003  , size_t M // Number of rows
6004  , size_t N > // Number of columns
6005 template< typename MT > // Type of the right-hand side sparse matrix
6006 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
6007 {
6009 
6010  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6011 
6012  typedef typename MT::ConstIterator RhsConstIterator;
6013 
6014  for( size_t i=0UL; i<M; ++i )
6015  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6016  v_[i+element->index()*MM] -= element->value();
6017 }
6019 //*************************************************************************************************
6020 
6021 
6022 
6023 
6024 
6025 
6026 
6027 
6028 //=================================================================================================
6029 //
6030 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
6031 //
6032 //=================================================================================================
6033 
6034 //*************************************************************************************************
6042 template< typename Type // Data type of the matrix
6043  , size_t M // Number of rows
6044  , bool SO > // Storage order
6045 class StaticMatrix<Type,M,0UL,SO>;
6047 //*************************************************************************************************
6048 
6049 
6050 //*************************************************************************************************
6058 template< typename Type // Data type of the matrix
6059  , size_t N // Number of columns
6060  , bool SO > // Storage order
6061 class StaticMatrix<Type,0UL,N,SO>;
6063 //*************************************************************************************************
6064 
6065 
6066 //*************************************************************************************************
6074 template< typename Type // Data type of the matrix
6075  , bool SO > // Storage order
6076 class StaticMatrix<Type,0UL,0UL,SO>;
6078 //*************************************************************************************************
6079 
6080 
6081 
6082 
6083 
6084 
6085 
6086 
6087 //=================================================================================================
6088 //
6089 // STATICMATRIX OPERATORS
6090 //
6091 //=================================================================================================
6092 
6093 //*************************************************************************************************
6096 template< typename Type, size_t M, size_t N, bool SO >
6097 inline void reset( StaticMatrix<Type,M,N,SO>& m );
6098 
6099 template< typename Type, size_t M, size_t N, bool SO >
6100 inline void reset( StaticMatrix<Type,M,N,SO>& m, size_t i );
6101 
6102 template< typename Type, size_t M, size_t N, bool SO >
6103 inline void clear( StaticMatrix<Type,M,N,SO>& m );
6104 
6105 template< typename Type, size_t M, size_t N, bool SO >
6106 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m );
6107 
6108 template< typename Type, size_t M, size_t N, bool SO >
6109 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */;
6110 
6111 template< typename Type, size_t M, size_t N, bool SO >
6112 inline void move( StaticMatrix<Type,M,N,SO>& dst, StaticMatrix<Type,M,N,SO>& src ) /* throw() */;
6114 //*************************************************************************************************
6115 
6116 
6117 //*************************************************************************************************
6124 template< typename Type // Data type of the matrix
6125  , size_t M // Number of rows
6126  , size_t N // Number of columns
6127  , bool SO > // Storage order
6129 {
6130  m.reset();
6131 }
6132 //*************************************************************************************************
6133 
6134 
6135 //*************************************************************************************************
6148 template< typename Type // Data type of the matrix
6149  , size_t M // Number of rows
6150  , size_t N // Number of columns
6151  , bool SO > // Storage order
6152 inline void reset( StaticMatrix<Type,M,N,SO>& m, size_t i )
6153 {
6154  m.reset( i );
6155 }
6156 //*************************************************************************************************
6157 
6158 
6159 //*************************************************************************************************
6168 template< typename Type // Data type of the matrix
6169  , size_t M // Number of rows
6170  , size_t N // Number of columns
6171  , bool SO > // Storage order
6173 {
6174  m.reset();
6175 }
6176 //*************************************************************************************************
6177 
6178 
6179 //*************************************************************************************************
6186 template< typename Type // Data type of the matrix
6187  , size_t M // Number of rows
6188  , size_t N // Number of columns
6189  , bool SO > // Storage order
6190 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m )
6191 {
6192  if( SO == rowMajor ) {
6193  for( size_t i=0UL; i<M; ++i )
6194  for( size_t j=0UL; j<N; ++j )
6195  if( !isDefault( m(i,j) ) ) return false;
6196  }
6197  else {
6198  for( size_t j=0UL; j<N; ++j )
6199  for( size_t i=0UL; i<M; ++i )
6200  if( !isDefault( m(i,j) ) ) return false;
6201  }
6202 
6203  return true;
6204 }
6205 //*************************************************************************************************
6206 
6207 
6208 //*************************************************************************************************
6217 template< typename Type // Data type of the matrix
6218  , size_t M // Number of rows
6219  , size_t N // Number of columns
6220  , bool SO > // Storage order
6221 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */
6222 {
6223  a.swap( b );
6224 }
6225 //*************************************************************************************************
6226 
6227 
6228 //*************************************************************************************************
6237 template< typename Type // Data type of the matrix
6238  , size_t M // Number of rows
6239  , size_t N // Number of columns
6240  , bool SO > // Storage order
6241 inline void move( StaticMatrix<Type,M,N,SO>& dst, StaticMatrix<Type,M,N,SO>& src ) /* throw() */
6242 {
6243  dst = src;
6244 }
6245 //*************************************************************************************************
6246 
6247 
6248 
6249 
6250 //=================================================================================================
6251 //
6252 // ROWS SPECIALIZATIONS
6253 //
6254 //=================================================================================================
6255 
6256 //*************************************************************************************************
6258 template< typename T, size_t M, size_t N, bool SO >
6259 struct Rows< StaticMatrix<T,M,N,SO> > : public SizeT<M>
6260 {};
6262 //*************************************************************************************************
6263 
6264 
6265 
6266 
6267 //=================================================================================================
6268 //
6269 // COLUMNS SPECIALIZATIONS
6270 //
6271 //=================================================================================================
6272 
6273 //*************************************************************************************************
6275 template< typename T, size_t M, size_t N, bool SO >
6276 struct Columns< StaticMatrix<T,M,N,SO> > : public SizeT<N>
6277 {};
6279 //*************************************************************************************************
6280 
6281 
6282 
6283 
6284 //=================================================================================================
6285 //
6286 // ISSQUARE SPECIALIZATIONS
6287 //
6288 //=================================================================================================
6289 
6290 //*************************************************************************************************
6292 template< typename T, size_t N, bool SO >
6293 struct IsSquare< StaticMatrix<T,N,N,SO> > : public TrueType
6294 {
6295  enum { value = 1 };
6296  typedef TrueType Type;
6297 };
6299 //*************************************************************************************************
6300 
6301 
6302 
6303 
6304 //=================================================================================================
6305 //
6306 // HASCONSTDATAACCESS SPECIALIZATIONS
6307 //
6308 //=================================================================================================
6309 
6310 //*************************************************************************************************
6312 template< typename T, size_t M, size_t N, bool SO >
6313 struct HasConstDataAccess< StaticMatrix<T,M,N,SO> > : public TrueType
6314 {
6315  enum { value = 1 };
6316  typedef TrueType Type;
6317 };
6319 //*************************************************************************************************
6320 
6321 
6322 
6323 
6324 //=================================================================================================
6325 //
6326 // HASMUTABLEDATAACCESS SPECIALIZATIONS
6327 //
6328 //=================================================================================================
6329 
6330 //*************************************************************************************************
6332 template< typename T, size_t M, size_t N, bool SO >
6333 struct HasMutableDataAccess< StaticMatrix<T,M,N,SO> > : public TrueType
6334 {
6335  enum { value = 1 };
6336  typedef TrueType Type;
6337 };
6339 //*************************************************************************************************
6340 
6341 
6342 
6343 
6344 //=================================================================================================
6345 //
6346 // ADDTRAIT SPECIALIZATIONS
6347 //
6348 //=================================================================================================
6349 
6350 //*************************************************************************************************
6352 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6353 struct AddTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6354 {
6355  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
6356 };
6357 
6358 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
6359 struct AddTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
6360 {
6361  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
6362 };
6364 //*************************************************************************************************
6365 
6366 
6367 
6368 
6369 //=================================================================================================
6370 //
6371 // SUBTRAIT SPECIALIZATIONS
6372 //
6373 //=================================================================================================
6374 
6375 //*************************************************************************************************
6377 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6378 struct SubTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6379 {
6380  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
6381 };
6382 
6383 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
6384 struct SubTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
6385 {
6386  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
6387 };
6389 //*************************************************************************************************
6390 
6391 
6392 
6393 
6394 //=================================================================================================
6395 //
6396 // MULTTRAIT SPECIALIZATIONS
6397 //
6398 //=================================================================================================
6399 
6400 //*************************************************************************************************
6402 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6403 struct MultTrait< StaticMatrix<T1,M,N,SO>, T2 >
6404 {
6405  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
6407 };
6408 
6409 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6410 struct MultTrait< T1, StaticMatrix<T2,M,N,SO> >
6411 {
6412  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
6414 };
6415 
6416 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6417 struct MultTrait< StaticMatrix<T1,M,N,SO>, StaticVector<T2,N,false> >
6418 {
6419  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6420 };
6421 
6422 template< typename T1, size_t M, typename T2, size_t N, bool SO >
6423 struct MultTrait< StaticVector<T1,M,true>, StaticMatrix<T2,M,N,SO> >
6424 {
6425  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6426 };
6427 
6428 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t L >
6429 struct MultTrait< StaticMatrix<T1,M,N,SO>, HybridVector<T2,L,false> >
6430 {
6431  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6432 };
6433 
6434 template< typename T1, size_t L, typename T2, size_t M, size_t N, bool SO >
6435 struct MultTrait< HybridVector<T1,L,true>, StaticMatrix<T2,M,N,SO> >
6436 {
6437  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6438 };
6439 
6440 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6441 struct MultTrait< StaticMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
6442 {
6443  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6444 };
6445 
6446 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6447 struct MultTrait< DynamicVector<T1,true>, StaticMatrix<T2,M,N,SO> >
6448 {
6449  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6450 };
6451 
6452 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6453 struct MultTrait< StaticMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
6454 {
6455  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6456 };
6457 
6458 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6459 struct MultTrait< CompressedVector<T1,true>, StaticMatrix<T2,M,N,SO> >
6460 {
6461  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6462 };
6463 
6464 template< typename T1, size_t M, size_t K, bool SO1, typename T2, size_t N, bool SO2 >
6465 struct MultTrait< StaticMatrix<T1,M,K,SO1>, StaticMatrix<T2,K,N,SO2> >
6466 {
6467  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO1 > Type;
6468 };
6470 //*************************************************************************************************
6471 
6472 
6473 
6474 
6475 //=================================================================================================
6476 //
6477 // DIVTRAIT SPECIALIZATIONS
6478 //
6479 //=================================================================================================
6480 
6481 //*************************************************************************************************
6483 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6484 struct DivTrait< StaticMatrix<T1,M,N,SO>, T2 >
6485 {
6486  typedef StaticMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
6488 };
6490 //*************************************************************************************************
6491 
6492 
6493 
6494 
6495 //=================================================================================================
6496 //
6497 // MATHTRAIT SPECIALIZATIONS
6498 //
6499 //=================================================================================================
6500 
6501 //*************************************************************************************************
6503 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6504 struct MathTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6505 {
6506  typedef StaticMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
6507  typedef StaticMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
6508 };
6510 //*************************************************************************************************
6511 
6512 
6513 
6514 
6515 //=================================================================================================
6516 //
6517 // SUBMATRIXTRAIT SPECIALIZATIONS
6518 //
6519 //=================================================================================================
6520 
6521 //*************************************************************************************************
6523 template< typename T1, size_t M, size_t N, bool SO >
6524 struct SubmatrixTrait< StaticMatrix<T1,M,N,SO> >
6525 {
6526  typedef HybridMatrix<T1,M,N,SO> Type;
6527 };
6529 //*************************************************************************************************
6530 
6531 
6532 
6533 
6534 //=================================================================================================
6535 //
6536 // ROWTRAIT SPECIALIZATIONS
6537 //
6538 //=================================================================================================
6539 
6540 //*************************************************************************************************
6542 template< typename T1, size_t M, size_t N, bool SO >
6543 struct RowTrait< StaticMatrix<T1,M,N,SO> >
6544 {
6545  typedef StaticVector<T1,N,true> Type;
6546 };
6548 //*************************************************************************************************
6549 
6550 
6551 
6552 
6553 //=================================================================================================
6554 //
6555 // COLUMNTRAIT SPECIALIZATIONS
6556 //
6557 //=================================================================================================
6558 
6559 //*************************************************************************************************
6561 template< typename T1, size_t M, size_t N, bool SO >
6562 struct ColumnTrait< StaticMatrix<T1,M,N,SO> >
6563 {
6564  typedef StaticVector<T1,M,false> Type;
6565 };
6567 //*************************************************************************************************
6568 
6569 } // namespace blaze
6570 
6571 #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
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.
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2529
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: StaticMatrix.h:2063
Header file for basic type definitions.
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: StaticMatrix.h:198
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const sse_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:76
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
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: StaticMatrix.h:2424
Header file for the IsSparseMatrix type trait.
Header file for the IsDiagonal type trait.
StaticMatrix()
The default constructor for StaticMatrix.
Definition: StaticMatrix.h:497
StaticMatrix< ET, M, N, SO > Other
The type of the other StaticMatrix.
Definition: StaticMatrix.h:229
Header file for the IsSame and IsStrictlySame type traits.
StaticMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: StaticMatrix.h:211
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
StaticMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: StaticMatrix.h:210
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
static const size_t NN
Alignment adjustment.
Definition: StaticMatrix.h:203
#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
Header file for the SizeT class template.
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1598
Header file for memory allocation and deallocation functionality.
This ResultType
Result type for expression template evaluations.
Definition: StaticMatrix.h:209
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: StaticMatrix.h:453
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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: StaticMatrix.h:2466
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: StaticMatrix.h:219
Header file for the SparseMatrix base class.
Header file for the IsSquare type trait.
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2565
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1646
const Type & ConstReference
Reference to a constant matrix value.
Definition: StaticMatrix.h:217
Header file for the DisableIf class template.
StaticMatrix & transpose()
Transposing the matrix.
Definition: StaticMatrix.h:2166
void swap(StaticMatrix &m)
Swapping the contents of two static matrices.
Definition: StaticMatrix.h:2214
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
Header file for nested template disabiguation.
Compile time assertion.
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: StaticMatrix.h:213
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2602
#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
Type & Reference
Reference to a non-constant matrix value.
Definition: StaticMatrix.h:216
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:58
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Header file for the Columns type trait.
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.
void reset()
Reset to the default initial values.
Definition: StaticMatrix.h:2117
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2493
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2638
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:116
size_t columns() const
Returns the current number of columns of the matrix.
Definition: StaticMatrix.h:1986
Header file for the IsLower type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:92
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
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: StaticMatrix.h:2021
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: StaticMatrix.h:2446
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1574
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1526
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: StaticMatrix.h:1390
Header file for the IsVectorizable type trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Type ElementType
Type of the matrix elements.
Definition: StaticMatrix.h:212
const This & CompositeType
Data type for composite expression templates.
Definition: StaticMatrix.h:215
#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.
Pointer data()
Low-level data access to the matrix elements.
Definition: StaticMatrix.h:1437
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.
Header file for the submatrix trait.
Constraint on the data type.
Type * Pointer
Pointer to a non-constant matrix value.
Definition: StaticMatrix.h:218
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
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const sse_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:77
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4934
Header file for the AlignedArray implementation.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
Header file for the column trait.
Header file for the isDefault shim.
Constraint on the data type.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
Constraint on the data type.
Constraint on the data type.
Header file for the HasMutableDataAccess type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
Header file for the IsRowMajorMatrix type trait.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: StaticMatrix.h:2005
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
size_t rows() const
Returns the current number of rows of the matrix.
Definition: StaticMatrix.h:1970
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticMatrix.h:220
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticMatrix.h:221
Rebind mechanism to obtain a StaticMatrix with different data/element type.
Definition: StaticMatrix.h:228
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2518
Header file for the IsUpper type trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
StaticMatrix< Type, M, N, SO > This
Type of this StaticMatrix instance.
Definition: StaticMatrix.h:208
#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
System settings for the inline keywords.
#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
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticMatrix.h:214