All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
49 #include <blaze/math/Forward.h>
50 #include <blaze/math/Intrinsics.h>
51 #include <blaze/math/shims/Equal.h>
53 #include <blaze/math/shims/Reset.h>
67 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Memory.h>
79 #include <blaze/util/Template.h>
80 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS DEFINITION
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
177 template< typename Type // Data type of the matrix
178  , size_t M // Number of rows
179  , size_t N // Number of columns
180  , bool SO = defaultStorageOrder > // Storage order
181 class StaticMatrix : public DenseMatrix< StaticMatrix<Type,M,N,SO>, SO >
182 {
183  private:
184  //**Type definitions****************************************************************************
186  //**********************************************************************************************
187 
188  //**********************************************************************************************
190  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
191  //**********************************************************************************************
192 
193  public:
194  //**Type definitions****************************************************************************
196  typedef This ResultType;
199  typedef Type ElementType;
200  typedef typename IT::Type IntrinsicType;
201  typedef const Type& ReturnType;
202  typedef const This& CompositeType;
203  typedef Type& Reference;
204  typedef const Type& ConstReference;
205  typedef Type* Pointer;
206  typedef const Type* ConstPointer;
209  //**********************************************************************************************
210 
211  //**Compilation flags***************************************************************************
213 
217  enum { vectorizable = IsVectorizable<Type>::value };
218 
220 
223  enum { smpAssignable = 0 };
224  //**********************************************************************************************
225 
226  //**Constructors********************************************************************************
229  explicit inline StaticMatrix();
230  explicit inline StaticMatrix( const Type& init );
231 
232  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
233  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
234 
235  inline StaticMatrix( const StaticMatrix& m );
236  template< typename Other, bool SO2 > inline StaticMatrix( const StaticMatrix<Other,M,N,SO2>& m );
237  template< typename MT , bool SO2 > inline StaticMatrix( const Matrix<MT,SO2>& m );
238 
239  inline StaticMatrix( const Type& v1, const Type& v2 );
240  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
241  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
242  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
243  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
244  const Type& v6 );
245  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
246  const Type& v6, const Type& v7 );
247  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
248  const Type& v6, const Type& v7, const Type& v8 );
249  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
250  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
251  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
252  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
254  //**********************************************************************************************
255 
256  //**Destructor**********************************************************************************
257  // No explicitly declared destructor.
258  //**********************************************************************************************
259 
260  //**Data access functions***********************************************************************
263  inline Reference operator()( size_t i, size_t j );
264  inline ConstReference operator()( size_t i, size_t j ) const;
265  inline Pointer data ();
266  inline ConstPointer data () const;
267  inline Pointer data ( size_t i );
268  inline ConstPointer data ( size_t i ) const;
269  inline Iterator begin ( size_t i );
270  inline ConstIterator begin ( size_t i ) const;
271  inline ConstIterator cbegin( size_t i ) const;
272  inline Iterator end ( size_t i );
273  inline ConstIterator end ( size_t i ) const;
274  inline ConstIterator cend ( size_t i ) const;
276  //**********************************************************************************************
277 
278  //**Assignment operators************************************************************************
281  template< typename Other >
282  inline StaticMatrix& operator=( const Other (&array)[M][N] );
283 
284  inline StaticMatrix& operator= ( const Type& set );
285  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
286  template< typename Other, bool SO2 > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO2>& rhs );
287  template< typename MT , bool SO2 > inline StaticMatrix& operator= ( const Matrix<MT,SO2>& rhs );
288  template< typename MT , bool SO2 > inline StaticMatrix& operator+=( const Matrix<MT,SO2>& rhs );
289  template< typename MT , bool SO2 > inline StaticMatrix& operator-=( const Matrix<MT,SO2>& rhs );
290  template< typename MT , bool SO2 > inline StaticMatrix& operator*=( const Matrix<MT,SO2>& rhs );
291 
292  template< typename Other >
293  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
294  operator*=( Other rhs );
295 
296  template< typename Other >
297  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
298  operator/=( Other rhs );
300  //**********************************************************************************************
301 
302  //**Utility functions***************************************************************************
305  inline size_t rows() const;
306  inline size_t columns() const;
307  inline size_t spacing() const;
308  inline size_t capacity() const;
309  inline size_t capacity( size_t i ) const;
310  inline size_t nonZeros() const;
311  inline size_t nonZeros( size_t i ) const;
312  inline void reset();
313  inline void reset( size_t i );
314  inline StaticMatrix& transpose();
315  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
316  inline void swap( StaticMatrix& m ) /* throw() */;
318  //**********************************************************************************************
319 
320  //**Memory functions****************************************************************************
323  static inline void* operator new ( std::size_t size );
324  static inline void* operator new[]( std::size_t size );
325  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
326  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
327 
328  static inline void operator delete ( void* ptr );
329  static inline void operator delete[]( void* ptr );
330  static inline void operator delete ( void* ptr, const std::nothrow_t& );
331  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
333  //**********************************************************************************************
334 
335  private:
336  //**********************************************************************************************
338  template< typename MT >
340  struct VectorizedAssign {
341  enum { value = vectorizable && MT::vectorizable &&
342  IsSame<Type,typename MT::ElementType>::value &&
343  IsRowMajorMatrix<MT>::value };
344  };
346  //**********************************************************************************************
347 
348  //**********************************************************************************************
350  template< typename MT >
352  struct VectorizedAddAssign {
353  enum { value = vectorizable && MT::vectorizable &&
354  IsSame<Type,typename MT::ElementType>::value &&
355  IntrinsicTrait<Type>::addition &&
356  IsRowMajorMatrix<MT>::value };
357  };
359  //**********************************************************************************************
360 
361  //**********************************************************************************************
363  template< typename MT >
365  struct VectorizedSubAssign {
366  enum { value = vectorizable && MT::vectorizable &&
367  IsSame<Type,typename MT::ElementType>::value &&
368  IntrinsicTrait<Type>::subtraction &&
369  IsRowMajorMatrix<MT>::value };
370  };
372  //**********************************************************************************************
373 
374  public:
375  //**Expression template evaluation functions****************************************************
378  template< typename Other > inline bool canAlias ( const Other* alias ) const;
379  template< typename Other > inline bool isAliased( const Other* alias ) const;
380 
381  inline bool isAligned() const;
382 
383  inline IntrinsicType load ( size_t i, size_t j ) const;
384  inline IntrinsicType loadu ( size_t i, size_t j ) const;
385  inline void store ( size_t i, size_t j, const IntrinsicType& value );
386  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
387  inline void stream( size_t i, size_t j, const IntrinsicType& value );
388 
389  template< typename MT, bool SO2 >
390  inline typename DisableIf< VectorizedAssign<MT> >::Type
391  assign( const DenseMatrix<MT,SO2>& rhs );
392 
393  template< typename MT, bool SO2 >
394  inline typename EnableIf< VectorizedAssign<MT> >::Type
395  assign( const DenseMatrix<MT,SO2>& rhs );
396 
397  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
398  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
399 
400  template< typename MT, bool SO2 >
401  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
402  addAssign( const DenseMatrix<MT,SO2>& rhs );
403 
404  template< typename MT, bool SO2 >
405  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
406  addAssign( const DenseMatrix<MT,SO2>& rhs );
407 
408  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
409  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
410 
411  template< typename MT, bool SO2 >
412  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
413  subAssign( const DenseMatrix<MT,SO2>& rhs );
414 
415  template< typename MT, bool SO2 >
416  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
417  subAssign( const DenseMatrix<MT,SO2>& rhs );
418 
419  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
420  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
422  //**********************************************************************************************
423 
424  private:
425  //**Member variables****************************************************************************
429 
439  //**********************************************************************************************
440 
441  //**Compile time checks*************************************************************************
447  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
448  BLAZE_STATIC_ASSERT( NN >= N );
450  //**********************************************************************************************
451 };
452 //*************************************************************************************************
453 
454 
455 
456 
457 //=================================================================================================
458 //
459 // CONSTRUCTORS
460 //
461 //=================================================================================================
462 
463 //*************************************************************************************************
468 template< typename Type // Data type of the matrix
469  , size_t M // Number of rows
470  , size_t N // Number of columns
471  , bool SO > // Storage order
473  : v_() // The statically allocated matrix elements
474 {
476  for( size_t i=0UL; i<M*NN; ++i )
477  v_[i] = Type();
478  }
479 }
480 //*************************************************************************************************
481 
482 
483 //*************************************************************************************************
488 template< typename Type // Data type of the matrix
489  , size_t M // Number of rows
490  , size_t N // Number of columns
491  , bool SO > // Storage order
492 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& init )
493  : v_() // The statically allocated matrix elements
494 {
495  for( size_t i=0UL; i<M; ++i ) {
496  for( size_t j=0UL; j<N; ++j )
497  v_[i*NN+j] = init;
498 
500  for( size_t j=N; j<NN; ++j )
501  v_[i*NN+j] = Type();
502  }
503  }
504 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
534 template< typename Type // Data type of the matrix
535  , size_t M // Number of rows
536  , size_t N // Number of columns
537  , bool SO > // Storage order
538 template< typename Other > // Data type of the initialization array
539 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( size_t m, size_t n, const Other* array )
540  : v_() // The statically allocated matrix elements
541 {
542  if( m > M || n > N )
543  throw std::invalid_argument( "Invalid setup of static matrix" );
544 
545  for( size_t i=0UL; i<m; ++i ) {
546  for( size_t j=0UL; j<n; ++j )
547  v_[i*NN+j] = array[i*n+j];
548 
550  for( size_t j=n; j<NN; ++j )
551  v_[i*NN+j] = Type();
552  }
553  }
554 
556  for( size_t i=m; i<M; ++i ) {
557  for( size_t j=0UL; j<NN; ++j )
558  v_[i*NN+j] = Type();
559  }
560  }
561 }
562 //*************************************************************************************************
563 
564 
565 //*************************************************************************************************
585 template< typename Type // Data type of the matrix
586  , size_t M // Number of rows
587  , size_t N // Number of columns
588  , bool SO > // Storage order
589 template< typename Other > // Data type of the initialization array
590 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Other (&array)[M][N] )
591  : v_() // The statically allocated matrix elements
592 {
593  for( size_t i=0UL; i<M; ++i ) {
594  for( size_t j=0UL; j<N; ++j )
595  v_[i*NN+j] = array[i][j];
596 
598  for( size_t j=N; j<NN; ++j )
599  v_[i*NN+j] = Type();
600  }
601  }
602 }
603 //*************************************************************************************************
604 
605 
606 //*************************************************************************************************
613 template< typename Type // Data type of the matrix
614  , size_t M // Number of rows
615  , size_t N // Number of columns
616  , bool SO > // Storage order
618  : v_() // The statically allocated matrix elements
619 {
620  for( size_t i=0UL; i<M*NN; ++i )
621  v_[i] = m.v_[i];
622 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
631 template< typename Type // Data type of the matrix
632  , size_t M // Number of rows
633  , size_t N // Number of columns
634  , bool SO > // Storage order
635 template< typename Other // Data type of the foreign matrix
636  , bool SO2 > // Storage order of the foreign matrix
638  : v_() // The statically allocated matrix elements
639 {
640  for( size_t i=0UL; i<M; ++i ) {
641  for( size_t j=0UL; j<N; ++j )
642  v_[i*NN+j] = m(i,j);
643 
645  for( size_t j=N; j<NN; ++j )
646  v_[i*NN+j] = Type();
647  }
648  }
649 }
650 //*************************************************************************************************
651 
652 
653 //*************************************************************************************************
663 template< typename Type // Data type of the matrix
664  , size_t M // Number of rows
665  , size_t N // Number of columns
666  , bool SO > // Storage order
667 template< typename MT // Type of the foreign matrix
668  , bool SO2 > // Storage order of the foreign matrix
670  : v_() // The statically allocated matrix elements
671 {
672  using blaze::assign;
673 
674  if( (~m).rows() != M || (~m).columns() != N )
675  throw std::invalid_argument( "Invalid setup of static matrix" );
676 
677  for( size_t i=0UL; i<M; ++i ) {
678  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : N );
679  j<( IsVectorizable<Type>::value ? NN : N ); ++j ) {
680  v_[i*NN+j] = Type();
681  }
682  }
683 
684  assign( *this, ~m );
685 }
686 //*************************************************************************************************
687 
688 
689 //*************************************************************************************************
706 template< typename Type // Data type of the matrix
707  , size_t M // Number of rows
708  , size_t N // Number of columns
709  , bool SO > // Storage order
710 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2 )
711  : v_() // The statically allocated matrix elements
712 {
713  BLAZE_STATIC_ASSERT( M*N == 2UL );
714 
715  // Initialization of a 1x2 matrix
716  if( M == 1UL ) {
717  v_[0UL] = v1;
718  v_[1UL] = v2;
719  }
720 
721  // Initialization of a 2x1 matrix
722  else {
723  v_[0UL] = v1;
724  v_[ NN] = v2;
725  }
726 
728  for( size_t i=0UL; i<M; ++i ) {
729  for( size_t j=N; j<NN; ++j )
730  v_[i*NN+j] = Type();
731  }
732  }
733 }
734 //*************************************************************************************************
735 
736 
737 //*************************************************************************************************
755 template< typename Type // Data type of the matrix
756  , size_t M // Number of rows
757  , size_t N // Number of columns
758  , bool SO > // Storage order
759 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
760  : v_() // The statically allocated matrix elements
761 {
762  BLAZE_STATIC_ASSERT( M*N == 3UL );
763 
764  // Initialization of a 1x3 matrix
765  if( M == 1UL ) {
766  v_[0UL] = v1;
767  v_[1UL] = v2;
768  v_[2UL] = v3;
769  }
770 
771  // Initialization of a 3x1 matrix
772  else {
773  v_[ 0UL] = v1;
774  v_[ NN] = v2;
775  v_[2UL*NN] = v3;
776  }
777 
779  for( size_t i=0UL; i<M; ++i ) {
780  for( size_t j=N; j<NN; ++j )
781  v_[i*NN+j] = Type();
782  }
783  }
784 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
809 template< typename Type // Data type of the matrix
810  , size_t M // Number of rows
811  , size_t N // Number of columns
812  , bool SO > // Storage order
813 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2,
814  const Type& v3, const Type& v4 )
815  : v_() // The statically allocated matrix elements
816 {
817  BLAZE_STATIC_ASSERT( M*N == 4UL );
818 
819  // Initialization of a 1x4 matrix
820  if( M == 1UL ) {
821  v_[0UL] = v1;
822  v_[1UL] = v2;
823  v_[2UL] = v3;
824  v_[3UL] = v4;
825  }
826 
827  // Initialization of a 2x2 matrix
828  else if( M == 2UL ) {
829  v_[ 0UL] = v1;
830  v_[ 1UL] = v2;
831  v_[NN ] = v3;
832  v_[NN+1UL] = v4;
833  }
834 
835  // Initialization of a 4x1 matrix
836  else {
837  v_[ 0UL] = v1;
838  v_[ NN] = v2;
839  v_[2UL*NN] = v3;
840  v_[3UL*NN] = v4;
841  }
842 
844  for( size_t i=0UL; i<M; ++i ) {
845  for( size_t j=N; j<NN; ++j )
846  v_[i*NN+j] = Type();
847  }
848  }
849 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
873 template< typename Type // Data type of the matrix
874  , size_t M // Number of rows
875  , size_t N // Number of columns
876  , bool SO > // Storage order
877 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
878  const Type& v4, const Type& v5 )
879  : v_() // The statically allocated matrix elements
880 {
881  BLAZE_STATIC_ASSERT( M*N == 5UL );
882 
883  // Initialization of a 1x5 matrix
884  if( M == 1UL ) {
885  v_[0UL] = v1;
886  v_[1UL] = v2;
887  v_[2UL] = v3;
888  v_[3UL] = v4;
889  v_[4UL] = v5;
890  }
891 
892  // Initialization of a 5x1 matrix
893  else {
894  v_[ 0UL] = v1;
895  v_[ NN] = v2;
896  v_[2UL*NN] = v3;
897  v_[3UL*NN] = v4;
898  v_[4UL*NN] = v5;
899  }
900 
902  for( size_t i=0UL; i<M; ++i ) {
903  for( size_t j=N; j<NN; ++j )
904  v_[i*NN+j] = Type();
905  }
906  }
907 }
908 //*************************************************************************************************
909 
910 
911 //*************************************************************************************************
935 template< typename Type // Data type of the matrix
936  , size_t M // Number of rows
937  , size_t N // Number of columns
938  , bool SO > // Storage order
939 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
940  const Type& v4, const Type& v5, const Type& v6 )
941  : v_() // The statically allocated matrix elements
942 {
943  BLAZE_STATIC_ASSERT( M*N == 6UL );
944 
945  // Initialization of a 1x6 matrix
946  if( M == 1UL ) {
947  v_[0UL] = v1;
948  v_[1UL] = v2;
949  v_[2UL] = v3;
950  v_[3UL] = v4;
951  v_[4UL] = v5;
952  v_[5UL] = v6;
953  }
954 
955  // Initialization of a 2x3 matrix
956  else if( M == 2UL ) {
957  v_[ 0UL] = v1;
958  v_[ 1UL] = v2;
959  v_[ 2UL] = v3;
960  v_[NN ] = v4;
961  v_[NN+1UL] = v5;
962  v_[NN+2UL] = v6;
963  }
964 
965  // Initialization of a 3x2 matrix
966  else if( M == 3UL ) {
967  v_[ 0UL] = v1;
968  v_[ 1UL] = v2;
969  v_[ NN ] = v3;
970  v_[ NN+1UL] = v4;
971  v_[2UL*NN ] = v5;
972  v_[2UL*NN+1UL] = v6;
973  }
974 
975  // Initialization of a 6x1 matrix
976  else {
977  v_[ 0UL] = v1;
978  v_[ NN] = v2;
979  v_[2UL*NN] = v3;
980  v_[3UL*NN] = v4;
981  v_[4UL*NN] = v5;
982  v_[5UL*NN] = v6;
983  }
984 
986  for( size_t i=0UL; i<M; ++i ) {
987  for( size_t j=N; j<NN; ++j )
988  v_[i*NN+j] = Type();
989  }
990  }
991 }
992 //*************************************************************************************************
993 
994 
995 //*************************************************************************************************
1017 template< typename Type // Data type of the matrix
1018  , size_t M // Number of rows
1019  , size_t N // Number of columns
1020  , bool SO > // Storage order
1021 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1022  const Type& v4, const Type& v5, const Type& v6,
1023  const Type& v7 )
1024  : v_() // The statically allocated matrix elements
1025 {
1026  BLAZE_STATIC_ASSERT( M*N == 7UL );
1027 
1028  // Initialization of a 1x7 matrix
1029  if( M == 1UL ) {
1030  v_[0UL] = v1;
1031  v_[1UL] = v2;
1032  v_[2UL] = v3;
1033  v_[3UL] = v4;
1034  v_[4UL] = v5;
1035  v_[5UL] = v6;
1036  v_[6UL] = v7;
1037  }
1038 
1039  // Initialization of a 7x1 matrix
1040  else {
1041  v_[ 0UL] = v1;
1042  v_[ NN] = v2;
1043  v_[2UL*NN] = v3;
1044  v_[3UL*NN] = v4;
1045  v_[4UL*NN] = v5;
1046  v_[5UL*NN] = v6;
1047  v_[6UL*NN] = v7;
1048  }
1049 
1051  for( size_t i=0UL; i<M; ++i ) {
1052  for( size_t j=N; j<NN; ++j )
1053  v_[i*NN+j] = Type();
1054  }
1055  }
1056 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1085 template< typename Type // Data type of the matrix
1086  , size_t M // Number of rows
1087  , size_t N // Number of columns
1088  , bool SO > // Storage order
1089 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1090  const Type& v4, const Type& v5, const Type& v6,
1091  const Type& v7, const Type& v8 )
1092  : v_() // The statically allocated matrix elements
1093 {
1094  BLAZE_STATIC_ASSERT( M*N == 8UL );
1095 
1096  // Initialization of a 1x8 matrix
1097  if( M == 1UL ) {
1098  v_[0UL] = v1;
1099  v_[1UL] = v2;
1100  v_[2UL] = v3;
1101  v_[3UL] = v4;
1102  v_[4UL] = v5;
1103  v_[5UL] = v6;
1104  v_[6UL] = v7;
1105  v_[7UL] = v8;
1106  }
1107 
1108  // Initialization of a 2x4 matrix
1109  else if( M == 2UL ) {
1110  v_[ 0UL] = v1;
1111  v_[ 1UL] = v2;
1112  v_[ 2UL] = v3;
1113  v_[ 3UL] = v4;
1114  v_[NN ] = v5;
1115  v_[NN+1UL] = v6;
1116  v_[NN+2UL] = v7;
1117  v_[NN+3UL] = v8;
1118  }
1119 
1120  // Initialization of a 4x2 matrix
1121  else if( M == 4UL ) {
1122  v_[ 0UL] = v1;
1123  v_[ 1UL] = v2;
1124  v_[ NN ] = v3;
1125  v_[ NN+1UL] = v4;
1126  v_[2UL*NN ] = v5;
1127  v_[2UL*NN+1UL] = v6;
1128  v_[3UL*NN ] = v7;
1129  v_[3UL*NN+1UL] = v8;
1130  }
1131 
1132  // Initialization of a 8x1 matrix
1133  else {
1134  v_[ 0UL] = v1;
1135  v_[ NN] = v2;
1136  v_[2UL*NN] = v3;
1137  v_[3UL*NN] = v4;
1138  v_[4UL*NN] = v5;
1139  v_[5UL*NN] = v6;
1140  v_[6UL*NN] = v7;
1141  v_[7UL*NN] = v8;
1142  }
1143 
1145  for( size_t i=0UL; i<M; ++i ) {
1146  for( size_t j=N; j<NN; ++j )
1147  v_[i*NN+j] = Type();
1148  }
1149  }
1150 }
1151 //*************************************************************************************************
1152 
1153 
1154 //*************************************************************************************************
1181 template< typename Type // Data type of the matrix
1182  , size_t M // Number of rows
1183  , size_t N // Number of columns
1184  , bool SO > // Storage order
1185 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1186  const Type& v4, const Type& v5, const Type& v6,
1187  const Type& v7, const Type& v8, const Type& v9 )
1188  : v_() // The statically allocated matrix elements
1189 {
1190  BLAZE_STATIC_ASSERT( M*N == 9UL );
1191 
1192  // Initialization of a 1x9 matrix
1193  if( M == 1UL ) {
1194  v_[0UL] = v1;
1195  v_[1UL] = v2;
1196  v_[2UL] = v3;
1197  v_[3UL] = v4;
1198  v_[4UL] = v5;
1199  v_[5UL] = v6;
1200  v_[6UL] = v7;
1201  v_[7UL] = v8;
1202  v_[8UL] = v9;
1203  }
1204 
1205  // Initialization of a 3x3 matrix
1206  else if( M == 3UL ) {
1207  v_[ 0UL] = v1;
1208  v_[ 1UL] = v2;
1209  v_[ 2UL] = v3;
1210  v_[ NN ] = v4;
1211  v_[ NN+1UL] = v5;
1212  v_[ NN+2UL] = v6;
1213  v_[2UL*NN ] = v7;
1214  v_[2UL*NN+1UL] = v8;
1215  v_[2UL*NN+2UL] = v9;
1216  }
1217 
1218  // Initialization of a 9x1 matrix
1219  else {
1220  v_[ 0UL] = v1;
1221  v_[ NN] = v2;
1222  v_[2UL*NN] = v3;
1223  v_[3UL*NN] = v4;
1224  v_[4UL*NN] = v5;
1225  v_[5UL*NN] = v6;
1226  v_[6UL*NN] = v7;
1227  v_[7UL*NN] = v8;
1228  v_[8UL*NN] = v9;
1229  }
1230 
1232  for( size_t i=0UL; i<M; ++i ) {
1233  for( size_t j=N; j<NN; ++j )
1234  v_[i*NN+j] = Type();
1235  }
1236  }
1237 }
1238 //*************************************************************************************************
1239 
1240 
1241 //*************************************************************************************************
1269 template< typename Type // Data type of the matrix
1270  , size_t M // Number of rows
1271  , size_t N // Number of columns
1272  , bool SO > // Storage order
1273 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1274  const Type& v4, const Type& v5, const Type& v6,
1275  const Type& v7, const Type& v8, const Type& v9,
1276  const Type& v10 )
1277  : v_() // The statically allocated matrix elements
1278 {
1279  BLAZE_STATIC_ASSERT( M*N == 10UL );
1280 
1281  // Initialization of a 1x10 matrix
1282  if( M == 1UL ) {
1283  v_[0UL] = v1;
1284  v_[1UL] = v2;
1285  v_[2UL] = v3;
1286  v_[3UL] = v4;
1287  v_[4UL] = v5;
1288  v_[5UL] = v6;
1289  v_[6UL] = v7;
1290  v_[7UL] = v8;
1291  v_[8UL] = v9;
1292  v_[9UL] = v10;
1293  }
1294 
1295  // Initialization of a 2x5 matrix
1296  else if( M == 2UL ) {
1297  v_[ 0UL] = v1;
1298  v_[ 1UL] = v2;
1299  v_[ 2UL] = v3;
1300  v_[ 3UL] = v4;
1301  v_[ 4UL] = v5;
1302  v_[NN ] = v6;
1303  v_[NN+1UL] = v7;
1304  v_[NN+2UL] = v8;
1305  v_[NN+3UL] = v9;
1306  v_[NN+4UL] = v10;
1307  }
1308 
1309  // Initialization of a 5x2 matrix
1310  else if( M == 5UL ) {
1311  v_[ 0UL] = v1;
1312  v_[ 1UL] = v2;
1313  v_[ NN ] = v3;
1314  v_[ NN+1UL] = v4;
1315  v_[2UL*NN ] = v5;
1316  v_[2UL*NN+1UL] = v6;
1317  v_[3UL*NN ] = v7;
1318  v_[3UL*NN+1UL] = v8;
1319  v_[4UL*NN ] = v9;
1320  v_[4UL*NN+1UL] = v10;
1321  }
1322 
1323  // Initialization of a 10x1 matrix
1324  else {
1325  v_[ 0UL] = v1;
1326  v_[ NN] = v2;
1327  v_[2UL*NN] = v3;
1328  v_[3UL*NN] = v4;
1329  v_[4UL*NN] = v5;
1330  v_[5UL*NN] = v6;
1331  v_[6UL*NN] = v7;
1332  v_[7UL*NN] = v8;
1333  v_[8UL*NN] = v9;
1334  v_[9UL*NN] = v10;
1335  }
1336 
1338  for( size_t i=0UL; i<M; ++i ) {
1339  for( size_t j=N; j<NN; ++j )
1340  v_[i*NN+j] = Type();
1341  }
1342  }
1343 }
1344 //*************************************************************************************************
1345 
1346 
1347 
1348 
1349 //=================================================================================================
1350 //
1351 // DATA ACCESS FUNCTIONS
1352 //
1353 //=================================================================================================
1354 
1355 //*************************************************************************************************
1362 template< typename Type // Data type of the matrix
1363  , size_t M // Number of rows
1364  , size_t N // Number of columns
1365  , bool SO > // Storage order
1368 {
1369  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1370  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1371  return v_[i*NN+j];
1372 }
1373 //*************************************************************************************************
1374 
1375 
1376 //*************************************************************************************************
1383 template< typename Type // Data type of the matrix
1384  , size_t M // Number of rows
1385  , size_t N // Number of columns
1386  , bool SO > // Storage order
1388  StaticMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
1389 {
1390  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1391  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1392  return v_[i*NN+j];
1393 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1409 template< typename Type // Data type of the matrix
1410  , size_t M // Number of rows
1411  , size_t N // Number of columns
1412  , bool SO > // Storage order
1413 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1415 {
1416  return v_;
1417 }
1418 //*************************************************************************************************
1419 
1420 
1421 //*************************************************************************************************
1433 template< typename Type // Data type of the matrix
1434  , size_t M // Number of rows
1435  , size_t N // Number of columns
1436  , bool SO > // Storage order
1439 {
1440  return v_;
1441 }
1442 //*************************************************************************************************
1443 
1444 
1445 //*************************************************************************************************
1453 template< typename Type // Data type of the matrix
1454  , size_t M // Number of rows
1455  , size_t N // Number of columns
1456  , bool SO > // Storage order
1457 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1459 {
1460  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1461  return v_ + i*NN;
1462 }
1463 //*************************************************************************************************
1464 
1465 
1466 //*************************************************************************************************
1474 template< typename Type // Data type of the matrix
1475  , size_t M // Number of rows
1476  , size_t N // Number of columns
1477  , bool SO > // Storage order
1480 {
1481  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1482  return v_ + i*NN;
1483 }
1484 //*************************************************************************************************
1485 
1486 
1487 //*************************************************************************************************
1498 template< typename Type // Data type of the matrix
1499  , size_t M // Number of rows
1500  , size_t N // Number of columns
1501  , bool SO > // Storage order
1504 {
1505  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1506  return Iterator( v_ + i*NN );
1507 }
1508 //*************************************************************************************************
1509 
1510 
1511 //*************************************************************************************************
1522 template< typename Type // Data type of the matrix
1523  , size_t M // Number of rows
1524  , size_t N // Number of columns
1525  , bool SO > // Storage order
1528 {
1529  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1530  return ConstIterator( v_ + i*NN );
1531 }
1532 //*************************************************************************************************
1533 
1534 
1535 //*************************************************************************************************
1546 template< typename Type // Data type of the matrix
1547  , size_t M // Number of rows
1548  , size_t N // Number of columns
1549  , bool SO > // Storage order
1552 {
1553  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1554  return ConstIterator( v_ + i*NN );
1555 }
1556 //*************************************************************************************************
1557 
1558 
1559 //*************************************************************************************************
1570 template< typename Type // Data type of the matrix
1571  , size_t M // Number of rows
1572  , size_t N // Number of columns
1573  , bool SO > // Storage order
1576 {
1577  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1578  return Iterator( v_ + i*NN + N );
1579 }
1580 //*************************************************************************************************
1581 
1582 
1583 //*************************************************************************************************
1594 template< typename Type // Data type of the matrix
1595  , size_t M // Number of rows
1596  , size_t N // Number of columns
1597  , bool SO > // Storage order
1600 {
1601  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1602  return ConstIterator( v_ + i*NN + N );
1603 }
1604 //*************************************************************************************************
1605 
1606 
1607 //*************************************************************************************************
1618 template< typename Type // Data type of the matrix
1619  , size_t M // Number of rows
1620  , size_t N // Number of columns
1621  , bool SO > // Storage order
1624 {
1625  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1626  return ConstIterator( v_ + i*NN + N );
1627 }
1628 //*************************************************************************************************
1629 
1630 
1631 
1632 
1633 //=================================================================================================
1634 //
1635 // ASSIGNMENT OPERATORS
1636 //
1637 //=================================================================================================
1638 
1639 //*************************************************************************************************
1660 template< typename Type // Data type of the matrix
1661  , size_t M // Number of rows
1662  , size_t N // Number of columns
1663  , bool SO > // Storage order
1664 template< typename Other > // Data type of the initialization array
1666 {
1667  for( size_t i=0UL; i<M; ++i )
1668  for( size_t j=0UL; j<N; ++j )
1669  v_[i*NN+j] = array[i][j];
1670 
1671  return *this;
1672 }
1673 //*************************************************************************************************
1674 
1675 
1676 //*************************************************************************************************
1682 template< typename Type // Data type of the matrix
1683  , size_t M // Number of rows
1684  , size_t N // Number of columns
1685  , bool SO > // Storage order
1687 {
1688  for( size_t i=0UL; i<M; ++i )
1689  for( size_t j=0UL; j<N; ++j )
1690  v_[i*NN+j] = set;
1691 
1692  return *this;
1693 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
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  using blaze::assign;
1712 
1713  assign( *this, ~rhs );
1714  return *this;
1715 }
1716 //*************************************************************************************************
1717 
1718 
1719 //*************************************************************************************************
1725 template< typename Type // Data type of the matrix
1726  , size_t M // Number of rows
1727  , size_t N // Number of columns
1728  , bool SO > // Storage order
1729 template< typename Other // Data type of the foreign matrix
1730  , bool SO2 > // Storage order of the foreign matrix
1733 {
1734  using blaze::assign;
1735 
1736  assign( *this, ~rhs );
1737  return *this;
1738 }
1739 //*************************************************************************************************
1740 
1741 
1742 //*************************************************************************************************
1753 template< typename Type // Data type of the matrix
1754  , size_t M // Number of rows
1755  , size_t N // Number of columns
1756  , bool SO > // Storage order
1757 template< typename MT // Type of the right-hand side matrix
1758  , bool SO2 > // Storage order of the right-hand side matrix
1760 {
1761  using blaze::assign;
1762 
1763  if( (~rhs).rows() != M || (~rhs).columns() != N )
1764  throw std::invalid_argument( "Invalid assignment to static matrix" );
1765 
1766  if( (~rhs).canAlias( this ) ) {
1767  StaticMatrix tmp( ~rhs );
1768  swap( tmp );
1769  }
1770  else {
1772  reset();
1773  assign( *this, ~rhs );
1774  }
1775 
1776  return *this;
1777 }
1778 //*************************************************************************************************
1779 
1780 
1781 //*************************************************************************************************
1791 template< typename Type // Data type of the matrix
1792  , size_t M // Number of rows
1793  , size_t N // Number of columns
1794  , bool SO > // Storage order
1795 template< typename MT // Type of the right-hand side matrix
1796  , bool SO2 > // Storage order of the right-hand side matrix
1798 {
1799  using blaze::addAssign;
1800 
1801  if( (~rhs).rows() != M || (~rhs).columns() != N )
1802  throw std::invalid_argument( "Matrix sizes do not match" );
1803 
1804  if( (~rhs).canAlias( this ) ) {
1805  typename MT::ResultType tmp( ~rhs );
1806  addAssign( *this, tmp );
1807  }
1808  else {
1809  addAssign( *this, ~rhs );
1810  }
1811 
1812  return *this;
1813 }
1814 //*************************************************************************************************
1815 
1816 
1817 //*************************************************************************************************
1827 template< typename Type // Data type of the matrix
1828  , size_t M // Number of rows
1829  , size_t N // Number of columns
1830  , bool SO > // Storage order
1831 template< typename MT // Type of the right-hand side matrix
1832  , bool SO2 > // Storage order of the right-hand side matrix
1834 {
1835  using blaze::subAssign;
1836 
1837  if( (~rhs).rows() != M || (~rhs).columns() != N )
1838  throw std::invalid_argument( "Matrix sizes do not match" );
1839 
1840  if( (~rhs).canAlias( this ) ) {
1841  typename MT::ResultType tmp( ~rhs );
1842  subAssign( *this, tmp );
1843  }
1844  else {
1845  subAssign( *this, ~rhs );
1846  }
1847 
1848  return *this;
1849 }
1850 //*************************************************************************************************
1851 
1852 
1853 //*************************************************************************************************
1863 template< typename Type // Data type of the matrix
1864  , size_t M // Number of rows
1865  , size_t N // Number of columns
1866  , bool SO > // Storage order
1867 template< typename MT // Type of the right-hand side matrix
1868  , bool SO2 > // Storage order of the right-hand side matrix
1870 {
1871  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
1872  throw std::invalid_argument( "Matrix sizes do not match" );
1873 
1874  StaticMatrix tmp( *this * (~rhs) );
1875  return this->operator=( tmp );
1876 }
1877 //*************************************************************************************************
1878 
1879 
1880 //*************************************************************************************************
1887 template< typename Type // Data type of the matrix
1888  , size_t M // Number of rows
1889  , size_t N // Number of columns
1890  , bool SO > // Storage order
1891 template< typename Other > // Data type of the right-hand side scalar
1892 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1894 {
1895  using blaze::assign;
1896 
1897  assign( *this, (*this) * rhs );
1898  return *this;
1899 }
1900 //*************************************************************************************************
1901 
1902 
1903 //*************************************************************************************************
1912 template< typename Type // Data type of the matrix
1913  , size_t M // Number of rows
1914  , size_t N // Number of columns
1915  , bool SO > // Storage order
1916 template< typename Other > // Data type of the right-hand side scalar
1917 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1919 {
1920  using blaze::assign;
1921 
1922  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1923 
1924  assign( *this, (*this) / rhs );
1925  return *this;
1926 }
1927 //*************************************************************************************************
1928 
1929 
1930 
1931 
1932 //=================================================================================================
1933 //
1934 // UTILITY FUNCTIONS
1935 //
1936 //=================================================================================================
1937 
1938 //*************************************************************************************************
1943 template< typename Type // Data type of the matrix
1944  , size_t M // Number of rows
1945  , size_t N // Number of columns
1946  , bool SO > // Storage order
1947 inline size_t StaticMatrix<Type,M,N,SO>::rows() const
1948 {
1949  return M;
1950 }
1951 //*************************************************************************************************
1952 
1953 
1954 //*************************************************************************************************
1959 template< typename Type // Data type of the matrix
1960  , size_t M // Number of rows
1961  , size_t N // Number of columns
1962  , bool SO > // Storage order
1964 {
1965  return N;
1966 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1978 template< typename Type // Data type of the matrix
1979  , size_t M // Number of rows
1980  , size_t N // Number of columns
1981  , bool SO > // Storage order
1983 {
1984  return NN;
1985 }
1986 //*************************************************************************************************
1987 
1988 
1989 //*************************************************************************************************
1994 template< typename Type // Data type of the matrix
1995  , size_t M // Number of rows
1996  , size_t N // Number of columns
1997  , bool SO > // Storage order
1999 {
2000  return M*NN;
2001 }
2002 //*************************************************************************************************
2003 
2004 
2005 //*************************************************************************************************
2016 template< typename Type // Data type of the matrix
2017  , size_t M // Number of rows
2018  , size_t N // Number of columns
2019  , bool SO > // Storage order
2020 inline size_t StaticMatrix<Type,M,N,SO>::capacity( size_t i ) const
2021 {
2022  UNUSED_PARAMETER( i );
2023 
2024  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2025 
2026  return NN;
2027 }
2028 //*************************************************************************************************
2029 
2030 
2031 //*************************************************************************************************
2036 template< typename Type // Data type of the matrix
2037  , size_t M // Number of rows
2038  , size_t N // Number of columns
2039  , bool SO > // Storage order
2041 {
2042  size_t nonzeros( 0UL );
2043 
2044  for( size_t i=0UL; i<M; ++i )
2045  for( size_t j=0UL; j<N; ++j )
2046  if( !isDefault( v_[i*NN+j] ) )
2047  ++nonzeros;
2048 
2049  return nonzeros;
2050 }
2051 //*************************************************************************************************
2052 
2053 
2054 //*************************************************************************************************
2065 template< typename Type // Data type of the matrix
2066  , size_t M // Number of rows
2067  , size_t N // Number of columns
2068  , bool SO > // Storage order
2069 inline size_t StaticMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
2070 {
2071  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2072 
2073  const size_t jend( (i+1UL)*NN );
2074  size_t nonzeros( 0UL );
2075 
2076  for( size_t j=i*NN; j<jend; ++j )
2077  if( !isDefault( v_[j] ) )
2078  ++nonzeros;
2079 
2080  return nonzeros;
2081 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2090 template< typename Type // Data type of the matrix
2091  , size_t M // Number of rows
2092  , size_t N // Number of columns
2093  , bool SO > // Storage order
2095 {
2096  using blaze::reset;
2097 
2098  for( size_t i=0UL; i<M; ++i )
2099  for( size_t j=0UL; j<N; ++j )
2100  reset( v_[i*NN+j] );
2101 }
2102 //*************************************************************************************************
2103 
2104 
2105 //*************************************************************************************************
2116 template< typename Type // Data type of the matrix
2117  , size_t M // Number of rows
2118  , size_t N // Number of columns
2119  , bool SO > // Storage order
2120 inline void StaticMatrix<Type,M,N,SO>::reset( size_t i )
2121 {
2122  using blaze::reset;
2123 
2124  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2125  for( size_t j=0UL; j<N; ++j )
2126  reset( v_[i*NN+j] );
2127 }
2128 //*************************************************************************************************
2129 
2130 
2131 //*************************************************************************************************
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
2144 {
2145  using std::swap;
2146 
2147  BLAZE_STATIC_ASSERT( M == N );
2148 
2149  for( size_t i=1UL; i<M; ++i )
2150  for( size_t j=0UL; j<i; ++j )
2151  swap( v_[i*NN+j], v_[j*NN+i] );
2152 
2153  return *this;
2154 }
2155 //*************************************************************************************************
2156 
2157 
2158 //*************************************************************************************************
2164 template< typename Type // Data type of the matrix
2165  , size_t M // Number of rows
2166  , size_t N // Number of columns
2167  , bool SO > // Storage order
2168 template< typename Other > // Data type of the scalar value
2170 {
2171  for( size_t i=0UL; i<M; ++i )
2172  for( size_t j=0UL; j<N; ++j )
2173  v_[i*NN+j] *= scalar;
2174 
2175  return *this;
2176 }
2177 //*************************************************************************************************
2178 
2179 
2180 //*************************************************************************************************
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 inline void StaticMatrix<Type,M,N,SO>::swap( StaticMatrix& m ) /* throw() */
2192 {
2193  using std::swap;
2194 
2195  for( size_t i=0UL; i<M; ++i ) {
2196  for( size_t j=0UL; j<N; ++j ) {
2197  swap( v_[i*NN+j], m(i,j) );
2198  }
2199  }
2200 }
2201 //*************************************************************************************************
2202 
2203 
2204 
2205 
2206 //=================================================================================================
2207 //
2208 // MEMORY FUNCTIONS
2209 //
2210 //=================================================================================================
2211 
2212 //*************************************************************************************************
2222 template< typename Type // Data type of the matrix
2223  , size_t M // Number of rows
2224  , size_t N // Number of columns
2225  , bool SO > // Storage order
2226 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size )
2227 {
2228  UNUSED_PARAMETER( size );
2229 
2230  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2231 
2232  return allocate<StaticMatrix>( 1UL );
2233 }
2234 //*************************************************************************************************
2235 
2236 
2237 //*************************************************************************************************
2247 template< typename Type // Data type of the matrix
2248  , size_t M // Number of rows
2249  , size_t N // Number of columns
2250  , bool SO > // Storage order
2251 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size )
2252 {
2253  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2254  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2255 
2256  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2257 }
2258 //*************************************************************************************************
2259 
2260 
2261 //*************************************************************************************************
2271 template< typename Type // Data type of the matrix
2272  , size_t M // Number of rows
2273  , size_t N // Number of columns
2274  , bool SO > // Storage order
2275 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size, const std::nothrow_t& )
2276 {
2277  UNUSED_PARAMETER( size );
2278 
2279  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2280 
2281  return allocate<StaticMatrix>( 1UL );
2282 }
2283 //*************************************************************************************************
2284 
2285 
2286 //*************************************************************************************************
2296 template< typename Type // Data type of the matrix
2297  , size_t M // Number of rows
2298  , size_t N // Number of columns
2299  , bool SO > // Storage order
2300 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size, const std::nothrow_t& )
2301 {
2302  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2303  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2304 
2305  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2306 }
2307 //*************************************************************************************************
2308 
2309 
2310 //*************************************************************************************************
2316 template< typename Type // Data type of the matrix
2317  , size_t M // Number of rows
2318  , size_t N // Number of columns
2319  , bool SO > // Storage order
2320 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr )
2321 {
2322  deallocate( static_cast<StaticMatrix*>( ptr ) );
2323 }
2324 //*************************************************************************************************
2325 
2326 
2327 //*************************************************************************************************
2333 template< typename Type // Data type of the matrix
2334  , size_t M // Number of rows
2335  , size_t N // Number of columns
2336  , bool SO > // Storage order
2337 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr )
2338 {
2339  deallocate( static_cast<StaticMatrix*>( ptr ) );
2340 }
2341 //*************************************************************************************************
2342 
2343 
2344 //*************************************************************************************************
2350 template< typename Type // Data type of the matrix
2351  , size_t M // Number of rows
2352  , size_t N // Number of columns
2353  , bool SO > // Storage order
2354 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr, const std::nothrow_t& )
2355 {
2356  deallocate( static_cast<StaticMatrix*>( ptr ) );
2357 }
2358 //*************************************************************************************************
2359 
2360 
2361 //*************************************************************************************************
2367 template< typename Type // Data type of the matrix
2368  , size_t M // Number of rows
2369  , size_t N // Number of columns
2370  , bool SO > // Storage order
2371 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr, const std::nothrow_t& )
2372 {
2373  deallocate( static_cast<StaticMatrix*>( ptr ) );
2374 }
2375 //*************************************************************************************************
2376 
2377 
2378 
2379 
2380 //=================================================================================================
2381 //
2382 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2383 //
2384 //=================================================================================================
2385 
2386 //*************************************************************************************************
2396 template< typename Type // Data type of the matrix
2397  , size_t M // Number of rows
2398  , size_t N // Number of columns
2399  , bool SO > // Storage order
2400 template< typename Other > // Data type of the foreign expression
2401 inline bool StaticMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
2402 {
2403  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2404 }
2405 //*************************************************************************************************
2406 
2407 
2408 //*************************************************************************************************
2418 template< typename Type // Data type of the matrix
2419  , size_t M // Number of rows
2420  , size_t N // Number of columns
2421  , bool SO > // Storage order
2422 template< typename Other > // Data type of the foreign expression
2423 inline bool StaticMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
2424 {
2425  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2426 }
2427 //*************************************************************************************************
2428 
2429 
2430 //*************************************************************************************************
2439 template< typename Type // Data type of the matrix
2440  , size_t M // Number of rows
2441  , size_t N // Number of columns
2442  , bool SO > // Storage order
2444 {
2445  return true;
2446 }
2447 //*************************************************************************************************
2448 
2449 
2450 //*************************************************************************************************
2465 template< typename Type // Data type of the matrix
2466  , size_t M // Number of rows
2467  , size_t N // Number of columns
2468  , bool SO > // Storage order
2470  StaticMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2471 {
2472  using blaze::load;
2473 
2475 
2476  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2477  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2478  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2479  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2480 
2481  return load( &v_[i*NN+j] );
2482 }
2483 //*************************************************************************************************
2484 
2485 
2486 //*************************************************************************************************
2501 template< typename Type // Data type of the matrix
2502  , size_t M // Number of rows
2503  , size_t N // Number of columns
2504  , bool SO > // Storage order
2506  StaticMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2507 {
2508  using blaze::loadu;
2509 
2511 
2512  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2513  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2514  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2515 
2516  return loadu( &v_[i*NN+j] );
2517 }
2518 //*************************************************************************************************
2519 
2520 
2521 //*************************************************************************************************
2537 template< typename Type // Data type of the matrix
2538  , size_t M // Number of rows
2539  , size_t N // Number of columns
2540  , bool SO > // Storage order
2541 inline void StaticMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2542 {
2543  using blaze::store;
2544 
2546 
2547  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2548  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2549  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2550  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2551 
2552  store( &v_[i*NN+j], value );
2553 }
2554 //*************************************************************************************************
2555 
2556 
2557 //*************************************************************************************************
2573 template< typename Type // Data type of the matrix
2574  , size_t M // Number of rows
2575  , size_t N // Number of columns
2576  , bool SO > // Storage order
2577 inline void StaticMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2578 {
2579  using blaze::storeu;
2580 
2582 
2583  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2584  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2585  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2586 
2587  storeu( &v_[i*NN+j], value );
2588 }
2589 //*************************************************************************************************
2590 
2591 
2592 //*************************************************************************************************
2608 template< typename Type // Data type of the matrix
2609  , size_t M // Number of rows
2610  , size_t N // Number of columns
2611  , bool SO > // Storage order
2612 inline void StaticMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2613 {
2614  using blaze::stream;
2615 
2617 
2618  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2619  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2620  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2621  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2622 
2623  stream( &v_[i*NN+j], value );
2624 }
2625 //*************************************************************************************************
2626 
2627 
2628 //*************************************************************************************************
2639 template< typename Type // Data type of the matrix
2640  , size_t M // Number of rows
2641  , size_t N // Number of columns
2642  , bool SO > // Storage order
2643 template< typename MT // Type of the right-hand side dense matrix
2644  , bool SO2 > // Storage order of the right-hand side dense matrix
2645 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2647 {
2648  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2649 
2650  for( size_t i=0UL; i<M; ++i ) {
2651  for( size_t j=0UL; j<N; ++j ) {
2652  v_[i*NN+j] = (~rhs)(i,j);
2653  }
2654  }
2655 }
2656 //*************************************************************************************************
2657 
2658 
2659 //*************************************************************************************************
2670 template< typename Type // Data type of the matrix
2671  , size_t M // Number of rows
2672  , size_t N // Number of columns
2673  , bool SO > // Storage order
2674 template< typename MT // Type of the right-hand side dense matrix
2675  , bool SO2 > // Storage order of the right-hand side dense matrix
2676 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2678 {
2679  using blaze::store;
2680 
2681  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2682 
2684 
2685  for( size_t i=0UL; i<M; ++i ) {
2686  for( size_t j=0UL; j<N; j+=IT::size ) {
2687  store( &v_[i*NN+j], (~rhs).load(i,j) );
2688  }
2689  }
2690 }
2691 //*************************************************************************************************
2692 
2693 
2694 //*************************************************************************************************
2705 template< typename Type // Data type of the matrix
2706  , size_t M // Number of rows
2707  , size_t N // Number of columns
2708  , bool SO > // Storage order
2709 template< typename MT > // Type of the right-hand side sparse matrix
2711 {
2712  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2713 
2714  typedef typename MT::ConstIterator RhsConstIterator;
2715 
2716  for( size_t i=0UL; i<M; ++i )
2717  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2718  v_[i*NN+element->index()] = element->value();
2719 }
2720 //*************************************************************************************************
2721 
2722 
2723 //*************************************************************************************************
2734 template< typename Type // Data type of the matrix
2735  , size_t M // Number of rows
2736  , size_t N // Number of columns
2737  , bool SO > // Storage order
2738 template< typename MT > // Type of the right-hand side sparse matrix
2740 {
2741  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2742 
2743  typedef typename MT::ConstIterator RhsConstIterator;
2744 
2745  for( size_t j=0UL; j<N; ++j )
2746  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2747  v_[element->index()*NN+j] = element->value();
2748 }
2749 //*************************************************************************************************
2750 
2751 
2752 //*************************************************************************************************
2763 template< typename Type // Data type of the matrix
2764  , size_t M // Number of rows
2765  , size_t N // Number of columns
2766  , bool SO > // Storage order
2767 template< typename MT // Type of the right-hand side dense matrix
2768  , bool SO2 > // Storage order of the right-hand side dense matrix
2769 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2771 {
2772  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2773 
2774  for( size_t i=0UL; i<M; ++i ) {
2775  for( size_t j=0UL; j<N; ++j ) {
2776  v_[i*NN+j] += (~rhs)(i,j);
2777  }
2778  }
2779 }
2780 //*************************************************************************************************
2781 
2782 
2783 //*************************************************************************************************
2794 template< typename Type // Data type of the matrix
2795  , size_t M // Number of rows
2796  , size_t N // Number of columns
2797  , bool SO > // Storage order
2798 template< typename MT // Type of the right-hand side dense matrix
2799  , bool SO2 > // Storage order of the right-hand side dense matrix
2800 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2802 {
2803  using blaze::load;
2804  using blaze::store;
2805 
2806  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2807 
2809 
2810  for( size_t i=0UL; i<M; ++i ) {
2811  for( size_t j=0UL; j<N; j+=IT::size ) {
2812  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2813  }
2814  }
2815 }
2816 //*************************************************************************************************
2817 
2818 
2819 //*************************************************************************************************
2830 template< typename Type // Data type of the matrix
2831  , size_t M // Number of rows
2832  , size_t N // Number of columns
2833  , bool SO > // Storage order
2834 template< typename MT > // Type of the right-hand side sparse matrix
2836 {
2837  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2838 
2839  typedef typename MT::ConstIterator RhsConstIterator;
2840 
2841  for( size_t i=0UL; i<M; ++i )
2842  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2843  v_[i*NN+element->index()] += element->value();
2844 }
2845 //*************************************************************************************************
2846 
2847 
2848 //*************************************************************************************************
2859 template< typename Type // Data type of the matrix
2860  , size_t M // Number of rows
2861  , size_t N // Number of columns
2862  , bool SO > // Storage order
2863 template< typename MT > // Type of the right-hand side sparse matrix
2865 {
2866  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2867 
2868  typedef typename MT::ConstIterator RhsConstIterator;
2869 
2870  for( size_t j=0UL; j<N; ++j )
2871  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2872  v_[element->index()*NN+j] += element->value();
2873 }
2874 //*************************************************************************************************
2875 
2876 
2877 //*************************************************************************************************
2888 template< typename Type // Data type of the matrix
2889  , size_t M // Number of rows
2890  , size_t N // Number of columns
2891  , bool SO > // Storage order
2892 template< typename MT // Type of the right-hand side dense matrix
2893  , bool SO2 > // Storage order of the right-hand side dense matrix
2894 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2896 {
2897  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2898 
2899  for( size_t i=0UL; i<M; ++i ) {
2900  for( size_t j=0UL; j<N; ++j ) {
2901  v_[i*NN+j] -= (~rhs)(i,j);
2902  }
2903  }
2904 }
2905 //*************************************************************************************************
2906 
2907 
2908 //*************************************************************************************************
2919 template< typename Type // Data type of the matrix
2920  , size_t M // Number of rows
2921  , size_t N // Number of columns
2922  , bool SO > // Storage order
2923 template< typename MT // Type of the right-hand side dense matrix
2924  , bool SO2 > // Storage order of the right-hand side dense matrix
2925 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2927 {
2928  using blaze::load;
2929  using blaze::store;
2930 
2931  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2932 
2934 
2935  for( size_t i=0UL; i<M; ++i ) {
2936  for( size_t j=0UL; j<N; j+=IT::size ) {
2937  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
2938  }
2939  }
2940 }
2941 //*************************************************************************************************
2942 
2943 
2944 //*************************************************************************************************
2955 template< typename Type // Data type of the matrix
2956  , size_t M // Number of rows
2957  , size_t N // Number of columns
2958  , bool SO > // Storage order
2959 template< typename MT > // Type of the right-hand side sparse matrix
2961 {
2962  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2963 
2964  typedef typename MT::ConstIterator RhsConstIterator;
2965 
2966  for( size_t i=0UL; i<M; ++i )
2967  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2968  v_[i*NN+element->index()] -= element->value();
2969 }
2970 //*************************************************************************************************
2971 
2972 
2973 //*************************************************************************************************
2984 template< typename Type // Data type of the matrix
2985  , size_t M // Number of rows
2986  , size_t N // Number of columns
2987  , bool SO > // Storage order
2988 template< typename MT > // Type of the right-hand side sparse matrix
2990 {
2991  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2992 
2993  typedef typename MT::ConstIterator RhsConstIterator;
2994 
2995  for( size_t j=0UL; j<N; ++j )
2996  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2997  v_[element->index()*NN+j] -= element->value();
2998 }
2999 //*************************************************************************************************
3000 
3001 
3002 
3003 
3004 
3005 
3006 
3007 
3008 //=================================================================================================
3009 //
3010 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
3011 //
3012 //=================================================================================================
3013 
3014 //*************************************************************************************************
3022 template< typename Type // Data type of the matrix
3023  , size_t M // Number of rows
3024  , size_t N > // Number of columns
3025 class StaticMatrix<Type,M,N,true> : public DenseMatrix< StaticMatrix<Type,M,N,true>, true >
3026 {
3027  private:
3028  //**Type definitions****************************************************************************
3029  typedef IntrinsicTrait<Type> IT;
3030  //**********************************************************************************************
3031 
3032  //**********************************************************************************************
3034  enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
3035  //**********************************************************************************************
3036 
3037  public:
3038  //**Type definitions****************************************************************************
3039  typedef StaticMatrix<Type,M,N,true> This;
3040  typedef This ResultType;
3041  typedef StaticMatrix<Type,M,N,false> OppositeType;
3042  typedef StaticMatrix<Type,N,M,false> TransposeType;
3043  typedef Type ElementType;
3044  typedef typename IT::Type IntrinsicType;
3045  typedef const Type& ReturnType;
3046  typedef const This& CompositeType;
3047  typedef Type& Reference;
3048  typedef const Type& ConstReference;
3049  typedef Type* Pointer;
3050  typedef const Type* ConstPointer;
3051  typedef DenseIterator<Type> Iterator;
3052  typedef DenseIterator<const Type> ConstIterator;
3053  //**********************************************************************************************
3054 
3055  //**Compilation flags***************************************************************************
3057 
3061  enum { vectorizable = IsVectorizable<Type>::value };
3062 
3064 
3067  enum { smpAssignable = 0 };
3068  //**********************************************************************************************
3069 
3070  //**Constructors********************************************************************************
3073  explicit inline StaticMatrix();
3074  explicit inline StaticMatrix( const Type& init );
3075 
3076  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
3077  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
3078 
3079  inline StaticMatrix( const StaticMatrix& m );
3080  template< typename Other, bool SO > inline StaticMatrix( const StaticMatrix<Other,M,N,SO>& m );
3081  template< typename MT , bool SO > inline StaticMatrix( const Matrix<MT,SO>& m );
3082 
3083  inline StaticMatrix( const Type& v1, const Type& v2 );
3084  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
3085  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
3086  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
3087  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3088  const Type& v6 );
3089  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3090  const Type& v6, const Type& v7 );
3091  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3092  const Type& v6, const Type& v7, const Type& v8 );
3093  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3094  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
3095  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3096  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
3098  //**********************************************************************************************
3099 
3100  //**Destructor**********************************************************************************
3101  // No explicitly declared destructor.
3102  //**********************************************************************************************
3103 
3104  //**Data access functions***********************************************************************
3107  inline Reference operator()( size_t i, size_t j );
3108  inline ConstReference operator()( size_t i, size_t j ) const;
3109  inline Pointer data ();
3110  inline ConstPointer data () const;
3111  inline Pointer data ( size_t j );
3112  inline ConstPointer data ( size_t j ) const;
3113  inline Iterator begin ( size_t j );
3114  inline ConstIterator begin ( size_t j ) const;
3115  inline ConstIterator cbegin( size_t j ) const;
3116  inline Iterator end ( size_t j );
3117  inline ConstIterator end ( size_t j ) const;
3118  inline ConstIterator cend ( size_t j ) const;
3120  //**********************************************************************************************
3121 
3122  //**Assignment operators************************************************************************
3125  template< typename Other >
3126  inline StaticMatrix& operator=( const Other (&array)[M][N] );
3127 
3128  inline StaticMatrix& operator= ( const Type& set );
3129  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
3130  template< typename Other, bool SO > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO>& rhs );
3131  template< typename MT , bool SO > inline StaticMatrix& operator= ( const Matrix<MT,SO>& rhs );
3132  template< typename MT , bool SO > inline StaticMatrix& operator+=( const Matrix<MT,SO>& rhs );
3133  template< typename MT , bool SO > inline StaticMatrix& operator-=( const Matrix<MT,SO>& rhs );
3134  template< typename MT , bool SO > inline StaticMatrix& operator*=( const Matrix<MT,SO>& rhs );
3135 
3136  template< typename Other >
3137  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3138  operator*=( Other rhs );
3139 
3140  template< typename Other >
3141  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3142  operator/=( Other rhs );
3144  //**********************************************************************************************
3145 
3146  //**Utility functions***************************************************************************
3149  inline size_t rows() const;
3150  inline size_t columns() const;
3151  inline size_t spacing() const;
3152  inline size_t capacity() const;
3153  inline size_t capacity( size_t j ) const;
3154  inline size_t nonZeros() const;
3155  inline size_t nonZeros( size_t j ) const;
3156  inline void reset();
3157  inline void reset( size_t i );
3158  inline StaticMatrix& transpose();
3159  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
3160  inline void swap( StaticMatrix& m ) /* throw() */;
3162  //**********************************************************************************************
3163 
3164  //**Memory functions****************************************************************************
3167  static inline void* operator new ( std::size_t size );
3168  static inline void* operator new[]( std::size_t size );
3169  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
3170  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
3171 
3172  static inline void operator delete ( void* ptr );
3173  static inline void operator delete[]( void* ptr );
3174  static inline void operator delete ( void* ptr, const std::nothrow_t& );
3175  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
3177  //**********************************************************************************************
3178 
3179  private:
3180  //**********************************************************************************************
3182  template< typename MT >
3183  struct VectorizedAssign {
3184  enum { value = vectorizable && MT::vectorizable &&
3185  IsSame<Type,typename MT::ElementType>::value &&
3186  IsColumnMajorMatrix<MT>::value };
3187  };
3188  //**********************************************************************************************
3189 
3190  //**********************************************************************************************
3192  template< typename MT >
3193  struct VectorizedAddAssign {
3194  enum { value = vectorizable && MT::vectorizable &&
3195  IsSame<Type,typename MT::ElementType>::value &&
3196  IntrinsicTrait<Type>::addition &&
3197  IsColumnMajorMatrix<MT>::value };
3198  };
3199  //**********************************************************************************************
3200 
3201  //**********************************************************************************************
3203  template< typename MT >
3204  struct VectorizedSubAssign {
3205  enum { value = vectorizable && MT::vectorizable &&
3206  IsSame<Type,typename MT::ElementType>::value &&
3207  IntrinsicTrait<Type>::subtraction &&
3208  IsColumnMajorMatrix<MT>::value };
3209  };
3210  //**********************************************************************************************
3211 
3212  public:
3213  //**Expression template evaluation functions****************************************************
3216  template< typename Other > inline bool canAlias ( const Other* alias ) const;
3217  template< typename Other > inline bool isAliased( const Other* alias ) const;
3218 
3219  inline bool isAligned() const;
3220 
3221  inline IntrinsicType load ( size_t i, size_t j ) const;
3222  inline IntrinsicType loadu ( size_t i, size_t j ) const;
3223  inline void store ( size_t i, size_t j, const IntrinsicType& value );
3224  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
3225  inline void stream( size_t i, size_t j, const IntrinsicType& value );
3226 
3227  template< typename MT, bool SO >
3228  inline typename DisableIf< VectorizedAssign<MT> >::Type
3229  assign( const DenseMatrix<MT,SO>& rhs );
3230 
3231  template< typename MT, bool SO >
3232  inline typename EnableIf< VectorizedAssign<MT> >::Type
3233  assign( const DenseMatrix<MT,SO>& rhs );
3234 
3235  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
3236  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
3237 
3238  template< typename MT, bool SO >
3239  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
3240  addAssign( const DenseMatrix<MT,SO>& rhs );
3241 
3242  template< typename MT, bool SO >
3243  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
3244  addAssign( const DenseMatrix<MT,SO>& rhs );
3245 
3246  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
3247  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
3248 
3249  template< typename MT, bool SO >
3250  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
3251  subAssign( const DenseMatrix<MT,SO>& rhs );
3252 
3253  template< typename MT, bool SO >
3254  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
3255  subAssign( const DenseMatrix<MT,SO>& rhs );
3256 
3257  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
3258  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
3260  //**********************************************************************************************
3261 
3262  private:
3263  //**Member variables****************************************************************************
3266  AlignedArray<Type,MM*N> v_;
3267 
3270  //**********************************************************************************************
3271 
3272  //**Compile time checks*************************************************************************
3277  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
3278  BLAZE_STATIC_ASSERT( MM >= M );
3279  //**********************************************************************************************
3280 };
3282 //*************************************************************************************************
3283 
3284 
3285 
3286 
3287 //=================================================================================================
3288 //
3289 // CONSTRUCTORS
3290 //
3291 //=================================================================================================
3292 
3293 //*************************************************************************************************
3299 template< typename Type // Data type of the matrix
3300  , size_t M // Number of rows
3301  , size_t N > // Number of columns
3303  : v_() // The statically allocated matrix elements
3304 {
3305  if( IsVectorizable<Type>::value ) {
3306  for( size_t i=0UL; i<MM*N; ++i )
3307  v_[i] = Type();
3308  }
3309 }
3311 //*************************************************************************************************
3312 
3313 
3314 //*************************************************************************************************
3320 template< typename Type // Data type of the matrix
3321  , size_t M // Number of rows
3322  , size_t N > // Number of columns
3323 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& init )
3324  : v_() // The statically allocated matrix elements
3325 {
3326  for( size_t j=0UL; j<N; ++j ) {
3327  for( size_t i=0UL; i<M; ++i )
3328  v_[i+j*MM] = init;
3329 
3330  if( IsVectorizable<Type>::value ) {
3331  for( size_t i=M; i<MM; ++i )
3332  v_[i+j*MM] = Type();
3333  }
3334  }
3335 }
3337 //*************************************************************************************************
3338 
3339 
3340 //*************************************************************************************************
3367 template< typename Type // Data type of the matrix
3368  , size_t M // Number of rows
3369  , size_t N > // Number of columns
3370 template< typename Other > // Data type of the initialization array
3371 inline StaticMatrix<Type,M,N,true>::StaticMatrix( size_t m, size_t n, const Other* array )
3372  : v_() // The statically allocated matrix elements
3373 {
3374  if( m > M || n > N )
3375  throw std::invalid_argument( "Invalid setup of static matrix" );
3376 
3377  for( size_t j=0UL; j<n; ++j ) {
3378  for( size_t i=0UL; i<m; ++i )
3379  v_[i+j*MM] = array[i+j*m];
3380 
3381  if( IsVectorizable<Type>::value ) {
3382  for( size_t i=m; i<MM; ++i )
3383  v_[i+j*MM] = Type();
3384  }
3385  }
3386 
3387  if( IsVectorizable<Type>::value ) {
3388  for( size_t j=n; j<N; ++j ) {
3389  for( size_t i=0UL; i<M; ++i )
3390  v_[i+j*MM] = Type();
3391  }
3392  }
3393 }
3395 //*************************************************************************************************
3396 
3397 
3398 //*************************************************************************************************
3419 template< typename Type // Data type of the matrix
3420  , size_t M // Number of rows
3421  , size_t N > // Number of columns
3422 template< typename Other > // Data type of the initialization array
3423 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Other (&array)[M][N] )
3424  : v_() // The statically allocated matrix elements
3425 {
3426  for( size_t j=0UL; j<N; ++j ) {
3427  for( size_t i=0UL; i<M; ++i )
3428  v_[i+j*MM] = array[i][j];
3429 
3430  if( IsVectorizable<Type>::value ) {
3431  for( size_t i=M; i<MM; ++i )
3432  v_[i+j*MM] = Type();
3433  }
3434  }
3435 }
3437 //*************************************************************************************************
3438 
3439 
3440 //*************************************************************************************************
3448 template< typename Type // Data type of the matrix
3449  , size_t M // Number of rows
3450  , size_t N > // Number of columns
3451 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix& m )
3452  : v_() // The statically allocated matrix elements
3453 {
3454  for( size_t i=0UL; i<MM*N; ++i )
3455  v_[i] = m.v_[i];
3456 }
3458 //*************************************************************************************************
3459 
3460 
3461 //*************************************************************************************************
3467 template< typename Type // Data type of the matrix
3468  , size_t M // Number of rows
3469  , size_t N > // Number of columns
3470 template< typename Other // Data type of the foreign matrix
3471  , bool SO > // Storage order of the foreign matrix
3472 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix<Other,M,N,SO>& m )
3473  : v_() // The statically allocated matrix elements
3474 {
3475  for( size_t j=0UL; j<N; ++j ) {
3476  for( size_t i=0UL; i<M; ++i )
3477  v_[i+j*MM] = m(i,j);
3478 
3479  if( IsVectorizable<Type>::value ) {
3480  for( size_t i=M; i<MM; ++i )
3481  v_[i+j*MM] = Type();
3482  }
3483  }
3484 }
3486 //*************************************************************************************************
3487 
3488 
3489 //*************************************************************************************************
3500 template< typename Type // Data type of the matrix
3501  , size_t M // Number of rows
3502  , size_t N > // Number of columns
3503 template< typename MT // Type of the foreign matrix
3504  , bool SO > // Storage order of the foreign matrix
3505 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Matrix<MT,SO>& m )
3506  : v_() // The statically allocated matrix elements
3507 {
3508  using blaze::assign;
3509 
3510  if( (~m).rows() != M || (~m).columns() != N )
3511  throw std::invalid_argument( "Invalid setup of static matrix" );
3512 
3513  for( size_t j=0UL; j<N; ++j ) {
3514  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : M );
3515  i<( IsVectorizable<Type>::value ? MM : M ); ++i ) {
3516  v_[i+j*MM] = Type();
3517  }
3518  }
3519 
3520  assign( *this, ~m );
3521 }
3523 //*************************************************************************************************
3524 
3525 
3526 //*************************************************************************************************
3544 template< typename Type // Data type of the matrix
3545  , size_t M // Number of rows
3546  , size_t N > // Number of columns
3547 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2 )
3548  : v_() // The statically allocated matrix elements
3549 {
3550  BLAZE_STATIC_ASSERT( M*N == 2UL );
3551 
3552  // Initialization of a 2x1 matrix
3553  if( N == 1UL ) {
3554  v_[0UL] = v1;
3555  v_[1UL] = v2;
3556  }
3557 
3558  // Initialization of a 1x2 matrix
3559  else {
3560  v_[0UL] = v1;
3561  v_[ MM] = v2;
3562  }
3563 
3564  if( IsVectorizable<Type>::value ) {
3565  for( size_t j=0UL; j<N; ++j )
3566  for( size_t i=M; i<MM; ++i ) {
3567  v_[i+j*MM] = Type();
3568  }
3569  }
3570 }
3572 //*************************************************************************************************
3573 
3574 
3575 //*************************************************************************************************
3594 template< typename Type // Data type of the matrix
3595  , size_t M // Number of rows
3596  , size_t N > // Number of columns
3597 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
3598  : v_() // The statically allocated matrix elements
3599 {
3600  BLAZE_STATIC_ASSERT( M*N == 3UL );
3601 
3602  // Initialization of a 3x1 matrix
3603  if( N == 1UL ) {
3604  v_[0UL] = v1;
3605  v_[1UL] = v2;
3606  v_[2UL] = v3;
3607  }
3608 
3609  // Initialization of a 1x3 matrix
3610  else {
3611  v_[ 0UL] = v1;
3612  v_[ MM] = v2;
3613  v_[2UL*MM] = v3;
3614  }
3615 
3616  if( IsVectorizable<Type>::value ) {
3617  for( size_t j=0UL; j<N; ++j )
3618  for( size_t i=M; i<MM; ++i ) {
3619  v_[i+j*MM] = Type();
3620  }
3621  }
3622 }
3624 //*************************************************************************************************
3625 
3626 
3627 //*************************************************************************************************
3649 template< typename Type // Data type of the matrix
3650  , size_t M // Number of rows
3651  , size_t N > // Number of columns
3652 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3653  const Type& v4 )
3654  : v_() // The statically allocated matrix elements
3655 {
3656  BLAZE_STATIC_ASSERT( M*N == 4UL );
3657 
3658  // Initialization of a 4x1 matrix
3659  if( N == 1UL ) {
3660  v_[0UL] = v1;
3661  v_[1UL] = v2;
3662  v_[2UL] = v3;
3663  v_[3UL] = v4;
3664  }
3665 
3666  // Initialization of a 2x2 matrix
3667  else if( N == 2UL ) {
3668  v_[ 0UL] = v1;
3669  v_[ 1UL] = v2;
3670  v_[MM ] = v3;
3671  v_[MM+1UL] = v4;
3672  }
3673 
3674  // Initialization of a 1x4 matrix
3675  else {
3676  v_[ 0UL] = v1;
3677  v_[ MM] = v2;
3678  v_[2UL*MM] = v3;
3679  v_[3UL*MM] = v4;
3680  }
3681 
3682  if( IsVectorizable<Type>::value ) {
3683  for( size_t j=0UL; j<N; ++j )
3684  for( size_t i=M; i<MM; ++i ) {
3685  v_[i+j*MM] = Type();
3686  }
3687  }
3688 }
3690 //*************************************************************************************************
3691 
3692 
3693 //*************************************************************************************************
3714 template< typename Type // Data type of the matrix
3715  , size_t M // Number of rows
3716  , size_t N > // Number of columns
3717 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3718  const Type& v4, const Type& v5 )
3719  : v_() // The statically allocated matrix elements
3720 {
3721  BLAZE_STATIC_ASSERT( M*N == 5UL );
3722 
3723  // Initialization of a 5x1 matrix
3724  if( N == 1UL ) {
3725  v_[0UL] = v1;
3726  v_[1UL] = v2;
3727  v_[2UL] = v3;
3728  v_[3UL] = v4;
3729  v_[4UL] = v5;
3730  }
3731 
3732  // Initialization of a 1x5 matrix
3733  else {
3734  v_[ 0UL] = v1;
3735  v_[ MM] = v2;
3736  v_[2UL*MM] = v3;
3737  v_[3UL*MM] = v4;
3738  v_[4UL*MM] = v5;
3739  }
3740 
3741  if( IsVectorizable<Type>::value ) {
3742  for( size_t j=0UL; j<N; ++j )
3743  for( size_t i=M; i<MM; ++i ) {
3744  v_[i+j*MM] = Type();
3745  }
3746  }
3747 }
3749 //*************************************************************************************************
3750 
3751 
3752 //*************************************************************************************************
3777 template< typename Type // Data type of the matrix
3778  , size_t M // Number of rows
3779  , size_t N > // Number of columns
3780 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3781  const Type& v4, const Type& v5, const Type& v6 )
3782  : v_() // The statically allocated matrix elements
3783 {
3784  BLAZE_STATIC_ASSERT( M*N == 6UL );
3785 
3786  // Initialization of a 6x1 matrix
3787  if( N == 1UL ) {
3788  v_[0UL] = v1;
3789  v_[1UL] = v2;
3790  v_[2UL] = v3;
3791  v_[3UL] = v4;
3792  v_[4UL] = v5;
3793  v_[5UL] = v6;
3794  }
3795 
3796  // Initialization of a 3x2 matrix
3797  else if( N == 2UL ) {
3798  v_[ 0UL] = v1;
3799  v_[ 1UL] = v2;
3800  v_[ 2UL] = v3;
3801  v_[MM ] = v4;
3802  v_[MM+1UL] = v5;
3803  v_[MM+2UL] = v6;
3804  }
3805 
3806  // Initialization of a 2x3 matrix
3807  else if( N == 3UL ) {
3808  v_[ 0UL] = v1;
3809  v_[ 1UL] = v2;
3810  v_[ MM ] = v3;
3811  v_[ MM+1UL] = v4;
3812  v_[2UL*MM ] = v5;
3813  v_[2UL*MM+1UL] = v6;
3814  }
3815 
3816  // Initialization of a 1x6 matrix
3817  else {
3818  v_[ 0UL] = v1;
3819  v_[ MM] = v2;
3820  v_[2UL*MM] = v3;
3821  v_[3UL*MM] = v4;
3822  v_[4UL*MM] = v5;
3823  v_[5UL*MM] = v6;
3824  }
3825 
3826  if( IsVectorizable<Type>::value ) {
3827  for( size_t j=0UL; j<N; ++j )
3828  for( size_t i=M; i<MM; ++i ) {
3829  v_[i+j*MM] = Type();
3830  }
3831  }
3832 }
3834 //*************************************************************************************************
3835 
3836 
3837 //*************************************************************************************************
3860 template< typename Type // Data type of the matrix
3861  , size_t M // Number of rows
3862  , size_t N > // Number of columns
3863 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3864  const Type& v4, const Type& v5, const Type& v6,
3865  const Type& v7 )
3866  : v_() // The statically allocated matrix elements
3867 {
3868  BLAZE_STATIC_ASSERT( M*N == 7UL );
3869 
3870  // Initialization of a 7x1 matrix
3871  if( N == 1UL ) {
3872  v_[0UL] = v1;
3873  v_[1UL] = v2;
3874  v_[2UL] = v3;
3875  v_[3UL] = v4;
3876  v_[4UL] = v5;
3877  v_[5UL] = v6;
3878  v_[6UL] = v7;
3879  }
3880 
3881  // Initialization of a 1x7 matrix
3882  else {
3883  v_[ 0UL] = v1;
3884  v_[ MM] = v2;
3885  v_[2UL*MM] = v3;
3886  v_[3UL*MM] = v4;
3887  v_[4UL*MM] = v5;
3888  v_[5UL*MM] = v6;
3889  v_[6UL*MM] = v7;
3890  }
3891 
3892  if( IsVectorizable<Type>::value ) {
3893  for( size_t j=0UL; j<N; ++j )
3894  for( size_t i=M; i<MM; ++i ) {
3895  v_[i+j*MM] = Type();
3896  }
3897  }
3898 }
3900 //*************************************************************************************************
3901 
3902 
3903 //*************************************************************************************************
3930 template< typename Type // Data type of the matrix
3931  , size_t M // Number of rows
3932  , size_t N > // Number of columns
3933 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3934  const Type& v4, const Type& v5, const Type& v6,
3935  const Type& v7, const Type& v8 )
3936  : v_() // The statically allocated matrix elements
3937 {
3938  BLAZE_STATIC_ASSERT( M*N == 8UL );
3939 
3940  // Initialization of a 8x1 matrix
3941  if( N == 1UL ) {
3942  v_[0UL] = v1;
3943  v_[1UL] = v2;
3944  v_[2UL] = v3;
3945  v_[3UL] = v4;
3946  v_[4UL] = v5;
3947  v_[5UL] = v6;
3948  v_[6UL] = v7;
3949  v_[7UL] = v8;
3950  }
3951 
3952  // Initialization of a 4x2 matrix
3953  else if( N == 2UL ) {
3954  v_[ 0UL] = v1;
3955  v_[ 1UL] = v2;
3956  v_[ 2UL] = v3;
3957  v_[ 3UL] = v4;
3958  v_[MM ] = v5;
3959  v_[MM+1UL] = v6;
3960  v_[MM+2UL] = v7;
3961  v_[MM+3UL] = v8;
3962  }
3963 
3964  // Initialization of a 2x4 matrix
3965  else if( N == 4UL ) {
3966  v_[ 0UL] = v1;
3967  v_[ 1UL] = v2;
3968  v_[ MM ] = v3;
3969  v_[ MM+1UL] = v4;
3970  v_[2UL*MM ] = v5;
3971  v_[2UL*MM+1UL] = v6;
3972  v_[3UL*MM ] = v7;
3973  v_[3UL*MM+1UL] = v8;
3974  }
3975 
3976  // Initialization of a 1x8 matrix
3977  else {
3978  v_[ 0UL] = v1;
3979  v_[ MM] = v2;
3980  v_[2UL*MM] = v3;
3981  v_[3UL*MM] = v4;
3982  v_[4UL*MM] = v5;
3983  v_[5UL*MM] = v6;
3984  v_[6UL*MM] = v7;
3985  v_[7UL*MM] = v8;
3986  }
3987 
3988  if( IsVectorizable<Type>::value ) {
3989  for( size_t j=0UL; j<N; ++j )
3990  for( size_t i=M; i<MM; ++i ) {
3991  v_[i+j*MM] = Type();
3992  }
3993  }
3994 }
3996 //*************************************************************************************************
3997 
3998 
3999 //*************************************************************************************************
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, const Type& v9 )
4033  : v_() // The statically allocated matrix elements
4034 {
4035  BLAZE_STATIC_ASSERT( M*N == 9UL );
4036 
4037  // Initialization of a 9x1 matrix
4038  if( N == 1 ) {
4039  v_[0UL] = v1;
4040  v_[1UL] = v2;
4041  v_[2UL] = v3;
4042  v_[3UL] = v4;
4043  v_[4UL] = v5;
4044  v_[5UL] = v6;
4045  v_[6UL] = v7;
4046  v_[7UL] = v8;
4047  v_[8UL] = v9;
4048  }
4049 
4050  // Initialization of a 3x3 matrix
4051  else if( N == 3UL ) {
4052  v_[ 0UL] = v1;
4053  v_[ 1UL] = v2;
4054  v_[ 2UL] = v3;
4055  v_[ MM ] = v4;
4056  v_[ MM+1UL] = v5;
4057  v_[ MM+2UL] = v6;
4058  v_[2UL*MM ] = v7;
4059  v_[2UL*MM+1UL] = v8;
4060  v_[2UL*MM+2UL] = v9;
4061  }
4062 
4063  // Initialization of a 1x9 matrix
4064  else {
4065  v_[ 0UL] = v1;
4066  v_[ MM] = v2;
4067  v_[2UL*MM] = v3;
4068  v_[3UL*MM] = v4;
4069  v_[4UL*MM] = v5;
4070  v_[5UL*MM] = v6;
4071  v_[6UL*MM] = v7;
4072  v_[7UL*MM] = v8;
4073  v_[8UL*MM] = v9;
4074  }
4075 
4076  if( IsVectorizable<Type>::value ) {
4077  for( size_t j=0UL; j<N; ++j )
4078  for( size_t i=M; i<MM; ++i ) {
4079  v_[i+j*MM] = Type();
4080  }
4081  }
4082 }
4084 //*************************************************************************************************
4085 
4086 
4087 //*************************************************************************************************
4116 template< typename Type // Data type of the matrix
4117  , size_t M // Number of rows
4118  , size_t N > // Number of columns
4119 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4120  const Type& v4, const Type& v5, const Type& v6,
4121  const Type& v7, const Type& v8, const Type& v9,
4122  const Type& v10 )
4123  : v_() // The statically allocated matrix elements
4124 {
4125  BLAZE_STATIC_ASSERT( M*N == 10UL );
4126 
4127  // Initialization of a 10x1 matrix
4128  if( N == 1UL ) {
4129  v_[0UL] = v1;
4130  v_[1UL] = v2;
4131  v_[2UL] = v3;
4132  v_[3UL] = v4;
4133  v_[4UL] = v5;
4134  v_[5UL] = v6;
4135  v_[6UL] = v7;
4136  v_[7UL] = v8;
4137  v_[8UL] = v9;
4138  v_[9UL] = v10;
4139  }
4140 
4141  // Initialization of a 5x2 matrix
4142  else if( N == 2UL ) {
4143  v_[ 0UL] = v1;
4144  v_[ 1UL] = v2;
4145  v_[ 2UL] = v3;
4146  v_[ 3UL] = v4;
4147  v_[ 4UL] = v5;
4148  v_[MM ] = v6;
4149  v_[MM+1UL] = v7;
4150  v_[MM+2UL] = v8;
4151  v_[MM+3UL] = v9;
4152  v_[MM+4UL] = v10;
4153  }
4154 
4155  // Initialization of a 2x5 matrix
4156  else if( N == 5UL ) {
4157  v_[ 0UL] = v1;
4158  v_[ 1UL] = v2;
4159  v_[ MM ] = v3;
4160  v_[ MM+1UL] = v4;
4161  v_[2UL*MM ] = v5;
4162  v_[2UL*MM+1UL] = v6;
4163  v_[3UL*MM ] = v7;
4164  v_[3UL*MM+1UL] = v8;
4165  v_[4UL*MM ] = v9;
4166  v_[4UL*MM+1UL] = v10;
4167  }
4168 
4169  // Initialization of a 1x10 matrix
4170  else {
4171  v_[ 0UL] = v1;
4172  v_[ MM] = v2;
4173  v_[2UL*MM] = v3;
4174  v_[3UL*MM] = v4;
4175  v_[4UL*MM] = v5;
4176  v_[5UL*MM] = v6;
4177  v_[6UL*MM] = v7;
4178  v_[7UL*MM] = v8;
4179  v_[8UL*MM] = v9;
4180  v_[9UL*MM] = v10;
4181  }
4182 
4183  if( IsVectorizable<Type>::value ) {
4184  for( size_t j=0UL; j<N; ++j )
4185  for( size_t i=M; i<MM; ++i ) {
4186  v_[i+j*MM] = Type();
4187  }
4188  }
4189 }
4191 //*************************************************************************************************
4192 
4193 
4194 
4195 
4196 //=================================================================================================
4197 //
4198 // DATA ACCESS FUNCTIONS
4199 //
4200 //=================================================================================================
4201 
4202 //*************************************************************************************************
4210 template< typename Type // Data type of the matrix
4211  , size_t M // Number of rows
4212  , size_t N > // Number of columns
4214  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
4215 {
4216  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4217  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4218  return v_[i+j*MM];
4219 }
4221 //*************************************************************************************************
4222 
4223 
4224 //*************************************************************************************************
4232 template< typename Type // Data type of the matrix
4233  , size_t M // Number of rows
4234  , size_t N > // Number of columns
4236  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
4237 {
4238  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4239  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4240  return v_[i+j*MM];
4241 }
4243 //*************************************************************************************************
4244 
4245 
4246 //*************************************************************************************************
4258 template< typename Type // Data type of the matrix
4259  , size_t M // Number of rows
4260  , size_t N > // Number of columns
4261 inline typename StaticMatrix<Type,M,N,true>::Pointer
4263 {
4264  return v_;
4265 }
4267 //*************************************************************************************************
4268 
4269 
4270 //*************************************************************************************************
4282 template< typename Type // Data type of the matrix
4283  , size_t M // Number of rows
4284  , size_t N > // Number of columns
4285 inline typename StaticMatrix<Type,M,N,true>::ConstPointer
4287 {
4288  return v_;
4289 }
4291 //*************************************************************************************************
4292 
4293 
4294 //*************************************************************************************************
4303 template< typename Type // Data type of the matrix
4304  , size_t M // Number of rows
4305  , size_t N > // Number of columns
4306 inline typename StaticMatrix<Type,M,N,true>::Pointer
4308 {
4309  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4310  return v_ + j*MM;
4311 }
4313 //*************************************************************************************************
4314 
4315 
4316 //*************************************************************************************************
4325 template< typename Type // Data type of the matrix
4326  , size_t M // Number of rows
4327  , size_t N > // Number of columns
4328 inline typename StaticMatrix<Type,M,N,true>::ConstPointer
4329  StaticMatrix<Type,M,N,true>::data( size_t j ) const
4330 {
4331  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4332  return v_ + j*MM;
4333 }
4335 //*************************************************************************************************
4336 
4337 
4338 //*************************************************************************************************
4345 template< typename Type // Data type of the matrix
4346  , size_t M // Number of rows
4347  , size_t N > // Number of columns
4350 {
4351  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4352  return Iterator( v_ + j*MM );
4353 }
4355 //*************************************************************************************************
4356 
4357 
4358 //*************************************************************************************************
4365 template< typename Type // Data type of the matrix
4366  , size_t M // Number of rows
4367  , size_t N > // Number of columns
4369  StaticMatrix<Type,M,N,true>::begin( size_t j ) const
4370 {
4371  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4372  return ConstIterator( v_ + j*MM );
4373 }
4375 //*************************************************************************************************
4376 
4377 
4378 //*************************************************************************************************
4385 template< typename Type // Data type of the matrix
4386  , size_t M // Number of rows
4387  , size_t N > // Number of columns
4389  StaticMatrix<Type,M,N,true>::cbegin( size_t j ) const
4390 {
4391  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4392  return ConstIterator( v_ + j*MM );
4393 }
4395 //*************************************************************************************************
4396 
4397 
4398 //*************************************************************************************************
4405 template< typename Type // Data type of the matrix
4406  , size_t M // Number of rows
4407  , size_t N > // Number of columns
4410 {
4411  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4412  return Iterator( v_ + j*MM + M );
4413 }
4415 //*************************************************************************************************
4416 
4417 
4418 //*************************************************************************************************
4425 template< typename Type // Data type of the matrix
4426  , size_t M // Number of rows
4427  , size_t N > // Number of columns
4429  StaticMatrix<Type,M,N,true>::end( size_t j ) const
4430 {
4431  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4432  return ConstIterator( v_ + j*MM + M );
4433 }
4435 //*************************************************************************************************
4436 
4437 
4438 //*************************************************************************************************
4445 template< typename Type // Data type of the matrix
4446  , size_t M // Number of rows
4447  , size_t N > // Number of columns
4449  StaticMatrix<Type,M,N,true>::cend( size_t j ) const
4450 {
4451  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4452  return ConstIterator( v_ + j*MM + M );
4453 }
4455 //*************************************************************************************************
4456 
4457 
4458 
4459 
4460 //=================================================================================================
4461 //
4462 // ASSIGNMENT OPERATORS
4463 //
4464 //=================================================================================================
4465 
4466 //*************************************************************************************************
4488 template< typename Type // Data type of the matrix
4489  , size_t M // Number of rows
4490  , size_t N > // Number of columns
4491 template< typename Other > // Data type of the initialization array
4492 inline StaticMatrix<Type,M,N,true>&
4493  StaticMatrix<Type,M,N,true>::operator=( const Other (&array)[M][N] )
4494 {
4495  for( size_t j=0UL; j<N; ++j )
4496  for( size_t i=0UL; i<M; ++i )
4497  v_[i+j*MM] = array[i][j];
4498 
4499  return *this;
4500 }
4502 //*************************************************************************************************
4503 
4504 
4505 //*************************************************************************************************
4512 template< typename Type // Data type of the matrix
4513  , size_t M // Number of rows
4514  , size_t N > // Number of columns
4515 inline StaticMatrix<Type,M,N,true>&
4516  StaticMatrix<Type,M,N,true>::operator=( const Type& set )
4517 {
4518  for( size_t j=0UL; j<N; ++j )
4519  for( size_t i=0UL; i<M; ++i )
4520  v_[i+j*MM] = set;
4521 
4522  return *this;
4523 }
4525 //*************************************************************************************************
4526 
4527 
4528 //*************************************************************************************************
4537 template< typename Type // Data type of the matrix
4538  , size_t M // Number of rows
4539  , size_t N > // Number of columns
4540 inline StaticMatrix<Type,M,N,true>&
4541  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix& rhs )
4542 {
4543  using blaze::assign;
4544 
4545  assign( *this, ~rhs );
4546  return *this;
4547 }
4549 //*************************************************************************************************
4550 
4551 
4552 //*************************************************************************************************
4559 template< typename Type // Data type of the matrix
4560  , size_t M // Number of rows
4561  , size_t N > // Number of columns
4562 template< typename Other // Data type of the foreign matrix
4563  , bool SO > // Storage order of the foreign matrix
4564 inline StaticMatrix<Type,M,N,true>&
4565  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix<Other,M,N,SO>& rhs )
4566 {
4567  using blaze::assign;
4568 
4569  assign( *this, ~rhs );
4570  return *this;
4571 }
4573 //*************************************************************************************************
4574 
4575 
4576 //*************************************************************************************************
4588 template< typename Type // Data type of the matrix
4589  , size_t M // Number of rows
4590  , size_t N > // Number of columns
4591 template< typename MT // Type of the right-hand side matrix
4592  , bool SO > // Storage order of the right-hand side matrix
4593 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
4594 {
4595  using blaze::assign;
4596 
4597  if( (~rhs).rows() != M || (~rhs).columns() != N )
4598  throw std::invalid_argument( "Invalid assignment to static matrix" );
4599 
4600  if( (~rhs).canAlias( this ) ) {
4601  StaticMatrix tmp( ~rhs );
4602  swap( tmp );
4603  }
4604  else {
4605  if( IsSparseMatrix<MT>::value )
4606  reset();
4607  assign( *this, ~rhs );
4608  }
4609 
4610  return *this;
4611 }
4613 //*************************************************************************************************
4614 
4615 
4616 //*************************************************************************************************
4627 template< typename Type // Data type of the matrix
4628  , size_t M // Number of rows
4629  , size_t N > // Number of columns
4630 template< typename MT // Type of the right-hand side matrix
4631  , bool SO > // Storage order of the right-hand side matrix
4632 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
4633 {
4634  using blaze::addAssign;
4635 
4636  if( (~rhs).rows() != M || (~rhs).columns() != N )
4637  throw std::invalid_argument( "Matrix sizes do not match" );
4638 
4639  if( (~rhs).canAlias( this ) ) {
4640  typename MT::ResultType tmp( ~rhs );
4641  addAssign( *this, tmp );
4642  }
4643  else {
4644  addAssign( *this, ~rhs );
4645  }
4646 
4647  return *this;
4648 }
4650 //*************************************************************************************************
4651 
4652 
4653 //*************************************************************************************************
4664 template< typename Type // Data type of the matrix
4665  , size_t M // Number of rows
4666  , size_t N > // Number of columns
4667 template< typename MT // Type of the right-hand side matrix
4668  , bool SO > // Storage order of the right-hand side matrix
4669 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
4670 {
4671  using blaze::subAssign;
4672 
4673  if( (~rhs).rows() != M || (~rhs).columns() != N )
4674  throw std::invalid_argument( "Matrix sizes do not match" );
4675 
4676  if( (~rhs).canAlias( this ) ) {
4677  typename MT::ResultType tmp( ~rhs );
4678  subAssign( *this, tmp );
4679  }
4680  else {
4681  subAssign( *this, ~rhs );
4682  }
4683 
4684  return *this;
4685 }
4687 //*************************************************************************************************
4688 
4689 
4690 //*************************************************************************************************
4701 template< typename Type // Data type of the matrix
4702  , size_t M // Number of rows
4703  , size_t N > // Number of columns
4704 template< typename MT // Type of the right-hand side matrix
4705  , bool SO > // Storage order of the right-hand side matrix
4706 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
4707 {
4708  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
4709  throw std::invalid_argument( "Matrix sizes do not match" );
4710 
4711  StaticMatrix tmp( *this * (~rhs) );
4712  return this->operator=( tmp );
4713 }
4715 //*************************************************************************************************
4716 
4717 
4718 //*************************************************************************************************
4726 template< typename Type // Data type of the matrix
4727  , size_t M // Number of rows
4728  , size_t N > // Number of columns
4729 template< typename Other > // Data type of the right-hand side scalar
4730 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4731  StaticMatrix<Type,M,N,true>::operator*=( Other rhs )
4732 {
4733  using blaze::assign;
4734 
4735  assign( *this, (*this) * rhs );
4736  return *this;
4737 }
4739 //*************************************************************************************************
4740 
4741 
4742 //*************************************************************************************************
4752 template< typename Type // Data type of the matrix
4753  , size_t M // Number of rows
4754  , size_t N > // Number of columns
4755 template< typename Other > // Data type of the right-hand side scalar
4756 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4757  StaticMatrix<Type,M,N,true>::operator/=( Other rhs )
4758 {
4759  using blaze::assign;
4760 
4761  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4762 
4763  assign( *this, (*this) / rhs );
4764  return *this;
4765 }
4767 //*************************************************************************************************
4768 
4769 
4770 
4771 
4772 //=================================================================================================
4773 //
4774 // UTILITY FUNCTIONS
4775 //
4776 //=================================================================================================
4777 
4778 //*************************************************************************************************
4784 template< typename Type // Data type of the matrix
4785  , size_t M // Number of rows
4786  , size_t N > // Number of columns
4787 inline size_t StaticMatrix<Type,M,N,true>::rows() const
4788 {
4789  return M;
4790 }
4792 //*************************************************************************************************
4793 
4794 
4795 //*************************************************************************************************
4801 template< typename Type // Data type of the matrix
4802  , size_t M // Number of rows
4803  , size_t N > // Number of columns
4804 inline size_t StaticMatrix<Type,M,N,true>::columns() const
4805 {
4806  return N;
4807 }
4809 //*************************************************************************************************
4810 
4811 
4812 //*************************************************************************************************
4821 template< typename Type // Data type of the matrix
4822  , size_t M // Number of rows
4823  , size_t N > // Number of columns
4824 inline size_t StaticMatrix<Type,M,N,true>::spacing() const
4825 {
4826  return MM;
4827 }
4829 //*************************************************************************************************
4830 
4831 
4832 //*************************************************************************************************
4838 template< typename Type // Data type of the matrix
4839  , size_t M // Number of rows
4840  , size_t N > // Number of columns
4841 inline size_t StaticMatrix<Type,M,N,true>::capacity() const
4842 {
4843  return MM*N;
4844 }
4846 //*************************************************************************************************
4847 
4848 
4849 //*************************************************************************************************
4856 template< typename Type // Data type of the matrix
4857  , size_t M // Number of rows
4858  , size_t N > // Number of columns
4859 inline size_t StaticMatrix<Type,M,N,true>::capacity( size_t j ) const
4860 {
4861  UNUSED_PARAMETER( j );
4862 
4863  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4864 
4865  return MM;
4866 }
4868 //*************************************************************************************************
4869 
4870 
4871 //*************************************************************************************************
4877 template< typename Type // Data type of the matrix
4878  , size_t M // Number of rows
4879  , size_t N > // Number of columns
4880 inline size_t StaticMatrix<Type,M,N,true>::nonZeros() const
4881 {
4882  size_t nonzeros( 0UL );
4883 
4884  for( size_t j=0UL; j<N; ++j )
4885  for( size_t i=0UL; i<M; ++i )
4886  if( !isDefault( v_[i+j*MM] ) )
4887  ++nonzeros;
4888 
4889  return nonzeros;
4890 }
4892 //*************************************************************************************************
4893 
4894 
4895 //*************************************************************************************************
4902 template< typename Type // Data type of the matrix
4903  , size_t M // Number of rows
4904  , size_t N > // Number of columns
4905 inline size_t StaticMatrix<Type,M,N,true>::nonZeros( size_t j ) const
4906 {
4907  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4908 
4909  const size_t iend( (j+1UL)*MM );
4910  size_t nonzeros( 0UL );
4911 
4912  for( size_t i=j*MM; i<iend; ++i )
4913  if( !isDefault( v_[i] ) )
4914  ++nonzeros;
4915 
4916  return nonzeros;
4917 }
4919 //*************************************************************************************************
4920 
4921 
4922 //*************************************************************************************************
4928 template< typename Type // Data type of the matrix
4929  , size_t M // Number of rows
4930  , size_t N > // Number of columns
4932 {
4933  using blaze::reset;
4934 
4935  for( size_t j=0UL; j<N; ++j )
4936  for( size_t i=0UL; i<M; ++i )
4937  reset( v_[i+j*MM] );
4938 }
4940 //*************************************************************************************************
4941 
4942 
4943 //*************************************************************************************************
4953 template< typename Type // Data type of the matrix
4954  , size_t M // Number of rows
4955  , size_t N > // Number of columns
4956 inline void StaticMatrix<Type,M,N,true>::reset( size_t j )
4957 {
4958  using blaze::reset;
4959 
4960  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4961  for( size_t i=0UL; i<M; ++i )
4962  reset( v_[i+j*MM] );
4963 }
4965 //*************************************************************************************************
4966 
4967 
4968 //*************************************************************************************************
4977 template< typename Type // Data type of the matrix
4978  , size_t M // Number of rows
4979  , size_t N > // Number of columns
4980 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::transpose()
4981 {
4982  using std::swap;
4983 
4984  BLAZE_STATIC_ASSERT( M == N );
4985 
4986  for( size_t j=1UL; j<N; ++j )
4987  for( size_t i=0UL; i<j; ++i )
4988  swap( v_[i+j*MM], v_[j+i*MM] );
4989 
4990  return *this;
4991 }
4993 //*************************************************************************************************
4994 
4995 
4996 //*************************************************************************************************
5003 template< typename Type // Data type of the matrix
5004  , size_t M // Number of rows
5005  , size_t N > // Number of columns
5006 template< typename Other > // Data type of the scalar value
5007 inline StaticMatrix<Type,M,N,true>&
5008  StaticMatrix<Type,M,N,true>::scale( const Other& scalar )
5009 {
5010  for( size_t j=0UL; j<N; ++j )
5011  for( size_t i=0UL; i<M; ++i )
5012  v_[i+j*MM] *= scalar;
5013 
5014  return *this;
5015 }
5017 //*************************************************************************************************
5018 
5019 
5020 //*************************************************************************************************
5028 template< typename Type // Data type of the matrix
5029  , size_t M // Number of rows
5030  , size_t N > // Number of columns
5031 inline void StaticMatrix<Type,M,N,true>::swap( StaticMatrix& m ) /* throw() */
5032 {
5033  using std::swap;
5034 
5035  for( size_t j=0UL; j<N; ++j ) {
5036  for( size_t i=0UL; i<M; ++i ) {
5037  swap( v_[i+j*MM], m(i,j) );
5038  }
5039  }
5040 }
5042 //*************************************************************************************************
5043 
5044 
5045 
5046 
5047 //=================================================================================================
5048 //
5049 // MEMORY FUNCTIONS
5050 //
5051 //=================================================================================================
5052 
5053 //*************************************************************************************************
5064 template< typename Type // Data type of the matrix
5065  , size_t M // Number of rows
5066  , size_t N > // Number of columns
5067 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size )
5068 {
5069  UNUSED_PARAMETER( size );
5070 
5071  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5072 
5073  return allocate<StaticMatrix>( 1UL );
5074 }
5076 //*************************************************************************************************
5077 
5078 
5079 //*************************************************************************************************
5090 template< typename Type // Data type of the matrix
5091  , size_t M // Number of rows
5092  , size_t N > // Number of columns
5093 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size )
5094 {
5095  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5096  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5097 
5098  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5099 }
5101 //*************************************************************************************************
5102 
5103 
5104 //*************************************************************************************************
5115 template< typename Type // Data type of the matrix
5116  , size_t M // Number of rows
5117  , size_t N > // Number of columns
5118 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size, const std::nothrow_t& )
5119 {
5120  UNUSED_PARAMETER( size );
5121 
5122  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5123 
5124  return allocate<StaticMatrix>( 1UL );
5125 }
5127 //*************************************************************************************************
5128 
5129 
5130 //*************************************************************************************************
5141 template< typename Type // Data type of the matrix
5142  , size_t M // Number of rows
5143  , size_t N > // Number of columns
5144 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size, const std::nothrow_t& )
5145 {
5146  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5147  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5148 
5149  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5150 }
5152 //*************************************************************************************************
5153 
5154 
5155 //*************************************************************************************************
5162 template< typename Type // Data type of the matrix
5163  , size_t M // Number of rows
5164  , size_t N > // Number of columns
5165 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr )
5166 {
5167  deallocate( static_cast<StaticMatrix*>( ptr ) );
5168 }
5170 //*************************************************************************************************
5171 
5172 
5173 //*************************************************************************************************
5180 template< typename Type // Data type of the matrix
5181  , size_t M // Number of rows
5182  , size_t N > // Number of columns
5183 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr )
5184 {
5185  deallocate( static_cast<StaticMatrix*>( ptr ) );
5186 }
5188 //*************************************************************************************************
5189 
5190 
5191 //*************************************************************************************************
5198 template< typename Type // Data type of the matrix
5199  , size_t M // Number of rows
5200  , size_t N > // Number of columns
5201 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr, const std::nothrow_t& )
5202 {
5203  deallocate( static_cast<StaticMatrix*>( ptr ) );
5204 }
5206 //*************************************************************************************************
5207 
5208 
5209 //*************************************************************************************************
5216 template< typename Type // Data type of the matrix
5217  , size_t M // Number of rows
5218  , size_t N > // Number of columns
5219 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr, const std::nothrow_t& )
5220 {
5221  deallocate( static_cast<StaticMatrix*>( ptr ) );
5222 }
5224 //*************************************************************************************************
5225 
5226 
5227 
5228 
5229 //=================================================================================================
5230 //
5231 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5232 //
5233 //=================================================================================================
5234 
5235 //*************************************************************************************************
5246 template< typename Type // Data type of the matrix
5247  , size_t M // Number of rows
5248  , size_t N > // Number of columns
5249 template< typename Other > // Data type of the foreign expression
5250 inline bool StaticMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
5251 {
5252  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5253 }
5255 //*************************************************************************************************
5256 
5257 
5258 //*************************************************************************************************
5269 template< typename Type // Data type of the matrix
5270  , size_t M // Number of rows
5271  , size_t N > // Number of columns
5272 template< typename Other > // Data type of the foreign expression
5273 inline bool StaticMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
5274 {
5275  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5276 }
5278 //*************************************************************************************************
5279 
5280 
5281 //*************************************************************************************************
5291 template< typename Type // Data type of the matrix
5292  , size_t M // Number of rows
5293  , size_t N > // Number of columns
5294 inline bool StaticMatrix<Type,M,N,true>::isAligned() const
5295 {
5296  return true;
5297 }
5299 //*************************************************************************************************
5300 
5301 
5302 //*************************************************************************************************
5317 template< typename Type // Data type of the matrix
5318  , size_t M // Number of rows
5319  , size_t N > // Number of columns
5320 inline typename StaticMatrix<Type,M,N,true>::IntrinsicType
5321  StaticMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
5322 {
5323  using blaze::load;
5324 
5326 
5327  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5328  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5329  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5330  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5331 
5332  return load( &v_[i+j*MM] );
5333 }
5335 //*************************************************************************************************
5336 
5337 
5338 //*************************************************************************************************
5353 template< typename Type // Data type of the matrix
5354  , size_t M // Number of rows
5355  , size_t N > // Number of columns
5356 inline typename StaticMatrix<Type,M,N,true>::IntrinsicType
5357  StaticMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
5358 {
5359  using blaze::loadu;
5360 
5362 
5363  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5364  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5365  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5366 
5367  return loadu( &v_[i+j*MM] );
5368 }
5370 //*************************************************************************************************
5371 
5372 
5373 //*************************************************************************************************
5389 template< typename Type // Data type of the matrix
5390  , size_t M // Number of rows
5391  , size_t N > // Number of columns
5392 inline void StaticMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
5393 {
5394  using blaze::store;
5395 
5397 
5398  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5399  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5400  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5401  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5402 
5403  store( &v_[i+j*MM], value );
5404 }
5406 //*************************************************************************************************
5407 
5408 
5409 //*************************************************************************************************
5425 template< typename Type // Data type of the matrix
5426  , size_t M // Number of rows
5427  , size_t N > // Number of columns
5428 inline void StaticMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
5429 {
5430  using blaze::storeu;
5431 
5433 
5434  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5435  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
5436  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5437 
5438  storeu( &v_[i+j*MM], value );
5439 }
5441 //*************************************************************************************************
5442 
5443 
5444 //*************************************************************************************************
5461 template< typename Type // Data type of the matrix
5462  , size_t M // Number of rows
5463  , size_t N > // Number of columns
5464 inline void StaticMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
5465 {
5466  using blaze::stream;
5467 
5469 
5470  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5471  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5472  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5473  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5474 
5475  stream( &v_[i+j*MM], value );
5476 }
5478 //*************************************************************************************************
5479 
5480 
5481 //*************************************************************************************************
5493 template< typename Type // Data type of the matrix
5494  , size_t M // Number of rows
5495  , size_t N > // Number of columns
5496 template< typename MT // Type of the right-hand side dense matrix
5497  , bool SO > // Storage order of the right-hand side dense matrix
5498 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5499  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5500 {
5501  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5502 
5503  for( size_t j=0UL; j<N; ++j ) {
5504  for( size_t i=0UL; i<M; ++i ) {
5505  v_[i+j*MM] = (~rhs)(i,j);
5506  }
5507  }
5508 }
5510 //*************************************************************************************************
5511 
5512 
5513 //*************************************************************************************************
5525 template< typename Type // Data type of the matrix
5526  , size_t M // Number of rows
5527  , size_t N > // Number of columns
5528 template< typename MT // Type of the right-hand side dense matrix
5529  , bool SO > // Storage order of the right-hand side dense matrix
5530 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5531  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5532 {
5533  using blaze::store;
5534 
5535  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5536 
5538 
5539  for( size_t j=0UL; j<N; ++j ) {
5540  for( size_t i=0UL; i<M; i+=IT::size ) {
5541  store( &v_[i+j*MM], (~rhs).load(i,j) );
5542  }
5543  }
5544 }
5546 //*************************************************************************************************
5547 
5548 
5549 //*************************************************************************************************
5561 template< typename Type // Data type of the matrix
5562  , size_t M // Number of rows
5563  , size_t N > // Number of columns
5564 template< typename MT > // Type of the right-hand side sparse matrix
5565 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
5566 {
5567  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5568 
5569  typedef typename MT::ConstIterator RhsConstIterator;
5570 
5571  for( size_t j=0UL; j<N; ++j )
5572  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5573  v_[element->index()+j*MM] = element->value();
5574 }
5576 //*************************************************************************************************
5577 
5578 
5579 //*************************************************************************************************
5591 template< typename Type // Data type of the matrix
5592  , size_t M // Number of rows
5593  , size_t N > // Number of columns
5594 template< typename MT > // Type of the right-hand side sparse matrix
5595 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
5596 {
5597  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5598 
5599  typedef typename MT::ConstIterator RhsConstIterator;
5600 
5601  for( size_t i=0UL; i<M; ++i )
5602  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5603  v_[i+element->index()*MM] = element->value();
5604 }
5606 //*************************************************************************************************
5607 
5608 
5609 //*************************************************************************************************
5621 template< typename Type // Data type of the matrix
5622  , size_t M // Number of rows
5623  , size_t N > // Number of columns
5624 template< typename MT // Type of the right-hand side dense matrix
5625  , bool SO > // Storage order of the right-hand side dense matrix
5626 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5627  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5628 {
5629  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5630 
5631  for( size_t j=0UL; j<N; ++j ) {
5632  for( size_t i=0UL; i<M; ++i ) {
5633  v_[i+j*MM] += (~rhs)(i,j);
5634  }
5635  }
5636 }
5638 //*************************************************************************************************
5639 
5640 
5641 //*************************************************************************************************
5653 template< typename Type // Data type of the matrix
5654  , size_t M // Number of rows
5655  , size_t N > // Number of columns
5656 template< typename MT // Type of the right-hand side dense matrix
5657  , bool SO > // Storage order of the right-hand side dense matrix
5658 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5659  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5660 {
5661  using blaze::load;
5662  using blaze::store;
5663 
5664  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5665 
5667 
5668  for( size_t j=0UL; j<N; ++j ) {
5669  for( size_t i=0UL; i<M; i+=IT::size ) {
5670  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
5671  }
5672  }
5673 }
5675 //*************************************************************************************************
5676 
5677 
5678 //*************************************************************************************************
5690 template< typename Type // Data type of the matrix
5691  , size_t M // Number of rows
5692  , size_t N > // Number of columns
5693 template< typename MT > // Type of the right-hand side sparse matrix
5694 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
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 j=0UL; j<N; ++j )
5701  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5702  v_[element->index()+j*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 sparse matrix
5724 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
5725 {
5726  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5727 
5728  typedef typename MT::ConstIterator RhsConstIterator;
5729 
5730  for( size_t i=0UL; i<M; ++i )
5731  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5732  v_[i+element->index()*MM] += element->value();
5733 }
5735 //*************************************************************************************************
5736 
5737 
5738 //*************************************************************************************************
5750 template< typename Type // Data type of the matrix
5751  , size_t M // Number of rows
5752  , size_t N > // Number of columns
5753 template< typename MT // Type of the right-hand side dense matrix
5754  , bool SO > // Storage order of the right-hand side dense matrix
5755 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5756  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5757 {
5758  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5759 
5760  for( size_t j=0UL; j<N; ++j ) {
5761  for( size_t i=0UL; i<M; ++i ) {
5762  v_[i+j*MM] -= (~rhs)(i,j);
5763  }
5764  }
5765 }
5767 //*************************************************************************************************
5768 
5769 
5770 //*************************************************************************************************
5782 template< typename Type // Data type of the matrix
5783  , size_t M // Number of rows
5784  , size_t N > // Number of columns
5785 template< typename MT // Type of the right-hand side dense matrix
5786  , bool SO > // Storage order of the right-hand side dense matrix
5787 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5788  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5789 {
5790  using blaze::load;
5791  using blaze::store;
5792 
5793  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5794 
5796 
5797  for( size_t j=0UL; j<N; ++j ) {
5798  for( size_t i=0UL; i<M; i+=IT::size ) {
5799  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
5800  }
5801  }
5802 }
5804 //*************************************************************************************************
5805 
5806 
5807 //*************************************************************************************************
5819 template< typename Type // Data type of the matrix
5820  , size_t M // Number of rows
5821  , size_t N > // Number of columns
5822 template< typename MT > // Type of the right-hand side sparse matrix
5823 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
5824 {
5825  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5826 
5827  typedef typename MT::ConstIterator RhsConstIterator;
5828 
5829  for( size_t j=0UL; j<N; ++j )
5830  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5831  v_[element->index()+j*MM] -= element->value();
5832 }
5834 //*************************************************************************************************
5835 
5836 
5837 //*************************************************************************************************
5849 template< typename Type // Data type of the matrix
5850  , size_t M // Number of rows
5851  , size_t N > // Number of columns
5852 template< typename MT > // Type of the right-hand side sparse matrix
5853 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
5854 {
5855  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5856 
5857  typedef typename MT::ConstIterator RhsConstIterator;
5858 
5859  for( size_t i=0UL; i<M; ++i )
5860  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5861  v_[i+element->index()*MM] -= element->value();
5862 }
5864 //*************************************************************************************************
5865 
5866 
5867 
5868 
5869 
5870 
5871 
5872 
5873 //=================================================================================================
5874 //
5875 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
5876 //
5877 //=================================================================================================
5878 
5879 //*************************************************************************************************
5887 template< typename Type // Data type of the matrix
5888  , size_t M // Number of rows
5889  , bool SO > // Storage order
5890 class StaticMatrix<Type,M,0UL,SO>;
5892 //*************************************************************************************************
5893 
5894 
5895 //*************************************************************************************************
5903 template< typename Type // Data type of the matrix
5904  , size_t N // Number of columns
5905  , bool SO > // Storage order
5906 class StaticMatrix<Type,0UL,N,SO>;
5908 //*************************************************************************************************
5909 
5910 
5911 //*************************************************************************************************
5919 template< typename Type // Data type of the matrix
5920  , bool SO > // Storage order
5921 class StaticMatrix<Type,0UL,0UL,SO>;
5923 //*************************************************************************************************
5924 
5925 
5926 
5927 
5928 
5929 
5930 
5931 
5932 //=================================================================================================
5933 //
5934 // STATICMATRIX OPERATORS
5935 //
5936 //=================================================================================================
5937 
5938 //*************************************************************************************************
5941 template< typename Type, size_t M, size_t N, bool SO >
5942 inline void reset( StaticMatrix<Type,M,N,SO>& m );
5943 
5944 template< typename Type, size_t M, size_t N, bool SO >
5945 inline void clear( StaticMatrix<Type,M,N,SO>& m );
5946 
5947 template< typename Type, size_t M, size_t N, bool SO >
5948 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m );
5949 
5950 template< typename Type, size_t M, size_t N, bool SO >
5951 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */;
5953 //*************************************************************************************************
5954 
5955 
5956 //*************************************************************************************************
5963 template< typename Type // Data type of the matrix
5964  , size_t M // Number of rows
5965  , size_t N // Number of columns
5966  , bool SO > // Storage order
5968 {
5969  m.reset();
5970 }
5971 //*************************************************************************************************
5972 
5973 
5974 //*************************************************************************************************
5983 template< typename Type // Data type of the matrix
5984  , size_t M // Number of rows
5985  , size_t N // Number of columns
5986  , bool SO > // Storage order
5988 {
5989  m.reset();
5990 }
5991 //*************************************************************************************************
5992 
5993 
5994 //*************************************************************************************************
6001 template< typename Type // Data type of the matrix
6002  , size_t M // Number of rows
6003  , size_t N // Number of columns
6004  , bool SO > // Storage order
6005 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m )
6006 {
6007  if( SO == rowMajor ) {
6008  for( size_t i=0UL; i<M; ++i )
6009  for( size_t j=0UL; j<N; ++j )
6010  if( !isDefault( m(i,j) ) ) return false;
6011  }
6012  else {
6013  for( size_t j=0UL; j<N; ++j )
6014  for( size_t i=0UL; i<M; ++i )
6015  if( !isDefault( m(i,j) ) ) return false;
6016  }
6017 
6018  return true;
6019 }
6020 //*************************************************************************************************
6021 
6022 
6023 //*************************************************************************************************
6032 template< typename Type // Data type of the matrix
6033  , size_t M // Number of rows
6034  , size_t N // Number of columns
6035  , bool SO > // Storage order
6036 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */
6037 {
6038  a.swap( b );
6039 }
6040 //*************************************************************************************************
6041 
6042 
6043 
6044 
6045 //=================================================================================================
6046 //
6047 // ADDTRAIT SPECIALIZATIONS
6048 //
6049 //=================================================================================================
6050 
6051 //*************************************************************************************************
6053 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6054 struct AddTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6055 {
6056  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
6057 };
6058 
6059 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
6060 struct AddTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
6061 {
6062  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
6063 };
6065 //*************************************************************************************************
6066 
6067 
6068 
6069 
6070 //=================================================================================================
6071 //
6072 // SUBTRAIT SPECIALIZATIONS
6073 //
6074 //=================================================================================================
6075 
6076 //*************************************************************************************************
6078 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6079 struct SubTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6080 {
6081  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
6082 };
6083 
6084 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
6085 struct SubTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
6086 {
6087  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
6088 };
6090 //*************************************************************************************************
6091 
6092 
6093 
6094 
6095 //=================================================================================================
6096 //
6097 // MULTTRAIT SPECIALIZATIONS
6098 //
6099 //=================================================================================================
6100 
6101 //*************************************************************************************************
6103 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6104 struct MultTrait< StaticMatrix<T1,M,N,SO>, T2 >
6105 {
6106  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
6108 };
6109 
6110 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6111 struct MultTrait< T1, StaticMatrix<T2,M,N,SO> >
6112 {
6113  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
6115 };
6116 
6117 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6118 struct MultTrait< StaticMatrix<T1,M,N,SO>, StaticVector<T2,N,false> >
6119 {
6120  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6121 };
6122 
6123 template< typename T1, size_t M, typename T2, size_t N, bool SO >
6124 struct MultTrait< StaticVector<T1,M,true>, StaticMatrix<T2,M,N,SO> >
6125 {
6126  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6127 };
6128 
6129 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t L >
6130 struct MultTrait< StaticMatrix<T1,M,N,SO>, HybridVector<T2,L,false> >
6131 {
6132  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6133 };
6134 
6135 template< typename T1, size_t L, typename T2, size_t M, size_t N, bool SO >
6136 struct MultTrait< HybridVector<T1,L,true>, StaticMatrix<T2,M,N,SO> >
6137 {
6138  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6139 };
6140 
6141 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6142 struct MultTrait< StaticMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
6143 {
6144  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6145 };
6146 
6147 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6148 struct MultTrait< DynamicVector<T1,true>, StaticMatrix<T2,M,N,SO> >
6149 {
6150  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6151 };
6152 
6153 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6154 struct MultTrait< StaticMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
6155 {
6156  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
6157 };
6158 
6159 template< typename T1, typename T2, size_t M, size_t N, bool SO >
6160 struct MultTrait< CompressedVector<T1,true>, StaticMatrix<T2,M,N,SO> >
6161 {
6162  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
6163 };
6164 
6165 template< typename T1, size_t M, size_t K, bool SO1, typename T2, size_t N, bool SO2 >
6166 struct MultTrait< StaticMatrix<T1,M,K,SO1>, StaticMatrix<T2,K,N,SO2> >
6167 {
6168  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO1 > Type;
6169 };
6171 //*************************************************************************************************
6172 
6173 
6174 
6175 
6176 //=================================================================================================
6177 //
6178 // DIVTRAIT SPECIALIZATIONS
6179 //
6180 //=================================================================================================
6181 
6182 //*************************************************************************************************
6184 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6185 struct DivTrait< StaticMatrix<T1,M,N,SO>, T2 >
6186 {
6187  typedef StaticMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
6189 };
6191 //*************************************************************************************************
6192 
6193 
6194 
6195 
6196 //=================================================================================================
6197 //
6198 // MATHTRAIT SPECIALIZATIONS
6199 //
6200 //=================================================================================================
6201 
6202 //*************************************************************************************************
6204 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
6205 struct MathTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
6206 {
6207  typedef StaticMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
6208  typedef StaticMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
6209 };
6211 //*************************************************************************************************
6212 
6213 
6214 
6215 
6216 //=================================================================================================
6217 //
6218 // SUBMATRIXTRAIT SPECIALIZATIONS
6219 //
6220 //=================================================================================================
6221 
6222 //*************************************************************************************************
6224 template< typename T1, size_t M, size_t N, bool SO >
6225 struct SubmatrixTrait< StaticMatrix<T1,M,N,SO> >
6226 {
6227  typedef HybridMatrix<T1,M,N,SO> Type;
6228 };
6230 //*************************************************************************************************
6231 
6232 
6233 
6234 
6235 //=================================================================================================
6236 //
6237 // ROWTRAIT SPECIALIZATIONS
6238 //
6239 //=================================================================================================
6240 
6241 //*************************************************************************************************
6243 template< typename T1, size_t M, size_t N, bool SO >
6244 struct RowTrait< StaticMatrix<T1,M,N,SO> >
6245 {
6246  typedef StaticVector<T1,N,true> Type;
6247 };
6249 //*************************************************************************************************
6250 
6251 
6252 
6253 
6254 //=================================================================================================
6255 //
6256 // COLUMNTRAIT SPECIALIZATIONS
6257 //
6258 //=================================================================================================
6259 
6260 //*************************************************************************************************
6262 template< typename T1, size_t M, size_t N, bool SO >
6263 struct ColumnTrait< StaticMatrix<T1,M,N,SO> >
6264 {
6265  typedef StaticVector<T1,M,false> Type;
6266 };
6268 //*************************************************************************************************
6269 
6270 } // namespace blaze
6271 
6272 #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
This ResultType
Result type for expression template evaluations.
Definition: StaticMatrix.h:196
Constraint on the data type.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: StaticMatrix.h:2040
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
Header file for the row trait.
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: StaticMatrix.h:2401
Header file for the IsSparseMatrix type trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
const Type & ConstReference
Reference to a constant matrix value.
Definition: StaticMatrix.h:204
StaticMatrix()
The default constructor for StaticMatrix.
Definition: StaticMatrix.h:472
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2577
Header file for the IsColumnMajorMatrix type trait.
StaticMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: StaticMatrix.h:198
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
Type ElementType
Type of the matrix elements.
Definition: StaticMatrix.h:199
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: StaticMatrix.h:428
#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
Type * Pointer
Pointer to a non-constant matrix value.
Definition: StaticMatrix.h:205
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1575
Header file for memory allocation and deallocation functionality.
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: StaticMatrix.h:206
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: StaticMatrix.h:2443
Header file for the SparseMatrix base class.
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:115
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1623
Header file for the DisableIf class template.
StaticMatrix & transpose()
Transposing the matrix.
Definition: StaticMatrix.h:2143
void swap(StaticMatrix &m)
Swapping the contents of two static matrices.
Definition: StaticMatrix.h:2191
Header file for the multiplication trait.
Header file for nested template disabiguation.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4605
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticMatrix.h:207
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
#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
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:51
Header file for the DenseMatrix base class.
Header file for the DenseIterator class template.
void reset()
Reset to the default initial values.
Definition: StaticMatrix.h:2094
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
Constraint on the data type.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: StaticMatrix.h:1963
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2506
const This & CompositeType
Data type for composite expression templates.
Definition: StaticMatrix.h:202
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:1998
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
Header file for the EnableIf class template.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: StaticMatrix.h:2423
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1551
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1503
Header file for the equal shim.
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: StaticMatrix.h:1367
Header file for the IsVectorizable type trait.
StaticMatrix< Type, M, N, SO > This
Type of this StaticMatrix instance.
Definition: StaticMatrix.h:195
Header file for the IsNumeric type trait.
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: StaticMatrix.h:185
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: StaticMatrix.h:200
EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
Pointer data()
Low-level data access to the matrix elements.
Definition: StaticMatrix.h:1414
Header file for the addition trait.
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4671
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
Header file for the submatrix trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Header file for the reset shim.
Header file for the AlignedArray implementation.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
Header file for the column trait.
Header file for the isDefault shim.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2541
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.
Header file for the IsRowMajorMatrix type trait.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: StaticMatrix.h:1982
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:1947
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticMatrix.h:201
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticMatrix.h:208
Type & Reference
Reference to a non-constant matrix value.
Definition: StaticMatrix.h:203
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
Header file for basic type definitions.
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:2409
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:2612
#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
StaticMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: StaticMatrix.h:197
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:154
#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
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2470
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209