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 //*************************************************************************************************
197 template< typename Type // Data type of the matrix
198  , size_t M // Number of rows
199  , size_t N // Number of columns
200  , bool SO = defaultStorageOrder > // Storage order
201 class StaticMatrix : public DenseMatrix< StaticMatrix<Type,M,N,SO>, SO >
202 {
203  private:
204  //**Type definitions****************************************************************************
206  //**********************************************************************************************
207 
208  //**********************************************************************************************
210  enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
211  //**********************************************************************************************
212 
213  public:
214  //**Type definitions****************************************************************************
216  typedef This ResultType;
219  typedef Type ElementType;
220  typedef typename IT::Type IntrinsicType;
221  typedef const Type& ReturnType;
222  typedef const This& CompositeType;
223  typedef Type& Reference;
224  typedef const Type& ConstReference;
227  //**********************************************************************************************
228 
229  //**Compilation flags***************************************************************************
231 
235  enum { vectorizable = IsVectorizable<Type>::value };
236 
238 
241  enum { smpAssignable = 0 };
242  //**********************************************************************************************
243 
244  //**Constructors********************************************************************************
247  explicit inline StaticMatrix();
248  explicit inline StaticMatrix( const Type& init );
249 
250  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
251  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
252 
253  inline StaticMatrix( const StaticMatrix& m );
254  template< typename Other, bool SO2 > inline StaticMatrix( const StaticMatrix<Other,M,N,SO2>& m );
255  template< typename MT , bool SO2 > inline StaticMatrix( const Matrix<MT,SO2>& m );
256 
257  inline StaticMatrix( const Type& v1, const Type& v2 );
258  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
259  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
260  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
261  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
262  const Type& v6 );
263  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
264  const Type& v6, const Type& v7 );
265  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
266  const Type& v6, const Type& v7, const Type& v8 );
267  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
268  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
269  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
270  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
272  //**********************************************************************************************
273 
274  //**Destructor**********************************************************************************
275  // No explicitly declared destructor.
276  //**********************************************************************************************
277 
278  //**Data access functions***********************************************************************
281  inline Reference operator()( size_t i, size_t j );
282  inline ConstReference operator()( size_t i, size_t j ) const;
283  inline Type* data ();
284  inline const Type* data () const;
285  inline Type* data ( size_t i );
286  inline const Type* data ( size_t i ) const;
287  inline Iterator begin ( size_t i );
288  inline ConstIterator begin ( size_t i ) const;
289  inline ConstIterator cbegin( size_t i ) const;
290  inline Iterator end ( size_t i );
291  inline ConstIterator end ( size_t i ) const;
292  inline ConstIterator cend ( size_t i ) const;
294  //**********************************************************************************************
295 
296  //**Assignment operators************************************************************************
299  template< typename Other >
300  inline StaticMatrix& operator=( const Other (&array)[M][N] );
301 
302  inline StaticMatrix& operator= ( const Type& set );
303  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
304  template< typename Other, bool SO2 > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO2>& rhs );
305  template< typename MT , bool SO2 > inline StaticMatrix& operator= ( const Matrix<MT,SO2>& rhs );
306  template< typename MT , bool SO2 > inline StaticMatrix& operator+=( const Matrix<MT,SO2>& rhs );
307  template< typename MT , bool SO2 > inline StaticMatrix& operator-=( const Matrix<MT,SO2>& rhs );
308  template< typename MT , bool SO2 > inline StaticMatrix& operator*=( const Matrix<MT,SO2>& rhs );
309 
310  template< typename Other >
311  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
312  operator*=( Other rhs );
313 
314  template< typename Other >
315  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
316  operator/=( Other rhs );
318  //**********************************************************************************************
319 
320  //**Utility functions***************************************************************************
323  inline size_t rows() const;
324  inline size_t columns() const;
325  inline size_t spacing() const;
326  inline size_t capacity() const;
327  inline size_t capacity( size_t i ) const;
328  inline size_t nonZeros() const;
329  inline size_t nonZeros( size_t i ) const;
330  inline void reset();
331  inline void reset( size_t i );
332  inline StaticMatrix& transpose();
333  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
334  inline void swap( StaticMatrix& m ) /* throw() */;
336  //**********************************************************************************************
337 
338  private:
339  //**********************************************************************************************
341  template< typename MT >
343  struct VectorizedAssign {
344  enum { value = vectorizable && MT::vectorizable &&
345  IsSame<Type,typename MT::ElementType>::value &&
346  IsRowMajorMatrix<MT>::value };
347  };
349  //**********************************************************************************************
350 
351  //**********************************************************************************************
353  template< typename MT >
355  struct VectorizedAddAssign {
356  enum { value = vectorizable && MT::vectorizable &&
357  IsSame<Type,typename MT::ElementType>::value &&
358  IntrinsicTrait<Type>::addition &&
359  IsRowMajorMatrix<MT>::value };
360  };
362  //**********************************************************************************************
363 
364  //**********************************************************************************************
366  template< typename MT >
368  struct VectorizedSubAssign {
369  enum { value = vectorizable && MT::vectorizable &&
370  IsSame<Type,typename MT::ElementType>::value &&
371  IntrinsicTrait<Type>::subtraction &&
372  IsRowMajorMatrix<MT>::value };
373  };
375  //**********************************************************************************************
376 
377  public:
378  //**Expression template evaluation functions****************************************************
381  template< typename Other > inline bool canAlias ( const Other* alias ) const;
382  template< typename Other > inline bool isAliased( const Other* alias ) const;
383 
384  inline bool isAligned() const;
385 
386  inline IntrinsicType load ( size_t i, size_t j ) const;
387  inline IntrinsicType loadu ( size_t i, size_t j ) const;
388  inline void store ( size_t i, size_t j, const IntrinsicType& value );
389  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
390  inline void stream( size_t i, size_t j, const IntrinsicType& value );
391 
392  template< typename MT, bool SO2 >
393  inline typename DisableIf< VectorizedAssign<MT> >::Type
394  assign( const DenseMatrix<MT,SO2>& rhs );
395 
396  template< typename MT, bool SO2 >
397  inline typename EnableIf< VectorizedAssign<MT> >::Type
398  assign( const DenseMatrix<MT,SO2>& rhs );
399 
400  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
401  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
402 
403  template< typename MT, bool SO2 >
404  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
405  addAssign( const DenseMatrix<MT,SO2>& rhs );
406 
407  template< typename MT, bool SO2 >
408  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
409  addAssign( const DenseMatrix<MT,SO2>& rhs );
410 
411  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
412  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
413 
414  template< typename MT, bool SO2 >
415  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
416  subAssign( const DenseMatrix<MT,SO2>& rhs );
417 
418  template< typename MT, bool SO2 >
419  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
420  subAssign( const DenseMatrix<MT,SO2>& rhs );
421 
422  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
423  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
425  //**********************************************************************************************
426 
427  private:
428  //**Member variables****************************************************************************
432 
442  //**********************************************************************************************
443 
444  //**Compile time checks*************************************************************************
450  BLAZE_STATIC_ASSERT( NN % IT::size == 0UL );
451  BLAZE_STATIC_ASSERT( NN >= N );
453  //**********************************************************************************************
454 };
455 //*************************************************************************************************
456 
457 
458 
459 
460 //=================================================================================================
461 //
462 // CONSTRUCTORS
463 //
464 //=================================================================================================
465 
466 //*************************************************************************************************
471 template< typename Type // Data type of the matrix
472  , size_t M // Number of rows
473  , size_t N // Number of columns
474  , bool SO > // Storage order
476 {
477  if( IsNumeric<Type>::value ) {
478  for( size_t i=0UL; i<M*NN; ++i )
479  v_[i] = Type();
480  }
481 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
490 template< typename Type // Data type of the matrix
491  , size_t M // Number of rows
492  , size_t N // Number of columns
493  , bool SO > // Storage order
494 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& init )
495 {
496  for( size_t i=0UL; i<M; ++i ) {
497  for( size_t j=0UL; j<N; ++j )
498  v_[i*NN+j] = init;
499 
500  if( IsNumeric<Type>::value ) {
501  for( size_t j=N; j<NN; ++j )
502  v_[i*NN+j] = Type();
503  }
504  }
505 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
535 template< typename Type // Data type of the matrix
536  , size_t M // Number of rows
537  , size_t N // Number of columns
538  , bool SO > // Storage order
539 template< typename Other > // Data type of the initialization array
540 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( size_t m, size_t n, const Other* array )
541 {
542  if( m > M || n > N )
543  throw std::invalid_argument( "Invalid setup of static matrix" );
544 
545  for( size_t i=0UL; i<m; ++i ) {
546  for( size_t j=0UL; j<n; ++j )
547  v_[i*NN+j] = array[i*n+j];
548 
549  if( IsNumeric<Type>::value ) {
550  for( size_t j=n; j<NN; ++j )
551  v_[i*NN+j] = Type();
552  }
553  }
554 
555  for( size_t i=m; i<M; ++i ) {
556  for( size_t j=0UL; j<NN; ++j )
557  v_[i*NN+j] = Type();
558  }
559 }
560 //*************************************************************************************************
561 
562 
563 //*************************************************************************************************
583 template< typename Type // Data type of the matrix
584  , size_t M // Number of rows
585  , size_t N // Number of columns
586  , bool SO > // Storage order
587 template< typename Other > // Data type of the initialization array
588 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Other (&array)[M][N] )
589 {
590  for( size_t i=0UL; i<M; ++i ) {
591  for( size_t j=0UL; j<N; ++j )
592  v_[i*NN+j] = array[i][j];
593 
594  if( IsNumeric<Type>::value ) {
595  for( size_t j=N; j<NN; ++j )
596  v_[i*NN+j] = Type();
597  }
598  }
599 }
600 //*************************************************************************************************
601 
602 
603 //*************************************************************************************************
610 template< typename Type // Data type of the matrix
611  , size_t M // Number of rows
612  , size_t N // Number of columns
613  , bool SO > // Storage order
615 {
616  for( size_t i=0UL; i<M*NN; ++i )
617  v_[i] = m.v_[i];
618 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
627 template< typename Type // Data type of the matrix
628  , size_t M // Number of rows
629  , size_t N // Number of columns
630  , bool SO > // Storage order
631 template< typename Other // Data type of the foreign matrix
632  , bool SO2 > // Storage order of the foreign matrix
634 {
635  for( size_t i=0UL; i<M; ++i ) {
636  for( size_t j=0UL; j<N; ++j )
637  v_[i*NN+j] = m(i,j);
638 
639  if( IsNumeric<Type>::value ) {
640  for( size_t j=N; j<NN; ++j )
641  v_[i*NN+j] = Type();
642  }
643  }
644 }
645 //*************************************************************************************************
646 
647 
648 //*************************************************************************************************
658 template< typename Type // Data type of the matrix
659  , size_t M // Number of rows
660  , size_t N // Number of columns
661  , bool SO > // Storage order
662 template< typename MT // Type of the foreign matrix
663  , bool SO2 > // Storage order of the foreign matrix
665 {
666  using blaze::assign;
667 
668  if( (~m).rows() != M || (~m).columns() != N )
669  throw std::invalid_argument( "Invalid setup of static matrix" );
670 
671  if( IsNumeric<Type>::value ) {
672  for( size_t i=0UL; i<M; ++i ) {
673  for( size_t j=( IsSparseMatrix<MT>::value )?( 0UL ):( N ); j<NN; ++j )
674  v_[i*NN+j] = Type();
675  }
676  }
677 
678  assign( *this, ~m );
679 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
700 template< typename Type // Data type of the matrix
701  , size_t M // Number of rows
702  , size_t N // Number of columns
703  , bool SO > // Storage order
704 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2 )
705 {
706  BLAZE_STATIC_ASSERT( M*N == 2UL );
707 
708  // Initialization of a 1x2 matrix
709  if( M == 1UL ) {
710  v_[0UL] = v1;
711  v_[1UL] = v2;
712  }
713 
714  // Initialization of a 2x1 matrix
715  else {
716  v_[0UL] = v1;
717  v_[ NN] = v2;
718  }
719 
720  if( IsNumeric<Type>::value ) {
721  for( size_t i=0UL; i<M; ++i ) {
722  for( size_t j=N; j<NN; ++j )
723  v_[i*NN+j] = Type();
724  }
725  }
726 }
727 //*************************************************************************************************
728 
729 
730 //*************************************************************************************************
748 template< typename Type // Data type of the matrix
749  , size_t M // Number of rows
750  , size_t N // Number of columns
751  , bool SO > // Storage order
752 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
753 {
754  BLAZE_STATIC_ASSERT( M*N == 3UL );
755 
756  // Initialization of a 1x3 matrix
757  if( M == 1UL ) {
758  v_[0UL] = v1;
759  v_[1UL] = v2;
760  v_[2UL] = v3;
761  }
762 
763  // Initialization of a 3x1 matrix
764  else {
765  v_[ 0UL] = v1;
766  v_[ NN] = v2;
767  v_[2UL*NN] = v3;
768  }
769 
770  if( IsNumeric<Type>::value ) {
771  for( size_t i=0UL; i<M; ++i ) {
772  for( size_t j=N; j<NN; ++j )
773  v_[i*NN+j] = Type();
774  }
775  }
776 }
777 //*************************************************************************************************
778 
779 
780 //*************************************************************************************************
801 template< typename Type // Data type of the matrix
802  , size_t M // Number of rows
803  , size_t N // Number of columns
804  , bool SO > // Storage order
805 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2,
806  const Type& v3, const Type& v4 )
807 {
808  BLAZE_STATIC_ASSERT( M*N == 4UL );
809 
810  // Initialization of a 1x4 matrix
811  if( M == 1UL ) {
812  v_[0UL] = v1;
813  v_[1UL] = v2;
814  v_[2UL] = v3;
815  v_[3UL] = v4;
816  }
817 
818  // Initialization of a 2x2 matrix
819  else if( M == 2UL ) {
820  v_[ 0UL] = v1;
821  v_[ 1UL] = v2;
822  v_[NN ] = v3;
823  v_[NN+1UL] = v4;
824  }
825 
826  // Initialization of a 4x1 matrix
827  else {
828  v_[ 0UL] = v1;
829  v_[ NN] = v2;
830  v_[2UL*NN] = v3;
831  v_[3UL*NN] = v4;
832  }
833 
834  if( IsNumeric<Type>::value ) {
835  for( size_t i=0UL; i<M; ++i ) {
836  for( size_t j=N; j<NN; ++j )
837  v_[i*NN+j] = Type();
838  }
839  }
840 }
841 //*************************************************************************************************
842 
843 
844 //*************************************************************************************************
864 template< typename Type // Data type of the matrix
865  , size_t M // Number of rows
866  , size_t N // Number of columns
867  , bool SO > // Storage order
868 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
869  const Type& v4, const Type& v5 )
870 {
871  BLAZE_STATIC_ASSERT( M*N == 5UL );
872 
873  // Initialization of a 1x5 matrix
874  if( M == 1UL ) {
875  v_[0UL] = v1;
876  v_[1UL] = v2;
877  v_[2UL] = v3;
878  v_[3UL] = v4;
879  v_[4UL] = v5;
880  }
881 
882  // Initialization of a 5x1 matrix
883  else {
884  v_[ 0UL] = v1;
885  v_[ NN] = v2;
886  v_[2UL*NN] = v3;
887  v_[3UL*NN] = v4;
888  v_[4UL*NN] = v5;
889  }
890 
891  if( IsNumeric<Type>::value ) {
892  for( size_t i=0UL; i<M; ++i ) {
893  for( size_t j=N; j<NN; ++j )
894  v_[i*NN+j] = Type();
895  }
896  }
897 }
898 //*************************************************************************************************
899 
900 
901 //*************************************************************************************************
925 template< typename Type // Data type of the matrix
926  , size_t M // Number of rows
927  , size_t N // Number of columns
928  , bool SO > // Storage order
929 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
930  const Type& v4, const Type& v5, const Type& v6 )
931 {
932  BLAZE_STATIC_ASSERT( M*N == 6UL );
933 
934  // Initialization of a 1x6 matrix
935  if( M == 1UL ) {
936  v_[0UL] = v1;
937  v_[1UL] = v2;
938  v_[2UL] = v3;
939  v_[3UL] = v4;
940  v_[4UL] = v5;
941  v_[5UL] = v6;
942  }
943 
944  // Initialization of a 2x3 matrix
945  else if( M == 2UL ) {
946  v_[ 0UL] = v1;
947  v_[ 1UL] = v2;
948  v_[ 2UL] = v3;
949  v_[NN ] = v4;
950  v_[NN+1UL] = v5;
951  v_[NN+2UL] = v6;
952  }
953 
954  // Initialization of a 3x2 matrix
955  else if( M == 3UL ) {
956  v_[ 0UL] = v1;
957  v_[ 1UL] = v2;
958  v_[ NN ] = v3;
959  v_[ NN+1UL] = v4;
960  v_[2UL*NN ] = v5;
961  v_[2UL*NN+1UL] = v6;
962  }
963 
964  // Initialization of a 6x1 matrix
965  else {
966  v_[ 0UL] = v1;
967  v_[ NN] = v2;
968  v_[2UL*NN] = v3;
969  v_[3UL*NN] = v4;
970  v_[4UL*NN] = v5;
971  v_[5UL*NN] = v6;
972  }
973 
974  if( IsNumeric<Type>::value ) {
975  for( size_t i=0UL; i<M; ++i ) {
976  for( size_t j=N; j<NN; ++j )
977  v_[i*NN+j] = Type();
978  }
979  }
980 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
1006 template< typename Type // Data type of the matrix
1007  , size_t M // Number of rows
1008  , size_t N // Number of columns
1009  , bool SO > // Storage order
1010 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1011  const Type& v4, const Type& v5, const Type& v6,
1012  const Type& v7 )
1013 {
1014  BLAZE_STATIC_ASSERT( M*N == 7UL );
1015 
1016  // Initialization of a 1x7 matrix
1017  if( M == 1UL ) {
1018  v_[0UL] = v1;
1019  v_[1UL] = v2;
1020  v_[2UL] = v3;
1021  v_[3UL] = v4;
1022  v_[4UL] = v5;
1023  v_[5UL] = v6;
1024  v_[6UL] = v7;
1025  }
1026 
1027  // Initialization of a 7x1 matrix
1028  else {
1029  v_[ 0UL] = v1;
1030  v_[ NN] = v2;
1031  v_[2UL*NN] = v3;
1032  v_[3UL*NN] = v4;
1033  v_[4UL*NN] = v5;
1034  v_[5UL*NN] = v6;
1035  v_[6UL*NN] = v7;
1036  }
1037 
1038  if( IsNumeric<Type>::value ) {
1039  for( size_t i=0UL; i<M; ++i ) {
1040  for( size_t j=N; j<NN; ++j )
1041  v_[i*NN+j] = Type();
1042  }
1043  }
1044 }
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1073 template< typename Type // Data type of the matrix
1074  , size_t M // Number of rows
1075  , size_t N // Number of columns
1076  , bool SO > // Storage order
1077 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1078  const Type& v4, const Type& v5, const Type& v6,
1079  const Type& v7, const Type& v8 )
1080 {
1081  BLAZE_STATIC_ASSERT( M*N == 8UL );
1082 
1083  // Initialization of a 1x8 matrix
1084  if( M == 1UL ) {
1085  v_[0UL] = v1;
1086  v_[1UL] = v2;
1087  v_[2UL] = v3;
1088  v_[3UL] = v4;
1089  v_[4UL] = v5;
1090  v_[5UL] = v6;
1091  v_[6UL] = v7;
1092  v_[7UL] = v8;
1093  }
1094 
1095  // Initialization of a 2x4 matrix
1096  else if( M == 2UL ) {
1097  v_[ 0UL] = v1;
1098  v_[ 1UL] = v2;
1099  v_[ 2UL] = v3;
1100  v_[ 3UL] = v4;
1101  v_[NN ] = v5;
1102  v_[NN+1UL] = v6;
1103  v_[NN+2UL] = v7;
1104  v_[NN+3UL] = v8;
1105  }
1106 
1107  // Initialization of a 4x2 matrix
1108  else if( M == 4UL ) {
1109  v_[ 0UL] = v1;
1110  v_[ 1UL] = v2;
1111  v_[ NN ] = v3;
1112  v_[ NN+1UL] = v4;
1113  v_[2UL*NN ] = v5;
1114  v_[2UL*NN+1UL] = v6;
1115  v_[3UL*NN ] = v7;
1116  v_[3UL*NN+1UL] = v8;
1117  }
1118 
1119  // Initialization of a 8x1 matrix
1120  else {
1121  v_[ 0UL] = v1;
1122  v_[ NN] = v2;
1123  v_[2UL*NN] = v3;
1124  v_[3UL*NN] = v4;
1125  v_[4UL*NN] = v5;
1126  v_[5UL*NN] = v6;
1127  v_[6UL*NN] = v7;
1128  v_[7UL*NN] = v8;
1129  }
1130 
1131  if( IsNumeric<Type>::value ) {
1132  for( size_t i=0UL; i<M; ++i ) {
1133  for( size_t j=N; j<NN; ++j )
1134  v_[i*NN+j] = Type();
1135  }
1136  }
1137 }
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1168 template< typename Type // Data type of the matrix
1169  , size_t M // Number of rows
1170  , size_t N // Number of columns
1171  , bool SO > // Storage order
1172 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1173  const Type& v4, const Type& v5, const Type& v6,
1174  const Type& v7, const Type& v8, const Type& v9 )
1175 {
1176  BLAZE_STATIC_ASSERT( M*N == 9UL );
1177 
1178  // Initialization of a 1x9 matrix
1179  if( M == 1UL ) {
1180  v_[0UL] = v1;
1181  v_[1UL] = v2;
1182  v_[2UL] = v3;
1183  v_[3UL] = v4;
1184  v_[4UL] = v5;
1185  v_[5UL] = v6;
1186  v_[6UL] = v7;
1187  v_[7UL] = v8;
1188  v_[8UL] = v9;
1189  }
1190 
1191  // Initialization of a 3x3 matrix
1192  else if( M == 3UL ) {
1193  v_[ 0UL] = v1;
1194  v_[ 1UL] = v2;
1195  v_[ 2UL] = v3;
1196  v_[ NN ] = v4;
1197  v_[ NN+1UL] = v5;
1198  v_[ NN+2UL] = v6;
1199  v_[2UL*NN ] = v7;
1200  v_[2UL*NN+1UL] = v8;
1201  v_[2UL*NN+2UL] = v9;
1202  }
1203 
1204  // Initialization of a 9x1 matrix
1205  else {
1206  v_[ 0UL] = v1;
1207  v_[ NN] = v2;
1208  v_[2UL*NN] = v3;
1209  v_[3UL*NN] = v4;
1210  v_[4UL*NN] = v5;
1211  v_[5UL*NN] = v6;
1212  v_[6UL*NN] = v7;
1213  v_[7UL*NN] = v8;
1214  v_[8UL*NN] = v9;
1215  }
1216 
1217  if( IsNumeric<Type>::value ) {
1218  for( size_t i=0UL; i<M; ++i ) {
1219  for( size_t j=N; j<NN; ++j )
1220  v_[i*NN+j] = Type();
1221  }
1222  }
1223 }
1224 //*************************************************************************************************
1225 
1226 
1227 //*************************************************************************************************
1255 template< typename Type // Data type of the matrix
1256  , size_t M // Number of rows
1257  , size_t N // Number of columns
1258  , bool SO > // Storage order
1259 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1260  const Type& v4, const Type& v5, const Type& v6,
1261  const Type& v7, const Type& v8, const Type& v9,
1262  const Type& v10 )
1263 {
1264  BLAZE_STATIC_ASSERT( M*N == 10UL );
1265 
1266  // Initialization of a 1x10 matrix
1267  if( M == 1UL ) {
1268  v_[0UL] = v1;
1269  v_[1UL] = v2;
1270  v_[2UL] = v3;
1271  v_[3UL] = v4;
1272  v_[4UL] = v5;
1273  v_[5UL] = v6;
1274  v_[6UL] = v7;
1275  v_[7UL] = v8;
1276  v_[8UL] = v9;
1277  v_[9UL] = v10;
1278  }
1279 
1280  // Initialization of a 2x5 matrix
1281  else if( M == 2UL ) {
1282  v_[ 0UL] = v1;
1283  v_[ 1UL] = v2;
1284  v_[ 2UL] = v3;
1285  v_[ 3UL] = v4;
1286  v_[ 4UL] = v5;
1287  v_[NN ] = v6;
1288  v_[NN+1UL] = v7;
1289  v_[NN+2UL] = v8;
1290  v_[NN+3UL] = v9;
1291  v_[NN+4UL] = v10;
1292  }
1293 
1294  // Initialization of a 5x2 matrix
1295  else if( M == 5UL ) {
1296  v_[ 0UL] = v1;
1297  v_[ 1UL] = v2;
1298  v_[ NN ] = v3;
1299  v_[ NN+1UL] = v4;
1300  v_[2UL*NN ] = v5;
1301  v_[2UL*NN+1UL] = v6;
1302  v_[3UL*NN ] = v7;
1303  v_[3UL*NN+1UL] = v8;
1304  v_[4UL*NN ] = v9;
1305  v_[4UL*NN+1UL] = v10;
1306  }
1307 
1308  // Initialization of a 10x1 matrix
1309  else {
1310  v_[ 0UL] = v1;
1311  v_[ NN] = v2;
1312  v_[2UL*NN] = v3;
1313  v_[3UL*NN] = v4;
1314  v_[4UL*NN] = v5;
1315  v_[5UL*NN] = v6;
1316  v_[6UL*NN] = v7;
1317  v_[7UL*NN] = v8;
1318  v_[8UL*NN] = v9;
1319  v_[9UL*NN] = v10;
1320  }
1321 
1322  if( IsNumeric<Type>::value ) {
1323  for( size_t i=0UL; i<M; ++i ) {
1324  for( size_t j=N; j<NN; ++j )
1325  v_[i*NN+j] = Type();
1326  }
1327  }
1328 }
1329 //*************************************************************************************************
1330 
1331 
1332 
1333 
1334 //=================================================================================================
1335 //
1336 // DATA ACCESS FUNCTIONS
1337 //
1338 //=================================================================================================
1339 
1340 //*************************************************************************************************
1347 template< typename Type // Data type of the matrix
1348  , size_t M // Number of rows
1349  , size_t N // Number of columns
1350  , bool SO > // Storage order
1353 {
1354  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1355  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1356  return v_[i*NN+j];
1357 }
1358 //*************************************************************************************************
1359 
1360 
1361 //*************************************************************************************************
1368 template< typename Type // Data type of the matrix
1369  , size_t M // Number of rows
1370  , size_t N // Number of columns
1371  , bool SO > // Storage order
1373  StaticMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
1374 {
1375  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1376  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1377  return v_[i*NN+j];
1378 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1391 template< typename Type // Data type of the matrix
1392  , size_t M // Number of rows
1393  , size_t N // Number of columns
1394  , bool SO > // Storage order
1396 {
1397  return v_;
1398 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1411 template< typename Type // Data type of the matrix
1412  , size_t M // Number of rows
1413  , size_t N // Number of columns
1414  , bool SO > // Storage order
1415 inline const Type* StaticMatrix<Type,M,N,SO>::data() const
1416 {
1417  return v_;
1418 }
1419 //*************************************************************************************************
1420 
1421 
1422 //*************************************************************************************************
1430 template< typename Type // Data type of the matrix
1431  , size_t M // Number of rows
1432  , size_t N // Number of columns
1433  , bool SO > // Storage order
1434 inline Type* StaticMatrix<Type,M,N,SO>::data( size_t i )
1435 {
1436  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1437  return v_ + i*NN;
1438 }
1439 //*************************************************************************************************
1440 
1441 
1442 //*************************************************************************************************
1450 template< typename Type // Data type of the matrix
1451  , size_t M // Number of rows
1452  , size_t N // Number of columns
1453  , bool SO > // Storage order
1454 inline const Type* StaticMatrix<Type,M,N,SO>::data( size_t i ) const
1455 {
1456  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1457  return v_ + i*NN;
1458 }
1459 //*************************************************************************************************
1460 
1461 
1462 //*************************************************************************************************
1473 template< typename Type // Data type of the matrix
1474  , size_t M // Number of rows
1475  , size_t N // Number of columns
1476  , bool SO > // Storage order
1479 {
1480  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1481  return Iterator( v_ + i*NN );
1482 }
1483 //*************************************************************************************************
1484 
1485 
1486 //*************************************************************************************************
1497 template< typename Type // Data type of the matrix
1498  , size_t M // Number of rows
1499  , size_t N // Number of columns
1500  , bool SO > // Storage order
1503 {
1504  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1505  return ConstIterator( v_ + i*NN );
1506 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1521 template< typename Type // Data type of the matrix
1522  , size_t M // Number of rows
1523  , size_t N // Number of columns
1524  , bool SO > // Storage order
1527 {
1528  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1529  return ConstIterator( v_ + i*NN );
1530 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1545 template< typename Type // Data type of the matrix
1546  , size_t M // Number of rows
1547  , size_t N // Number of columns
1548  , bool SO > // Storage order
1551 {
1552  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1553  return Iterator( v_ + i*NN + N );
1554 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1569 template< typename Type // Data type of the matrix
1570  , size_t M // Number of rows
1571  , size_t N // Number of columns
1572  , bool SO > // Storage order
1575 {
1576  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1577  return ConstIterator( v_ + i*NN + N );
1578 }
1579 //*************************************************************************************************
1580 
1581 
1582 //*************************************************************************************************
1593 template< typename Type // Data type of the matrix
1594  , size_t M // Number of rows
1595  , size_t N // Number of columns
1596  , bool SO > // Storage order
1599 {
1600  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1601  return ConstIterator( v_ + i*NN + N );
1602 }
1603 //*************************************************************************************************
1604 
1605 
1606 
1607 
1608 //=================================================================================================
1609 //
1610 // ASSIGNMENT OPERATORS
1611 //
1612 //=================================================================================================
1613 
1614 //*************************************************************************************************
1635 template< typename Type // Data type of the matrix
1636  , size_t M // Number of rows
1637  , size_t N // Number of columns
1638  , bool SO > // Storage order
1639 template< typename Other > // Data type of the initialization array
1641 {
1642  for( size_t i=0UL; i<M; ++i )
1643  for( size_t j=0UL; j<N; ++j )
1644  v_[i*NN+j] = array[i][j];
1645 
1646  return *this;
1647 }
1648 //*************************************************************************************************
1649 
1650 
1651 //*************************************************************************************************
1657 template< typename Type // Data type of the matrix
1658  , size_t M // Number of rows
1659  , size_t N // Number of columns
1660  , bool SO > // Storage order
1662 {
1663  for( size_t i=0UL; i<M; ++i )
1664  for( size_t j=0UL; j<N; ++j )
1665  v_[i*NN+j] = set;
1666 
1667  return *this;
1668 }
1669 //*************************************************************************************************
1670 
1671 
1672 //*************************************************************************************************
1680 template< typename Type // Data type of the matrix
1681  , size_t M // Number of rows
1682  , size_t N // Number of columns
1683  , bool SO > // Storage order
1685 {
1686  using blaze::assign;
1687 
1688  assign( *this, ~rhs );
1689  return *this;
1690 }
1691 //*************************************************************************************************
1692 
1693 
1694 //*************************************************************************************************
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 Other // Data type of the foreign matrix
1705  , bool SO2 > // Storage order of the foreign matrix
1708 {
1709  using blaze::assign;
1710 
1711  assign( *this, ~rhs );
1712  return *this;
1713 }
1714 //*************************************************************************************************
1715 
1716 
1717 //*************************************************************************************************
1728 template< typename Type // Data type of the matrix
1729  , size_t M // Number of rows
1730  , size_t N // Number of columns
1731  , bool SO > // Storage order
1732 template< typename MT // Type of the right-hand side matrix
1733  , bool SO2 > // Storage order of the right-hand side matrix
1735 {
1736  using blaze::assign;
1737 
1738  if( (~rhs).rows() != M || (~rhs).columns() != N )
1739  throw std::invalid_argument( "Invalid assignment to static matrix" );
1740 
1741  if( (~rhs).canAlias( this ) ) {
1742  StaticMatrix tmp( ~rhs );
1743  swap( tmp );
1744  }
1745  else {
1747  reset();
1748  assign( *this, ~rhs );
1749  }
1750 
1751  return *this;
1752 }
1753 //*************************************************************************************************
1754 
1755 
1756 //*************************************************************************************************
1766 template< typename Type // Data type of the matrix
1767  , size_t M // Number of rows
1768  , size_t N // Number of columns
1769  , bool SO > // Storage order
1770 template< typename MT // Type of the right-hand side matrix
1771  , bool SO2 > // Storage order of the right-hand side matrix
1773 {
1774  using blaze::addAssign;
1775 
1776  if( (~rhs).rows() != M || (~rhs).columns() != N )
1777  throw std::invalid_argument( "Matrix sizes do not match" );
1778 
1779  if( (~rhs).canAlias( this ) ) {
1780  StaticMatrix tmp( ~rhs );
1781  addAssign( *this, tmp );
1782  }
1783  else {
1784  addAssign( *this, ~rhs );
1785  }
1786 
1787  return *this;
1788 }
1789 //*************************************************************************************************
1790 
1791 
1792 //*************************************************************************************************
1802 template< typename Type // Data type of the matrix
1803  , size_t M // Number of rows
1804  , size_t N // Number of columns
1805  , bool SO > // Storage order
1806 template< typename MT // Type of the right-hand side matrix
1807  , bool SO2 > // Storage order of the right-hand side matrix
1809 {
1810  using blaze::subAssign;
1811 
1812  if( (~rhs).rows() != M || (~rhs).columns() != N )
1813  throw std::invalid_argument( "Matrix sizes do not match" );
1814 
1815  if( (~rhs).canAlias( this ) ) {
1816  StaticMatrix tmp( ~rhs );
1817  subAssign( *this, tmp );
1818  }
1819  else {
1820  subAssign( *this, ~rhs );
1821  }
1822 
1823  return *this;
1824 }
1825 //*************************************************************************************************
1826 
1827 
1828 //*************************************************************************************************
1838 template< typename Type // Data type of the matrix
1839  , size_t M // Number of rows
1840  , size_t N // Number of columns
1841  , bool SO > // Storage order
1842 template< typename MT // Type of the right-hand side matrix
1843  , bool SO2 > // Storage order of the right-hand side matrix
1845 {
1846  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
1847  throw std::invalid_argument( "Matrix sizes do not match" );
1848 
1849  StaticMatrix tmp( *this * (~rhs) );
1850  return this->operator=( tmp );
1851 }
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1862 template< typename Type // Data type of the matrix
1863  , size_t M // Number of rows
1864  , size_t N // Number of columns
1865  , bool SO > // Storage order
1866 template< typename Other > // Data type of the right-hand side scalar
1867 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1869 {
1870  using blaze::assign;
1871 
1872  assign( *this, (*this) * rhs );
1873  return *this;
1874 }
1875 //*************************************************************************************************
1876 
1877 
1878 //*************************************************************************************************
1887 template< typename Type // Data type of the matrix
1888  , size_t M // Number of rows
1889  , size_t N // Number of columns
1890  , bool SO > // Storage order
1891 template< typename Other > // Data type of the right-hand side scalar
1892 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
1894 {
1895  using blaze::assign;
1896 
1897  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1898 
1899  assign( *this, (*this) / rhs );
1900  return *this;
1901 }
1902 //*************************************************************************************************
1903 
1904 
1905 
1906 
1907 //=================================================================================================
1908 //
1909 // UTILITY FUNCTIONS
1910 //
1911 //=================================================================================================
1912 
1913 //*************************************************************************************************
1918 template< typename Type // Data type of the matrix
1919  , size_t M // Number of rows
1920  , size_t N // Number of columns
1921  , bool SO > // Storage order
1922 inline size_t StaticMatrix<Type,M,N,SO>::rows() const
1923 {
1924  return M;
1925 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1934 template< typename Type // Data type of the matrix
1935  , size_t M // Number of rows
1936  , size_t N // Number of columns
1937  , bool SO > // Storage order
1939 {
1940  return N;
1941 }
1942 //*************************************************************************************************
1943 
1944 
1945 //*************************************************************************************************
1953 template< typename Type // Data type of the matrix
1954  , size_t M // Number of rows
1955  , size_t N // Number of columns
1956  , bool SO > // Storage order
1958 {
1959  return NN;
1960 }
1961 //*************************************************************************************************
1962 
1963 
1964 //*************************************************************************************************
1969 template< typename Type // Data type of the matrix
1970  , size_t M // Number of rows
1971  , size_t N // Number of columns
1972  , bool SO > // Storage order
1974 {
1975  return M*NN;
1976 }
1977 //*************************************************************************************************
1978 
1979 
1980 //*************************************************************************************************
1991 template< typename Type // Data type of the matrix
1992  , size_t M // Number of rows
1993  , size_t N // Number of columns
1994  , bool SO > // Storage order
1995 inline size_t StaticMatrix<Type,M,N,SO>::capacity( size_t i ) const
1996 {
1997  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
1998  return NN;
1999 }
2000 //*************************************************************************************************
2001 
2002 
2003 //*************************************************************************************************
2008 template< typename Type // Data type of the matrix
2009  , size_t M // Number of rows
2010  , size_t N // Number of columns
2011  , bool SO > // Storage order
2013 {
2014  size_t nonzeros( 0UL );
2015 
2016  for( size_t i=0UL; i<M; ++i )
2017  for( size_t j=0UL; j<N; ++j )
2018  if( !isDefault( v_[i*NN+j] ) )
2019  ++nonzeros;
2020 
2021  return nonzeros;
2022 }
2023 //*************************************************************************************************
2024 
2025 
2026 //*************************************************************************************************
2037 template< typename Type // Data type of the matrix
2038  , size_t M // Number of rows
2039  , size_t N // Number of columns
2040  , bool SO > // Storage order
2041 inline size_t StaticMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
2042 {
2043  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2044 
2045  const size_t jend( (i+1UL)*NN );
2046  size_t nonzeros( 0UL );
2047 
2048  for( size_t j=i*NN; j<jend; ++j )
2049  if( !isDefault( v_[j] ) )
2050  ++nonzeros;
2051 
2052  return nonzeros;
2053 }
2054 //*************************************************************************************************
2055 
2056 
2057 //*************************************************************************************************
2062 template< typename Type // Data type of the matrix
2063  , size_t M // Number of rows
2064  , size_t N // Number of columns
2065  , bool SO > // Storage order
2067 {
2068  using blaze::reset;
2069 
2070  for( size_t i=0UL; i<M; ++i )
2071  for( size_t j=0UL; j<N; ++j )
2072  reset( v_[i*NN+j] );
2073 }
2074 //*************************************************************************************************
2075 
2076 
2077 //*************************************************************************************************
2088 template< typename Type // Data type of the matrix
2089  , size_t M // Number of rows
2090  , size_t N // Number of columns
2091  , bool SO > // Storage order
2092 inline void StaticMatrix<Type,M,N,SO>::reset( size_t i )
2093 {
2094  using blaze::reset;
2095 
2096  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2097  for( size_t j=0UL; j<N; ++j )
2098  reset( v_[i*NN+j] );
2099 }
2100 //*************************************************************************************************
2101 
2102 
2103 //*************************************************************************************************
2108 template< typename Type // Data type of the matrix
2109  , size_t M // Number of rows
2110  , size_t N // Number of columns
2111  , bool SO > // Storage order
2113 {
2114  using std::swap;
2115 
2116  for( size_t i=1UL; i<M; ++i )
2117  for( size_t j=0UL; j<i; ++j )
2118  swap( v_[i*NN+j], v_[j*NN+i] );
2119 
2120  return *this;
2121 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2131 template< typename Type // Data type of the matrix
2132  , size_t M // Number of rows
2133  , size_t N // Number of columns
2134  , bool SO > // Storage order
2135 template< typename Other > // Data type of the scalar value
2137 {
2138  for( size_t i=0UL; i<M; ++i )
2139  for( size_t j=0UL; j<N; ++j )
2140  v_[i*NN+j] *= scalar;
2141 
2142  return *this;
2143 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2154 template< typename Type // Data type of the matrix
2155  , size_t M // Number of rows
2156  , size_t N // Number of columns
2157  , bool SO > // Storage order
2158 inline void StaticMatrix<Type,M,N,SO>::swap( StaticMatrix& m ) /* throw() */
2159 {
2160  using std::swap;
2161 
2162  for( size_t i=0UL; i<M; ++i ) {
2163  for( size_t j=0UL; j<N; ++j ) {
2164  swap( v_[i*NN+j], m(i,j) );
2165  }
2166  }
2167 }
2168 //*************************************************************************************************
2169 
2170 
2171 
2172 
2173 //=================================================================================================
2174 //
2175 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2176 //
2177 //=================================================================================================
2178 
2179 //*************************************************************************************************
2189 template< typename Type // Data type of the matrix
2190  , size_t M // Number of rows
2191  , size_t N // Number of columns
2192  , bool SO > // Storage order
2193 template< typename Other > // Data type of the foreign expression
2194 inline bool StaticMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
2195 {
2196  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2197 }
2198 //*************************************************************************************************
2199 
2200 
2201 //*************************************************************************************************
2211 template< typename Type // Data type of the matrix
2212  , size_t M // Number of rows
2213  , size_t N // Number of columns
2214  , bool SO > // Storage order
2215 template< typename Other > // Data type of the foreign expression
2216 inline bool StaticMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
2217 {
2218  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2219 }
2220 //*************************************************************************************************
2221 
2222 
2223 //*************************************************************************************************
2232 template< typename Type // Data type of the matrix
2233  , size_t M // Number of rows
2234  , size_t N // Number of columns
2235  , bool SO > // Storage order
2237 {
2238  return true;
2239 }
2240 //*************************************************************************************************
2241 
2242 
2243 //*************************************************************************************************
2258 template< typename Type // Data type of the matrix
2259  , size_t M // Number of rows
2260  , size_t N // Number of columns
2261  , bool SO > // Storage order
2263  StaticMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2264 {
2265  using blaze::load;
2266 
2268 
2269  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2270  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2271  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2272  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2273 
2274  return load( &v_[i*NN+j] );
2275 }
2276 //*************************************************************************************************
2277 
2278 
2279 //*************************************************************************************************
2294 template< typename Type // Data type of the matrix
2295  , size_t M // Number of rows
2296  , size_t N // Number of columns
2297  , bool SO > // Storage order
2299  StaticMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2300 {
2301  using blaze::loadu;
2302 
2304 
2305  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2306  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2307  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2308 
2309  return loadu( &v_[i*NN+j] );
2310 }
2311 //*************************************************************************************************
2312 
2313 
2314 //*************************************************************************************************
2330 template< typename Type // Data type of the matrix
2331  , size_t M // Number of rows
2332  , size_t N // Number of columns
2333  , bool SO > // Storage order
2334 inline void StaticMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2335 {
2336  using blaze::store;
2337 
2339 
2340  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2341  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2342  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2343  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2344 
2345  store( &v_[i*NN+j], value );
2346 }
2347 //*************************************************************************************************
2348 
2349 
2350 //*************************************************************************************************
2366 template< typename Type // Data type of the matrix
2367  , size_t M // Number of rows
2368  , size_t N // Number of columns
2369  , bool SO > // Storage order
2370 inline void StaticMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2371 {
2372  using blaze::storeu;
2373 
2375 
2376  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2377  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2378  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2379 
2380  storeu( &v_[i*NN+j], value );
2381 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2401 template< typename Type // Data type of the matrix
2402  , size_t M // Number of rows
2403  , size_t N // Number of columns
2404  , bool SO > // Storage order
2405 inline void StaticMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2406 {
2407  using blaze::stream;
2408 
2410 
2411  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
2412  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
2413  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN , "Invalid column access index" );
2414  BLAZE_INTERNAL_ASSERT( j % IT::size == 0UL, "Invalid column access index" );
2415 
2416  stream( &v_[i*NN+j], value );
2417 }
2418 //*************************************************************************************************
2419 
2420 
2421 //*************************************************************************************************
2432 template< typename Type // Data type of the matrix
2433  , size_t M // Number of rows
2434  , size_t N // Number of columns
2435  , bool SO > // Storage order
2436 template< typename MT // Type of the right-hand side dense matrix
2437  , bool SO2 > // Storage order of the right-hand side dense matrix
2438 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2440 {
2441  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2442 
2443  for( size_t i=0UL; i<M; ++i ) {
2444  for( size_t j=0UL; j<N; ++j ) {
2445  v_[i*NN+j] = (~rhs)(i,j);
2446  }
2447  }
2448 }
2449 //*************************************************************************************************
2450 
2451 
2452 //*************************************************************************************************
2463 template< typename Type // Data type of the matrix
2464  , size_t M // Number of rows
2465  , size_t N // Number of columns
2466  , bool SO > // Storage order
2467 template< typename MT // Type of the right-hand side dense matrix
2468  , bool SO2 > // Storage order of the right-hand side dense matrix
2469 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2471 {
2472  using blaze::store;
2473 
2474  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2475 
2477 
2478  for( size_t i=0UL; i<M; ++i ) {
2479  for( size_t j=0UL; j<N; j+=IT::size ) {
2480  store( &v_[i*NN+j], (~rhs).load(i,j) );
2481  }
2482  }
2483 }
2484 //*************************************************************************************************
2485 
2486 
2487 //*************************************************************************************************
2498 template< typename Type // Data type of the matrix
2499  , size_t M // Number of rows
2500  , size_t N // Number of columns
2501  , bool SO > // Storage order
2502 template< typename MT > // Type of the right-hand side sparse matrix
2504 {
2505  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2506 
2507  typedef typename MT::ConstIterator RhsConstIterator;
2508 
2509  for( size_t i=0UL; i<M; ++i )
2510  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2511  v_[i*NN+element->index()] = element->value();
2512 }
2513 //*************************************************************************************************
2514 
2515 
2516 //*************************************************************************************************
2527 template< typename Type // Data type of the matrix
2528  , size_t M // Number of rows
2529  , size_t N // Number of columns
2530  , bool SO > // Storage order
2531 template< typename MT > // Type of the right-hand side sparse matrix
2533 {
2534  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2535 
2536  typedef typename MT::ConstIterator RhsConstIterator;
2537 
2538  for( size_t j=0UL; j<N; ++j )
2539  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2540  v_[element->index()*NN+j] = element->value();
2541 }
2542 //*************************************************************************************************
2543 
2544 
2545 //*************************************************************************************************
2556 template< typename Type // Data type of the matrix
2557  , size_t M // Number of rows
2558  , size_t N // Number of columns
2559  , bool SO > // Storage order
2560 template< typename MT // Type of the right-hand side dense matrix
2561  , bool SO2 > // Storage order of the right-hand side dense matrix
2562 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2564 {
2565  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2566 
2567  for( size_t i=0UL; i<M; ++i ) {
2568  for( size_t j=0UL; j<N; ++j ) {
2569  v_[i*NN+j] += (~rhs)(i,j);
2570  }
2571  }
2572 }
2573 //*************************************************************************************************
2574 
2575 
2576 //*************************************************************************************************
2587 template< typename Type // Data type of the matrix
2588  , size_t M // Number of rows
2589  , size_t N // Number of columns
2590  , bool SO > // Storage order
2591 template< typename MT // Type of the right-hand side dense matrix
2592  , bool SO2 > // Storage order of the right-hand side dense matrix
2593 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
2595 {
2596  using blaze::load;
2597  using blaze::store;
2598 
2599  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2600 
2602 
2603  for( size_t i=0UL; i<M; ++i ) {
2604  for( size_t j=0UL; j<N; j+=IT::size ) {
2605  store( &v_[i*NN+j], load( &v_[i*NN+j] ) + (~rhs).load(i,j) );
2606  }
2607  }
2608 }
2609 //*************************************************************************************************
2610 
2611 
2612 //*************************************************************************************************
2623 template< typename Type // Data type of the matrix
2624  , size_t M // Number of rows
2625  , size_t N // Number of columns
2626  , bool SO > // Storage order
2627 template< typename MT > // Type of the right-hand side sparse matrix
2629 {
2630  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2631 
2632  typedef typename MT::ConstIterator RhsConstIterator;
2633 
2634  for( size_t i=0UL; i<M; ++i )
2635  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2636  v_[i*NN+element->index()] += element->value();
2637 }
2638 //*************************************************************************************************
2639 
2640 
2641 //*************************************************************************************************
2652 template< typename Type // Data type of the matrix
2653  , size_t M // Number of rows
2654  , size_t N // Number of columns
2655  , bool SO > // Storage order
2656 template< typename MT > // Type of the right-hand side sparse matrix
2658 {
2659  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2660 
2661  typedef typename MT::ConstIterator RhsConstIterator;
2662 
2663  for( size_t j=0UL; j<N; ++j )
2664  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2665  v_[element->index()*NN+j] += element->value();
2666 }
2667 //*************************************************************************************************
2668 
2669 
2670 //*************************************************************************************************
2681 template< typename Type // Data type of the matrix
2682  , size_t M // Number of rows
2683  , size_t N // Number of columns
2684  , bool SO > // Storage order
2685 template< typename MT // Type of the right-hand side dense matrix
2686  , bool SO2 > // Storage order of the right-hand side dense matrix
2687 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2689 {
2690  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2691 
2692  for( size_t i=0UL; i<M; ++i ) {
2693  for( size_t j=0UL; j<N; ++j ) {
2694  v_[i*NN+j] -= (~rhs)(i,j);
2695  }
2696  }
2697 }
2698 //*************************************************************************************************
2699 
2700 
2701 //*************************************************************************************************
2712 template< typename Type // Data type of the matrix
2713  , size_t M // Number of rows
2714  , size_t N // Number of columns
2715  , bool SO > // Storage order
2716 template< typename MT // Type of the right-hand side dense matrix
2717  , bool SO2 > // Storage order of the right-hand side dense matrix
2718 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
2720 {
2721  using blaze::load;
2722  using blaze::store;
2723 
2724  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2725 
2727 
2728  for( size_t i=0UL; i<M; ++i ) {
2729  for( size_t j=0UL; j<N; j+=IT::size ) {
2730  store( &v_[i*NN+j], load( &v_[i*NN+j] ) - (~rhs).load(i,j) );
2731  }
2732  }
2733 }
2734 //*************************************************************************************************
2735 
2736 
2737 //*************************************************************************************************
2748 template< typename Type // Data type of the matrix
2749  , size_t M // Number of rows
2750  , size_t N // Number of columns
2751  , bool SO > // Storage order
2752 template< typename MT > // Type of the right-hand side sparse matrix
2754 {
2755  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2756 
2757  typedef typename MT::ConstIterator RhsConstIterator;
2758 
2759  for( size_t i=0UL; i<M; ++i )
2760  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2761  v_[i*NN+element->index()] -= element->value();
2762 }
2763 //*************************************************************************************************
2764 
2765 
2766 //*************************************************************************************************
2777 template< typename Type // Data type of the matrix
2778  , size_t M // Number of rows
2779  , size_t N // Number of columns
2780  , bool SO > // Storage order
2781 template< typename MT > // Type of the right-hand side sparse matrix
2783 {
2784  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2785 
2786  typedef typename MT::ConstIterator RhsConstIterator;
2787 
2788  for( size_t j=0UL; j<N; ++j )
2789  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2790  v_[element->index()*NN+j] -= element->value();
2791 }
2792 //*************************************************************************************************
2793 
2794 
2795 
2796 
2797 
2798 
2799 
2800 
2801 //=================================================================================================
2802 //
2803 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
2804 //
2805 //=================================================================================================
2806 
2807 //*************************************************************************************************
2815 template< typename Type // Data type of the matrix
2816  , size_t M // Number of rows
2817  , size_t N > // Number of columns
2818 class StaticMatrix<Type,M,N,true> : public DenseMatrix< StaticMatrix<Type,M,N,true>, true >
2819 {
2820  private:
2821  //**Type definitions****************************************************************************
2822  typedef IntrinsicTrait<Type> IT;
2823  //**********************************************************************************************
2824 
2825  //**********************************************************************************************
2827  enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
2828  //**********************************************************************************************
2829 
2830  public:
2831  //**Type definitions****************************************************************************
2832  typedef StaticMatrix<Type,M,N,true> This;
2833  typedef This ResultType;
2834  typedef StaticMatrix<Type,M,N,false> OppositeType;
2835  typedef StaticMatrix<Type,N,M,false> TransposeType;
2836  typedef Type ElementType;
2837  typedef typename IT::Type IntrinsicType;
2838  typedef const Type& ReturnType;
2839  typedef const This& CompositeType;
2840  typedef Type& Reference;
2841  typedef const Type& ConstReference;
2842  typedef DenseIterator<Type> Iterator;
2843  typedef DenseIterator<const Type> ConstIterator;
2844  //**********************************************************************************************
2845 
2846  //**Compilation flags***************************************************************************
2848 
2852  enum { vectorizable = IsVectorizable<Type>::value };
2853 
2855 
2858  enum { smpAssignable = 0 };
2859  //**********************************************************************************************
2860 
2861  //**Constructors********************************************************************************
2864  explicit inline StaticMatrix();
2865  explicit inline StaticMatrix( const Type& init );
2866 
2867  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
2868  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
2869 
2870  inline StaticMatrix( const StaticMatrix& m );
2871  template< typename Other, bool SO > inline StaticMatrix( const StaticMatrix<Other,M,N,SO>& m );
2872  template< typename MT , bool SO > inline StaticMatrix( const Matrix<MT,SO>& m );
2873 
2874  inline StaticMatrix( const Type& v1, const Type& v2 );
2875  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
2876  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
2877  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
2878  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2879  const Type& v6 );
2880  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2881  const Type& v6, const Type& v7 );
2882  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2883  const Type& v6, const Type& v7, const Type& v8 );
2884  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2885  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
2886  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
2887  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
2889  //**********************************************************************************************
2890 
2891  //**Destructor**********************************************************************************
2892  // No explicitly declared destructor.
2893  //**********************************************************************************************
2894 
2895  //**Data access functions***********************************************************************
2898  inline Reference operator()( size_t i, size_t j );
2899  inline ConstReference operator()( size_t i, size_t j ) const;
2900  inline Type* data ();
2901  inline const Type* data () const;
2902  inline Type* data ( size_t j );
2903  inline const Type* data ( size_t j ) const;
2904  inline Iterator begin ( size_t j );
2905  inline ConstIterator begin ( size_t j ) const;
2906  inline ConstIterator cbegin( size_t j ) const;
2907  inline Iterator end ( size_t j );
2908  inline ConstIterator end ( size_t j ) const;
2909  inline ConstIterator cend ( size_t j ) const;
2911  //**********************************************************************************************
2912 
2913  //**Assignment operators************************************************************************
2916  template< typename Other >
2917  inline StaticMatrix& operator=( const Other (&array)[M][N] );
2918 
2919  inline StaticMatrix& operator= ( const Type& set );
2920  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
2921  template< typename Other, bool SO > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO>& rhs );
2922  template< typename MT , bool SO > inline StaticMatrix& operator= ( const Matrix<MT,SO>& rhs );
2923  template< typename MT , bool SO > inline StaticMatrix& operator+=( const Matrix<MT,SO>& rhs );
2924  template< typename MT , bool SO > inline StaticMatrix& operator-=( const Matrix<MT,SO>& rhs );
2925  template< typename MT , bool SO > inline StaticMatrix& operator*=( const Matrix<MT,SO>& rhs );
2926 
2927  template< typename Other >
2928  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
2929  operator*=( Other rhs );
2930 
2931  template< typename Other >
2932  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
2933  operator/=( Other rhs );
2935  //**********************************************************************************************
2936 
2937  //**Utility functions***************************************************************************
2940  inline size_t rows() const;
2941  inline size_t columns() const;
2942  inline size_t spacing() const;
2943  inline size_t capacity() const;
2944  inline size_t capacity( size_t j ) const;
2945  inline size_t nonZeros() const;
2946  inline size_t nonZeros( size_t j ) const;
2947  inline void reset();
2948  inline void reset( size_t i );
2949  inline StaticMatrix& transpose();
2950  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
2951  inline void swap( StaticMatrix& m ) /* throw() */;
2953  //**********************************************************************************************
2954 
2955  private:
2956  //**********************************************************************************************
2958  template< typename MT >
2959  struct VectorizedAssign {
2960  enum { value = vectorizable && MT::vectorizable &&
2961  IsSame<Type,typename MT::ElementType>::value &&
2962  IsColumnMajorMatrix<MT>::value };
2963  };
2964  //**********************************************************************************************
2965 
2966  //**********************************************************************************************
2968  template< typename MT >
2969  struct VectorizedAddAssign {
2970  enum { value = vectorizable && MT::vectorizable &&
2971  IsSame<Type,typename MT::ElementType>::value &&
2972  IntrinsicTrait<Type>::addition &&
2973  IsColumnMajorMatrix<MT>::value };
2974  };
2975  //**********************************************************************************************
2976 
2977  //**********************************************************************************************
2979  template< typename MT >
2980  struct VectorizedSubAssign {
2981  enum { value = vectorizable && MT::vectorizable &&
2982  IsSame<Type,typename MT::ElementType>::value &&
2983  IntrinsicTrait<Type>::subtraction &&
2984  IsColumnMajorMatrix<MT>::value };
2985  };
2986  //**********************************************************************************************
2987 
2988  public:
2989  //**Expression template evaluation functions****************************************************
2992  template< typename Other > inline bool canAlias ( const Other* alias ) const;
2993  template< typename Other > inline bool isAliased( const Other* alias ) const;
2994 
2995  inline bool isAligned() const;
2996 
2997  inline IntrinsicType load ( size_t i, size_t j ) const;
2998  inline IntrinsicType loadu ( size_t i, size_t j ) const;
2999  inline void store ( size_t i, size_t j, const IntrinsicType& value );
3000  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
3001  inline void stream( size_t i, size_t j, const IntrinsicType& value );
3002 
3003  template< typename MT, bool SO >
3004  inline typename DisableIf< VectorizedAssign<MT> >::Type
3005  assign( const DenseMatrix<MT,SO>& rhs );
3006 
3007  template< typename MT, bool SO >
3008  inline typename EnableIf< VectorizedAssign<MT> >::Type
3009  assign( const DenseMatrix<MT,SO>& rhs );
3010 
3011  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
3012  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
3013 
3014  template< typename MT, bool SO >
3015  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
3016  addAssign( const DenseMatrix<MT,SO>& rhs );
3017 
3018  template< typename MT, bool SO >
3019  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
3020  addAssign( const DenseMatrix<MT,SO>& rhs );
3021 
3022  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
3023  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
3024 
3025  template< typename MT, bool SO >
3026  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
3027  subAssign( const DenseMatrix<MT,SO>& rhs );
3028 
3029  template< typename MT, bool SO >
3030  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
3031  subAssign( const DenseMatrix<MT,SO>& rhs );
3032 
3033  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
3034  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
3036  //**********************************************************************************************
3037 
3038  private:
3039  //**Member variables****************************************************************************
3042  AlignedArray<Type,MM*N> v_;
3043 
3046  //**********************************************************************************************
3047 
3048  //**Compile time checks*************************************************************************
3053  BLAZE_STATIC_ASSERT( MM % IT::size == 0UL );
3054  BLAZE_STATIC_ASSERT( MM >= M );
3055  //**********************************************************************************************
3056 };
3058 //*************************************************************************************************
3059 
3060 
3061 
3062 
3063 //=================================================================================================
3064 //
3065 // CONSTRUCTORS
3066 //
3067 //=================================================================================================
3068 
3069 //*************************************************************************************************
3075 template< typename Type // Data type of the matrix
3076  , size_t M // Number of rows
3077  , size_t N > // Number of columns
3079 {
3080  if( IsNumeric<Type>::value ) {
3081  for( size_t i=0UL; i<MM*N; ++i )
3082  v_[i] = Type();
3083  }
3084 }
3086 //*************************************************************************************************
3087 
3088 
3089 //*************************************************************************************************
3095 template< typename Type // Data type of the matrix
3096  , size_t M // Number of rows
3097  , size_t N > // Number of columns
3098 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& init )
3099 {
3100  for( size_t j=0UL; j<N; ++j ) {
3101  for( size_t i=0UL; i<M; ++i )
3102  v_[i+j*MM] = init;
3103 
3104  if( IsNumeric<Type>::value ) {
3105  for( size_t i=M; i<MM; ++i )
3106  v_[i+j*MM] = Type();
3107  }
3108  }
3109 }
3111 //*************************************************************************************************
3112 
3113 
3114 //*************************************************************************************************
3141 template< typename Type // Data type of the matrix
3142  , size_t M // Number of rows
3143  , size_t N > // Number of columns
3144 template< typename Other > // Data type of the initialization array
3145 inline StaticMatrix<Type,M,N,true>::StaticMatrix( size_t m, size_t n, const Other* array )
3146 {
3147  if( m > M || n > N )
3148  throw std::invalid_argument( "Invalid setup of static matrix" );
3149 
3150  for( size_t j=0UL; j<n; ++j ) {
3151  for( size_t i=0UL; i<m; ++i )
3152  v_[i+j*MM] = array[i+j*m];
3153 
3154  if( IsNumeric<Type>::value ) {
3155  for( size_t i=m; i<MM; ++i )
3156  v_[i+j*MM] = Type();
3157  }
3158  }
3159 
3160  for( size_t j=n; j<N; ++j ) {
3161  for( size_t i=0UL; i<M; ++i )
3162  v_[i+j*MM] = Type();
3163  }
3164 }
3166 //*************************************************************************************************
3167 
3168 
3169 //*************************************************************************************************
3190 template< typename Type // Data type of the matrix
3191  , size_t M // Number of rows
3192  , size_t N > // Number of columns
3193 template< typename Other > // Data type of the initialization array
3194 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Other (&array)[M][N] )
3195 {
3196  for( size_t j=0UL; j<N; ++j ) {
3197  for( size_t i=0UL; i<M; ++i )
3198  v_[i+j*MM] = array[i][j];
3199 
3200  if( IsNumeric<Type>::value ) {
3201  for( size_t i=M; i<MM; ++i )
3202  v_[i+j*MM] = Type();
3203  }
3204  }
3205 }
3207 //*************************************************************************************************
3208 
3209 
3210 //*************************************************************************************************
3218 template< typename Type // Data type of the matrix
3219  , size_t M // Number of rows
3220  , size_t N > // Number of columns
3221 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix& m )
3222 {
3223  for( size_t i=0UL; i<MM*N; ++i )
3224  v_[i] = m.v_[i];
3225 }
3227 //*************************************************************************************************
3228 
3229 
3230 //*************************************************************************************************
3236 template< typename Type // Data type of the matrix
3237  , size_t M // Number of rows
3238  , size_t N > // Number of columns
3239 template< typename Other // Data type of the foreign matrix
3240  , bool SO > // Storage order of the foreign matrix
3241 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix<Other,M,N,SO>& m )
3242 {
3243  for( size_t j=0UL; j<N; ++j ) {
3244  for( size_t i=0UL; i<M; ++i )
3245  v_[i+j*MM] = m(i,j);
3246 
3247  if( IsNumeric<Type>::value ) {
3248  for( size_t i=M; i<MM; ++i )
3249  v_[i+j*MM] = Type();
3250  }
3251  }
3252 }
3254 //*************************************************************************************************
3255 
3256 
3257 //*************************************************************************************************
3268 template< typename Type // Data type of the matrix
3269  , size_t M // Number of rows
3270  , size_t N > // Number of columns
3271 template< typename MT // Type of the foreign matrix
3272  , bool SO > // Storage order of the foreign matrix
3273 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Matrix<MT,SO>& m )
3274 {
3275  using blaze::assign;
3276 
3277  if( (~m).rows() != M || (~m).columns() != N )
3278  throw std::invalid_argument( "Invalid setup of static matrix" );
3279 
3280  if( IsNumeric<Type>::value ) {
3281  for( size_t j=0UL; j<N; ++j )
3282  for( size_t i=( IsSparseMatrix<MT>::value )?( 0UL ):( M ); i<MM; ++i ) {
3283  v_[i+j*MM] = Type();
3284  }
3285  }
3286 
3287  assign( *this, ~m );
3288 }
3290 //*************************************************************************************************
3291 
3292 
3293 //*************************************************************************************************
3311 template< typename Type // Data type of the matrix
3312  , size_t M // Number of rows
3313  , size_t N > // Number of columns
3314 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2 )
3315 {
3316  BLAZE_STATIC_ASSERT( M*N == 2UL );
3317 
3318  // Initialization of a 2x1 matrix
3319  if( N == 1UL ) {
3320  v_[0UL] = v1;
3321  v_[1UL] = v2;
3322  }
3323 
3324  // Initialization of a 1x2 matrix
3325  else {
3326  v_[0UL] = v1;
3327  v_[ MM] = v2;
3328  }
3329 
3330  if( IsNumeric<Type>::value ) {
3331  for( size_t j=0UL; j<N; ++j )
3332  for( size_t i=M; i<MM; ++i ) {
3333  v_[i+j*MM] = Type();
3334  }
3335  }
3336 }
3338 //*************************************************************************************************
3339 
3340 
3341 //*************************************************************************************************
3360 template< typename Type // Data type of the matrix
3361  , size_t M // Number of rows
3362  , size_t N > // Number of columns
3363 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
3364 {
3365  BLAZE_STATIC_ASSERT( M*N == 3UL );
3366 
3367  // Initialization of a 3x1 matrix
3368  if( N == 1UL ) {
3369  v_[0UL] = v1;
3370  v_[1UL] = v2;
3371  v_[2UL] = v3;
3372  }
3373 
3374  // Initialization of a 1x3 matrix
3375  else {
3376  v_[ 0UL] = v1;
3377  v_[ MM] = v2;
3378  v_[2UL*MM] = v3;
3379  }
3380 
3381  if( IsNumeric<Type>::value ) {
3382  for( size_t j=0UL; j<N; ++j )
3383  for( size_t i=M; i<MM; ++i ) {
3384  v_[i+j*MM] = Type();
3385  }
3386  }
3387 }
3389 //*************************************************************************************************
3390 
3391 
3392 //*************************************************************************************************
3414 template< typename Type // Data type of the matrix
3415  , size_t M // Number of rows
3416  , size_t N > // Number of columns
3417 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3418  const Type& v4 )
3419 {
3420  BLAZE_STATIC_ASSERT( M*N == 4UL );
3421 
3422  // Initialization of a 4x1 matrix
3423  if( N == 1UL ) {
3424  v_[0UL] = v1;
3425  v_[1UL] = v2;
3426  v_[2UL] = v3;
3427  v_[3UL] = v4;
3428  }
3429 
3430  // Initialization of a 2x2 matrix
3431  else if( N == 2UL ) {
3432  v_[ 0UL] = v1;
3433  v_[ 1UL] = v2;
3434  v_[MM ] = v3;
3435  v_[MM+1UL] = v4;
3436  }
3437 
3438  // Initialization of a 1x4 matrix
3439  else {
3440  v_[ 0UL] = v1;
3441  v_[ MM] = v2;
3442  v_[2UL*MM] = v3;
3443  v_[3UL*MM] = v4;
3444  }
3445 
3446  if( IsNumeric<Type>::value ) {
3447  for( size_t j=0UL; j<N; ++j )
3448  for( size_t i=M; i<MM; ++i ) {
3449  v_[i+j*MM] = Type();
3450  }
3451  }
3452 }
3454 //*************************************************************************************************
3455 
3456 
3457 //*************************************************************************************************
3478 template< typename Type // Data type of the matrix
3479  , size_t M // Number of rows
3480  , size_t N > // Number of columns
3481 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3482  const Type& v4, const Type& v5 )
3483 {
3484  BLAZE_STATIC_ASSERT( M*N == 5UL );
3485 
3486  // Initialization of a 5x1 matrix
3487  if( N == 1UL ) {
3488  v_[0UL] = v1;
3489  v_[1UL] = v2;
3490  v_[2UL] = v3;
3491  v_[3UL] = v4;
3492  v_[4UL] = v5;
3493  }
3494 
3495  // Initialization of a 1x5 matrix
3496  else {
3497  v_[ 0UL] = v1;
3498  v_[ MM] = v2;
3499  v_[2UL*MM] = v3;
3500  v_[3UL*MM] = v4;
3501  v_[4UL*MM] = v5;
3502  }
3503 
3504  if( IsNumeric<Type>::value ) {
3505  for( size_t j=0UL; j<N; ++j )
3506  for( size_t i=M; i<MM; ++i ) {
3507  v_[i+j*MM] = Type();
3508  }
3509  }
3510 }
3512 //*************************************************************************************************
3513 
3514 
3515 //*************************************************************************************************
3540 template< typename Type // Data type of the matrix
3541  , size_t M // Number of rows
3542  , size_t N > // Number of columns
3543 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3544  const Type& v4, const Type& v5, const Type& v6 )
3545 {
3546  BLAZE_STATIC_ASSERT( M*N == 6UL );
3547 
3548  // Initialization of a 6x1 matrix
3549  if( N == 1UL ) {
3550  v_[0UL] = v1;
3551  v_[1UL] = v2;
3552  v_[2UL] = v3;
3553  v_[3UL] = v4;
3554  v_[4UL] = v5;
3555  v_[5UL] = v6;
3556  }
3557 
3558  // Initialization of a 3x2 matrix
3559  else if( N == 2UL ) {
3560  v_[ 0UL] = v1;
3561  v_[ 1UL] = v2;
3562  v_[ 2UL] = v3;
3563  v_[MM ] = v4;
3564  v_[MM+1UL] = v5;
3565  v_[MM+2UL] = v6;
3566  }
3567 
3568  // Initialization of a 2x3 matrix
3569  else if( N == 3UL ) {
3570  v_[ 0UL] = v1;
3571  v_[ 1UL] = v2;
3572  v_[ MM ] = v3;
3573  v_[ MM+1UL] = v4;
3574  v_[2UL*MM ] = v5;
3575  v_[2UL*MM+1UL] = v6;
3576  }
3577 
3578  // Initialization of a 1x6 matrix
3579  else {
3580  v_[ 0UL] = v1;
3581  v_[ MM] = v2;
3582  v_[2UL*MM] = v3;
3583  v_[3UL*MM] = v4;
3584  v_[4UL*MM] = v5;
3585  v_[5UL*MM] = v6;
3586  }
3587 
3588  if( IsNumeric<Type>::value ) {
3589  for( size_t j=0UL; j<N; ++j )
3590  for( size_t i=M; i<MM; ++i ) {
3591  v_[i+j*MM] = Type();
3592  }
3593  }
3594 }
3596 //*************************************************************************************************
3597 
3598 
3599 //*************************************************************************************************
3622 template< typename Type // Data type of the matrix
3623  , size_t M // Number of rows
3624  , size_t N > // Number of columns
3625 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3626  const Type& v4, const Type& v5, const Type& v6,
3627  const Type& v7 )
3628 {
3629  BLAZE_STATIC_ASSERT( M*N == 7UL );
3630 
3631  // Initialization of a 7x1 matrix
3632  if( N == 1UL ) {
3633  v_[0UL] = v1;
3634  v_[1UL] = v2;
3635  v_[2UL] = v3;
3636  v_[3UL] = v4;
3637  v_[4UL] = v5;
3638  v_[5UL] = v6;
3639  v_[6UL] = v7;
3640  }
3641 
3642  // Initialization of a 1x7 matrix
3643  else {
3644  v_[ 0UL] = v1;
3645  v_[ MM] = v2;
3646  v_[2UL*MM] = v3;
3647  v_[3UL*MM] = v4;
3648  v_[4UL*MM] = v5;
3649  v_[5UL*MM] = v6;
3650  v_[6UL*MM] = v7;
3651  }
3652 
3653  if( IsNumeric<Type>::value ) {
3654  for( size_t j=0UL; j<N; ++j )
3655  for( size_t i=M; i<MM; ++i ) {
3656  v_[i+j*MM] = Type();
3657  }
3658  }
3659 }
3661 //*************************************************************************************************
3662 
3663 
3664 //*************************************************************************************************
3691 template< typename Type // Data type of the matrix
3692  , size_t M // Number of rows
3693  , size_t N > // Number of columns
3694 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3695  const Type& v4, const Type& v5, const Type& v6,
3696  const Type& v7, const Type& v8 )
3697 {
3698  BLAZE_STATIC_ASSERT( M*N == 8UL );
3699 
3700  // Initialization of a 8x1 matrix
3701  if( N == 1UL ) {
3702  v_[0UL] = v1;
3703  v_[1UL] = v2;
3704  v_[2UL] = v3;
3705  v_[3UL] = v4;
3706  v_[4UL] = v5;
3707  v_[5UL] = v6;
3708  v_[6UL] = v7;
3709  v_[7UL] = v8;
3710  }
3711 
3712  // Initialization of a 4x2 matrix
3713  else if( N == 2UL ) {
3714  v_[ 0UL] = v1;
3715  v_[ 1UL] = v2;
3716  v_[ 2UL] = v3;
3717  v_[ 3UL] = v4;
3718  v_[MM ] = v5;
3719  v_[MM+1UL] = v6;
3720  v_[MM+2UL] = v7;
3721  v_[MM+3UL] = v8;
3722  }
3723 
3724  // Initialization of a 2x4 matrix
3725  else if( N == 4UL ) {
3726  v_[ 0UL] = v1;
3727  v_[ 1UL] = v2;
3728  v_[ MM ] = v3;
3729  v_[ MM+1UL] = v4;
3730  v_[2UL*MM ] = v5;
3731  v_[2UL*MM+1UL] = v6;
3732  v_[3UL*MM ] = v7;
3733  v_[3UL*MM+1UL] = v8;
3734  }
3735 
3736  // Initialization of a 1x8 matrix
3737  else {
3738  v_[ 0UL] = v1;
3739  v_[ MM] = v2;
3740  v_[2UL*MM] = v3;
3741  v_[3UL*MM] = v4;
3742  v_[4UL*MM] = v5;
3743  v_[5UL*MM] = v6;
3744  v_[6UL*MM] = v7;
3745  v_[7UL*MM] = v8;
3746  }
3747 
3748  if( IsNumeric<Type>::value ) {
3749  for( size_t j=0UL; j<N; ++j )
3750  for( size_t i=M; i<MM; ++i ) {
3751  v_[i+j*MM] = Type();
3752  }
3753  }
3754 }
3756 //*************************************************************************************************
3757 
3758 
3759 //*************************************************************************************************
3787 template< typename Type // Data type of the matrix
3788  , size_t M // Number of rows
3789  , size_t N > // Number of columns
3790 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3791  const Type& v4, const Type& v5, const Type& v6,
3792  const Type& v7, const Type& v8, const Type& v9 )
3793 {
3794  BLAZE_STATIC_ASSERT( M*N == 9UL );
3795 
3796  // Initialization of a 9x1 matrix
3797  if( N == 1 ) {
3798  v_[0UL] = v1;
3799  v_[1UL] = v2;
3800  v_[2UL] = v3;
3801  v_[3UL] = v4;
3802  v_[4UL] = v5;
3803  v_[5UL] = v6;
3804  v_[6UL] = v7;
3805  v_[7UL] = v8;
3806  v_[8UL] = v9;
3807  }
3808 
3809  // Initialization of a 3x3 matrix
3810  else if( N == 3UL ) {
3811  v_[ 0UL] = v1;
3812  v_[ 1UL] = v2;
3813  v_[ 2UL] = v3;
3814  v_[ MM ] = v4;
3815  v_[ MM+1UL] = v5;
3816  v_[ MM+2UL] = v6;
3817  v_[2UL*MM ] = v7;
3818  v_[2UL*MM+1UL] = v8;
3819  v_[2UL*MM+2UL] = v9;
3820  }
3821 
3822  // Initialization of a 1x9 matrix
3823  else {
3824  v_[ 0UL] = v1;
3825  v_[ MM] = v2;
3826  v_[2UL*MM] = v3;
3827  v_[3UL*MM] = v4;
3828  v_[4UL*MM] = v5;
3829  v_[5UL*MM] = v6;
3830  v_[6UL*MM] = v7;
3831  v_[7UL*MM] = v8;
3832  v_[8UL*MM] = v9;
3833  }
3834 
3835  if( IsNumeric<Type>::value ) {
3836  for( size_t j=0UL; j<N; ++j )
3837  for( size_t i=M; i<MM; ++i ) {
3838  v_[i+j*MM] = Type();
3839  }
3840  }
3841 }
3843 //*************************************************************************************************
3844 
3845 
3846 //*************************************************************************************************
3875 template< typename Type // Data type of the matrix
3876  , size_t M // Number of rows
3877  , size_t N > // Number of columns
3878 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
3879  const Type& v4, const Type& v5, const Type& v6,
3880  const Type& v7, const Type& v8, const Type& v9,
3881  const Type& v10 )
3882 {
3883  BLAZE_STATIC_ASSERT( M*N == 10UL );
3884 
3885  // Initialization of a 10x1 matrix
3886  if( N == 1UL ) {
3887  v_[0UL] = v1;
3888  v_[1UL] = v2;
3889  v_[2UL] = v3;
3890  v_[3UL] = v4;
3891  v_[4UL] = v5;
3892  v_[5UL] = v6;
3893  v_[6UL] = v7;
3894  v_[7UL] = v8;
3895  v_[8UL] = v9;
3896  v_[9UL] = v10;
3897  }
3898 
3899  // Initialization of a 5x2 matrix
3900  else if( N == 2UL ) {
3901  v_[ 0UL] = v1;
3902  v_[ 1UL] = v2;
3903  v_[ 2UL] = v3;
3904  v_[ 3UL] = v4;
3905  v_[ 4UL] = v5;
3906  v_[MM ] = v6;
3907  v_[MM+1UL] = v7;
3908  v_[MM+2UL] = v8;
3909  v_[MM+3UL] = v9;
3910  v_[MM+4UL] = v10;
3911  }
3912 
3913  // Initialization of a 2x5 matrix
3914  else if( N == 5UL ) {
3915  v_[ 0UL] = v1;
3916  v_[ 1UL] = v2;
3917  v_[ MM ] = v3;
3918  v_[ MM+1UL] = v4;
3919  v_[2UL*MM ] = v5;
3920  v_[2UL*MM+1UL] = v6;
3921  v_[3UL*MM ] = v7;
3922  v_[3UL*MM+1UL] = v8;
3923  v_[4UL*MM ] = v9;
3924  v_[4UL*MM+1UL] = v10;
3925  }
3926 
3927  // Initialization of a 1x10 matrix
3928  else {
3929  v_[ 0UL] = v1;
3930  v_[ MM] = v2;
3931  v_[2UL*MM] = v3;
3932  v_[3UL*MM] = v4;
3933  v_[4UL*MM] = v5;
3934  v_[5UL*MM] = v6;
3935  v_[6UL*MM] = v7;
3936  v_[7UL*MM] = v8;
3937  v_[8UL*MM] = v9;
3938  v_[9UL*MM] = v10;
3939  }
3940 
3941  if( IsNumeric<Type>::value ) {
3942  for( size_t j=0UL; j<N; ++j )
3943  for( size_t i=M; i<MM; ++i ) {
3944  v_[i+j*MM] = Type();
3945  }
3946  }
3947 }
3949 //*************************************************************************************************
3950 
3951 
3952 
3953 
3954 //=================================================================================================
3955 //
3956 // DATA ACCESS FUNCTIONS
3957 //
3958 //=================================================================================================
3959 
3960 //*************************************************************************************************
3968 template< typename Type // Data type of the matrix
3969  , size_t M // Number of rows
3970  , size_t N > // Number of columns
3972  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
3973 {
3974  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3975  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3976  return v_[i+j*MM];
3977 }
3979 //*************************************************************************************************
3980 
3981 
3982 //*************************************************************************************************
3990 template< typename Type // Data type of the matrix
3991  , size_t M // Number of rows
3992  , size_t N > // Number of columns
3994  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
3995 {
3996  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
3997  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
3998  return v_[i+j*MM];
3999 }
4001 //*************************************************************************************************
4002 
4003 
4004 //*************************************************************************************************
4014 template< typename Type // Data type of the matrix
4015  , size_t M // Number of rows
4016  , size_t N > // Number of columns
4017 inline Type* StaticMatrix<Type,M,N,true>::data()
4018 {
4019  return v_;
4020 }
4022 //*************************************************************************************************
4023 
4024 
4025 //*************************************************************************************************
4035 template< typename Type // Data type of the matrix
4036  , size_t M // Number of rows
4037  , size_t N > // Number of columns
4038 inline const Type* StaticMatrix<Type,M,N,true>::data() const
4039 {
4040  return v_;
4041 }
4043 //*************************************************************************************************
4044 
4045 
4046 //*************************************************************************************************
4055 template< typename Type // Data type of the matrix
4056  , size_t M // Number of rows
4057  , size_t N > // Number of columns
4058 inline Type* StaticMatrix<Type,M,N,true>::data( size_t j )
4059 {
4060  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4061  return v_ + j*MM;
4062 }
4064 //*************************************************************************************************
4065 
4066 
4067 //*************************************************************************************************
4076 template< typename Type // Data type of the matrix
4077  , size_t M // Number of rows
4078  , size_t N > // Number of columns
4079 inline const Type* StaticMatrix<Type,M,N,true>::data( size_t j ) const
4080 {
4081  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4082  return v_ + j*MM;
4083 }
4085 //*************************************************************************************************
4086 
4087 
4088 //*************************************************************************************************
4095 template< typename Type // Data type of the matrix
4096  , size_t M // Number of rows
4097  , size_t N > // Number of columns
4100 {
4101  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4102  return Iterator( v_ + j*MM );
4103 }
4105 //*************************************************************************************************
4106 
4107 
4108 //*************************************************************************************************
4115 template< typename Type // Data type of the matrix
4116  , size_t M // Number of rows
4117  , size_t N > // Number of columns
4119  StaticMatrix<Type,M,N,true>::begin( size_t j ) const
4120 {
4121  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4122  return ConstIterator( v_ + j*MM );
4123 }
4125 //*************************************************************************************************
4126 
4127 
4128 //*************************************************************************************************
4135 template< typename Type // Data type of the matrix
4136  , size_t M // Number of rows
4137  , size_t N > // Number of columns
4139  StaticMatrix<Type,M,N,true>::cbegin( size_t j ) const
4140 {
4141  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4142  return ConstIterator( v_ + j*MM );
4143 }
4145 //*************************************************************************************************
4146 
4147 
4148 //*************************************************************************************************
4155 template< typename Type // Data type of the matrix
4156  , size_t M // Number of rows
4157  , size_t N > // Number of columns
4160 {
4161  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4162  return Iterator( v_ + j*MM + M );
4163 }
4165 //*************************************************************************************************
4166 
4167 
4168 //*************************************************************************************************
4175 template< typename Type // Data type of the matrix
4176  , size_t M // Number of rows
4177  , size_t N > // Number of columns
4179  StaticMatrix<Type,M,N,true>::end( size_t j ) const
4180 {
4181  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4182  return ConstIterator( v_ + j*MM + M );
4183 }
4185 //*************************************************************************************************
4186 
4187 
4188 //*************************************************************************************************
4195 template< typename Type // Data type of the matrix
4196  , size_t M // Number of rows
4197  , size_t N > // Number of columns
4199  StaticMatrix<Type,M,N,true>::cend( size_t j ) const
4200 {
4201  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4202  return ConstIterator( v_ + j*MM + M );
4203 }
4205 //*************************************************************************************************
4206 
4207 
4208 
4209 
4210 //=================================================================================================
4211 //
4212 // ASSIGNMENT OPERATORS
4213 //
4214 //=================================================================================================
4215 
4216 //*************************************************************************************************
4238 template< typename Type // Data type of the matrix
4239  , size_t M // Number of rows
4240  , size_t N > // Number of columns
4241 template< typename Other > // Data type of the initialization array
4242 inline StaticMatrix<Type,M,N,true>&
4243  StaticMatrix<Type,M,N,true>::operator=( const Other (&array)[M][N] )
4244 {
4245  for( size_t j=0UL; j<N; ++j )
4246  for( size_t i=0UL; i<M; ++i )
4247  v_[i+j*MM] = array[i][j];
4248 
4249  return *this;
4250 }
4252 //*************************************************************************************************
4253 
4254 
4255 //*************************************************************************************************
4262 template< typename Type // Data type of the matrix
4263  , size_t M // Number of rows
4264  , size_t N > // Number of columns
4265 inline StaticMatrix<Type,M,N,true>&
4266  StaticMatrix<Type,M,N,true>::operator=( const Type& set )
4267 {
4268  for( size_t j=0UL; j<N; ++j )
4269  for( size_t i=0UL; i<M; ++i )
4270  v_[i+j*MM] = set;
4271 
4272  return *this;
4273 }
4275 //*************************************************************************************************
4276 
4277 
4278 //*************************************************************************************************
4287 template< typename Type // Data type of the matrix
4288  , size_t M // Number of rows
4289  , size_t N > // Number of columns
4290 inline StaticMatrix<Type,M,N,true>&
4291  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix& rhs )
4292 {
4293  using blaze::assign;
4294 
4295  assign( *this, ~rhs );
4296  return *this;
4297 }
4299 //*************************************************************************************************
4300 
4301 
4302 //*************************************************************************************************
4309 template< typename Type // Data type of the matrix
4310  , size_t M // Number of rows
4311  , size_t N > // Number of columns
4312 template< typename Other // Data type of the foreign matrix
4313  , bool SO > // Storage order of the foreign matrix
4314 inline StaticMatrix<Type,M,N,true>&
4315  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix<Other,M,N,SO>& rhs )
4316 {
4317  using blaze::assign;
4318 
4319  assign( *this, ~rhs );
4320  return *this;
4321 }
4323 //*************************************************************************************************
4324 
4325 
4326 //*************************************************************************************************
4338 template< typename Type // Data type of the matrix
4339  , size_t M // Number of rows
4340  , size_t N > // Number of columns
4341 template< typename MT // Type of the right-hand side matrix
4342  , bool SO > // Storage order of the right-hand side matrix
4343 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
4344 {
4345  using blaze::assign;
4346 
4347  if( (~rhs).rows() != M || (~rhs).columns() != N )
4348  throw std::invalid_argument( "Invalid assignment to static matrix" );
4349 
4350  if( (~rhs).canAlias( this ) ) {
4351  StaticMatrix tmp( ~rhs );
4352  swap( tmp );
4353  }
4354  else {
4355  if( IsSparseMatrix<MT>::value )
4356  reset();
4357  assign( *this, ~rhs );
4358  }
4359 
4360  return *this;
4361 }
4363 //*************************************************************************************************
4364 
4365 
4366 //*************************************************************************************************
4377 template< typename Type // Data type of the matrix
4378  , size_t M // Number of rows
4379  , size_t N > // Number of columns
4380 template< typename MT // Type of the right-hand side matrix
4381  , bool SO > // Storage order of the right-hand side matrix
4382 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
4383 {
4384  using blaze::addAssign;
4385 
4386  if( (~rhs).rows() != M || (~rhs).columns() != N )
4387  throw std::invalid_argument( "Matrix sizes do not match" );
4388 
4389  if( (~rhs).canAlias( this ) ) {
4390  StaticMatrix tmp( ~rhs );
4391  addAssign( *this, tmp );
4392  }
4393  else {
4394  addAssign( *this, ~rhs );
4395  }
4396 
4397  return *this;
4398 }
4400 //*************************************************************************************************
4401 
4402 
4403 //*************************************************************************************************
4414 template< typename Type // Data type of the matrix
4415  , size_t M // Number of rows
4416  , size_t N > // Number of columns
4417 template< typename MT // Type of the right-hand side matrix
4418  , bool SO > // Storage order of the right-hand side matrix
4419 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
4420 {
4421  using blaze::subAssign;
4422 
4423  if( (~rhs).rows() != M || (~rhs).columns() != N )
4424  throw std::invalid_argument( "Matrix sizes do not match" );
4425 
4426  if( (~rhs).canAlias( this ) ) {
4427  StaticMatrix tmp( ~rhs );
4428  subAssign( *this, tmp );
4429  }
4430  else {
4431  subAssign( *this, ~rhs );
4432  }
4433 
4434  return *this;
4435 }
4437 //*************************************************************************************************
4438 
4439 
4440 //*************************************************************************************************
4451 template< typename Type // Data type of the matrix
4452  , size_t M // Number of rows
4453  , size_t N > // Number of columns
4454 template< typename MT // Type of the right-hand side matrix
4455  , bool SO > // Storage order of the right-hand side matrix
4456 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
4457 {
4458  if( M != N || (~rhs).rows() != M || (~rhs).columns() != M )
4459  throw std::invalid_argument( "Matrix sizes do not match" );
4460 
4461  StaticMatrix tmp( *this * (~rhs) );
4462  return this->operator=( tmp );
4463 }
4465 //*************************************************************************************************
4466 
4467 
4468 //*************************************************************************************************
4476 template< typename Type // Data type of the matrix
4477  , size_t M // Number of rows
4478  , size_t N > // Number of columns
4479 template< typename Other > // Data type of the right-hand side scalar
4480 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4481  StaticMatrix<Type,M,N,true>::operator*=( Other rhs )
4482 {
4483  using blaze::assign;
4484 
4485  assign( *this, (*this) * rhs );
4486  return *this;
4487 }
4489 //*************************************************************************************************
4490 
4491 
4492 //*************************************************************************************************
4502 template< typename Type // Data type of the matrix
4503  , size_t M // Number of rows
4504  , size_t N > // Number of columns
4505 template< typename Other > // Data type of the right-hand side scalar
4506 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
4507  StaticMatrix<Type,M,N,true>::operator/=( Other rhs )
4508 {
4509  using blaze::assign;
4510 
4511  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
4512 
4513  assign( *this, (*this) / rhs );
4514  return *this;
4515 }
4517 //*************************************************************************************************
4518 
4519 
4520 
4521 
4522 //=================================================================================================
4523 //
4524 // UTILITY FUNCTIONS
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>::rows() const
4538 {
4539  return M;
4540 }
4542 //*************************************************************************************************
4543 
4544 
4545 //*************************************************************************************************
4551 template< typename Type // Data type of the matrix
4552  , size_t M // Number of rows
4553  , size_t N > // Number of columns
4554 inline size_t StaticMatrix<Type,M,N,true>::columns() const
4555 {
4556  return N;
4557 }
4559 //*************************************************************************************************
4560 
4561 
4562 //*************************************************************************************************
4571 template< typename Type // Data type of the matrix
4572  , size_t M // Number of rows
4573  , size_t N > // Number of columns
4574 inline size_t StaticMatrix<Type,M,N,true>::spacing() const
4575 {
4576  return MM;
4577 }
4579 //*************************************************************************************************
4580 
4581 
4582 //*************************************************************************************************
4588 template< typename Type // Data type of the matrix
4589  , size_t M // Number of rows
4590  , size_t N > // Number of columns
4591 inline size_t StaticMatrix<Type,M,N,true>::capacity() const
4592 {
4593  return MM*N;
4594 }
4596 //*************************************************************************************************
4597 
4598 
4599 //*************************************************************************************************
4606 template< typename Type // Data type of the matrix
4607  , size_t M // Number of rows
4608  , size_t N > // Number of columns
4609 inline size_t StaticMatrix<Type,M,N,true>::capacity( size_t j ) const
4610 {
4611  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4612  return MM;
4613 }
4615 //*************************************************************************************************
4616 
4617 
4618 //*************************************************************************************************
4624 template< typename Type // Data type of the matrix
4625  , size_t M // Number of rows
4626  , size_t N > // Number of columns
4627 inline size_t StaticMatrix<Type,M,N,true>::nonZeros() const
4628 {
4629  size_t nonzeros( 0UL );
4630 
4631  for( size_t j=0UL; j<N; ++j )
4632  for( size_t i=0UL; i<M; ++i )
4633  if( !isDefault( v_[i+j*MM] ) )
4634  ++nonzeros;
4635 
4636  return nonzeros;
4637 }
4639 //*************************************************************************************************
4640 
4641 
4642 //*************************************************************************************************
4649 template< typename Type // Data type of the matrix
4650  , size_t M // Number of rows
4651  , size_t N > // Number of columns
4652 inline size_t StaticMatrix<Type,M,N,true>::nonZeros( size_t j ) const
4653 {
4654  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4655 
4656  const size_t iend( (j+1UL)*MM );
4657  size_t nonzeros( 0UL );
4658 
4659  for( size_t i=j*MM; i<iend; ++i )
4660  if( !isDefault( v_[i] ) )
4661  ++nonzeros;
4662 
4663  return nonzeros;
4664 }
4666 //*************************************************************************************************
4667 
4668 
4669 //*************************************************************************************************
4675 template< typename Type // Data type of the matrix
4676  , size_t M // Number of rows
4677  , size_t N > // Number of columns
4679 {
4680  using blaze::reset;
4681 
4682  for( size_t j=0UL; j<N; ++j )
4683  for( size_t i=0UL; i<M; ++i )
4684  reset( v_[i+j*MM] );
4685 }
4687 //*************************************************************************************************
4688 
4689 
4690 //*************************************************************************************************
4700 template< typename Type // Data type of the matrix
4701  , size_t M // Number of rows
4702  , size_t N > // Number of columns
4703 inline void StaticMatrix<Type,M,N,true>::reset( size_t j )
4704 {
4705  using blaze::reset;
4706 
4707  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
4708  for( size_t i=0UL; i<M; ++i )
4709  reset( v_[i+j*MM] );
4710 }
4712 //*************************************************************************************************
4713 
4714 
4715 //*************************************************************************************************
4721 template< typename Type // Data type of the matrix
4722  , size_t M // Number of rows
4723  , size_t N > // Number of columns
4724 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::transpose()
4725 {
4726  using std::swap;
4727 
4728  for( size_t j=1UL; j<N; ++j )
4729  for( size_t i=0UL; i<j; ++i )
4730  swap( v_[i+j*MM], v_[j+i*MM] );
4731 
4732  return *this;
4733 }
4735 //*************************************************************************************************
4736 
4737 
4738 //*************************************************************************************************
4745 template< typename Type // Data type of the matrix
4746  , size_t M // Number of rows
4747  , size_t N > // Number of columns
4748 template< typename Other > // Data type of the scalar value
4749 inline StaticMatrix<Type,M,N,true>&
4750  StaticMatrix<Type,M,N,true>::scale( const Other& scalar )
4751 {
4752  for( size_t j=0UL; j<N; ++j )
4753  for( size_t i=0UL; i<M; ++i )
4754  v_[i+j*MM] *= scalar;
4755 
4756  return *this;
4757 }
4759 //*************************************************************************************************
4760 
4761 
4762 //*************************************************************************************************
4770 template< typename Type // Data type of the matrix
4771  , size_t M // Number of rows
4772  , size_t N > // Number of columns
4773 inline void StaticMatrix<Type,M,N,true>::swap( StaticMatrix& m ) /* throw() */
4774 {
4775  using std::swap;
4776 
4777  for( size_t j=0UL; j<N; ++j ) {
4778  for( size_t i=0UL; i<M; ++i ) {
4779  swap( v_[i+j*MM], m(i,j) );
4780  }
4781  }
4782 }
4784 //*************************************************************************************************
4785 
4786 
4787 
4788 
4789 //=================================================================================================
4790 //
4791 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
4792 //
4793 //=================================================================================================
4794 
4795 //*************************************************************************************************
4806 template< typename Type // Data type of the matrix
4807  , size_t M // Number of rows
4808  , size_t N > // Number of columns
4809 template< typename Other > // Data type of the foreign expression
4810 inline bool StaticMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
4811 {
4812  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4813 }
4815 //*************************************************************************************************
4816 
4817 
4818 //*************************************************************************************************
4829 template< typename Type // Data type of the matrix
4830  , size_t M // Number of rows
4831  , size_t N > // Number of columns
4832 template< typename Other > // Data type of the foreign expression
4833 inline bool StaticMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
4834 {
4835  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
4836 }
4838 //*************************************************************************************************
4839 
4840 
4841 //*************************************************************************************************
4851 template< typename Type // Data type of the matrix
4852  , size_t M // Number of rows
4853  , size_t N > // Number of columns
4854 inline bool StaticMatrix<Type,M,N,true>::isAligned() const
4855 {
4856  return true;
4857 }
4859 //*************************************************************************************************
4860 
4861 
4862 //*************************************************************************************************
4877 template< typename Type // Data type of the matrix
4878  , size_t M // Number of rows
4879  , size_t N > // Number of columns
4880 inline typename StaticMatrix<Type,M,N,true>::IntrinsicType
4881  StaticMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
4882 {
4883  using blaze::load;
4884 
4886 
4887  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4888  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4889  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4890  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4891 
4892  return load( &v_[i+j*MM] );
4893 }
4895 //*************************************************************************************************
4896 
4897 
4898 //*************************************************************************************************
4913 template< typename Type // Data type of the matrix
4914  , size_t M // Number of rows
4915  , size_t N > // Number of columns
4916 inline typename StaticMatrix<Type,M,N,true>::IntrinsicType
4917  StaticMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
4918 {
4919  using blaze::loadu;
4920 
4922 
4923  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4924  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4925  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4926 
4927  return loadu( &v_[i+j*MM] );
4928 }
4930 //*************************************************************************************************
4931 
4932 
4933 //*************************************************************************************************
4949 template< typename Type // Data type of the matrix
4950  , size_t M // Number of rows
4951  , size_t N > // Number of columns
4952 inline void StaticMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
4953 {
4954  using blaze::store;
4955 
4957 
4958  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4959  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
4960  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
4961  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4962 
4963  store( &v_[i+j*MM], value );
4964 }
4966 //*************************************************************************************************
4967 
4968 
4969 //*************************************************************************************************
4985 template< typename Type // Data type of the matrix
4986  , size_t M // Number of rows
4987  , size_t N > // Number of columns
4988 inline void StaticMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
4989 {
4990  using blaze::storeu;
4991 
4993 
4994  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
4995  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
4996  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
4997 
4998  storeu( &v_[i+j*MM], value );
4999 }
5001 //*************************************************************************************************
5002 
5003 
5004 //*************************************************************************************************
5021 template< typename Type // Data type of the matrix
5022  , size_t M // Number of rows
5023  , size_t N > // Number of columns
5024 inline void StaticMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
5025 {
5026  using blaze::stream;
5027 
5029 
5030  BLAZE_INTERNAL_ASSERT( i < M , "Invalid row access index" );
5031  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM , "Invalid row access index" );
5032  BLAZE_INTERNAL_ASSERT( i % IT::size == 0UL, "Invalid row access index" );
5033  BLAZE_INTERNAL_ASSERT( j < N , "Invalid column access index" );
5034 
5035  stream( &v_[i+j*MM], value );
5036 }
5038 //*************************************************************************************************
5039 
5040 
5041 //*************************************************************************************************
5053 template< typename Type // Data type of the matrix
5054  , size_t M // Number of rows
5055  , size_t N > // Number of columns
5056 template< typename MT // Type of the right-hand side dense matrix
5057  , bool SO > // Storage order of the right-hand side dense matrix
5058 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5059  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5060 {
5061  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5062 
5063  for( size_t j=0UL; j<N; ++j ) {
5064  for( size_t i=0UL; i<M; ++i ) {
5065  v_[i+j*MM] = (~rhs)(i,j);
5066  }
5067  }
5068 }
5070 //*************************************************************************************************
5071 
5072 
5073 //*************************************************************************************************
5085 template< typename Type // Data type of the matrix
5086  , size_t M // Number of rows
5087  , size_t N > // Number of columns
5088 template< typename MT // Type of the right-hand side dense matrix
5089  , bool SO > // Storage order of the right-hand side dense matrix
5090 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
5091  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
5092 {
5093  using blaze::store;
5094 
5095  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5096 
5098 
5099  for( size_t j=0UL; j<N; ++j ) {
5100  for( size_t i=0UL; i<M; i+=IT::size ) {
5101  store( &v_[i+j*MM], (~rhs).load(i,j) );
5102  }
5103  }
5104 }
5106 //*************************************************************************************************
5107 
5108 
5109 //*************************************************************************************************
5121 template< typename Type // Data type of the matrix
5122  , size_t M // Number of rows
5123  , size_t N > // Number of columns
5124 template< typename MT > // Type of the right-hand side sparse matrix
5125 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
5126 {
5127  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5128 
5129  typedef typename MT::ConstIterator RhsConstIterator;
5130 
5131  for( size_t j=0UL; j<N; ++j )
5132  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5133  v_[element->index()+j*MM] = element->value();
5134 }
5136 //*************************************************************************************************
5137 
5138 
5139 //*************************************************************************************************
5151 template< typename Type // Data type of the matrix
5152  , size_t M // Number of rows
5153  , size_t N > // Number of columns
5154 template< typename MT > // Type of the right-hand side sparse matrix
5155 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
5156 {
5157  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5158 
5159  typedef typename MT::ConstIterator RhsConstIterator;
5160 
5161  for( size_t i=0UL; i<M; ++i )
5162  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5163  v_[i+element->index()*MM] = element->value();
5164 }
5166 //*************************************************************************************************
5167 
5168 
5169 //*************************************************************************************************
5181 template< typename Type // Data type of the matrix
5182  , size_t M // Number of rows
5183  , size_t N > // Number of columns
5184 template< typename MT // Type of the right-hand side dense matrix
5185  , bool SO > // Storage order of the right-hand side dense matrix
5186 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5187  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5188 {
5189  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5190 
5191  for( size_t j=0UL; j<N; ++j ) {
5192  for( size_t i=0UL; i<M; ++i ) {
5193  v_[i+j*MM] += (~rhs)(i,j);
5194  }
5195  }
5196 }
5198 //*************************************************************************************************
5199 
5200 
5201 //*************************************************************************************************
5213 template< typename Type // Data type of the matrix
5214  , size_t M // Number of rows
5215  , size_t N > // Number of columns
5216 template< typename MT // Type of the right-hand side dense matrix
5217  , bool SO > // Storage order of the right-hand side dense matrix
5218 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
5219  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
5220 {
5221  using blaze::load;
5222  using blaze::store;
5223 
5224  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5225 
5227 
5228  for( size_t j=0UL; j<N; ++j ) {
5229  for( size_t i=0UL; i<M; i+=IT::size ) {
5230  store( &v_[i+j*MM], load( &v_[i+j*MM] ) + (~rhs).load(i,j) );
5231  }
5232  }
5233 }
5235 //*************************************************************************************************
5236 
5237 
5238 //*************************************************************************************************
5250 template< typename Type // Data type of the matrix
5251  , size_t M // Number of rows
5252  , size_t N > // Number of columns
5253 template< typename MT > // Type of the right-hand side sparse matrix
5254 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
5255 {
5256  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5257 
5258  typedef typename MT::ConstIterator RhsConstIterator;
5259 
5260  for( size_t j=0UL; j<N; ++j )
5261  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5262  v_[element->index()+j*MM] += element->value();
5263 }
5265 //*************************************************************************************************
5266 
5267 
5268 //*************************************************************************************************
5280 template< typename Type // Data type of the matrix
5281  , size_t M // Number of rows
5282  , size_t N > // Number of columns
5283 template< typename MT > // Type of the right-hand side sparse matrix
5284 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
5285 {
5286  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5287 
5288  typedef typename MT::ConstIterator RhsConstIterator;
5289 
5290  for( size_t i=0UL; i<M; ++i )
5291  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5292  v_[i+element->index()*MM] += element->value();
5293 }
5295 //*************************************************************************************************
5296 
5297 
5298 //*************************************************************************************************
5310 template< typename Type // Data type of the matrix
5311  , size_t M // Number of rows
5312  , size_t N > // Number of columns
5313 template< typename MT // Type of the right-hand side dense matrix
5314  , bool SO > // Storage order of the right-hand side dense matrix
5315 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5316  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5317 {
5318  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5319 
5320  for( size_t j=0UL; j<N; ++j ) {
5321  for( size_t i=0UL; i<M; ++i ) {
5322  v_[i+j*MM] -= (~rhs)(i,j);
5323  }
5324  }
5325 }
5327 //*************************************************************************************************
5328 
5329 
5330 //*************************************************************************************************
5342 template< typename Type // Data type of the matrix
5343  , size_t M // Number of rows
5344  , size_t N > // Number of columns
5345 template< typename MT // Type of the right-hand side dense matrix
5346  , bool SO > // Storage order of the right-hand side dense matrix
5347 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5348  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
5349 {
5350  using blaze::load;
5351  using blaze::store;
5352 
5353  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5354 
5356 
5357  for( size_t j=0UL; j<N; ++j ) {
5358  for( size_t i=0UL; i<M; i+=IT::size ) {
5359  store( &v_[i+j*MM], load( &v_[i+j*MM] ) - (~rhs).load(i,j) );
5360  }
5361  }
5362 }
5364 //*************************************************************************************************
5365 
5366 
5367 //*************************************************************************************************
5379 template< typename Type // Data type of the matrix
5380  , size_t M // Number of rows
5381  , size_t N > // Number of columns
5382 template< typename MT > // Type of the right-hand side sparse matrix
5383 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
5384 {
5385  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5386 
5387  typedef typename MT::ConstIterator RhsConstIterator;
5388 
5389  for( size_t j=0UL; j<N; ++j )
5390  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
5391  v_[element->index()+j*MM] -= element->value();
5392 }
5394 //*************************************************************************************************
5395 
5396 
5397 //*************************************************************************************************
5409 template< typename Type // Data type of the matrix
5410  , size_t M // Number of rows
5411  , size_t N > // Number of columns
5412 template< typename MT > // Type of the right-hand side sparse matrix
5413 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
5414 {
5415  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
5416 
5417  typedef typename MT::ConstIterator RhsConstIterator;
5418 
5419  for( size_t i=0UL; i<M; ++i )
5420  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
5421  v_[i+element->index()*MM] -= element->value();
5422 }
5424 //*************************************************************************************************
5425 
5426 
5427 
5428 
5429 
5430 
5431 
5432 
5433 //=================================================================================================
5434 //
5435 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
5436 //
5437 //=================================================================================================
5438 
5439 //*************************************************************************************************
5447 template< typename Type // Data type of the matrix
5448  , size_t M // Number of rows
5449  , bool SO > // Storage order
5450 class StaticMatrix<Type,M,0UL,SO>;
5452 //*************************************************************************************************
5453 
5454 
5455 //*************************************************************************************************
5463 template< typename Type // Data type of the matrix
5464  , size_t N // Number of columns
5465  , bool SO > // Storage order
5466 class StaticMatrix<Type,0UL,N,SO>;
5468 //*************************************************************************************************
5469 
5470 
5471 //*************************************************************************************************
5479 template< typename Type // Data type of the matrix
5480  , bool SO > // Storage order
5481 class StaticMatrix<Type,0UL,0UL,SO>;
5483 //*************************************************************************************************
5484 
5485 
5486 
5487 
5488 
5489 
5490 
5491 
5492 //=================================================================================================
5493 //
5494 // STATICMATRIX OPERATORS
5495 //
5496 //=================================================================================================
5497 
5498 //*************************************************************************************************
5501 template< typename Type, size_t M, size_t N, bool SO >
5502 inline void reset( StaticMatrix<Type,M,N,SO>& m );
5503 
5504 template< typename Type, size_t M, size_t N, bool SO >
5505 inline void clear( StaticMatrix<Type,M,N,SO>& m );
5506 
5507 template< typename Type, size_t M, size_t N, bool SO >
5508 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m );
5509 
5510 template< typename Type, size_t M, size_t N, bool SO >
5511 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */;
5513 //*************************************************************************************************
5514 
5515 
5516 //*************************************************************************************************
5523 template< typename Type // Data type of the matrix
5524  , size_t M // Number of rows
5525  , size_t N // Number of columns
5526  , bool SO > // Storage order
5528 {
5529  m.reset();
5530 }
5531 //*************************************************************************************************
5532 
5533 
5534 //*************************************************************************************************
5543 template< typename Type // Data type of the matrix
5544  , size_t M // Number of rows
5545  , size_t N // Number of columns
5546  , bool SO > // Storage order
5548 {
5549  m.reset();
5550 }
5551 //*************************************************************************************************
5552 
5553 
5554 //*************************************************************************************************
5561 template< typename Type // Data type of the matrix
5562  , size_t M // Number of rows
5563  , size_t N // Number of columns
5564  , bool SO > // Storage order
5565 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m )
5566 {
5567  if( SO == rowMajor ) {
5568  for( size_t i=0UL; i<M; ++i )
5569  for( size_t j=0UL; j<N; ++j )
5570  if( !isDefault( m(i,j) ) ) return false;
5571  }
5572  else {
5573  for( size_t j=0UL; j<N; ++j )
5574  for( size_t i=0UL; i<M; ++i )
5575  if( !isDefault( m(i,j) ) ) return false;
5576  }
5577 
5578  return true;
5579 }
5580 //*************************************************************************************************
5581 
5582 
5583 //*************************************************************************************************
5592 template< typename Type // Data type of the matrix
5593  , size_t M // Number of rows
5594  , size_t N // Number of columns
5595  , bool SO > // Storage order
5596 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */
5597 {
5598  a.swap( b );
5599 }
5600 //*************************************************************************************************
5601 
5602 
5603 
5604 
5605 //=================================================================================================
5606 //
5607 // ADDTRAIT SPECIALIZATIONS
5608 //
5609 //=================================================================================================
5610 
5611 //*************************************************************************************************
5613 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5614 struct AddTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5615 {
5616  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
5617 };
5618 
5619 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5620 struct AddTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
5621 {
5622  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
5623 };
5625 //*************************************************************************************************
5626 
5627 
5628 
5629 
5630 //=================================================================================================
5631 //
5632 // SUBTRAIT SPECIALIZATIONS
5633 //
5634 //=================================================================================================
5635 
5636 //*************************************************************************************************
5638 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5639 struct SubTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5640 {
5641  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
5642 };
5643 
5644 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
5645 struct SubTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
5646 {
5647  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
5648 };
5650 //*************************************************************************************************
5651 
5652 
5653 
5654 
5655 //=================================================================================================
5656 //
5657 // MULTTRAIT SPECIALIZATIONS
5658 //
5659 //=================================================================================================
5660 
5661 //*************************************************************************************************
5663 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5664 struct MultTrait< StaticMatrix<T1,M,N,SO>, T2 >
5665 {
5666  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5668 };
5669 
5670 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5671 struct MultTrait< T1, StaticMatrix<T2,M,N,SO> >
5672 {
5673  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5675 };
5676 
5677 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5678 struct MultTrait< StaticMatrix<T1,M,N,SO>, StaticVector<T2,N,false> >
5679 {
5680  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5681 };
5682 
5683 template< typename T1, size_t M, typename T2, size_t N, bool SO >
5684 struct MultTrait< StaticVector<T1,M,true>, StaticMatrix<T2,M,N,SO> >
5685 {
5686  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5687 };
5688 
5689 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t L >
5690 struct MultTrait< StaticMatrix<T1,M,N,SO>, HybridVector<T2,L,false> >
5691 {
5692  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5693 };
5694 
5695 template< typename T1, size_t L, typename T2, size_t M, size_t N, bool SO >
5696 struct MultTrait< HybridVector<T1,L,true>, StaticMatrix<T2,M,N,SO> >
5697 {
5698  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5699 };
5700 
5701 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5702 struct MultTrait< StaticMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5703 {
5704  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5705 };
5706 
5707 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5708 struct MultTrait< DynamicVector<T1,true>, StaticMatrix<T2,M,N,SO> >
5709 {
5710  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5711 };
5712 
5713 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5714 struct MultTrait< StaticMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5715 {
5716  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
5717 };
5718 
5719 template< typename T1, typename T2, size_t M, size_t N, bool SO >
5720 struct MultTrait< CompressedVector<T1,true>, StaticMatrix<T2,M,N,SO> >
5721 {
5722  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
5723 };
5724 
5725 template< typename T1, size_t M, size_t K, bool SO1, typename T2, size_t N, bool SO2 >
5726 struct MultTrait< StaticMatrix<T1,M,K,SO1>, StaticMatrix<T2,K,N,SO2> >
5727 {
5728  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO1 > Type;
5729 };
5731 //*************************************************************************************************
5732 
5733 
5734 
5735 
5736 //=================================================================================================
5737 //
5738 // DIVTRAIT SPECIALIZATIONS
5739 //
5740 //=================================================================================================
5741 
5742 //*************************************************************************************************
5744 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5745 struct DivTrait< StaticMatrix<T1,M,N,SO>, T2 >
5746 {
5747  typedef StaticMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5749 };
5751 //*************************************************************************************************
5752 
5753 
5754 
5755 
5756 //=================================================================================================
5757 //
5758 // MATHTRAIT SPECIALIZATIONS
5759 //
5760 //=================================================================================================
5761 
5762 //*************************************************************************************************
5764 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
5765 struct MathTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
5766 {
5767  typedef StaticMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5768  typedef StaticMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5769 };
5771 //*************************************************************************************************
5772 
5773 
5774 
5775 
5776 //=================================================================================================
5777 //
5778 // SUBMATRIXTRAIT SPECIALIZATIONS
5779 //
5780 //=================================================================================================
5781 
5782 //*************************************************************************************************
5784 template< typename T1, size_t M, size_t N, bool SO >
5785 struct SubmatrixTrait< StaticMatrix<T1,M,N,SO> >
5786 {
5787  typedef DynamicMatrix<T1,SO> Type;
5788 };
5790 //*************************************************************************************************
5791 
5792 
5793 
5794 
5795 //=================================================================================================
5796 //
5797 // ROWTRAIT SPECIALIZATIONS
5798 //
5799 //=================================================================================================
5800 
5801 //*************************************************************************************************
5803 template< typename T1, size_t M, size_t N, bool SO >
5804 struct RowTrait< StaticMatrix<T1,M,N,SO> >
5805 {
5806  typedef StaticVector<T1,N,true> Type;
5807 };
5809 //*************************************************************************************************
5810 
5811 
5812 
5813 
5814 //=================================================================================================
5815 //
5816 // COLUMNTRAIT SPECIALIZATIONS
5817 //
5818 //=================================================================================================
5819 
5820 //*************************************************************************************************
5822 template< typename T1, size_t M, size_t N, bool SO >
5823 struct ColumnTrait< StaticMatrix<T1,M,N,SO> >
5824 {
5825  typedef StaticVector<T1,M,false> Type;
5826 };
5828 //*************************************************************************************************
5829 
5830 } // namespace blaze
5831 
5832 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
This ResultType
Result type for expression template evaluations.
Definition: StaticMatrix.h:216
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:4579
#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:2012
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:2194
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:4622
const Type & ConstReference
Reference to a constant matrix value.
Definition: StaticMatrix.h:224
StaticMatrix()
The default constructor for StaticMatrix.
Definition: StaticMatrix.h:475
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:2370
Header file for the IsColumnMajorMatrix type trait.
StaticMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: StaticMatrix.h:218
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:219
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: StaticMatrix.h:431
#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
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1550
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4595
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.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: StaticMatrix.h:2236
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:1598
Header file for the DisableIf class template.
StaticMatrix & transpose()
Transposing the matrix.
Definition: StaticMatrix.h:2112
void swap(StaticMatrix &m)
Swapping the contents of two static matrices.
Definition: StaticMatrix.h:2158
Header file for the multiplication trait.
Header file for nested template disabiguation.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4558
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: StaticMatrix.h:225
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2388
#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:2066
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:1938
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2299
const This & CompositeType
Data type for composite expression templates.
Definition: StaticMatrix.h:222
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:1973
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2386
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:2216
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1526
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1478
Header file for the equal shim.
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: StaticMatrix.h:1352
Header file for the IsVectorizable type trait.
StaticMatrix< Type, M, N, SO > This
Type of this StaticMatrix instance.
Definition: StaticMatrix.h:215
Header file for the IsNumeric type trait.
Type * data()
Low-level data access to the matrix elements.
Definition: StaticMatrix.h:1395
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: StaticMatrix.h:205
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: StaticMatrix.h:220
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
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:4651
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:2387
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:2334
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:1957
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:1922
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticMatrix.h:221
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: StaticMatrix.h:226
Type & Reference
Reference to a non-constant matrix value.
Definition: StaticMatrix.h:223
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:2385
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:2405
#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:217
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:2263
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