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>
78 #include <blaze/util/Template.h>
79 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS DEFINITION
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
175 template< typename Type // Data type of the matrix
176  , size_t M // Number of rows
177  , size_t N // Number of columns
178  , bool SO = defaultStorageOrder > // Storage order
179 class StaticMatrix : public DenseMatrix< StaticMatrix<Type,M,N,SO>, SO >
180 {
181  private:
182  //**Type definitions****************************************************************************
184  //**********************************************************************************************
185 
186  //**********************************************************************************************
188  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
189  //**********************************************************************************************
190 
191  public:
192  //**Type definitions****************************************************************************
194  typedef This ResultType;
197  typedef Type ElementType;
198  typedef typename IT::Type IntrinsicType;
199  typedef const Type& ReturnType;
200  typedef const This& CompositeType;
201  typedef Type& Reference;
202  typedef const Type& ConstReference;
205  //**********************************************************************************************
206 
207  //**Compilation flags***************************************************************************
209 
213  enum { vectorizable = IsVectorizable<Type>::value };
214  //**********************************************************************************************
215 
216  //**Constructors********************************************************************************
219  explicit inline StaticMatrix();
220  explicit inline StaticMatrix( const Type& init );
221 
222  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
223  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
224 
225  inline StaticMatrix( const StaticMatrix& m );
226  template< typename Other, bool SO2 > inline StaticMatrix( const StaticMatrix<Other,M,N,SO2>& m );
227  template< typename MT , bool SO2 > inline StaticMatrix( const Matrix<MT,SO2>& m );
228 
229  inline StaticMatrix( const Type& v1, const Type& v2 );
230  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
231  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
232  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
233  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
234  const Type& v6 );
235  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
236  const Type& v6, const Type& v7 );
237  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
238  const Type& v6, const Type& v7, const Type& v8 );
239  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
240  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
241  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
242  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
244  //**********************************************************************************************
245 
246  //**Destructor**********************************************************************************
247  // No explicitly declared destructor.
248  //**********************************************************************************************
249 
250  //**Data access functions***********************************************************************
253  inline Reference operator()( size_t i, size_t j );
254  inline ConstReference operator()( size_t i, size_t j ) const;
255  inline Type* data ();
256  inline const Type* data () const;
257  inline Type* data ( size_t i );
258  inline const Type* data ( size_t i ) const;
259  inline Iterator begin ( size_t i );
260  inline ConstIterator begin ( size_t i ) const;
261  inline ConstIterator cbegin( size_t i ) const;
262  inline Iterator end ( size_t i );
263  inline ConstIterator end ( size_t i ) const;
264  inline ConstIterator cend ( size_t i ) const;
266  //**********************************************************************************************
267 
268  //**Assignment operators************************************************************************
271  template< typename Other >
272  inline StaticMatrix& operator=( const Other (&array)[M][N] );
273 
274  inline StaticMatrix& operator= ( const Type& set );
275  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
276  template< typename Other, bool SO2 > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO2>& rhs );
277  template< typename MT , bool SO2 > inline StaticMatrix& operator= ( const Matrix<MT,SO2>& rhs );
278  template< typename MT , bool SO2 > inline StaticMatrix& operator+=( const Matrix<MT,SO2>& rhs );
279  template< typename MT , bool SO2 > inline StaticMatrix& operator-=( const Matrix<MT,SO2>& rhs );
280  template< typename MT , bool SO2 > inline StaticMatrix& operator*=( const Matrix<MT,SO2>& rhs );
281 
282  template< typename Other >
283  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
284  operator*=( Other rhs );
285 
286  template< typename Other >
287  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
288  operator/=( Other rhs );
290  //**********************************************************************************************
291 
292  //**Utility functions***************************************************************************
295  inline size_t rows() const;
296  inline size_t columns() const;
297  inline size_t spacing() const;
298  inline size_t capacity() const;
299  inline size_t capacity( size_t i ) const;
300  inline size_t nonZeros() const;
301  inline size_t nonZeros( size_t i ) const;
302  inline void reset();
303  inline void reset( size_t i );
304  inline StaticMatrix& transpose();
305  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
306  inline void swap( StaticMatrix& m ) /* throw() */;
308  //**********************************************************************************************
309 
310  private:
311  //**********************************************************************************************
313  template< typename MT >
315  struct VectorizedAssign {
316  enum { value = vectorizable && MT::vectorizable &&
319  };
321  //**********************************************************************************************
322 
323  //**********************************************************************************************
325  template< typename MT >
327  struct VectorizedAddAssign {
328  enum { value = vectorizable && MT::vectorizable &&
329  IsSame<Type,typename MT::ElementType>::value &&
330  IntrinsicTrait<Type>::addition &&
331  IsRowMajorMatrix<MT>::value };
332  };
334  //**********************************************************************************************
335 
336  //**********************************************************************************************
338  template< typename MT >
340  struct VectorizedSubAssign {
341  enum { value = vectorizable && MT::vectorizable &&
342  IsSame<Type,typename MT::ElementType>::value &&
343  IntrinsicTrait<Type>::subtraction &&
344  IsRowMajorMatrix<MT>::value };
345  };
347  //**********************************************************************************************
348 
349  public:
350  //**Expression template evaluation functions****************************************************
353  template< typename Other > inline bool canAlias ( const Other* alias ) const;
354  template< typename Other > inline bool isAliased( const Other* alias ) const;
355 
356  inline IntrinsicType load ( size_t i, size_t j ) const;
357  inline IntrinsicType loadu ( size_t i, size_t j ) const;
358  inline void store ( size_t i, size_t j, const IntrinsicType& value );
359  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
360  inline void stream( size_t i, size_t j, const IntrinsicType& value );
361 
362  template< typename MT, bool SO2 >
363  inline typename DisableIf< VectorizedAssign<MT> >::Type
364  assign( const DenseMatrix<MT,SO2>& rhs );
365 
366  template< typename MT, bool SO2 >
367  inline typename EnableIf< VectorizedAssign<MT> >::Type
368  assign( const DenseMatrix<MT,SO2>& rhs );
369 
370  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
371  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
372 
373  template< typename MT, bool SO2 >
374  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
375  addAssign( const DenseMatrix<MT,SO2>& rhs );
376 
377  template< typename MT, bool SO2 >
378  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
379  addAssign( const DenseMatrix<MT,SO2>& rhs );
380 
381  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
382  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
383 
384  template< typename MT, bool SO2 >
385  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
386  subAssign( const DenseMatrix<MT,SO2>& rhs );
387 
388  template< typename MT, bool SO2 >
389  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
390  subAssign( const DenseMatrix<MT,SO2>& rhs );
391 
392  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
393  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
395  //**********************************************************************************************
396 
397  private:
398  //**Member variables****************************************************************************
402 
412  //**********************************************************************************************
413 
414  //**Compile time checks*************************************************************************
420  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
421  BLAZE_STATIC_ASSERT( NN >= N );
423  //**********************************************************************************************
424 };
425 //*************************************************************************************************
426 
427 
428 
429 
430 //=================================================================================================
431 //
432 // CONSTRUCTORS
433 //
434 //=================================================================================================
435 
436 //*************************************************************************************************
441 template< typename Type // Data type of the matrix
442  , size_t M // Number of rows
443  , size_t N // Number of columns
444  , bool SO > // Storage order
446 {
447  if( IsNumeric<Type>::value ) {
448  for( size_t i=0UL; i<M*NN; ++i )
449  v_[i] = Type();
450  }
451 }
452 //*************************************************************************************************
453 
454 
455 //*************************************************************************************************
460 template< typename Type // Data type of the matrix
461  , size_t M // Number of rows
462  , size_t N // Number of columns
463  , bool SO > // Storage order
464 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& init )
465 {
466  for( size_t i=0UL; i<M; ++i ) {
467  for( size_t j=0UL; j<N; ++j )
468  v_[i*NN+j] = init;
469 
470  if( IsNumeric<Type>::value ) {
471  for( size_t j=N; j<NN; ++j )
472  v_[i*NN+j] = Type();
473  }
474  }
475 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
505 template< typename Type // Data type of the matrix
506  , size_t M // Number of rows
507  , size_t N // Number of columns
508  , bool SO > // Storage order
509 template< typename Other > // Data type of the initialization array
510 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( size_t m, size_t n, const Other* array )
511 {
512  if( m > M || n > N )
513  throw std::invalid_argument( "Invalid setup of static matrix" );
514 
515  for( size_t i=0UL; i<m; ++i ) {
516  for( size_t j=0UL; j<n; ++j )
517  v_[i*NN+j] = array[i*n+j];
518 
519  if( IsNumeric<Type>::value ) {
520  for( size_t j=n; j<NN; ++j )
521  v_[i*NN+j] = Type();
522  }
523  }
524 
525  for( size_t i=m; i<M; ++i ) {
526  for( size_t j=0UL; j<NN; ++j )
527  v_[i*NN+j] = Type();
528  }
529 }
530 //*************************************************************************************************
531 
532 
533 //*************************************************************************************************
553 template< typename Type // Data type of the matrix
554  , size_t M // Number of rows
555  , size_t N // Number of columns
556  , bool SO > // Storage order
557 template< typename Other > // Data type of the initialization array
558 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Other (&array)[M][N] )
559 {
560  for( size_t i=0UL; i<M; ++i ) {
561  for( size_t j=0UL; j<N; ++j )
562  v_[i*NN+j] = array[i][j];
563 
564  if( IsNumeric<Type>::value ) {
565  for( size_t j=N; j<NN; ++j )
566  v_[i*NN+j] = Type();
567  }
568  }
569 }
570 //*************************************************************************************************
571 
572 
573 //*************************************************************************************************
580 template< typename Type // Data type of the matrix
581  , size_t M // Number of rows
582  , size_t N // Number of columns
583  , bool SO > // Storage order
585 {
586  for( size_t i=0UL; i<M*NN; ++i )
587  v_[i] = m.v_[i];
588 }
589 //*************************************************************************************************
590 
591 
592 //*************************************************************************************************
597 template< typename Type // Data type of the matrix
598  , size_t M // Number of rows
599  , size_t N // Number of columns
600  , bool SO > // Storage order
601 template< typename Other // Data type of the foreign matrix
602  , bool SO2 > // Storage order of the foreign matrix
604 {
605  for( size_t i=0UL; i<M; ++i ) {
606  for( size_t j=0UL; j<N; ++j )
607  v_[i*NN+j] = m(i,j);
608 
609  if( IsNumeric<Type>::value ) {
610  for( size_t j=N; j<NN; ++j )
611  v_[i*NN+j] = Type();
612  }
613  }
614 }
615 //*************************************************************************************************
616 
617 
618 //*************************************************************************************************
628 template< typename Type // Data type of the matrix
629  , size_t M // Number of rows
630  , size_t N // Number of columns
631  , bool SO > // Storage order
632 template< typename MT // Type of the foreign matrix
633  , bool SO2 > // Storage order of the foreign matrix
635 {
636  using blaze::assign;
637 
638  if( (~m).rows() != M || (~m).columns() != N )
639  throw std::invalid_argument( "Invalid setup of static matrix" );
640 
641  if( IsNumeric<Type>::value ) {
642  for( size_t i=0UL; i<M; ++i ) {
643  for( size_t j=( IsSparseMatrix<MT>::value )?( 0UL ):( N ); j<NN; ++j )
644  v_[i*NN+j] = Type();
645  }
646  }
647 
648  assign( *this, ~m );
649 }
650 //*************************************************************************************************
651 
652 
653 //*************************************************************************************************
670 template< typename Type // Data type of the matrix
671  , size_t M // Number of rows
672  , size_t N // Number of columns
673  , bool SO > // Storage order
674 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2 )
675 {
676  BLAZE_STATIC_ASSERT( M*N == 2UL );
677 
678  // Initialization of a 1x2 matrix
679  if( M == 1UL ) {
680  v_[0UL] = v1;
681  v_[1UL] = v2;
682  }
683 
684  // Initialization of a 2x1 matrix
685  else {
686  v_[0UL] = v1;
687  v_[ NN] = v2;
688  }
689 
690  if( IsNumeric<Type>::value ) {
691  for( size_t i=0UL; i<M; ++i ) {
692  for( size_t j=N; j<NN; ++j )
693  v_[i*NN+j] = Type();
694  }
695  }
696 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
718 template< typename Type // Data type of the matrix
719  , size_t M // Number of rows
720  , size_t N // Number of columns
721  , bool SO > // Storage order
722 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
723 {
724  BLAZE_STATIC_ASSERT( M*N == 3UL );
725 
726  // Initialization of a 1x3 matrix
727  if( M == 1UL ) {
728  v_[0UL] = v1;
729  v_[1UL] = v2;
730  v_[2UL] = v3;
731  }
732 
733  // Initialization of a 3x1 matrix
734  else {
735  v_[ 0UL] = v1;
736  v_[ NN] = v2;
737  v_[2UL*NN] = v3;
738  }
739 
740  if( IsNumeric<Type>::value ) {
741  for( size_t i=0UL; i<M; ++i ) {
742  for( size_t j=N; j<NN; ++j )
743  v_[i*NN+j] = Type();
744  }
745  }
746 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
771 template< typename Type // Data type of the matrix
772  , size_t M // Number of rows
773  , size_t N // Number of columns
774  , bool SO > // Storage order
775 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2,
776  const Type& v3, const Type& v4 )
777 {
778  BLAZE_STATIC_ASSERT( M*N == 4UL );
779 
780  // Initialization of a 1x4 matrix
781  if( M == 1UL ) {
782  v_[0UL] = v1;
783  v_[1UL] = v2;
784  v_[2UL] = v3;
785  v_[3UL] = v4;
786  }
787 
788  // Initialization of a 2x2 matrix
789  else if( M == 2UL ) {
790  v_[ 0UL] = v1;
791  v_[ 1UL] = v2;
792  v_[NN ] = v3;
793  v_[NN+1UL] = v4;
794  }
795 
796  // Initialization of a 4x1 matrix
797  else {
798  v_[ 0UL] = v1;
799  v_[ NN] = v2;
800  v_[2UL*NN] = v3;
801  v_[3UL*NN] = v4;
802  }
803 
804  if( IsNumeric<Type>::value ) {
805  for( size_t i=0UL; i<M; ++i ) {
806  for( size_t j=N; j<NN; ++j )
807  v_[i*NN+j] = Type();
808  }
809  }
810 }
811 //*************************************************************************************************
812 
813 
814 //*************************************************************************************************
834 template< typename Type // Data type of the matrix
835  , size_t M // Number of rows
836  , size_t N // Number of columns
837  , bool SO > // Storage order
838 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
839  const Type& v4, const Type& v5 )
840 {
841  BLAZE_STATIC_ASSERT( M*N == 5UL );
842 
843  // Initialization of a 1x5 matrix
844  if( M == 1UL ) {
845  v_[0UL] = v1;
846  v_[1UL] = v2;
847  v_[2UL] = v3;
848  v_[3UL] = v4;
849  v_[4UL] = v5;
850  }
851 
852  // Initialization of a 5x1 matrix
853  else {
854  v_[ 0UL] = v1;
855  v_[ NN] = v2;
856  v_[2UL*NN] = v3;
857  v_[3UL*NN] = v4;
858  v_[4UL*NN] = v5;
859  }
860 
861  if( IsNumeric<Type>::value ) {
862  for( size_t i=0UL; i<M; ++i ) {
863  for( size_t j=N; j<NN; ++j )
864  v_[i*NN+j] = Type();
865  }
866  }
867 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
895 template< typename Type // Data type of the matrix
896  , size_t M // Number of rows
897  , size_t N // Number of columns
898  , bool SO > // Storage order
899 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
900  const Type& v4, const Type& v5, const Type& v6 )
901 {
902  BLAZE_STATIC_ASSERT( M*N == 6UL );
903 
904  // Initialization of a 1x6 matrix
905  if( M == 1UL ) {
906  v_[0UL] = v1;
907  v_[1UL] = v2;
908  v_[2UL] = v3;
909  v_[3UL] = v4;
910  v_[4UL] = v5;
911  v_[5UL] = v6;
912  }
913 
914  // Initialization of a 2x3 matrix
915  else if( M == 2UL ) {
916  v_[ 0UL] = v1;
917  v_[ 1UL] = v2;
918  v_[ 2UL] = v3;
919  v_[NN ] = v4;
920  v_[NN+1UL] = v5;
921  v_[NN+2UL] = v6;
922  }
923 
924  // Initialization of a 3x2 matrix
925  else if( M == 3UL ) {
926  v_[ 0UL] = v1;
927  v_[ 1UL] = v2;
928  v_[ NN ] = v3;
929  v_[ NN+1UL] = v4;
930  v_[2UL*NN ] = v5;
931  v_[2UL*NN+1UL] = v6;
932  }
933 
934  // Initialization of a 6x1 matrix
935  else {
936  v_[ 0UL] = v1;
937  v_[ NN] = v2;
938  v_[2UL*NN] = v3;
939  v_[3UL*NN] = v4;
940  v_[4UL*NN] = v5;
941  v_[5UL*NN] = v6;
942  }
943 
944  if( IsNumeric<Type>::value ) {
945  for( size_t i=0UL; i<M; ++i ) {
946  for( size_t j=N; j<NN; ++j )
947  v_[i*NN+j] = Type();
948  }
949  }
950 }
951 //*************************************************************************************************
952 
953 
954 //*************************************************************************************************
976 template< typename Type // Data type of the matrix
977  , size_t M // Number of rows
978  , size_t N // Number of columns
979  , bool SO > // Storage order
980 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
981  const Type& v4, const Type& v5, const Type& v6,
982  const Type& v7 )
983 {
984  BLAZE_STATIC_ASSERT( M*N == 7UL );
985 
986  // Initialization of a 1x7 matrix
987  if( M == 1UL ) {
988  v_[0UL] = v1;
989  v_[1UL] = v2;
990  v_[2UL] = v3;
991  v_[3UL] = v4;
992  v_[4UL] = v5;
993  v_[5UL] = v6;
994  v_[6UL] = v7;
995  }
996 
997  // Initialization of a 7x1 matrix
998  else {
999  v_[ 0UL] = v1;
1000  v_[ NN] = v2;
1001  v_[2UL*NN] = v3;
1002  v_[3UL*NN] = v4;
1003  v_[4UL*NN] = v5;
1004  v_[5UL*NN] = v6;
1005  v_[6UL*NN] = v7;
1006  }
1007 
1008  if( IsNumeric<Type>::value ) {
1009  for( size_t i=0UL; i<M; ++i ) {
1010  for( size_t j=N; j<NN; ++j )
1011  v_[i*NN+j] = Type();
1012  }
1013  }
1014 }
1015 //*************************************************************************************************
1016 
1017 
1018 //*************************************************************************************************
1043 template< typename Type // Data type of the matrix
1044  , size_t M // Number of rows
1045  , size_t N // Number of columns
1046  , bool SO > // Storage order
1047 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1048  const Type& v4, const Type& v5, const Type& v6,
1049  const Type& v7, const Type& v8 )
1050 {
1051  BLAZE_STATIC_ASSERT( M*N == 8UL );
1052 
1053  // Initialization of a 1x8 matrix
1054  if( M == 1UL ) {
1055  v_[0UL] = v1;
1056  v_[1UL] = v2;
1057  v_[2UL] = v3;
1058  v_[3UL] = v4;
1059  v_[4UL] = v5;
1060  v_[5UL] = v6;
1061  v_[6UL] = v7;
1062  v_[7UL] = v8;
1063  }
1064 
1065  // Initialization of a 2x4 matrix
1066  else if( M == 2UL ) {
1067  v_[ 0UL] = v1;
1068  v_[ 1UL] = v2;
1069  v_[ 2UL] = v3;
1070  v_[ 3UL] = v4;
1071  v_[NN ] = v5;
1072  v_[NN+1UL] = v6;
1073  v_[NN+2UL] = v7;
1074  v_[NN+3UL] = v8;
1075  }
1076 
1077  // Initialization of a 4x2 matrix
1078  else if( M == 4UL ) {
1079  v_[ 0UL] = v1;
1080  v_[ 1UL] = v2;
1081  v_[ NN ] = v3;
1082  v_[ NN+1UL] = v4;
1083  v_[2UL*NN ] = v5;
1084  v_[2UL*NN+1UL] = v6;
1085  v_[3UL*NN ] = v7;
1086  v_[3UL*NN+1UL] = v8;
1087  }
1088 
1089  // Initialization of a 8x1 matrix
1090  else {
1091  v_[ 0UL] = v1;
1092  v_[ NN] = v2;
1093  v_[2UL*NN] = v3;
1094  v_[3UL*NN] = v4;
1095  v_[4UL*NN] = v5;
1096  v_[5UL*NN] = v6;
1097  v_[6UL*NN] = v7;
1098  v_[7UL*NN] = v8;
1099  }
1100 
1101  if( IsNumeric<Type>::value ) {
1102  for( size_t i=0UL; i<M; ++i ) {
1103  for( size_t j=N; j<NN; ++j )
1104  v_[i*NN+j] = Type();
1105  }
1106  }
1107 }
1108 //*************************************************************************************************
1109 
1110 
1111 //*************************************************************************************************
1138 template< typename Type // Data type of the matrix
1139  , size_t M // Number of rows
1140  , size_t N // Number of columns
1141  , bool SO > // Storage order
1142 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1143  const Type& v4, const Type& v5, const Type& v6,
1144  const Type& v7, const Type& v8, const Type& v9 )
1145 {
1146  BLAZE_STATIC_ASSERT( M*N == 9UL );
1147 
1148  // Initialization of a 1x9 matrix
1149  if( M == 1UL ) {
1150  v_[0UL] = v1;
1151  v_[1UL] = v2;
1152  v_[2UL] = v3;
1153  v_[3UL] = v4;
1154  v_[4UL] = v5;
1155  v_[5UL] = v6;
1156  v_[6UL] = v7;
1157  v_[7UL] = v8;
1158  v_[8UL] = v9;
1159  }
1160 
1161  // Initialization of a 3x3 matrix
1162  else if( M == 3UL ) {
1163  v_[ 0UL] = v1;
1164  v_[ 1UL] = v2;
1165  v_[ 2UL] = v3;
1166  v_[ NN ] = v4;
1167  v_[ NN+1UL] = v5;
1168  v_[ NN+2UL] = v6;
1169  v_[2UL*NN ] = v7;
1170  v_[2UL*NN+1UL] = v8;
1171  v_[2UL*NN+2UL] = v9;
1172  }
1173 
1174  // Initialization of a 9x1 matrix
1175  else {
1176  v_[ 0UL] = v1;
1177  v_[ NN] = v2;
1178  v_[2UL*NN] = v3;
1179  v_[3UL*NN] = v4;
1180  v_[4UL*NN] = v5;
1181  v_[5UL*NN] = v6;
1182  v_[6UL*NN] = v7;
1183  v_[7UL*NN] = v8;
1184  v_[8UL*NN] = v9;
1185  }
1186 
1187  if( IsNumeric<Type>::value ) {
1188  for( size_t i=0UL; i<M; ++i ) {
1189  for( size_t j=N; j<NN; ++j )
1190  v_[i*NN+j] = Type();
1191  }
1192  }
1193 }
1194 //*************************************************************************************************
1195 
1196 
1197 //*************************************************************************************************
1225 template< typename Type // Data type of the matrix
1226  , size_t M // Number of rows
1227  , size_t N // Number of columns
1228  , bool SO > // Storage order
1229 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1230  const Type& v4, const Type& v5, const Type& v6,
1231  const Type& v7, const Type& v8, const Type& v9,
1232  const Type& v10 )
1233 {
1234  BLAZE_STATIC_ASSERT( M*N == 10UL );
1235 
1236  // Initialization of a 1x10 matrix
1237  if( M == 1UL ) {
1238  v_[0UL] = v1;
1239  v_[1UL] = v2;
1240  v_[2UL] = v3;
1241  v_[3UL] = v4;
1242  v_[4UL] = v5;
1243  v_[5UL] = v6;
1244  v_[6UL] = v7;
1245  v_[7UL] = v8;
1246  v_[8UL] = v9;
1247  v_[9UL] = v10;
1248  }
1249 
1250  // Initialization of a 2x5 matrix
1251  else if( M == 2UL ) {
1252  v_[ 0UL] = v1;
1253  v_[ 1UL] = v2;
1254  v_[ 2UL] = v3;
1255  v_[ 3UL] = v4;
1256  v_[ 4UL] = v5;
1257  v_[NN ] = v6;
1258  v_[NN+1UL] = v7;
1259  v_[NN+2UL] = v8;
1260  v_[NN+3UL] = v9;
1261  v_[NN+4UL] = v10;
1262  }
1263 
1264  // Initialization of a 5x2 matrix
1265  else if( M == 5UL ) {
1266  v_[ 0UL] = v1;
1267  v_[ 1UL] = v2;
1268  v_[ NN ] = v3;
1269  v_[ NN+1UL] = v4;
1270  v_[2UL*NN ] = v5;
1271  v_[2UL*NN+1UL] = v6;
1272  v_[3UL*NN ] = v7;
1273  v_[3UL*NN+1UL] = v8;
1274  v_[4UL*NN ] = v9;
1275  v_[4UL*NN+1UL] = v10;
1276  }
1277 
1278  // Initialization of a 10x1 matrix
1279  else {
1280  v_[ 0UL] = v1;
1281  v_[ NN] = v2;
1282  v_[2UL*NN] = v3;
1283  v_[3UL*NN] = v4;
1284  v_[4UL*NN] = v5;
1285  v_[5UL*NN] = v6;
1286  v_[6UL*NN] = v7;
1287  v_[7UL*NN] = v8;
1288  v_[8UL*NN] = v9;
1289  v_[9UL*NN] = v10;
1290  }
1291 
1292  if( IsNumeric<Type>::value ) {
1293  for( size_t i=0UL; i<M; ++i ) {
1294  for( size_t j=N; j<NN; ++j )
1295  v_[i*NN+j] = Type();
1296  }
1297  }
1298 }
1299 //*************************************************************************************************
1300 
1301 
1302 
1303 
1304 //=================================================================================================
1305 //
1306 // DATA ACCESS FUNCTIONS
1307 //
1308 //=================================================================================================
1309 
1310 //*************************************************************************************************
1317 template< typename Type // Data type of the matrix
1318  , size_t M // Number of rows
1319  , size_t N // Number of columns
1320  , bool SO > // Storage order
1323 {
1324  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1325  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1326  return v_[i*NN+j];
1327 }
1328 //*************************************************************************************************
1329 
1330 
1331 //*************************************************************************************************
1338 template< typename Type // Data type of the matrix
1339  , size_t M // Number of rows
1340  , size_t N // Number of columns
1341  , bool SO > // Storage order
1343  StaticMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
1344 {
1345  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1346  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1347  return v_[i*NN+j];
1348 }
1349 //*************************************************************************************************
1350 
1351 
1352 //*************************************************************************************************
1361 template< typename Type // Data type of the matrix
1362  , size_t M // Number of rows
1363  , size_t N // Number of columns
1364  , bool SO > // Storage order
1366 {
1367  return v_;
1368 }
1369 //*************************************************************************************************
1370 
1371 
1372 //*************************************************************************************************
1381 template< typename Type // Data type of the matrix
1382  , size_t M // Number of rows
1383  , size_t N // Number of columns
1384  , bool SO > // Storage order
1385 inline const Type* StaticMatrix<Type,M,N,SO>::data() const
1386 {
1387  return v_;
1388 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1400 template< typename Type // Data type of the matrix
1401  , size_t M // Number of rows
1402  , size_t N // Number of columns
1403  , bool SO > // Storage order
1404 inline Type* StaticMatrix<Type,M,N,SO>::data( size_t i )
1405 {
1406  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1407  return v_ + i*NN;
1408 }
1409 //*************************************************************************************************
1410 
1411 
1412 //*************************************************************************************************
1420 template< typename Type // Data type of the matrix
1421  , size_t M // Number of rows
1422  , size_t N // Number of columns
1423  , bool SO > // Storage order
1424 inline const Type* StaticMatrix<Type,M,N,SO>::data( size_t i ) const
1425 {
1426  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1427  return v_ + i*NN;
1428 }
1429 //*************************************************************************************************
1430 
1431 
1432 //*************************************************************************************************
1443 template< typename Type // Data type of the matrix
1444  , size_t M // Number of rows
1445  , size_t N // Number of columns
1446  , bool SO > // Storage order
1449 {
1450  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1451  return Iterator( v_ + i*NN );
1452 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1467 template< typename Type // Data type of the matrix
1468  , size_t M // Number of rows
1469  , size_t N // Number of columns
1470  , bool SO > // Storage order
1473 {
1474  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1475  return ConstIterator( v_ + i*NN );
1476 }
1477 //*************************************************************************************************
1478 
1479 
1480 //*************************************************************************************************
1491 template< typename Type // Data type of the matrix
1492  , size_t M // Number of rows
1493  , size_t N // Number of columns
1494  , bool SO > // Storage order
1497 {
1498  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1499  return ConstIterator( v_ + i*NN );
1500 }
1501 //*************************************************************************************************
1502 
1503 
1504 //*************************************************************************************************
1515 template< typename Type // Data type of the matrix
1516  , size_t M // Number of rows
1517  , size_t N // Number of columns
1518  , bool SO > // Storage order
1521 {
1522  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1523  return Iterator( v_ + i*NN + N );
1524 }
1525 //*************************************************************************************************
1526 
1527 
1528 //*************************************************************************************************
1539 template< typename Type // Data type of the matrix
1540  , size_t M // Number of rows
1541  , size_t N // Number of columns
1542  , bool SO > // Storage order
1545 {
1546  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1547  return ConstIterator( v_ + i*NN + N );
1548 }
1549 //*************************************************************************************************
1550 
1551 
1552 //*************************************************************************************************
1563 template< typename Type // Data type of the matrix
1564  , size_t M // Number of rows
1565  , size_t N // Number of columns
1566  , bool SO > // Storage order
1569 {
1570  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1571  return ConstIterator( v_ + i*NN + N );
1572 }
1573 //*************************************************************************************************
1574 
1575 
1576 
1577 
1578 //=================================================================================================
1579 //
1580 // ASSIGNMENT OPERATORS
1581 //
1582 //=================================================================================================
1583 
1584 //*************************************************************************************************
1605 template< typename Type // Data type of the matrix
1606  , size_t M // Number of rows
1607  , size_t N // Number of columns
1608  , bool SO > // Storage order
1609 template< typename Other > // Data type of the initialization array
1611 {
1612  for( size_t i=0UL; i<M; ++i )
1613  for( size_t j=0UL; j<N; ++j )
1614  v_[i*NN+j] = array[i][j];
1615 
1616  return *this;
1617 }
1618 //*************************************************************************************************
1619 
1620 
1621 //*************************************************************************************************
1627 template< typename Type // Data type of the matrix
1628  , size_t M // Number of rows
1629  , size_t N // Number of columns
1630  , bool SO > // Storage order
1632 {
1633  for( size_t i=0UL; i<M; ++i )
1634  for( size_t j=0UL; j<N; ++j )
1635  v_[i*NN+j] = set;
1636 
1637  return *this;
1638 }
1639 //*************************************************************************************************
1640 
1641 
1642 //*************************************************************************************************
1650 template< typename Type // Data type of the matrix
1651  , size_t M // Number of rows
1652  , size_t N // Number of columns
1653  , bool SO > // Storage order
1655 {
1656  for( size_t i=0UL; i<M; ++i )
1657  for( size_t j=0UL; j<N; ++j )
1658  v_[i*NN+j] = rhs(i,j);
1659 
1660  return *this;
1661 }
1662 //*************************************************************************************************
1663 
1664 
1665 //*************************************************************************************************
1671 template< typename Type // Data type of the matrix
1672  , size_t M // Number of rows
1673  , size_t N // Number of columns
1674  , bool SO > // Storage order
1675 template< typename Other // Data type of the foreign matrix
1676  , bool SO2 > // Storage order of the foreign matrix
1679 {
1680  for( size_t i=0UL; i<M; ++i )
1681  for( size_t j=0UL; j<N; ++j )
1682  v_[i*NN+j] = rhs(i,j);
1683 
1684  return *this;
1685 }
1686 //*************************************************************************************************
1687 
1688 
1689 //*************************************************************************************************
1700 template< typename Type // Data type of the matrix
1701  , size_t M // Number of rows
1702  , size_t N // Number of columns
1703  , bool SO > // Storage order
1704 template< typename MT // Type of the right-hand side matrix
1705  , bool SO2 > // Storage order of the right-hand side matrix
1707 {
1708  using blaze::assign;
1709 
1710  if( (~rhs).rows() != M || (~rhs).columns() != N )
1711  throw std::invalid_argument( "Invalid assignment to static matrix" );
1712 
1713  if( (~rhs).canAlias( this ) ) {
1714  StaticMatrix tmp( ~rhs );
1715  swap( tmp );
1716  }
1717  else {
1719  reset();
1720  assign( *this, ~rhs );
1721  }
1722 
1723  return *this;
1724 }
1725 //*************************************************************************************************
1726 
1727 
1728 //*************************************************************************************************
1738 template< typename Type // Data type of the matrix
1739  , size_t M // Number of rows
1740  , size_t N // Number of columns
1741  , bool SO > // Storage order
1742 template< typename MT // Type of the right-hand side matrix
1743  , bool SO2 > // Storage order of the right-hand side matrix
1745 {
1746  using blaze::addAssign;
1747 
1748  if( (~rhs).rows() != M || (~rhs).columns() != N )
1749  throw std::invalid_argument( "Matrix sizes do not match" );
1750 
1751  if( (~rhs).canAlias( this ) ) {
1752  StaticMatrix tmp( ~rhs );
1753  addAssign( *this, tmp );
1754  }
1755  else {
1756  addAssign( *this, ~rhs );
1757  }
1758 
1759  return *this;
1760 }
1761 //*************************************************************************************************
1762 
1763 
1764 //*************************************************************************************************
1774 template< typename Type // Data type of the matrix
1775  , size_t M // Number of rows
1776  , size_t N // Number of columns
1777  , bool SO > // Storage order
1778 template< typename MT // Type of the right-hand side matrix
1779  , bool SO2 > // Storage order of the right-hand side matrix
1781 {
1782  using blaze::subAssign;
1783 
1784  if( (~rhs).rows() != M || (~rhs).columns() != N )
1785  throw std::invalid_argument( "Matrix sizes do not match" );
1786 
1787  if( (~rhs).canAlias( this ) ) {
1788  StaticMatrix tmp( ~rhs );
1789  subAssign( *this, tmp );
1790  }
1791  else {
1792  subAssign( *this, ~rhs );
1793  }
1794 
1795  return *this;
1796 }
1797 //*************************************************************************************************
1798 
1799 
1800 //*************************************************************************************************
1810 template< typename Type // Data type of the matrix
1811  , size_t M // Number of rows
1812  , size_t N // Number of columns
1813  , bool SO > // Storage order
1814 template< typename MT // Type of the right-hand side matrix
1815  , bool SO2 > // Storage order of the right-hand side matrix
1817 {
1818  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
1819  throw std::invalid_argument( "Matrix sizes do not match" );
1820 
1821  StaticMatrix tmp( *this * (~rhs) );
1822  return this->operator=( tmp );
1823 }
1824 //*************************************************************************************************
1825 
1826 
1827 //*************************************************************************************************
1834 template< typename Type // Data type of the matrix
1835  , size_t M // Number of rows
1836  , size_t N // Number of columns
1837  , bool SO > // Storage order
1838 template< typename Other > // Data type of the right-hand side scalar
1839 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1841 {
1842  using blaze::assign;
1843 
1844  assign( *this, (*this) * rhs );
1845  return *this;
1846 }
1847 //*************************************************************************************************
1848 
1849 
1850 //*************************************************************************************************
1859 template< typename Type // Data type of the matrix
1860  , size_t M // Number of rows
1861  , size_t N // Number of columns
1862  , bool SO > // Storage order
1863 template< typename Other > // Data type of the right-hand side scalar
1864 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1866 {
1867  using blaze::assign;
1868 
1869  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1870 
1871  assign( *this, (*this) / rhs );
1872  return *this;
1873 }
1874 //*************************************************************************************************
1875 
1876 
1877 
1878 
1879 //=================================================================================================
1880 //
1881 // UTILITY FUNCTIONS
1882 //
1883 //=================================================================================================
1884 
1885 //*************************************************************************************************
1890 template< typename Type // Data type of the matrix
1891  , size_t M // Number of rows
1892  , size_t N // Number of columns
1893  , bool SO > // Storage order
1894 inline size_t StaticMatrix<Type,M,N,SO>::rows() const
1895 {
1896  return M;
1897 }
1898 //*************************************************************************************************
1899 
1900 
1901 //*************************************************************************************************
1906 template< typename Type // Data type of the matrix
1907  , size_t M // Number of rows
1908  , size_t N // Number of columns
1909  , bool SO > // Storage order
1911 {
1912  return N;
1913 }
1914 //*************************************************************************************************
1915 
1916 
1917 //*************************************************************************************************
1925 template< typename Type // Data type of the matrix
1926  , size_t M // Number of rows
1927  , size_t N // Number of columns
1928  , bool SO > // Storage order
1930 {
1931  return NN;
1932 }
1933 //*************************************************************************************************
1934 
1935 
1936 //*************************************************************************************************
1941 template< typename Type // Data type of the matrix
1942  , size_t M // Number of rows
1943  , size_t N // Number of columns
1944  , bool SO > // Storage order
1946 {
1947  return M*NN;
1948 }
1949 //*************************************************************************************************
1950 
1951 
1952 //*************************************************************************************************
1963 template< typename Type // Data type of the matrix
1964  , size_t M // Number of rows
1965  , size_t N // Number of columns
1966  , bool SO > // Storage order
1967 inline size_t StaticMatrix<Type,M,N,SO>::capacity( size_t i ) const
1968 {
1969  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1970  return NN;
1971 }
1972 //*************************************************************************************************
1973 
1974 
1975 //*************************************************************************************************
1980 template< typename Type // Data type of the matrix
1981  , size_t M // Number of rows
1982  , size_t N // Number of columns
1983  , bool SO > // Storage order
1985 {
1986  size_t nonzeros( 0UL );
1987 
1988  for( size_t i=0UL; i<M; ++i )
1989  for( size_t j=0UL; j<N; ++j )
1990  if( !isDefault( v_[i*NN+j] ) )
1991  ++nonzeros;
1992 
1993  return nonzeros;
1994 }
1995 //*************************************************************************************************
1996 
1997 
1998 //*************************************************************************************************
2009 template< typename Type // Data type of the matrix
2010  , size_t M // Number of rows
2011  , size_t N // Number of columns
2012  , bool SO > // Storage order
2013 inline size_t StaticMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
2014 {
2015  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2016 
2017  const size_t jend( (i+1UL)*NN );
2018  size_t nonzeros( 0UL );
2019 
2020  for( size_t j=i*NN; j<jend; ++j )
2021  if( !isDefault( v_[j] ) )
2022  ++nonzeros;
2023 
2024  return nonzeros;
2025 }
2026 //*************************************************************************************************
2027 
2028 
2029 //*************************************************************************************************
2034 template< typename Type // Data type of the matrix
2035  , size_t M // Number of rows
2036  , size_t N // Number of columns
2037  , bool SO > // Storage order
2039 {
2040  using blaze::reset;
2041 
2042  for( size_t i=0UL; i<M; ++i )
2043  for( size_t j=0UL; j<N; ++j )
2044  reset( v_[i*NN+j] );
2045 }
2046 //*************************************************************************************************
2047 
2048 
2049 //*************************************************************************************************
2060 template< typename Type // Data type of the matrix
2061  , size_t M // Number of rows
2062  , size_t N // Number of columns
2063  , bool SO > // Storage order
2064 inline void StaticMatrix<Type,M,N,SO>::reset( size_t i )
2065 {
2066  using blaze::reset;
2067 
2068  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2069  for( size_t j=0UL; j<N; ++j )
2070  reset( v_[i*NN+j] );
2071 }
2072 //*************************************************************************************************
2073 
2074 
2075 //*************************************************************************************************
2080 template< typename Type // Data type of the matrix
2081  , size_t M // Number of rows
2082  , size_t N // Number of columns
2083  , bool SO > // Storage order
2085 {
2086  using std::swap;
2087 
2088  for( size_t i=1UL; i<M; ++i )
2089  for( size_t j=0UL; j<i; ++j )
2090  swap( v_[i*NN+j], v_[j*NN+i] );
2091 
2092  return *this;
2093 }
2094 //*************************************************************************************************
2095 
2096 
2097 //*************************************************************************************************
2103 template< typename Type // Data type of the matrix
2104  , size_t M // Number of rows
2105  , size_t N // Number of columns
2106  , bool SO > // Storage order
2107 template< typename Other > // Data type of the scalar value
2109 {
2110  for( size_t i=0UL; i<M; ++i )
2111  for( size_t j=0UL; j<N; ++j )
2112  v_[i*NN+j] *= scalar;
2113 
2114  return *this;
2115 }
2116 //*************************************************************************************************
2117 
2118 
2119 //*************************************************************************************************
2126 template< typename Type // Data type of the matrix
2127  , size_t M // Number of rows
2128  , size_t N // Number of columns
2129  , bool SO > // Storage order
2130 inline void StaticMatrix<Type,M,N,SO>::swap( StaticMatrix& m ) /* throw() */
2131 {
2132  using std::swap;
2133 
2134  for( size_t i=0UL; i<M; ++i ) {
2135  for( size_t j=0UL; j<N; ++j ) {
2136  swap( v_[i*NN+j], m(i,j) );
2137  }
2138  }
2139 }
2140 //*************************************************************************************************
2141 
2142 
2143 
2144 
2145 //=================================================================================================
2146 //
2147 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2148 //
2149 //=================================================================================================
2150 
2151 //*************************************************************************************************
2161 template< typename Type // Data type of the matrix
2162  , size_t M // Number of rows
2163  , size_t N // Number of columns
2164  , bool SO > // Storage order
2165 template< typename Other > // Data type of the foreign expression
2166 inline bool StaticMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
2167 {
2168  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2169 }
2170 //*************************************************************************************************
2171 
2172 
2173 //*************************************************************************************************
2183 template< typename Type // Data type of the matrix
2184  , size_t M // Number of rows
2185  , size_t N // Number of columns
2186  , bool SO > // Storage order
2187 template< typename Other > // Data type of the foreign expression
2188 inline bool StaticMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
2189 {
2190  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2191 }
2192 //*************************************************************************************************
2193 
2194 
2195 //*************************************************************************************************
2210 template< typename Type // Data type of the matrix
2211  , size_t M // Number of rows
2212  , size_t N // Number of columns
2213  , bool SO > // Storage order
2215  StaticMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2216 {
2217  using blaze::load;
2218 
2220 
2221  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2222  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2223  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2224  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2225 
2226  return load( &v_[i*NN+j] );
2227 }
2228 //*************************************************************************************************
2229 
2230 
2231 //*************************************************************************************************
2246 template< typename Type // Data type of the matrix
2247  , size_t M // Number of rows
2248  , size_t N // Number of columns
2249  , bool SO > // Storage order
2251  StaticMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2252 {
2253  using blaze::loadu;
2254 
2256 
2257  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2258  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2259  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2260 
2261  return loadu( &v_[i*NN+j] );
2262 }
2263 //*************************************************************************************************
2264 
2265 
2266 //*************************************************************************************************
2282 template< typename Type // Data type of the matrix
2283  , size_t M // Number of rows
2284  , size_t N // Number of columns
2285  , bool SO > // Storage order
2286 inline void StaticMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2287 {
2288  using blaze::store;
2289 
2291 
2292  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2293  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2294  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2295  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2296 
2297  store( &v_[i*NN+j], value );
2298 }
2299 //*************************************************************************************************
2300 
2301 
2302 //*************************************************************************************************
2318 template< typename Type // Data type of the matrix
2319  , size_t M // Number of rows
2320  , size_t N // Number of columns
2321  , bool SO > // Storage order
2322 inline void StaticMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2323 {
2324  using blaze::storeu;
2325 
2327 
2328  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2329  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2330  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2331 
2332  storeu( &v_[i*NN+j], value );
2333 }
2334 //*************************************************************************************************
2335 
2336 
2337 //*************************************************************************************************
2353 template< typename Type // Data type of the matrix
2354  , size_t M // Number of rows
2355  , size_t N // Number of columns
2356  , bool SO > // Storage order
2357 inline void StaticMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2358 {
2359  using blaze::stream;
2360 
2362 
2363  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2364  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2365  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2366  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2367 
2368  stream( &v_[i*NN+j], value );
2369 }
2370 //*************************************************************************************************
2371 
2372 
2373 //*************************************************************************************************
2384 template< typename Type // Data type of the matrix
2385  , size_t M // Number of rows
2386  , size_t N // Number of columns
2387  , bool SO > // Storage order
2388 template< typename MT // Type of the right-hand side dense matrix
2389  , bool SO2 > // Storage order of the right-hand side dense matrix
2390 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2392 {
2393  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2394 
2395  for( size_t i=0UL; i<M; ++i ) {
2396  for( size_t j=0UL; j<N; ++j ) {
2397  v_[i*NN+j] = (~rhs)(i,j);
2398  }
2399  }
2400 }
2401 //*************************************************************************************************
2402 
2403 
2404 //*************************************************************************************************
2415 template< typename Type // Data type of the matrix
2416  , size_t M // Number of rows
2417  , size_t N // Number of columns
2418  , bool SO > // Storage order
2419 template< typename MT // Type of the right-hand side dense matrix
2420  , bool SO2 > // Storage order of the right-hand side dense matrix
2421 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2423 {
2424  using blaze::store;
2425 
2426  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2427 
2429 
2430  for( size_t i=0UL; i<M; ++i ) {
2431  for( size_t j=0UL; j<N; j+=IT::size ) {
2432  store( &v_[i*NN+j], (~rhs).load(i,j) );
2433  }
2434  }
2435 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2450 template< typename Type // Data type of the matrix
2451  , size_t M // Number of rows
2452  , size_t N // Number of columns
2453  , bool SO > // Storage order
2454 template< typename MT > // Type of the right-hand side sparse matrix
2456 {
2457  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2458 
2459  typedef typename MT::ConstIterator RhsConstIterator;
2460 
2461  for( size_t i=0UL; i<M; ++i )
2462  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2463  v_[i*NN+element->index()] = element->value();
2464 }
2465 //*************************************************************************************************
2466 
2467 
2468 //*************************************************************************************************
2479 template< typename Type // Data type of the matrix
2480  , size_t M // Number of rows
2481  , size_t N // Number of columns
2482  , bool SO > // Storage order
2483 template< typename MT > // Type of the right-hand side sparse matrix
2485 {
2486  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2487 
2488  typedef typename MT::ConstIterator RhsConstIterator;
2489 
2490  for( size_t j=0UL; j<N; ++j )
2491  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2492  v_[element->index()*NN+j] = element->value();
2493 }
2494 //*************************************************************************************************
2495 
2496 
2497 //*************************************************************************************************
2508 template< typename Type // Data type of the matrix
2509  , size_t M // Number of rows
2510  , size_t N // Number of columns
2511  , bool SO > // Storage order
2512 template< typename MT // Type of the right-hand side dense matrix
2513  , bool SO2 > // Storage order of the right-hand side dense matrix
2514 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2516 {
2517  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2518 
2519  for( size_t i=0UL; i<M; ++i ) {
2520  for( size_t j=0UL; j<N; ++j ) {
2521  v_[i*NN+j] += (~rhs)(i,j);
2522  }
2523  }
2524 }
2525 //*************************************************************************************************
2526 
2527 
2528 //*************************************************************************************************
2539 template< typename Type // Data type of the matrix
2540  , size_t M // Number of rows
2541  , size_t N // Number of columns
2542  , bool SO > // Storage order
2543 template< typename MT // Type of the right-hand side dense matrix
2544  , bool SO2 > // Storage order of the right-hand side dense matrix
2545 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2547 {
2548  using blaze::load;
2549  using blaze::store;
2550 
2551  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2552 
2554 
2555  for( size_t i=0UL; i<M; ++i ) {
2556  for( size_t j=0UL; j<N; j+=IT::size ) {
2557  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2558  }
2559  }
2560 }
2561 //*************************************************************************************************
2562 
2563 
2564 //*************************************************************************************************
2575 template< typename Type // Data type of the matrix
2576  , size_t M // Number of rows
2577  , size_t N // Number of columns
2578  , bool SO > // Storage order
2579 template< typename MT > // Type of the right-hand side sparse matrix
2581 {
2582  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2583 
2584  typedef typename MT::ConstIterator RhsConstIterator;
2585 
2586  for( size_t i=0UL; i<M; ++i )
2587  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2588  v_[i*NN+element->index()] += element->value();
2589 }
2590 //*************************************************************************************************
2591 
2592 
2593 //*************************************************************************************************
2604 template< typename Type // Data type of the matrix
2605  , size_t M // Number of rows
2606  , size_t N // Number of columns
2607  , bool SO > // Storage order
2608 template< typename MT > // Type of the right-hand side sparse matrix
2610 {
2611  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2612 
2613  typedef typename MT::ConstIterator RhsConstIterator;
2614 
2615  for( size_t j=0UL; j<N; ++j )
2616  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2617  v_[element->index()*NN+j] += element->value();
2618 }
2619 //*************************************************************************************************
2620 
2621 
2622 //*************************************************************************************************
2633 template< typename Type // Data type of the matrix
2634  , size_t M // Number of rows
2635  , size_t N // Number of columns
2636  , bool SO > // Storage order
2637 template< typename MT // Type of the right-hand side dense matrix
2638  , bool SO2 > // Storage order of the right-hand side dense matrix
2639 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2641 {
2642  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2643 
2644  for( size_t i=0UL; i<M; ++i ) {
2645  for( size_t j=0UL; j<N; ++j ) {
2646  v_[i*NN+j] -= (~rhs)(i,j);
2647  }
2648  }
2649 }
2650 //*************************************************************************************************
2651 
2652 
2653 //*************************************************************************************************
2664 template< typename Type // Data type of the matrix
2665  , size_t M // Number of rows
2666  , size_t N // Number of columns
2667  , bool SO > // Storage order
2668 template< typename MT // Type of the right-hand side dense matrix
2669  , bool SO2 > // Storage order of the right-hand side dense matrix
2670 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2672 {
2673  using blaze::load;
2674  using blaze::store;
2675 
2676  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2677 
2679 
2680  for( size_t i=0UL; i<M; ++i ) {
2681  for( size_t j=0UL; j<N; j+=IT::size ) {
2682  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
2683  }
2684  }
2685 }
2686 //*************************************************************************************************
2687 
2688 
2689 //*************************************************************************************************
2700 template< typename Type // Data type of the matrix
2701  , size_t M // Number of rows
2702  , size_t N // Number of columns
2703  , bool SO > // Storage order
2704 template< typename MT > // Type of the right-hand side sparse matrix
2706 {
2707  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2708 
2709  typedef typename MT::ConstIterator RhsConstIterator;
2710 
2711  for( size_t i=0UL; i<M; ++i )
2712  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2713  v_[i*NN+element->index()] -= element->value();
2714 }
2715 //*************************************************************************************************
2716 
2717 
2718 //*************************************************************************************************
2729 template< typename Type // Data type of the matrix
2730  , size_t M // Number of rows
2731  , size_t N // Number of columns
2732  , bool SO > // Storage order
2733 template< typename MT > // Type of the right-hand side sparse matrix
2735 {
2736  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2737 
2738  typedef typename MT::ConstIterator RhsConstIterator;
2739 
2740  for( size_t j=0UL; j<N; ++j )
2741  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2742  v_[element->index()*NN+j] -= element->value();
2743 }
2744 //*************************************************************************************************
2745 
2746 
2747 
2748 
2749 
2750 
2751 
2752 
2753 //=================================================================================================
2754 //
2755 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2756 //
2757 //=================================================================================================
2758 
2759 //*************************************************************************************************
2767 template< typename Type // Data type of the matrix
2768  , size_t M // Number of rows
2769  , size_t N > // Number of columns
2770 class StaticMatrix<Type,M,N,true> : public DenseMatrix< StaticMatrix<Type,M,N,true>, true >
2771 {
2772  private:
2773  //**Type definitions****************************************************************************
2774  typedef IntrinsicTrait<Type> IT;
2775  //**********************************************************************************************
2776 
2777  //**********************************************************************************************
2779  enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
2780  //**********************************************************************************************
2781 
2782  public:
2783  //**Type definitions****************************************************************************
2784  typedef StaticMatrix<Type,M,N,true> This;
2785  typedef This ResultType;
2786  typedef StaticMatrix<Type,M,N,false> OppositeType;
2787  typedef StaticMatrix<Type,N,M,false> TransposeType;
2788  typedef Type ElementType;
2789  typedef typename IT::Type IntrinsicType;
2790  typedef const Type& ReturnType;
2791  typedef const This& CompositeType;
2792  typedef Type& Reference;
2793  typedef const Type& ConstReference;
2794  typedef DenseIterator<Type> Iterator;
2795  typedef DenseIterator<const Type> ConstIterator;
2796  //**********************************************************************************************
2797 
2798  //**Compilation flags***************************************************************************
2800 
2804  enum { vectorizable = IsVectorizable<Type>::value };
2805  //**********************************************************************************************
2806 
2807  //**Constructors********************************************************************************
2810  explicit inline StaticMatrix();
2811  explicit inline StaticMatrix( const Type& init );
2812 
2813  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
2814  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
2815 
2816  inline StaticMatrix( const StaticMatrix& m );
2817  template< typename Other, bool SO > inline StaticMatrix( const StaticMatrix<Other,M,N,SO>& m );
2818  template< typename MT , bool SO > inline StaticMatrix( const Matrix<MT,SO>& m );
2819 
2820  inline StaticMatrix( const Type& v1, const Type& v2 );
2821  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
2822  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
2823  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
2824  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2825  const Type& v6 );
2826  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2827  const Type& v6, const Type& v7 );
2828  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2829  const Type& v6, const Type& v7, const Type& v8 );
2830  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2831  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
2832  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2833  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
2835  //**********************************************************************************************
2836 
2837  //**Destructor**********************************************************************************
2838  // No explicitly declared destructor.
2839  //**********************************************************************************************
2840 
2841  //**Data access functions***********************************************************************
2844  inline Reference operator()( size_t i, size_t j );
2845  inline ConstReference operator()( size_t i, size_t j ) const;
2846  inline Type* data ();
2847  inline const Type* data () const;
2848  inline Type* data ( size_t j );
2849  inline const Type* data ( size_t j ) const;
2850  inline Iterator begin ( size_t j );
2851  inline ConstIterator begin ( size_t j ) const;
2852  inline ConstIterator cbegin( size_t j ) const;
2853  inline Iterator end ( size_t j );
2854  inline ConstIterator end ( size_t j ) const;
2855  inline ConstIterator cend ( size_t j ) const;
2857  //**********************************************************************************************
2858 
2859  //**Assignment operators************************************************************************
2862  template< typename Other >
2863  inline StaticMatrix& operator=( const Other (&array)[M][N] );
2864 
2865  inline StaticMatrix& operator= ( const Type& set );
2866  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
2867  template< typename Other, bool SO > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO>& rhs );
2868  template< typename MT , bool SO > inline StaticMatrix& operator= ( const Matrix<MT,SO>& rhs );
2869  template< typename MT , bool SO > inline StaticMatrix& operator+=( const Matrix<MT,SO>& rhs );
2870  template< typename MT , bool SO > inline StaticMatrix& operator-=( const Matrix<MT,SO>& rhs );
2871  template< typename MT , bool SO > inline StaticMatrix& operator*=( const Matrix<MT,SO>& rhs );
2872 
2873  template< typename Other >
2874  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
2875  operator*=( Other rhs );
2876 
2877  template< typename Other >
2878  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
2879  operator/=( Other rhs );
2881  //**********************************************************************************************
2882 
2883  //**Utility functions***************************************************************************
2886  inline size_t rows() const;
2887  inline size_t columns() const;
2888  inline size_t spacing() const;
2889  inline size_t capacity() const;
2890  inline size_t capacity( size_t j ) const;
2891  inline size_t nonZeros() const;
2892  inline size_t nonZeros( size_t j ) const;
2893  inline void reset();
2894  inline void reset( size_t i );
2895  inline StaticMatrix& transpose();
2896  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
2897  inline void swap( StaticMatrix& m ) /* throw() */;
2899  //**********************************************************************************************
2900 
2901  private:
2902  //**********************************************************************************************
2904  template< typename MT >
2905  struct VectorizedAssign {
2906  enum { value = vectorizable && MT::vectorizable &&
2907  IsSame<Type,typename MT::ElementType>::value &&
2908  IsColumnMajorMatrix<MT>::value };
2909  };
2910  //**********************************************************************************************
2911 
2912  //**********************************************************************************************
2914  template< typename MT >
2915  struct VectorizedAddAssign {
2916  enum { value = vectorizable && MT::vectorizable &&
2917  IsSame<Type,typename MT::ElementType>::value &&
2918  IntrinsicTrait<Type>::addition &&
2919  IsColumnMajorMatrix<MT>::value };
2920  };
2921  //**********************************************************************************************
2922 
2923  //**********************************************************************************************
2925  template< typename MT >
2926  struct VectorizedSubAssign {
2927  enum { value = vectorizable && MT::vectorizable &&
2928  IsSame<Type,typename MT::ElementType>::value &&
2929  IntrinsicTrait<Type>::subtraction &&
2930  IsColumnMajorMatrix<MT>::value };
2931  };
2932  //**********************************************************************************************
2933 
2934  public:
2935  //**Expression template evaluation functions****************************************************
2938  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2939  template< typename Other > inline bool isAliased( const Other* alias ) const;
2940 
2941  inline IntrinsicType load ( size_t i, size_t j ) const;
2942  inline IntrinsicType loadu ( size_t i, size_t j ) const;
2943  inline void store ( size_t i, size_t j, const IntrinsicType& value );
2944  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
2945  inline void stream( size_t i, size_t j, const IntrinsicType& value );
2946 
2947  template< typename MT, bool SO >
2948  inline typename DisableIf< VectorizedAssign<MT> >::Type
2949  assign( const DenseMatrix<MT,SO>& rhs );
2950 
2951  template< typename MT, bool SO >
2952  inline typename EnableIf< VectorizedAssign<MT> >::Type
2953  assign( const DenseMatrix<MT,SO>& rhs );
2954 
2955  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
2956  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
2957 
2958  template< typename MT, bool SO >
2959  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2960  addAssign( const DenseMatrix<MT,SO>& rhs );
2961 
2962  template< typename MT, bool SO >
2963  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2964  addAssign( const DenseMatrix<MT,SO>& rhs );
2965 
2966  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
2967  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
2968 
2969  template< typename MT, bool SO >
2970  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2971  subAssign( const DenseMatrix<MT,SO>& rhs );
2972 
2973  template< typename MT, bool SO >
2974  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2975  subAssign( const DenseMatrix<MT,SO>& rhs );
2976 
2977  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
2978  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
2980  //**********************************************************************************************
2981 
2982  private:
2983  //**Member variables****************************************************************************
2986  AlignedArray<Type,MM*N> v_;
2987 
2990  //**********************************************************************************************
2991 
2992  //**Compile time checks*************************************************************************
2997  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
2998  BLAZE_STATIC_ASSERT( MM >= M );
2999  //**********************************************************************************************
3000 };
3002 //*************************************************************************************************
3003 
3004 
3005 
3006 
3007 //=================================================================================================
3008 //
3009 // CONSTRUCTORS
3010 //
3011 //=================================================================================================
3012 
3013 //*************************************************************************************************
3019 template< typename Type // Data type of the matrix
3020  , size_t M // Number of rows
3021  , size_t N > // Number of columns
3023 {
3024  if( IsNumeric<Type>::value ) {
3025  for( size_t i=0UL; i<MM*N; ++i )
3026  v_[i] = Type();
3027  }
3028 }
3030 //*************************************************************************************************
3031 
3032 
3033 //*************************************************************************************************
3039 template< typename Type // Data type of the matrix
3040  , size_t M // Number of rows
3041  , size_t N > // Number of columns
3042 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& init )
3043 {
3044  for( size_t j=0UL; j<N; ++j ) {
3045  for( size_t i=0UL; i<M; ++i )
3046  v_[i+j*MM] = init;
3047 
3048  if( IsNumeric<Type>::value ) {
3049  for( size_t i=M; i<MM; ++i )
3050  v_[i+j*MM] = Type();
3051  }
3052  }
3053 }
3055 //*************************************************************************************************
3056 
3057 
3058 //*************************************************************************************************
3085 template< typename Type // Data type of the matrix
3086  , size_t M // Number of rows
3087  , size_t N > // Number of columns
3088 template< typename Other > // Data type of the initialization array
3089 inline StaticMatrix<Type,M,N,true>::StaticMatrix( size_t m, size_t n, const Other* array )
3090 {
3091  if( m > M || n > N )
3092  throw std::invalid_argument( "Invalid setup of static matrix" );
3093 
3094  for( size_t j=0UL; j<n; ++j ) {
3095  for( size_t i=0UL; i<m; ++i )
3096  v_[i+j*MM] = array[i+j*m];
3097 
3098  if( IsNumeric<Type>::value ) {
3099  for( size_t i=m; i<MM; ++i )
3100  v_[i+j*MM] = Type();
3101  }
3102  }
3103 
3104  for( size_t j=n; j<N; ++j ) {
3105  for( size_t i=0UL; i<M; ++i )
3106  v_[i+j*MM] = Type();
3107  }
3108 }
3110 //*************************************************************************************************
3111 
3112 
3113 //*************************************************************************************************
3134 template< typename Type // Data type of the matrix
3135  , size_t M // Number of rows
3136  , size_t N > // Number of columns
3137 template< typename Other > // Data type of the initialization array
3138 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Other (&array)[M][N] )
3139 {
3140  for( size_t j=0UL; j<N; ++j ) {
3141  for( size_t i=0UL; i<M; ++i )
3142  v_[i+j*MM] = array[i][j];
3143 
3144  if( IsNumeric<Type>::value ) {
3145  for( size_t i=M; i<MM; ++i )
3146  v_[i+j*MM] = Type();
3147  }
3148  }
3149 }
3151 //*************************************************************************************************
3152 
3153 
3154 //*************************************************************************************************
3162 template< typename Type // Data type of the matrix
3163  , size_t M // Number of rows
3164  , size_t N > // Number of columns
3165 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix& m )
3166 {
3167  for( size_t i=0UL; i<MM*N; ++i )
3168  v_[i] = m.v_[i];
3169 }
3171 //*************************************************************************************************
3172 
3173 
3174 //*************************************************************************************************
3180 template< typename Type // Data type of the matrix
3181  , size_t M // Number of rows
3182  , size_t N > // Number of columns
3183 template< typename Other // Data type of the foreign matrix
3184  , bool SO > // Storage order of the foreign matrix
3185 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix<Other,M,N,SO>& m )
3186 {
3187  for( size_t j=0UL; j<N; ++j ) {
3188  for( size_t i=0UL; i<M; ++i )
3189  v_[i+j*MM] = m(i,j);
3190 
3191  if( IsNumeric<Type>::value ) {
3192  for( size_t i=M; i<MM; ++i )
3193  v_[i+j*MM] = Type();
3194  }
3195  }
3196 }
3198 //*************************************************************************************************
3199 
3200 
3201 //*************************************************************************************************
3212 template< typename Type // Data type of the matrix
3213  , size_t M // Number of rows
3214  , size_t N > // Number of columns
3215 template< typename MT // Type of the foreign matrix
3216  , bool SO > // Storage order of the foreign matrix
3217 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Matrix<MT,SO>& m )
3218 {
3219  using blaze::assign;
3220 
3221  if( (~m).rows() != M || (~m).columns() != N )
3222  throw std::invalid_argument( "Invalid setup of static matrix" );
3223 
3224  if( IsNumeric<Type>::value ) {
3225  for( size_t j=0UL; j<N; ++j )
3226  for( size_t i=( IsSparseMatrix<MT>::value )?( 0UL ):( M ); i<MM; ++i ) {
3227  v_[i+j*MM] = Type();
3228  }
3229  }
3230 
3231  assign( *this, ~m );
3232 }
3234 //*************************************************************************************************
3235 
3236 
3237 //*************************************************************************************************
3255 template< typename Type // Data type of the matrix
3256  , size_t M // Number of rows
3257  , size_t N > // Number of columns
3258 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2 )
3259 {
3260  BLAZE_STATIC_ASSERT( M*N == 2UL );
3261 
3262  // Initialization of a 2x1 matrix
3263  if( N == 1UL ) {
3264  v_[0UL] = v1;
3265  v_[1UL] = v2;
3266  }
3267 
3268  // Initialization of a 1x2 matrix
3269  else {
3270  v_[0UL] = v1;
3271  v_[ MM] = v2;
3272  }
3273 
3274  if( IsNumeric<Type>::value ) {
3275  for( size_t j=0UL; j<N; ++j )
3276  for( size_t i=M; i<MM; ++i ) {
3277  v_[i+j*MM] = Type();
3278  }
3279  }
3280 }
3282 //*************************************************************************************************
3283 
3284 
3285 //*************************************************************************************************
3304 template< typename Type // Data type of the matrix
3305  , size_t M // Number of rows
3306  , size_t N > // Number of columns
3307 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
3308 {
3309  BLAZE_STATIC_ASSERT( M*N == 3UL );
3310 
3311  // Initialization of a 3x1 matrix
3312  if( N == 1UL ) {
3313  v_[0UL] = v1;
3314  v_[1UL] = v2;
3315  v_[2UL] = v3;
3316  }
3317 
3318  // Initialization of a 1x3 matrix
3319  else {
3320  v_[ 0UL] = v1;
3321  v_[ MM] = v2;
3322  v_[2UL*MM] = v3;
3323  }
3324 
3325  if( IsNumeric<Type>::value ) {
3326  for( size_t j=0UL; j<N; ++j )
3327  for( size_t i=M; i<MM; ++i ) {
3328  v_[i+j*MM] = Type();
3329  }
3330  }
3331 }
3333 //*************************************************************************************************
3334 
3335 
3336 //*************************************************************************************************
3358 template< typename Type // Data type of the matrix
3359  , size_t M // Number of rows
3360  , size_t N > // Number of columns
3361 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3362  const Type& v4 )
3363 {
3364  BLAZE_STATIC_ASSERT( M*N == 4UL );
3365 
3366  // Initialization of a 4x1 matrix
3367  if( N == 1UL ) {
3368  v_[0UL] = v1;
3369  v_[1UL] = v2;
3370  v_[2UL] = v3;
3371  v_[3UL] = v4;
3372  }
3373 
3374  // Initialization of a 2x2 matrix
3375  else if( N == 2UL ) {
3376  v_[ 0UL] = v1;
3377  v_[ 1UL] = v2;
3378  v_[MM ] = v3;
3379  v_[MM+1UL] = v4;
3380  }
3381 
3382  // Initialization of a 1x4 matrix
3383  else {
3384  v_[ 0UL] = v1;
3385  v_[ MM] = v2;
3386  v_[2UL*MM] = v3;
3387  v_[3UL*MM] = v4;
3388  }
3389 
3390  if( IsNumeric<Type>::value ) {
3391  for( size_t j=0UL; j<N; ++j )
3392  for( size_t i=M; i<MM; ++i ) {
3393  v_[i+j*MM] = Type();
3394  }
3395  }
3396 }
3398 //*************************************************************************************************
3399 
3400 
3401 //*************************************************************************************************
3422 template< typename Type // Data type of the matrix
3423  , size_t M // Number of rows
3424  , size_t N > // Number of columns
3425 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3426  const Type& v4, const Type& v5 )
3427 {
3428  BLAZE_STATIC_ASSERT( M*N == 5UL );
3429 
3430  // Initialization of a 5x1 matrix
3431  if( N == 1UL ) {
3432  v_[0UL] = v1;
3433  v_[1UL] = v2;
3434  v_[2UL] = v3;
3435  v_[3UL] = v4;
3436  v_[4UL] = v5;
3437  }
3438 
3439  // Initialization of a 1x5 matrix
3440  else {
3441  v_[ 0UL] = v1;
3442  v_[ MM] = v2;
3443  v_[2UL*MM] = v3;
3444  v_[3UL*MM] = v4;
3445  v_[4UL*MM] = v5;
3446  }
3447 
3448  if( IsNumeric<Type>::value ) {
3449  for( size_t j=0UL; j<N; ++j )
3450  for( size_t i=M; i<MM; ++i ) {
3451  v_[i+j*MM] = Type();
3452  }
3453  }
3454 }
3456 //*************************************************************************************************
3457 
3458 
3459 //*************************************************************************************************
3484 template< typename Type // Data type of the matrix
3485  , size_t M // Number of rows
3486  , size_t N > // Number of columns
3487 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3488  const Type& v4, const Type& v5, const Type& v6 )
3489 {
3490  BLAZE_STATIC_ASSERT( M*N == 6UL );
3491 
3492  // Initialization of a 6x1 matrix
3493  if( N == 1UL ) {
3494  v_[0UL] = v1;
3495  v_[1UL] = v2;
3496  v_[2UL] = v3;
3497  v_[3UL] = v4;
3498  v_[4UL] = v5;
3499  v_[5UL] = v6;
3500  }
3501 
3502  // Initialization of a 3x2 matrix
3503  else if( N == 2UL ) {
3504  v_[ 0UL] = v1;
3505  v_[ 1UL] = v2;
3506  v_[ 2UL] = v3;
3507  v_[MM ] = v4;
3508  v_[MM+1UL] = v5;
3509  v_[MM+2UL] = v6;
3510  }
3511 
3512  // Initialization of a 2x3 matrix
3513  else if( N == 3UL ) {
3514  v_[ 0UL] = v1;
3515  v_[ 1UL] = v2;
3516  v_[ MM ] = v3;
3517  v_[ MM+1UL] = v4;
3518  v_[2UL*MM ] = v5;
3519  v_[2UL*MM+1UL] = v6;
3520  }
3521 
3522  // Initialization of a 1x6 matrix
3523  else {
3524  v_[ 0UL] = v1;
3525  v_[ MM] = v2;
3526  v_[2UL*MM] = v3;
3527  v_[3UL*MM] = v4;
3528  v_[4UL*MM] = v5;
3529  v_[5UL*MM] = v6;
3530  }
3531 
3532  if( IsNumeric<Type>::value ) {
3533  for( size_t j=0UL; j<N; ++j )
3534  for( size_t i=M; i<MM; ++i ) {
3535  v_[i+j*MM] = Type();
3536  }
3537  }
3538 }
3540 //*************************************************************************************************
3541 
3542 
3543 //*************************************************************************************************
3566 template< typename Type // Data type of the matrix
3567  , size_t M // Number of rows
3568  , size_t N > // Number of columns
3569 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3570  const Type& v4, const Type& v5, const Type& v6,
3571  const Type& v7 )
3572 {
3573  BLAZE_STATIC_ASSERT( M*N == 7UL );
3574 
3575  // Initialization of a 7x1 matrix
3576  if( N == 1UL ) {
3577  v_[0UL] = v1;
3578  v_[1UL] = v2;
3579  v_[2UL] = v3;
3580  v_[3UL] = v4;
3581  v_[4UL] = v5;
3582  v_[5UL] = v6;
3583  v_[6UL] = v7;
3584  }
3585 
3586  // Initialization of a 1x7 matrix
3587  else {
3588  v_[ 0UL] = v1;
3589  v_[ MM] = v2;
3590  v_[2UL*MM] = v3;
3591  v_[3UL*MM] = v4;
3592  v_[4UL*MM] = v5;
3593  v_[5UL*MM] = v6;
3594  v_[6UL*MM] = v7;
3595  }
3596 
3597  if( IsNumeric<Type>::value ) {
3598  for( size_t j=0UL; j<N; ++j )
3599  for( size_t i=M; i<MM; ++i ) {
3600  v_[i+j*MM] = Type();
3601  }
3602  }
3603 }
3605 //*************************************************************************************************
3606 
3607 
3608 //*************************************************************************************************
3635 template< typename Type // Data type of the matrix
3636  , size_t M // Number of rows
3637  , size_t N > // Number of columns
3638 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3639  const Type& v4, const Type& v5, const Type& v6,
3640  const Type& v7, const Type& v8 )
3641 {
3642  BLAZE_STATIC_ASSERT( M*N == 8UL );
3643 
3644  // Initialization of a 8x1 matrix
3645  if( N == 1UL ) {
3646  v_[0UL] = v1;
3647  v_[1UL] = v2;
3648  v_[2UL] = v3;
3649  v_[3UL] = v4;
3650  v_[4UL] = v5;
3651  v_[5UL] = v6;
3652  v_[6UL] = v7;
3653  v_[7UL] = v8;
3654  }
3655 
3656  // Initialization of a 4x2 matrix
3657  else if( N == 2UL ) {
3658  v_[ 0UL] = v1;
3659  v_[ 1UL] = v2;
3660  v_[ 2UL] = v3;
3661  v_[ 3UL] = v4;
3662  v_[MM ] = v5;
3663  v_[MM+1UL] = v6;
3664  v_[MM+2UL] = v7;
3665  v_[MM+3UL] = v8;
3666  }
3667 
3668  // Initialization of a 2x4 matrix
3669  else if( N == 4UL ) {
3670  v_[ 0UL] = v1;
3671  v_[ 1UL] = v2;
3672  v_[ MM ] = v3;
3673  v_[ MM+1UL] = v4;
3674  v_[2UL*MM ] = v5;
3675  v_[2UL*MM+1UL] = v6;
3676  v_[3UL*MM ] = v7;
3677  v_[3UL*MM+1UL] = v8;
3678  }
3679 
3680  // Initialization of a 1x8 matrix
3681  else {
3682  v_[ 0UL] = v1;
3683  v_[ MM] = v2;
3684  v_[2UL*MM] = v3;
3685  v_[3UL*MM] = v4;
3686  v_[4UL*MM] = v5;
3687  v_[5UL*MM] = v6;
3688  v_[6UL*MM] = v7;
3689  v_[7UL*MM] = v8;
3690  }
3691 
3692  if( IsNumeric<Type>::value ) {
3693  for( size_t j=0UL; j<N; ++j )
3694  for( size_t i=M; i<MM; ++i ) {
3695  v_[i+j*MM] = Type();
3696  }
3697  }
3698 }
3700 //*************************************************************************************************
3701 
3702 
3703 //*************************************************************************************************
3731 template< typename Type // Data type of the matrix
3732  , size_t M // Number of rows
3733  , size_t N > // Number of columns
3734 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3735  const Type& v4, const Type& v5, const Type& v6,
3736  const Type& v7, const Type& v8, const Type& v9 )
3737 {
3738  BLAZE_STATIC_ASSERT( M*N == 9UL );
3739 
3740  // Initialization of a 9x1 matrix
3741  if( N == 1 ) {
3742  v_[0UL] = v1;
3743  v_[1UL] = v2;
3744  v_[2UL] = v3;
3745  v_[3UL] = v4;
3746  v_[4UL] = v5;
3747  v_[5UL] = v6;
3748  v_[6UL] = v7;
3749  v_[7UL] = v8;
3750  v_[8UL] = v9;
3751  }
3752 
3753  // Initialization of a 3x3 matrix
3754  else if( N == 3UL ) {
3755  v_[ 0UL] = v1;
3756  v_[ 1UL] = v2;
3757  v_[ 2UL] = v3;
3758  v_[ MM ] = v4;
3759  v_[ MM+1UL] = v5;
3760  v_[ MM+2UL] = v6;
3761  v_[2UL*MM ] = v7;
3762  v_[2UL*MM+1UL] = v8;
3763  v_[2UL*MM+2UL] = v9;
3764  }
3765 
3766  // Initialization of a 1x9 matrix
3767  else {
3768  v_[ 0UL] = v1;
3769  v_[ MM] = v2;
3770  v_[2UL*MM] = v3;
3771  v_[3UL*MM] = v4;
3772  v_[4UL*MM] = v5;
3773  v_[5UL*MM] = v6;
3774  v_[6UL*MM] = v7;
3775  v_[7UL*MM] = v8;
3776  v_[8UL*MM] = v9;
3777  }
3778 
3779  if( IsNumeric<Type>::value ) {
3780  for( size_t j=0UL; j<N; ++j )
3781  for( size_t i=M; i<MM; ++i ) {
3782  v_[i+j*MM] = Type();
3783  }
3784  }
3785 }
3787 //*************************************************************************************************
3788 
3789 
3790 //*************************************************************************************************
3819 template< typename Type // Data type of the matrix
3820  , size_t M // Number of rows
3821  , size_t N > // Number of columns
3822 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3823  const Type& v4, const Type& v5, const Type& v6,
3824  const Type& v7, const Type& v8, const Type& v9,
3825  const Type& v10 )
3826 {
3827  BLAZE_STATIC_ASSERT( M*N == 10UL );
3828 
3829  // Initialization of a 10x1 matrix
3830  if( N == 1UL ) {
3831  v_[0UL] = v1;
3832  v_[1UL] = v2;
3833  v_[2UL] = v3;
3834  v_[3UL] = v4;
3835  v_[4UL] = v5;
3836  v_[5UL] = v6;
3837  v_[6UL] = v7;
3838  v_[7UL] = v8;
3839  v_[8UL] = v9;
3840  v_[9UL] = v10;
3841  }
3842 
3843  // Initialization of a 5x2 matrix
3844  else if( N == 2UL ) {
3845  v_[ 0UL] = v1;
3846  v_[ 1UL] = v2;
3847  v_[ 2UL] = v3;
3848  v_[ 3UL] = v4;
3849  v_[ 4UL] = v5;
3850  v_[MM ] = v6;
3851  v_[MM+1UL] = v7;
3852  v_[MM+2UL] = v8;
3853  v_[MM+3UL] = v9;
3854  v_[MM+4UL] = v10;
3855  }
3856 
3857  // Initialization of a 2x5 matrix
3858  else if( N == 5UL ) {
3859  v_[ 0UL] = v1;
3860  v_[ 1UL] = v2;
3861  v_[ MM ] = v3;
3862  v_[ MM+1UL] = v4;
3863  v_[2UL*MM ] = v5;
3864  v_[2UL*MM+1UL] = v6;
3865  v_[3UL*MM ] = v7;
3866  v_[3UL*MM+1UL] = v8;
3867  v_[4UL*MM ] = v9;
3868  v_[4UL*MM+1UL] = v10;
3869  }
3870 
3871  // Initialization of a 1x10 matrix
3872  else {
3873  v_[ 0UL] = v1;
3874  v_[ MM] = v2;
3875  v_[2UL*MM] = v3;
3876  v_[3UL*MM] = v4;
3877  v_[4UL*MM] = v5;
3878  v_[5UL*MM] = v6;
3879  v_[6UL*MM] = v7;
3880  v_[7UL*MM] = v8;
3881  v_[8UL*MM] = v9;
3882  v_[9UL*MM] = v10;
3883  }
3884 
3885  if( IsNumeric<Type>::value ) {
3886  for( size_t j=0UL; j<N; ++j )
3887  for( size_t i=M; i<MM; ++i ) {
3888  v_[i+j*MM] = Type();
3889  }
3890  }
3891 }
3893 //*************************************************************************************************
3894 
3895 
3896 
3897 
3898 //=================================================================================================
3899 //
3900 // DATA ACCESS FUNCTIONS
3901 //
3902 //=================================================================================================
3903 
3904 //*************************************************************************************************
3912 template< typename Type // Data type of the matrix
3913  , size_t M // Number of rows
3914  , size_t N > // Number of columns
3916  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
3917 {
3918  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3919  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3920  return v_[i+j*MM];
3921 }
3923 //*************************************************************************************************
3924 
3925 
3926 //*************************************************************************************************
3934 template< typename Type // Data type of the matrix
3935  , size_t M // Number of rows
3936  , size_t N > // Number of columns
3938  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
3939 {
3940  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3941  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3942  return v_[i+j*MM];
3943 }
3945 //*************************************************************************************************
3946 
3947 
3948 //*************************************************************************************************
3958 template< typename Type // Data type of the matrix
3959  , size_t M // Number of rows
3960  , size_t N > // Number of columns
3961 inline Type* StaticMatrix<Type,M,N,true>::data()
3962 {
3963  return v_;
3964 }
3966 //*************************************************************************************************
3967 
3968 
3969 //*************************************************************************************************
3979 template< typename Type // Data type of the matrix
3980  , size_t M // Number of rows
3981  , size_t N > // Number of columns
3982 inline const Type* StaticMatrix<Type,M,N,true>::data() const
3983 {
3984  return v_;
3985 }
3987 //*************************************************************************************************
3988 
3989 
3990 //*************************************************************************************************
3999 template< typename Type // Data type of the matrix
4000  , size_t M // Number of rows
4001  , size_t N > // Number of columns
4002 inline Type* StaticMatrix<Type,M,N,true>::data( size_t j )
4003 {
4004  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4005  return v_ + j*MM;
4006 }
4008 //*************************************************************************************************
4009 
4010 
4011 //*************************************************************************************************
4020 template< typename Type // Data type of the matrix
4021  , size_t M // Number of rows
4022  , size_t N > // Number of columns
4023 inline const Type* StaticMatrix<Type,M,N,true>::data( size_t j ) const
4024 {
4025  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4026  return v_ + j*MM;
4027 }
4029 //*************************************************************************************************
4030 
4031 
4032 //*************************************************************************************************
4039 template< typename Type // Data type of the matrix
4040  , size_t M // Number of rows
4041  , size_t N > // Number of columns
4044 {
4045  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4046  return Iterator( v_ + j*MM );
4047 }
4049 //*************************************************************************************************
4050 
4051 
4052 //*************************************************************************************************
4059 template< typename Type // Data type of the matrix
4060  , size_t M // Number of rows
4061  , size_t N > // Number of columns
4063  StaticMatrix<Type,M,N,true>::begin( size_t j ) const
4064 {
4065  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4066  return ConstIterator( v_ + j*MM );
4067 }
4069 //*************************************************************************************************
4070 
4071 
4072 //*************************************************************************************************
4079 template< typename Type // Data type of the matrix
4080  , size_t M // Number of rows
4081  , size_t N > // Number of columns
4083  StaticMatrix<Type,M,N,true>::cbegin( size_t j ) const
4084 {
4085  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4086  return ConstIterator( v_ + j*MM );
4087 }
4089 //*************************************************************************************************
4090 
4091 
4092 //*************************************************************************************************
4099 template< typename Type // Data type of the matrix
4100  , size_t M // Number of rows
4101  , size_t N > // Number of columns
4104 {
4105  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4106  return Iterator( v_ + j*MM + M );
4107 }
4109 //*************************************************************************************************
4110 
4111 
4112 //*************************************************************************************************
4119 template< typename Type // Data type of the matrix
4120  , size_t M // Number of rows
4121  , size_t N > // Number of columns
4123  StaticMatrix<Type,M,N,true>::end( size_t j ) const
4124 {
4125  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4126  return ConstIterator( v_ + j*MM + M );
4127 }
4129 //*************************************************************************************************
4130 
4131 
4132 //*************************************************************************************************
4139 template< typename Type // Data type of the matrix
4140  , size_t M // Number of rows
4141  , size_t N > // Number of columns
4143  StaticMatrix<Type,M,N,true>::cend( size_t j ) const
4144 {
4145  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4146  return ConstIterator( v_ + j*MM + M );
4147 }
4149 //*************************************************************************************************
4150 
4151 
4152 
4153 
4154 //=================================================================================================
4155 //
4156 // ASSIGNMENT OPERATORS
4157 //
4158 //=================================================================================================
4159 
4160 //*************************************************************************************************
4182 template< typename Type // Data type of the matrix
4183  , size_t M // Number of rows
4184  , size_t N > // Number of columns
4185 template< typename Other > // Data type of the initialization array
4186 inline StaticMatrix<Type,M,N,true>&
4187  StaticMatrix<Type,M,N,true>::operator=( const Other (&array)[M][N] )
4188 {
4189  for( size_t j=0UL; j<N; ++j )
4190  for( size_t i=0UL; i<M; ++i )
4191  v_[i+j*MM] = array[i][j];
4192 
4193  return *this;
4194 }
4196 //*************************************************************************************************
4197 
4198 
4199 //*************************************************************************************************
4206 template< typename Type // Data type of the matrix
4207  , size_t M // Number of rows
4208  , size_t N > // Number of columns
4209 inline StaticMatrix<Type,M,N,true>&
4210  StaticMatrix<Type,M,N,true>::operator=( const Type& set )
4211 {
4212  for( size_t j=0UL; j<N; ++j )
4213  for( size_t i=0UL; i<M; ++i )
4214  v_[i+j*MM] = set;
4215 
4216  return *this;
4217 }
4219 //*************************************************************************************************
4220 
4221 
4222 //*************************************************************************************************
4231 template< typename Type // Data type of the matrix
4232  , size_t M // Number of rows
4233  , size_t N > // Number of columns
4234 inline StaticMatrix<Type,M,N,true>&
4235  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix& rhs )
4236 {
4237  for( size_t j=0UL; j<N; ++j )
4238  for( size_t i=0UL; i<M; ++i )
4239  v_[i+j*MM] = rhs(i,j);
4240 
4241  return *this;
4242 }
4244 //*************************************************************************************************
4245 
4246 
4247 //*************************************************************************************************
4254 template< typename Type // Data type of the matrix
4255  , size_t M // Number of rows
4256  , size_t N > // Number of columns
4257 template< typename Other // Data type of the foreign matrix
4258  , bool SO > // Storage order of the foreign matrix
4259 inline StaticMatrix<Type,M,N,true>&
4260  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix<Other,M,N,SO>& rhs )
4261 {
4262  for( size_t j=0UL; j<N; ++j )
4263  for( size_t i=0UL; i<M; ++i )
4264  v_[i+j*MM] = rhs(i,j);
4265 
4266  return *this;
4267 }
4269 //*************************************************************************************************
4270 
4271 
4272 //*************************************************************************************************
4284 template< typename Type // Data type of the matrix
4285  , size_t M // Number of rows
4286  , size_t N > // Number of columns
4287 template< typename MT // Type of the right-hand side matrix
4288  , bool SO > // Storage order of the right-hand side matrix
4289 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
4290 {
4291  using blaze::assign;
4292 
4293  if( (~rhs).rows() != M || (~rhs).columns() != N )
4294  throw std::invalid_argument( "Invalid assignment to static matrix" );
4295 
4296  if( (~rhs).canAlias( this ) ) {
4297  StaticMatrix tmp( ~rhs );
4298  swap( tmp );
4299  }
4300  else {
4301  if( IsSparseMatrix<MT>::value )
4302  reset();
4303  assign( *this, ~rhs );
4304  }
4305 
4306  return *this;
4307 }
4309 //*************************************************************************************************
4310 
4311 
4312 //*************************************************************************************************
4323 template< typename Type // Data type of the matrix
4324  , size_t M // Number of rows
4325  , size_t N > // Number of columns
4326 template< typename MT // Type of the right-hand side matrix
4327  , bool SO > // Storage order of the right-hand side matrix
4328 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
4329 {
4330  using blaze::addAssign;
4331 
4332  if( (~rhs).rows() != M || (~rhs).columns() != N )
4333  throw std::invalid_argument( "Matrix sizes do not match" );
4334 
4335  if( (~rhs).canAlias( this ) ) {
4336  StaticMatrix tmp( ~rhs );
4337  addAssign( *this, tmp );
4338  }
4339  else {
4340  addAssign( *this, ~rhs );
4341  }
4342 
4343  return *this;
4344 }
4346 //*************************************************************************************************
4347 
4348 
4349 //*************************************************************************************************
4360 template< typename Type // Data type of the matrix
4361  , size_t M // Number of rows
4362  , size_t N > // Number of columns
4363 template< typename MT // Type of the right-hand side matrix
4364  , bool SO > // Storage order of the right-hand side matrix
4365 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
4366 {
4367  using blaze::subAssign;
4368 
4369  if( (~rhs).rows() != M || (~rhs).columns() != N )
4370  throw std::invalid_argument( "Matrix sizes do not match" );
4371 
4372  if( (~rhs).canAlias( this ) ) {
4373  StaticMatrix tmp( ~rhs );
4374  subAssign( *this, tmp );
4375  }
4376  else {
4377  subAssign( *this, ~rhs );
4378  }
4379 
4380  return *this;
4381 }
4383 //*************************************************************************************************
4384 
4385 
4386 //*************************************************************************************************
4397 template< typename Type // Data type of the matrix
4398  , size_t M // Number of rows
4399  , size_t N > // Number of columns
4400 template< typename MT // Type of the right-hand side matrix
4401  , bool SO > // Storage order of the right-hand side matrix
4402 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
4403 {
4404  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
4405  throw std::invalid_argument( "Matrix sizes do not match" );
4406 
4407  StaticMatrix tmp( *this * (~rhs) );
4408  return this->operator=( tmp );
4409 }
4411 //*************************************************************************************************
4412 
4413 
4414 //*************************************************************************************************
4422 template< typename Type // Data type of the matrix
4423  , size_t M // Number of rows
4424  , size_t N > // Number of columns
4425 template< typename Other > // Data type of the right-hand side scalar
4426 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4427  StaticMatrix<Type,M,N,true>::operator*=( Other rhs )
4428 {
4429  using blaze::assign;
4430 
4431  assign( *this, (*this) * rhs );
4432  return *this;
4433 }
4435 //*************************************************************************************************
4436 
4437 
4438 //*************************************************************************************************
4448 template< typename Type // Data type of the matrix
4449  , size_t M // Number of rows
4450  , size_t N > // Number of columns
4451 template< typename Other > // Data type of the right-hand side scalar
4452 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4453  StaticMatrix<Type,M,N,true>::operator/=( Other rhs )
4454 {
4455  using blaze::assign;
4456 
4457  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4458 
4459  assign( *this, (*this) / rhs );
4460  return *this;
4461 }
4463 //*************************************************************************************************
4464 
4465 
4466 
4467 
4468 //=================================================================================================
4469 //
4470 // UTILITY FUNCTIONS
4471 //
4472 //=================================================================================================
4473 
4474 //*************************************************************************************************
4480 template< typename Type // Data type of the matrix
4481  , size_t M // Number of rows
4482  , size_t N > // Number of columns
4483 inline size_t StaticMatrix<Type,M,N,true>::rows() const
4484 {
4485  return M;
4486 }
4488 //*************************************************************************************************
4489 
4490 
4491 //*************************************************************************************************
4497 template< typename Type // Data type of the matrix
4498  , size_t M // Number of rows
4499  , size_t N > // Number of columns
4500 inline size_t StaticMatrix<Type,M,N,true>::columns() const
4501 {
4502  return N;
4503 }
4505 //*************************************************************************************************
4506 
4507 
4508 //*************************************************************************************************
4517 template< typename Type // Data type of the matrix
4518  , size_t M // Number of rows
4519  , size_t N > // Number of columns
4520 inline size_t StaticMatrix<Type,M,N,true>::spacing() const
4521 {
4522  return MM;
4523 }
4525 //*************************************************************************************************
4526 
4527 
4528 //*************************************************************************************************
4534 template< typename Type // Data type of the matrix
4535  , size_t M // Number of rows
4536  , size_t N > // Number of columns
4537 inline size_t StaticMatrix<Type,M,N,true>::capacity() const
4538 {
4539  return MM*N;
4540 }
4542 //*************************************************************************************************
4543 
4544 
4545 //*************************************************************************************************
4552 template< typename Type // Data type of the matrix
4553  , size_t M // Number of rows
4554  , size_t N > // Number of columns
4555 inline size_t StaticMatrix<Type,M,N,true>::capacity( size_t j ) const
4556 {
4557  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4558  return MM;
4559 }
4561 //*************************************************************************************************
4562 
4563 
4564 //*************************************************************************************************
4570 template< typename Type // Data type of the matrix
4571  , size_t M // Number of rows
4572  , size_t N > // Number of columns
4573 inline size_t StaticMatrix<Type,M,N,true>::nonZeros() const
4574 {
4575  size_t nonzeros( 0UL );
4576 
4577  for( size_t j=0UL; j<N; ++j )
4578  for( size_t i=0UL; i<M; ++i )
4579  if( !isDefault( v_[i+j*MM] ) )
4580  ++nonzeros;
4581 
4582  return nonzeros;
4583 }
4585 //*************************************************************************************************
4586 
4587 
4588 //*************************************************************************************************
4595 template< typename Type // Data type of the matrix
4596  , size_t M // Number of rows
4597  , size_t N > // Number of columns
4598 inline size_t StaticMatrix<Type,M,N,true>::nonZeros( size_t j ) const
4599 {
4600  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4601 
4602  const size_t iend( (j+1UL)*MM );
4603  size_t nonzeros( 0UL );
4604 
4605  for( size_t i=j*MM; i<iend; ++i )
4606  if( !isDefault( v_[i] ) )
4607  ++nonzeros;
4608 
4609  return nonzeros;
4610 }
4612 //*************************************************************************************************
4613 
4614 
4615 //*************************************************************************************************
4621 template< typename Type // Data type of the matrix
4622  , size_t M // Number of rows
4623  , size_t N > // Number of columns
4625 {
4626  using blaze::reset;
4627 
4628  for( size_t j=0UL; j<N; ++j )
4629  for( size_t i=0UL; i<M; ++i )
4630  reset( v_[i+j*MM] );
4631 }
4633 //*************************************************************************************************
4634 
4635 
4636 //*************************************************************************************************
4646 template< typename Type // Data type of the matrix
4647  , size_t M // Number of rows
4648  , size_t N > // Number of columns
4649 inline void StaticMatrix<Type,M,N,true>::reset( size_t j )
4650 {
4651  using blaze::reset;
4652 
4653  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4654  for( size_t i=0UL; i<M; ++i )
4655  reset( v_[i+j*MM] );
4656 }
4658 //*************************************************************************************************
4659 
4660 
4661 //*************************************************************************************************
4667 template< typename Type // Data type of the matrix
4668  , size_t M // Number of rows
4669  , size_t N > // Number of columns
4670 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::transpose()
4671 {
4672  using std::swap;
4673 
4674  for( size_t j=1UL; j<N; ++j )
4675  for( size_t i=0UL; i<j; ++i )
4676  swap( v_[i+j*MM], v_[j+i*MM] );
4677 
4678  return *this;
4679 }
4681 //*************************************************************************************************
4682 
4683 
4684 //*************************************************************************************************
4691 template< typename Type // Data type of the matrix
4692  , size_t M // Number of rows
4693  , size_t N > // Number of columns
4694 template< typename Other > // Data type of the scalar value
4695 inline StaticMatrix<Type,M,N,true>&
4696  StaticMatrix<Type,M,N,true>::scale( const Other& scalar )
4697 {
4698  for( size_t j=0UL; j<N; ++j )
4699  for( size_t i=0UL; i<M; ++i )
4700  v_[i+j*MM] *= scalar;
4701 
4702  return *this;
4703 }
4705 //*************************************************************************************************
4706 
4707 
4708 //*************************************************************************************************
4716 template< typename Type // Data type of the matrix
4717  , size_t M // Number of rows
4718  , size_t N > // Number of columns
4719 inline void StaticMatrix<Type,M,N,true>::swap( StaticMatrix& m ) /* throw() */
4720 {
4721  using std::swap;
4722 
4723  for( size_t j=0UL; j<N; ++j ) {
4724  for( size_t i=0UL; i<M; ++i ) {
4725  swap( v_[i+j*MM], m(i,j) );
4726  }
4727  }
4728 }
4730 //*************************************************************************************************
4731 
4732 
4733 
4734 
4735 //=================================================================================================
4736 //
4737 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4738 //
4739 //=================================================================================================
4740 
4741 //*************************************************************************************************
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 foreign expression
4756 inline bool StaticMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
4757 {
4758  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4759 }
4761 //*************************************************************************************************
4762 
4763 
4764 //*************************************************************************************************
4775 template< typename Type // Data type of the matrix
4776  , size_t M // Number of rows
4777  , size_t N > // Number of columns
4778 template< typename Other > // Data type of the foreign expression
4779 inline bool StaticMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
4780 {
4781  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4782 }
4784 //*************************************************************************************************
4785 
4786 
4787 //*************************************************************************************************
4802 template< typename Type // Data type of the matrix
4803  , size_t M // Number of rows
4804  , size_t N > // Number of columns
4805 inline typename StaticMatrix<Type,M,N,true>::IntrinsicType
4806  StaticMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
4807 {
4808  using blaze::load;
4809 
4811 
4812  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4813  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4814  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4815  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4816 
4817  return load( &v_[i+j*MM] );
4818 }
4820 //*************************************************************************************************
4821 
4822 
4823 //*************************************************************************************************
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 typename StaticMatrix<Type,M,N,true>::IntrinsicType
4842  StaticMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
4843 {
4844  using blaze::loadu;
4845 
4847 
4848  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4849  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4850  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4851 
4852  return loadu( &v_[i+j*MM] );
4853 }
4855 //*************************************************************************************************
4856 
4857 
4858 //*************************************************************************************************
4874 template< typename Type // Data type of the matrix
4875  , size_t M // Number of rows
4876  , size_t N > // Number of columns
4877 inline void StaticMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
4878 {
4879  using blaze::store;
4880 
4882 
4883  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4884  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4885  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4886  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4887 
4888  store( &v_[i+j*MM], value );
4889 }
4891 //*************************************************************************************************
4892 
4893 
4894 //*************************************************************************************************
4910 template< typename Type // Data type of the matrix
4911  , size_t M // Number of rows
4912  , size_t N > // Number of columns
4913 inline void StaticMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4914 {
4915  using blaze::storeu;
4916 
4918 
4919  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4920  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
4921  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4922 
4923  storeu( &v_[i+j*MM], value );
4924 }
4926 //*************************************************************************************************
4927 
4928 
4929 //*************************************************************************************************
4946 template< typename Type // Data type of the matrix
4947  , size_t M // Number of rows
4948  , size_t N > // Number of columns
4949 inline void StaticMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
4950 {
4951  using blaze::stream;
4952 
4954 
4955  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4956  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4957  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4958  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4959 
4960  stream( &v_[i+j*MM], value );
4961 }
4963 //*************************************************************************************************
4964 
4965 
4966 //*************************************************************************************************
4978 template< typename Type // Data type of the matrix
4979  , size_t M // Number of rows
4980  , size_t N > // Number of columns
4981 template< typename MT // Type of the right-hand side dense matrix
4982  , bool SO > // Storage order of the right-hand side dense matrix
4983 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4984  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
4985 {
4986  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
4987 
4988  for( size_t j=0UL; j<N; ++j ) {
4989  for( size_t i=0UL; i<M; ++i ) {
4990  v_[i+j*MM] = (~rhs)(i,j);
4991  }
4992  }
4993 }
4995 //*************************************************************************************************
4996 
4997 
4998 //*************************************************************************************************
5010 template< typename Type // Data type of the matrix
5011  , size_t M // Number of rows
5012  , size_t N > // Number of columns
5013 template< typename MT // Type of the right-hand side dense matrix
5014  , bool SO > // Storage order of the right-hand side dense matrix
5015 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5016  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5017 {
5018  using blaze::store;
5019 
5020  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5021 
5023 
5024  for( size_t j=0UL; j<N; ++j ) {
5025  for( size_t i=0UL; i<M; i+=IT::size ) {
5026  store( &v_[i+j*MM], (~rhs).load(i,j) );
5027  }
5028  }
5029 }
5031 //*************************************************************************************************
5032 
5033 
5034 //*************************************************************************************************
5046 template< typename Type // Data type of the matrix
5047  , size_t M // Number of rows
5048  , size_t N > // Number of columns
5049 template< typename MT > // Type of the right-hand side sparse matrix
5050 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
5051 {
5052  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5053 
5054  typedef typename MT::ConstIterator RhsConstIterator;
5055 
5056  for( size_t j=0UL; j<N; ++j )
5057  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5058  v_[element->index()+j*MM] = element->value();
5059 }
5061 //*************************************************************************************************
5062 
5063 
5064 //*************************************************************************************************
5076 template< typename Type // Data type of the matrix
5077  , size_t M // Number of rows
5078  , size_t N > // Number of columns
5079 template< typename MT > // Type of the right-hand side sparse matrix
5080 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
5081 {
5082  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5083 
5084  typedef typename MT::ConstIterator RhsConstIterator;
5085 
5086  for( size_t i=0UL; i<M; ++i )
5087  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5088  v_[i+element->index()*MM] = element->value();
5089 }
5091 //*************************************************************************************************
5092 
5093 
5094 //*************************************************************************************************
5106 template< typename Type // Data type of the matrix
5107  , size_t M // Number of rows
5108  , size_t N > // Number of columns
5109 template< typename MT // Type of the right-hand side dense matrix
5110  , bool SO > // Storage order of the right-hand side dense matrix
5111 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5112  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5113 {
5114  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5115 
5116  for( size_t j=0UL; j<N; ++j ) {
5117  for( size_t i=0UL; i<M; ++i ) {
5118  v_[i+j*MM] += (~rhs)(i,j);
5119  }
5120  }
5121 }
5123 //*************************************************************************************************
5124 
5125 
5126 //*************************************************************************************************
5138 template< typename Type // Data type of the matrix
5139  , size_t M // Number of rows
5140  , size_t N > // Number of columns
5141 template< typename MT // Type of the right-hand side dense matrix
5142  , bool SO > // Storage order of the right-hand side dense matrix
5143 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5144  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5145 {
5146  using blaze::load;
5147  using blaze::store;
5148 
5149  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5150 
5152 
5153  for( size_t j=0UL; j<N; ++j ) {
5154  for( size_t i=0UL; i<M; i+=IT::size ) {
5155  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
5156  }
5157  }
5158 }
5160 //*************************************************************************************************
5161 
5162 
5163 //*************************************************************************************************
5175 template< typename Type // Data type of the matrix
5176  , size_t M // Number of rows
5177  , size_t N > // Number of columns
5178 template< typename MT > // Type of the right-hand side sparse matrix
5179 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
5180 {
5181  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5182 
5183  typedef typename MT::ConstIterator RhsConstIterator;
5184 
5185  for( size_t j=0UL; j<N; ++j )
5186  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5187  v_[element->index()+j*MM] += element->value();
5188 }
5190 //*************************************************************************************************
5191 
5192 
5193 //*************************************************************************************************
5205 template< typename Type // Data type of the matrix
5206  , size_t M // Number of rows
5207  , size_t N > // Number of columns
5208 template< typename MT > // Type of the right-hand side sparse matrix
5209 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
5210 {
5211  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5212 
5213  typedef typename MT::ConstIterator RhsConstIterator;
5214 
5215  for( size_t i=0UL; i<M; ++i )
5216  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5217  v_[i+element->index()*MM] += element->value();
5218 }
5220 //*************************************************************************************************
5221 
5222 
5223 //*************************************************************************************************
5235 template< typename Type // Data type of the matrix
5236  , size_t M // Number of rows
5237  , size_t N > // Number of columns
5238 template< typename MT // Type of the right-hand side dense matrix
5239  , bool SO > // Storage order of the right-hand side dense matrix
5240 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5241  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5242 {
5243  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5244 
5245  for( size_t j=0UL; j<N; ++j ) {
5246  for( size_t i=0UL; i<M; ++i ) {
5247  v_[i+j*MM] -= (~rhs)(i,j);
5248  }
5249  }
5250 }
5252 //*************************************************************************************************
5253 
5254 
5255 //*************************************************************************************************
5267 template< typename Type // Data type of the matrix
5268  , size_t M // Number of rows
5269  , size_t N > // Number of columns
5270 template< typename MT // Type of the right-hand side dense matrix
5271  , bool SO > // Storage order of the right-hand side dense matrix
5272 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5273  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5274 {
5275  using blaze::load;
5276  using blaze::store;
5277 
5278  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5279 
5281 
5282  for( size_t j=0UL; j<N; ++j ) {
5283  for( size_t i=0UL; i<M; i+=IT::size ) {
5284  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
5285  }
5286  }
5287 }
5289 //*************************************************************************************************
5290 
5291 
5292 //*************************************************************************************************
5304 template< typename Type // Data type of the matrix
5305  , size_t M // Number of rows
5306  , size_t N > // Number of columns
5307 template< typename MT > // Type of the right-hand side sparse matrix
5308 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
5309 {
5310  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5311 
5312  typedef typename MT::ConstIterator RhsConstIterator;
5313 
5314  for( size_t j=0UL; j<N; ++j )
5315  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5316  v_[element->index()+j*MM] -= element->value();
5317 }
5319 //*************************************************************************************************
5320 
5321 
5322 //*************************************************************************************************
5334 template< typename Type // Data type of the matrix
5335  , size_t M // Number of rows
5336  , size_t N > // Number of columns
5337 template< typename MT > // Type of the right-hand side sparse matrix
5338 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
5339 {
5340  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5341 
5342  typedef typename MT::ConstIterator RhsConstIterator;
5343 
5344  for( size_t i=0UL; i<M; ++i )
5345  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5346  v_[i+element->index()*MM] -= element->value();
5347 }
5349 //*************************************************************************************************
5350 
5351 
5352 
5353 
5354 
5355 
5356 
5357 
5358 //=================================================================================================
5359 //
5360 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
5361 //
5362 //=================================================================================================
5363 
5364 //*************************************************************************************************
5372 template< typename Type // Data type of the matrix
5373  , size_t M // Number of rows
5374  , bool SO > // Storage order
5375 class StaticMatrix<Type,M,0UL,SO>;
5377 //*************************************************************************************************
5378 
5379 
5380 //*************************************************************************************************
5388 template< typename Type // Data type of the matrix
5389  , size_t N // Number of columns
5390  , bool SO > // Storage order
5391 class StaticMatrix<Type,0UL,N,SO>;
5393 //*************************************************************************************************
5394 
5395 
5396 //*************************************************************************************************
5404 template< typename Type // Data type of the matrix
5405  , bool SO > // Storage order
5406 class StaticMatrix<Type,0UL,0UL,SO>;
5408 //*************************************************************************************************
5409 
5410 
5411 
5412 
5413 
5414 
5415 
5416 
5417 //=================================================================================================
5418 //
5419 // STATICMATRIX OPERATORS
5420 //
5421 //=================================================================================================
5422 
5423 //*************************************************************************************************
5426 template< typename Type, size_t M, size_t N, bool SO >
5427 inline void reset( StaticMatrix<Type,M,N,SO>& m );
5428 
5429 template< typename Type, size_t M, size_t N, bool SO >
5430 inline void clear( StaticMatrix<Type,M,N,SO>& m );
5431 
5432 template< typename Type, size_t M, size_t N, bool SO >
5433 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m );
5434 
5435 template< typename Type, size_t M, size_t N, bool SO >
5436 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */;
5438 //*************************************************************************************************
5439 
5440 
5441 //*************************************************************************************************
5448 template< typename Type // Data type of the matrix
5449  , size_t M // Number of rows
5450  , size_t N // Number of columns
5451  , bool SO > // Storage order
5453 {
5454  m.reset();
5455 }
5456 //*************************************************************************************************
5457 
5458 
5459 //*************************************************************************************************
5468 template< typename Type // Data type of the matrix
5469  , size_t M // Number of rows
5470  , size_t N // Number of columns
5471  , bool SO > // Storage order
5473 {
5474  m.reset();
5475 }
5476 //*************************************************************************************************
5477 
5478 
5479 //*************************************************************************************************
5486 template< typename Type // Data type of the matrix
5487  , size_t M // Number of rows
5488  , size_t N // Number of columns
5489  , bool SO > // Storage order
5490 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m )
5491 {
5492  if( SO == rowMajor ) {
5493  for( size_t i=0UL; i<M; ++i )
5494  for( size_t j=0UL; j<N; ++j )
5495  if( !isDefault( m(i,j) ) ) return false;
5496  }
5497  else {
5498  for( size_t j=0UL; j<N; ++j )
5499  for( size_t i=0UL; i<M; ++i )
5500  if( !isDefault( m(i,j) ) ) return false;
5501  }
5502 
5503  return true;
5504 }
5505 //*************************************************************************************************
5506 
5507 
5508 //*************************************************************************************************
5517 template< typename Type // Data type of the matrix
5518  , size_t M // Number of rows
5519  , size_t N // Number of columns
5520  , bool SO > // Storage order
5521 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */
5522 {
5523  a.swap( b );
5524 }
5525 //*************************************************************************************************
5526 
5527 
5528 
5529 
5530 //=================================================================================================
5531 //
5532 // ADDTRAIT SPECIALIZATIONS
5533 //
5534 //=================================================================================================
5535 
5536 //*************************************************************************************************
5538 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5539 struct AddTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5540 {
5541  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5542 };
5543 
5544 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5545 struct AddTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
5546 {
5547  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5548 };
5550 //*************************************************************************************************
5551 
5552 
5553 
5554 
5555 //=================================================================================================
5556 //
5557 // SUBTRAIT SPECIALIZATIONS
5558 //
5559 //=================================================================================================
5560 
5561 //*************************************************************************************************
5563 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5564 struct SubTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5565 {
5566  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5567 };
5568 
5569 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5570 struct SubTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
5571 {
5572  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5573 };
5575 //*************************************************************************************************
5576 
5577 
5578 
5579 
5580 //=================================================================================================
5581 //
5582 // MULTTRAIT SPECIALIZATIONS
5583 //
5584 //=================================================================================================
5585 
5586 //*************************************************************************************************
5588 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5589 struct MultTrait< StaticMatrix<T1,M,N,SO>, T2 >
5590 {
5591  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5593 };
5594 
5595 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5596 struct MultTrait< T1, StaticMatrix<T2,M,N,SO> >
5597 {
5598  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5600 };
5601 
5602 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5603 struct MultTrait< StaticMatrix<T1,M,N,SO>, StaticVector<T2,N,false> >
5604 {
5605  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5606 };
5607 
5608 template< typename T1, size_t M, typename T2, size_t N, bool SO >
5609 struct MultTrait< StaticVector<T1,M,true>, StaticMatrix<T2,M,N,SO> >
5610 {
5611  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5612 };
5613 
5614 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t L >
5615 struct MultTrait< StaticMatrix<T1,M,N,SO>, HybridVector<T2,L,false> >
5616 {
5617  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5618 };
5619 
5620 template< typename T1, size_t L, typename T2, size_t M, size_t N, bool SO >
5621 struct MultTrait< HybridVector<T1,L,true>, StaticMatrix<T2,M,N,SO> >
5622 {
5623  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5624 };
5625 
5626 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5627 struct MultTrait< StaticMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5628 {
5629  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5630 };
5631 
5632 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5633 struct MultTrait< DynamicVector<T1,true>, StaticMatrix<T2,M,N,SO> >
5634 {
5635  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5636 };
5637 
5638 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5639 struct MultTrait< StaticMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5640 {
5641  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5642 };
5643 
5644 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5645 struct MultTrait< CompressedVector<T1,true>, StaticMatrix<T2,M,N,SO> >
5646 {
5647  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5648 };
5649 
5650 template< typename T1, size_t M, size_t K, bool SO1, typename T2, size_t N, bool SO2 >
5651 struct MultTrait< StaticMatrix<T1,M,K,SO1>, StaticMatrix<T2,K,N,SO2> >
5652 {
5653  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO1 > Type;
5654 };
5656 //*************************************************************************************************
5657 
5658 
5659 
5660 
5661 //=================================================================================================
5662 //
5663 // DIVTRAIT SPECIALIZATIONS
5664 //
5665 //=================================================================================================
5666 
5667 //*************************************************************************************************
5669 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5670 struct DivTrait< StaticMatrix<T1,M,N,SO>, T2 >
5671 {
5672  typedef StaticMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5674 };
5676 //*************************************************************************************************
5677 
5678 
5679 
5680 
5681 //=================================================================================================
5682 //
5683 // MATHTRAIT SPECIALIZATIONS
5684 //
5685 //=================================================================================================
5686 
5687 //*************************************************************************************************
5689 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5690 struct MathTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5691 {
5692  typedef StaticMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5693  typedef StaticMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5694 };
5696 //*************************************************************************************************
5697 
5698 
5699 
5700 
5701 //=================================================================================================
5702 //
5703 // SUBMATRIXTRAIT SPECIALIZATIONS
5704 //
5705 //=================================================================================================
5706 
5707 //*************************************************************************************************
5709 template< typename T1, size_t M, size_t N, bool SO >
5710 struct SubmatrixTrait< StaticMatrix<T1,M,N,SO> >
5711 {
5712  typedef DynamicMatrix<T1,SO> Type;
5713 };
5715 //*************************************************************************************************
5716 
5717 
5718 
5719 
5720 //=================================================================================================
5721 //
5722 // ROWTRAIT SPECIALIZATIONS
5723 //
5724 //=================================================================================================
5725 
5726 //*************************************************************************************************
5728 template< typename T1, size_t M, size_t N, bool SO >
5729 struct RowTrait< StaticMatrix<T1,M,N,SO> >
5730 {
5731  typedef StaticVector<T1,N,true> Type;
5732 };
5734 //*************************************************************************************************
5735 
5736 
5737 
5738 
5739 //=================================================================================================
5740 //
5741 // COLUMNTRAIT SPECIALIZATIONS
5742 //
5743 //=================================================================================================
5744 
5745 //*************************************************************************************************
5747 template< typename T1, size_t M, size_t N, bool SO >
5748 struct ColumnTrait< StaticMatrix<T1,M,N,SO> >
5749 {
5750  typedef StaticVector<T1,M,false> Type;
5751 };
5753 //*************************************************************************************************
5754 
5755 } // namespace blaze
5756 
5757 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:107
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:194
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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 >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the subtraction trait.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: StaticMatrix.h:1984
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:2166
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:4555
const Type & ConstReference
Reference to a constant matrix value.
Definition: StaticMatrix.h:202
StaticMatrix()
The default constructor for StaticMatrix.
Definition: StaticMatrix.h:445
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:2322
Header file for the IsColumnMajorMatrix type trait.
StaticMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: StaticMatrix.h:196
void storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of &#39;float&#39; values.
Definition: Storeu.h:234
Type ElementType
Type of the matrix elements.
Definition: StaticMatrix.h:197
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: StaticMatrix.h:401
#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
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:86
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1520
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
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:104
Constraint on the data type.
Header file for the SparseMatrix base class.
void stream(float *address, const sse_float_t &value)
Aligned, non-temporal store of a vector of &#39;float&#39; values.
Definition: Stream.h:233
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1568
Header file for the DisableIf class template.
StaticMatrix & transpose()
Transposing the matrix.
Definition: StaticMatrix.h:2084
void swap(StaticMatrix &m)
Swapping the contents of two static matrices.
Definition: StaticMatrix.h:2130
Header file for the multiplication trait.
Header file for nested template disabiguation.
Compile time assertion.
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:104
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4541
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticMatrix.h:203
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
#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:50
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:2038
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:179
Constraint on the data type.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: StaticMatrix.h:1910
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2251
const This & CompositeType
Data type for composite expression templates.
Definition: StaticMatrix.h:200
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:1945
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
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:2188
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1496
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1448
Header file for the equal shim.
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: StaticMatrix.h:1322
Header file for the IsVectorizable type trait.
StaticMatrix< Type, M, N, SO > This
Type of this StaticMatrix instance.
Definition: StaticMatrix.h:193
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the IsNumeric type trait.
Type * data()
Low-level data access to the matrix elements.
Definition: StaticMatrix.h:1365
IntrinsicTrait< Type > IT
Intrinsic trait for the vector element type.
Definition: StaticMatrix.h:183
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: StaticMatrix.h:198
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
Header file for run time assertion macros.
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:4584
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:209
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:239
#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:2378
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:85
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:2286
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:1929
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:1894
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticMatrix.h:199
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticMatrix.h:204
Type & Reference
Reference to a non-constant matrix value.
Definition: StaticMatrix.h:201
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
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:2376
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
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:2357
#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:195
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#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:2215
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
void store(float *address, const sse_float_t &value)
Aligned store of a vector of &#39;float&#39; values.
Definition: Store.h:242