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>
50 #include <blaze/math/Forward.h>
51 #include <blaze/math/Intrinsics.h>
52 #include <blaze/math/shims/Clear.h>
80 #include <blaze/system/Inline.h>
85 #include <blaze/util/Assert.h>
92 #include <blaze/util/DisableIf.h>
93 #include <blaze/util/EnableIf.h>
94 #include <blaze/util/Exception.h>
95 #include <blaze/util/FalseType.h>
96 #include <blaze/util/Memory.h>
98 #include <blaze/util/mpl/SizeT.h>
100 #include <blaze/util/Template.h>
101 #include <blaze/util/TrueType.h>
102 #include <blaze/util/Types.h>
106 #include <blaze/util/Unused.h>
108 
109 
110 namespace blaze {
111 
112 //=================================================================================================
113 //
114 // CLASS DEFINITION
115 //
116 //=================================================================================================
117 
118 //*************************************************************************************************
200 template< typename Type // Data type of the matrix
201  , size_t M // Number of rows
202  , size_t N // Number of columns
203  , bool SO = defaultStorageOrder > // Storage order
204 class StaticMatrix : public DenseMatrix< StaticMatrix<Type,M,N,SO>, SO >
205 {
206  private:
207  //**Type definitions****************************************************************************
209  //**********************************************************************************************
210 
211  //**********************************************************************************************
213  static const size_t NN = ( usePadding )?( NextMultiple< SizeT<N>, SizeT<IT::size> >::value ):( N );
214  //**********************************************************************************************
215 
216  public:
217  //**Type definitions****************************************************************************
219  typedef This ResultType;
222  typedef Type ElementType;
223  typedef typename IT::Type IntrinsicType;
224  typedef const Type& ReturnType;
225  typedef const This& CompositeType;
226 
227  typedef Type& Reference;
228  typedef const Type& ConstReference;
229  typedef Type* Pointer;
230  typedef const Type* ConstPointer;
231 
234  //**********************************************************************************************
235 
236  //**Rebind struct definition********************************************************************
239  template< typename ET > // Data type of the other matrix
240  struct Rebind {
242  };
243  //**********************************************************************************************
244 
245  //**Compilation flags***************************************************************************
247 
251  enum { vectorizable = IsVectorizable<Type>::value };
252 
254 
257  enum { smpAssignable = 0 };
258  //**********************************************************************************************
259 
260  //**Constructors********************************************************************************
263  explicit inline StaticMatrix();
264  explicit inline StaticMatrix( const Type& init );
265 
266  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
267  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
268 
269  inline StaticMatrix( const StaticMatrix& m );
270  template< typename Other, bool SO2 > inline StaticMatrix( const StaticMatrix<Other,M,N,SO2>& m );
271  template< typename MT , bool SO2 > inline StaticMatrix( const Matrix<MT,SO2>& m );
272 
273  inline StaticMatrix( const Type& v1, const Type& v2 );
274  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
275  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
276  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
277  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
278  const Type& v6 );
279  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
280  const Type& v6, const Type& v7 );
281  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
282  const Type& v6, const Type& v7, const Type& v8 );
283  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
284  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
285  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
286  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
288  //**********************************************************************************************
289 
290  //**Destructor**********************************************************************************
291  // No explicitly declared destructor.
292  //**********************************************************************************************
293 
294  //**Data access functions***********************************************************************
297  inline Reference operator()( size_t i, size_t j );
298  inline ConstReference operator()( size_t i, size_t j ) const;
299  inline Reference at( size_t i, size_t j );
300  inline ConstReference at( size_t i, size_t j ) const;
301  inline Pointer data ();
302  inline ConstPointer data () const;
303  inline Pointer data ( size_t i );
304  inline ConstPointer data ( size_t i ) const;
305  inline Iterator begin ( size_t i );
306  inline ConstIterator begin ( size_t i ) const;
307  inline ConstIterator cbegin( size_t i ) const;
308  inline Iterator end ( size_t i );
309  inline ConstIterator end ( size_t i ) const;
310  inline ConstIterator cend ( size_t i ) const;
312  //**********************************************************************************************
313 
314  //**Assignment operators************************************************************************
317  template< typename Other >
318  inline StaticMatrix& operator=( const Other (&array)[M][N] );
319 
320  inline StaticMatrix& operator= ( const Type& set );
321  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
322  template< typename Other, bool SO2 > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO2>& rhs );
323  template< typename MT , bool SO2 > inline StaticMatrix& operator= ( const Matrix<MT,SO2>& rhs );
324  template< typename MT , bool SO2 > inline StaticMatrix& operator+=( const Matrix<MT,SO2>& rhs );
325  template< typename MT , bool SO2 > inline StaticMatrix& operator-=( const Matrix<MT,SO2>& rhs );
326  template< typename MT , bool SO2 > inline StaticMatrix& operator*=( const Matrix<MT,SO2>& rhs );
327 
328  template< typename Other >
329  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
330  operator*=( Other rhs );
331 
332  template< typename Other >
333  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
334  operator/=( Other rhs );
336  //**********************************************************************************************
337 
338  //**Utility functions***************************************************************************
341  inline size_t rows() const;
342  inline size_t columns() const;
343  inline size_t spacing() const;
344  inline size_t capacity() const;
345  inline size_t capacity( size_t i ) const;
346  inline size_t nonZeros() const;
347  inline size_t nonZeros( size_t i ) const;
348  inline void reset();
349  inline void reset( size_t i );
350  inline StaticMatrix& transpose();
351  inline StaticMatrix& ctranspose();
352  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
353  inline void swap( StaticMatrix& m ) /* throw() */;
355  //**********************************************************************************************
356 
357  //**Memory functions****************************************************************************
360  static inline void* operator new ( std::size_t size );
361  static inline void* operator new[]( std::size_t size );
362  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
363  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
364 
365  static inline void operator delete ( void* ptr );
366  static inline void operator delete[]( void* ptr );
367  static inline void operator delete ( void* ptr, const std::nothrow_t& );
368  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
370  //**********************************************************************************************
371 
372  private:
373  //**********************************************************************************************
375  template< typename MT >
377  struct VectorizedAssign {
378  enum { value = useOptimizedKernels &&
379  vectorizable && MT::vectorizable &&
380  IsSame<Type,typename MT::ElementType>::value &&
381  IsRowMajorMatrix<MT>::value };
382  };
384  //**********************************************************************************************
385 
386  //**********************************************************************************************
388  template< typename MT >
390  struct VectorizedAddAssign {
391  enum { value = useOptimizedKernels &&
392  vectorizable && MT::vectorizable &&
393  IsSame<Type,typename MT::ElementType>::value &&
394  IntrinsicTrait<Type>::addition &&
395  IsRowMajorMatrix<MT>::value &&
396  !IsDiagonal<MT>::value };
397  };
399  //**********************************************************************************************
400 
401  //**********************************************************************************************
403  template< typename MT >
405  struct VectorizedSubAssign {
406  enum { value = useOptimizedKernels &&
407  vectorizable && MT::vectorizable &&
408  IsSame<Type,typename MT::ElementType>::value &&
409  IntrinsicTrait<Type>::subtraction &&
410  IsRowMajorMatrix<MT>::value &&
411  !IsDiagonal<MT>::value };
412  };
414  //**********************************************************************************************
415 
416  public:
417  //**Expression template evaluation functions****************************************************
420  template< typename Other > inline bool canAlias ( const Other* alias ) const;
421  template< typename Other > inline bool isAliased( const Other* alias ) const;
422 
423  inline bool isAligned() const;
424 
425  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
426  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
427  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
428 
429  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
430  BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const IntrinsicType& value );
431  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
432  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
433 
434  template< typename MT, bool SO2 >
435  inline typename DisableIf< VectorizedAssign<MT> >::Type
436  assign( const DenseMatrix<MT,SO2>& rhs );
437 
438  template< typename MT, bool SO2 >
439  inline typename EnableIf< VectorizedAssign<MT> >::Type
440  assign( const DenseMatrix<MT,SO2>& rhs );
441 
442  template< typename MT > inline void assign( const SparseMatrix<MT,SO>& rhs );
443  template< typename MT > inline void assign( const SparseMatrix<MT,!SO>& rhs );
444 
445  template< typename MT, bool SO2 >
446  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
447  addAssign( const DenseMatrix<MT,SO2>& rhs );
448 
449  template< typename MT, bool SO2 >
450  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
451  addAssign( const DenseMatrix<MT,SO2>& rhs );
452 
453  template< typename MT > inline void addAssign( const SparseMatrix<MT,SO>& rhs );
454  template< typename MT > inline void addAssign( const SparseMatrix<MT,!SO>& rhs );
455 
456  template< typename MT, bool SO2 >
457  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
458  subAssign( const DenseMatrix<MT,SO2>& rhs );
459 
460  template< typename MT, bool SO2 >
461  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
462  subAssign( const DenseMatrix<MT,SO2>& rhs );
463 
464  template< typename MT > inline void subAssign( const SparseMatrix<MT,SO>& rhs );
465  template< typename MT > inline void subAssign( const SparseMatrix<MT,!SO>& rhs );
467  //**********************************************************************************************
468 
469  private:
470  //**Utility functions***************************************************************************
472  inline void transpose ( TrueType );
473  inline void transpose ( FalseType );
474  inline void ctranspose( TrueType );
475  inline void ctranspose( FalseType );
477  //**********************************************************************************************
478 
479  //**Member variables****************************************************************************
483 
493  //**********************************************************************************************
494 
495  //**Compile time checks*************************************************************************
501  BLAZE_STATIC_ASSERT( !usePadding || NN % IT::size == 0UL );
502  BLAZE_STATIC_ASSERT( NN >= N );
504  //**********************************************************************************************
505 };
506 //*************************************************************************************************
507 
508 
509 
510 
511 //=================================================================================================
512 //
513 // CONSTRUCTORS
514 //
515 //=================================================================================================
516 
517 //*************************************************************************************************
522 template< typename Type // Data type of the matrix
523  , size_t M // Number of rows
524  , size_t N // Number of columns
525  , bool SO > // Storage order
527  : v_() // The statically allocated matrix elements
528 {
530 
531  if( IsNumeric<Type>::value ) {
532  for( size_t i=0UL; i<M*NN; ++i )
533  v_[i] = Type();
534  }
535 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
544 template< typename Type // Data type of the matrix
545  , size_t M // Number of rows
546  , size_t N // Number of columns
547  , bool SO > // Storage order
548 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& init )
549  : v_() // The statically allocated matrix elements
550 {
552 
553  for( size_t i=0UL; i<M; ++i ) {
554  for( size_t j=0UL; j<N; ++j )
555  v_[i*NN+j] = init;
556 
557  for( size_t j=N; j<NN; ++j )
558  v_[i*NN+j] = Type();
559  }
560 }
561 //*************************************************************************************************
562 
563 
564 //*************************************************************************************************
590 template< typename Type // Data type of the matrix
591  , size_t M // Number of rows
592  , size_t N // Number of columns
593  , bool SO > // Storage order
594 template< typename Other > // Data type of the initialization array
595 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( size_t m, size_t n, const Other* array )
596  : v_() // The statically allocated matrix elements
597 {
599 
600  if( m > M || n > N ) {
601  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static matrix" );
602  }
603 
604  for( size_t i=0UL; i<m; ++i ) {
605  for( size_t j=0UL; j<n; ++j )
606  v_[i*NN+j] = array[i*n+j];
607 
608  if( IsNumeric<Type>::value ) {
609  for( size_t j=n; j<NN; ++j )
610  v_[i*NN+j] = Type();
611  }
612  }
613 
614  if( IsNumeric<Type>::value ) {
615  for( size_t i=m; i<M; ++i ) {
616  for( size_t j=0UL; j<NN; ++j )
617  v_[i*NN+j] = Type();
618  }
619  }
620 }
621 //*************************************************************************************************
622 
623 
624 //*************************************************************************************************
644 template< typename Type // Data type of the matrix
645  , size_t M // Number of rows
646  , size_t N // Number of columns
647  , bool SO > // Storage order
648 template< typename Other > // Data type of the initialization array
649 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Other (&array)[M][N] )
650  : v_() // The statically allocated matrix elements
651 {
653 
654  for( size_t i=0UL; i<M; ++i ) {
655  for( size_t j=0UL; j<N; ++j )
656  v_[i*NN+j] = array[i][j];
657 
658  for( size_t j=N; j<NN; ++j )
659  v_[i*NN+j] = Type();
660  }
661 }
662 //*************************************************************************************************
663 
664 
665 //*************************************************************************************************
672 template< typename Type // Data type of the matrix
673  , size_t M // Number of rows
674  , size_t N // Number of columns
675  , bool SO > // Storage order
677  : v_() // The statically allocated matrix elements
678 {
680 
681  for( size_t i=0UL; i<M*NN; ++i )
682  v_[i] = m.v_[i];
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
692 template< typename Type // Data type of the matrix
693  , size_t M // Number of rows
694  , size_t N // Number of columns
695  , bool SO > // Storage order
696 template< typename Other // Data type of the foreign matrix
697  , bool SO2 > // Storage order of the foreign matrix
699  : v_() // The statically allocated matrix elements
700 {
702 
703  for( size_t i=0UL; i<M; ++i ) {
704  for( size_t j=0UL; j<N; ++j )
705  v_[i*NN+j] = m(i,j);
706 
707  for( size_t j=N; j<NN; ++j )
708  v_[i*NN+j] = Type();
709  }
710 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
724 template< typename Type // Data type of the matrix
725  , size_t M // Number of rows
726  , size_t N // Number of columns
727  , bool SO > // Storage order
728 template< typename MT // Type of the foreign matrix
729  , bool SO2 > // Storage order of the foreign matrix
731  : v_() // The statically allocated matrix elements
732 {
733  using blaze::assign;
734 
736 
737  if( (~m).rows() != M || (~m).columns() != N ) {
738  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static matrix" );
739  }
740 
741  for( size_t i=0UL; i<M; ++i ) {
742  for( size_t j=( IsSparseMatrix<MT>::value ? 0UL : N ); j<NN; ++j ) {
743  v_[i*NN+j] = Type();
744  }
745  }
746 
747  assign( *this, ~m );
748 }
749 //*************************************************************************************************
750 
751 
752 //*************************************************************************************************
769 template< typename Type // Data type of the matrix
770  , size_t M // Number of rows
771  , size_t N // Number of columns
772  , bool SO > // Storage order
773 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2 )
774  : v_() // The statically allocated matrix elements
775 {
776  BLAZE_STATIC_ASSERT( M*N == 2UL );
778 
779  // Initialization of a 1x2 matrix
780  if( M == 1UL ) {
781  v_[0UL] = v1;
782  v_[1UL] = v2;
783  }
784 
785  // Initialization of a 2x1 matrix
786  else {
787  v_[0UL] = v1;
788  v_[ NN] = v2;
789  }
790 
791  for( size_t i=0UL; i<M; ++i ) {
792  for( size_t j=N; j<NN; ++j )
793  v_[i*NN+j] = Type();
794  }
795 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
817 template< typename Type // Data type of the matrix
818  , size_t M // Number of rows
819  , size_t N // Number of columns
820  , bool SO > // Storage order
821 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
822  : v_() // The statically allocated matrix elements
823 {
824  BLAZE_STATIC_ASSERT( M*N == 3UL );
826 
827  // Initialization of a 1x3 matrix
828  if( M == 1UL ) {
829  v_[0UL] = v1;
830  v_[1UL] = v2;
831  v_[2UL] = v3;
832  }
833 
834  // Initialization of a 3x1 matrix
835  else {
836  v_[ 0UL] = v1;
837  v_[ NN] = v2;
838  v_[2UL*NN] = v3;
839  }
840 
841  for( size_t i=0UL; i<M; ++i ) {
842  for( size_t j=N; j<NN; ++j )
843  v_[i*NN+j] = Type();
844  }
845 }
846 //*************************************************************************************************
847 
848 
849 //*************************************************************************************************
870 template< typename Type // Data type of the matrix
871  , size_t M // Number of rows
872  , size_t N // Number of columns
873  , bool SO > // Storage order
874 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2,
875  const Type& v3, const Type& v4 )
876  : v_() // The statically allocated matrix elements
877 {
878  BLAZE_STATIC_ASSERT( M*N == 4UL );
880 
881  // Initialization of a 1x4 matrix
882  if( M == 1UL ) {
883  v_[0UL] = v1;
884  v_[1UL] = v2;
885  v_[2UL] = v3;
886  v_[3UL] = v4;
887  }
888 
889  // Initialization of a 2x2 matrix
890  else if( M == 2UL ) {
891  v_[ 0UL] = v1;
892  v_[ 1UL] = v2;
893  v_[NN ] = v3;
894  v_[NN+1UL] = v4;
895  }
896 
897  // Initialization of a 4x1 matrix
898  else {
899  v_[ 0UL] = v1;
900  v_[ NN] = v2;
901  v_[2UL*NN] = v3;
902  v_[3UL*NN] = v4;
903  }
904 
905  for( size_t i=0UL; i<M; ++i ) {
906  for( size_t j=N; j<NN; ++j )
907  v_[i*NN+j] = Type();
908  }
909 }
910 //*************************************************************************************************
911 
912 
913 //*************************************************************************************************
933 template< typename Type // Data type of the matrix
934  , size_t M // Number of rows
935  , size_t N // Number of columns
936  , bool SO > // Storage order
937 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
938  const Type& v4, const Type& v5 )
939  : v_() // The statically allocated matrix elements
940 {
941  BLAZE_STATIC_ASSERT( M*N == 5UL );
943 
944  // Initialization of a 1x5 matrix
945  if( M == 1UL ) {
946  v_[0UL] = v1;
947  v_[1UL] = v2;
948  v_[2UL] = v3;
949  v_[3UL] = v4;
950  v_[4UL] = v5;
951  }
952 
953  // Initialization of a 5x1 matrix
954  else {
955  v_[ 0UL] = v1;
956  v_[ NN] = v2;
957  v_[2UL*NN] = v3;
958  v_[3UL*NN] = v4;
959  v_[4UL*NN] = v5;
960  }
961 
962  for( size_t i=0UL; i<M; ++i ) {
963  for( size_t j=N; j<NN; ++j )
964  v_[i*NN+j] = Type();
965  }
966 }
967 //*************************************************************************************************
968 
969 
970 //*************************************************************************************************
994 template< typename Type // Data type of the matrix
995  , size_t M // Number of rows
996  , size_t N // Number of columns
997  , bool SO > // Storage order
998 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
999  const Type& v4, const Type& v5, const Type& v6 )
1000  : v_() // The statically allocated matrix elements
1001 {
1002  BLAZE_STATIC_ASSERT( M*N == 6UL );
1004 
1005  // Initialization of a 1x6 matrix
1006  if( M == 1UL ) {
1007  v_[0UL] = v1;
1008  v_[1UL] = v2;
1009  v_[2UL] = v3;
1010  v_[3UL] = v4;
1011  v_[4UL] = v5;
1012  v_[5UL] = v6;
1013  }
1014 
1015  // Initialization of a 2x3 matrix
1016  else if( M == 2UL ) {
1017  v_[ 0UL] = v1;
1018  v_[ 1UL] = v2;
1019  v_[ 2UL] = v3;
1020  v_[NN ] = v4;
1021  v_[NN+1UL] = v5;
1022  v_[NN+2UL] = v6;
1023  }
1024 
1025  // Initialization of a 3x2 matrix
1026  else if( M == 3UL ) {
1027  v_[ 0UL] = v1;
1028  v_[ 1UL] = v2;
1029  v_[ NN ] = v3;
1030  v_[ NN+1UL] = v4;
1031  v_[2UL*NN ] = v5;
1032  v_[2UL*NN+1UL] = v6;
1033  }
1034 
1035  // Initialization of a 6x1 matrix
1036  else {
1037  v_[ 0UL] = v1;
1038  v_[ NN] = v2;
1039  v_[2UL*NN] = v3;
1040  v_[3UL*NN] = v4;
1041  v_[4UL*NN] = v5;
1042  v_[5UL*NN] = v6;
1043  }
1044 
1045  for( size_t i=0UL; i<M; ++i ) {
1046  for( size_t j=N; j<NN; ++j )
1047  v_[i*NN+j] = Type();
1048  }
1049 }
1050 //*************************************************************************************************
1051 
1052 
1053 //*************************************************************************************************
1075 template< typename Type // Data type of the matrix
1076  , size_t M // Number of rows
1077  , size_t N // Number of columns
1078  , bool SO > // Storage order
1079 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1080  const Type& v4, const Type& v5, const Type& v6,
1081  const Type& v7 )
1082  : v_() // The statically allocated matrix elements
1083 {
1084  BLAZE_STATIC_ASSERT( M*N == 7UL );
1086 
1087  // Initialization of a 1x7 matrix
1088  if( M == 1UL ) {
1089  v_[0UL] = v1;
1090  v_[1UL] = v2;
1091  v_[2UL] = v3;
1092  v_[3UL] = v4;
1093  v_[4UL] = v5;
1094  v_[5UL] = v6;
1095  v_[6UL] = v7;
1096  }
1097 
1098  // Initialization of a 7x1 matrix
1099  else {
1100  v_[ 0UL] = v1;
1101  v_[ NN] = v2;
1102  v_[2UL*NN] = v3;
1103  v_[3UL*NN] = v4;
1104  v_[4UL*NN] = v5;
1105  v_[5UL*NN] = v6;
1106  v_[6UL*NN] = v7;
1107  }
1108 
1109  for( size_t i=0UL; i<M; ++i ) {
1110  for( size_t j=N; j<NN; ++j )
1111  v_[i*NN+j] = Type();
1112  }
1113 }
1114 //*************************************************************************************************
1115 
1116 
1117 //*************************************************************************************************
1142 template< typename Type // Data type of the matrix
1143  , size_t M // Number of rows
1144  , size_t N // Number of columns
1145  , bool SO > // Storage order
1146 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1147  const Type& v4, const Type& v5, const Type& v6,
1148  const Type& v7, const Type& v8 )
1149  : v_() // The statically allocated matrix elements
1150 {
1151  BLAZE_STATIC_ASSERT( M*N == 8UL );
1153 
1154  // Initialization of a 1x8 matrix
1155  if( M == 1UL ) {
1156  v_[0UL] = v1;
1157  v_[1UL] = v2;
1158  v_[2UL] = v3;
1159  v_[3UL] = v4;
1160  v_[4UL] = v5;
1161  v_[5UL] = v6;
1162  v_[6UL] = v7;
1163  v_[7UL] = v8;
1164  }
1165 
1166  // Initialization of a 2x4 matrix
1167  else if( M == 2UL ) {
1168  v_[ 0UL] = v1;
1169  v_[ 1UL] = v2;
1170  v_[ 2UL] = v3;
1171  v_[ 3UL] = v4;
1172  v_[NN ] = v5;
1173  v_[NN+1UL] = v6;
1174  v_[NN+2UL] = v7;
1175  v_[NN+3UL] = v8;
1176  }
1177 
1178  // Initialization of a 4x2 matrix
1179  else if( M == 4UL ) {
1180  v_[ 0UL] = v1;
1181  v_[ 1UL] = v2;
1182  v_[ NN ] = v3;
1183  v_[ NN+1UL] = v4;
1184  v_[2UL*NN ] = v5;
1185  v_[2UL*NN+1UL] = v6;
1186  v_[3UL*NN ] = v7;
1187  v_[3UL*NN+1UL] = v8;
1188  }
1189 
1190  // Initialization of a 8x1 matrix
1191  else {
1192  v_[ 0UL] = v1;
1193  v_[ NN] = v2;
1194  v_[2UL*NN] = v3;
1195  v_[3UL*NN] = v4;
1196  v_[4UL*NN] = v5;
1197  v_[5UL*NN] = v6;
1198  v_[6UL*NN] = v7;
1199  v_[7UL*NN] = v8;
1200  }
1201 
1202  for( size_t i=0UL; i<M; ++i ) {
1203  for( size_t j=N; j<NN; ++j )
1204  v_[i*NN+j] = Type();
1205  }
1206 }
1207 //*************************************************************************************************
1208 
1209 
1210 //*************************************************************************************************
1237 template< typename Type // Data type of the matrix
1238  , size_t M // Number of rows
1239  , size_t N // Number of columns
1240  , bool SO > // Storage order
1241 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1242  const Type& v4, const Type& v5, const Type& v6,
1243  const Type& v7, const Type& v8, const Type& v9 )
1244  : v_() // The statically allocated matrix elements
1245 {
1246  BLAZE_STATIC_ASSERT( M*N == 9UL );
1248 
1249  // Initialization of a 1x9 matrix
1250  if( M == 1UL ) {
1251  v_[0UL] = v1;
1252  v_[1UL] = v2;
1253  v_[2UL] = v3;
1254  v_[3UL] = v4;
1255  v_[4UL] = v5;
1256  v_[5UL] = v6;
1257  v_[6UL] = v7;
1258  v_[7UL] = v8;
1259  v_[8UL] = v9;
1260  }
1261 
1262  // Initialization of a 3x3 matrix
1263  else if( M == 3UL ) {
1264  v_[ 0UL] = v1;
1265  v_[ 1UL] = v2;
1266  v_[ 2UL] = v3;
1267  v_[ NN ] = v4;
1268  v_[ NN+1UL] = v5;
1269  v_[ NN+2UL] = v6;
1270  v_[2UL*NN ] = v7;
1271  v_[2UL*NN+1UL] = v8;
1272  v_[2UL*NN+2UL] = v9;
1273  }
1274 
1275  // Initialization of a 9x1 matrix
1276  else {
1277  v_[ 0UL] = v1;
1278  v_[ NN] = v2;
1279  v_[2UL*NN] = v3;
1280  v_[3UL*NN] = v4;
1281  v_[4UL*NN] = v5;
1282  v_[5UL*NN] = v6;
1283  v_[6UL*NN] = v7;
1284  v_[7UL*NN] = v8;
1285  v_[8UL*NN] = v9;
1286  }
1287 
1288  for( size_t i=0UL; i<M; ++i ) {
1289  for( size_t j=N; j<NN; ++j )
1290  v_[i*NN+j] = Type();
1291  }
1292 }
1293 //*************************************************************************************************
1294 
1295 
1296 //*************************************************************************************************
1324 template< typename Type // Data type of the matrix
1325  , size_t M // Number of rows
1326  , size_t N // Number of columns
1327  , bool SO > // Storage order
1328 inline StaticMatrix<Type,M,N,SO>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
1329  const Type& v4, const Type& v5, const Type& v6,
1330  const Type& v7, const Type& v8, const Type& v9,
1331  const Type& v10 )
1332  : v_() // The statically allocated matrix elements
1333 {
1334  BLAZE_STATIC_ASSERT( M*N == 10UL );
1336 
1337  // Initialization of a 1x10 matrix
1338  if( M == 1UL ) {
1339  v_[0UL] = v1;
1340  v_[1UL] = v2;
1341  v_[2UL] = v3;
1342  v_[3UL] = v4;
1343  v_[4UL] = v5;
1344  v_[5UL] = v6;
1345  v_[6UL] = v7;
1346  v_[7UL] = v8;
1347  v_[8UL] = v9;
1348  v_[9UL] = v10;
1349  }
1350 
1351  // Initialization of a 2x5 matrix
1352  else if( M == 2UL ) {
1353  v_[ 0UL] = v1;
1354  v_[ 1UL] = v2;
1355  v_[ 2UL] = v3;
1356  v_[ 3UL] = v4;
1357  v_[ 4UL] = v5;
1358  v_[NN ] = v6;
1359  v_[NN+1UL] = v7;
1360  v_[NN+2UL] = v8;
1361  v_[NN+3UL] = v9;
1362  v_[NN+4UL] = v10;
1363  }
1364 
1365  // Initialization of a 5x2 matrix
1366  else if( M == 5UL ) {
1367  v_[ 0UL] = v1;
1368  v_[ 1UL] = v2;
1369  v_[ NN ] = v3;
1370  v_[ NN+1UL] = v4;
1371  v_[2UL*NN ] = v5;
1372  v_[2UL*NN+1UL] = v6;
1373  v_[3UL*NN ] = v7;
1374  v_[3UL*NN+1UL] = v8;
1375  v_[4UL*NN ] = v9;
1376  v_[4UL*NN+1UL] = v10;
1377  }
1378 
1379  // Initialization of a 10x1 matrix
1380  else {
1381  v_[ 0UL] = v1;
1382  v_[ NN] = v2;
1383  v_[2UL*NN] = v3;
1384  v_[3UL*NN] = v4;
1385  v_[4UL*NN] = v5;
1386  v_[5UL*NN] = v6;
1387  v_[6UL*NN] = v7;
1388  v_[7UL*NN] = v8;
1389  v_[8UL*NN] = v9;
1390  v_[9UL*NN] = v10;
1391  }
1392 
1393  for( size_t i=0UL; i<M; ++i ) {
1394  for( size_t j=N; j<NN; ++j )
1395  v_[i*NN+j] = Type();
1396  }
1397 }
1398 //*************************************************************************************************
1399 
1400 
1401 
1402 
1403 //=================================================================================================
1404 //
1405 // DATA ACCESS FUNCTIONS
1406 //
1407 //=================================================================================================
1408 
1409 //*************************************************************************************************
1419 template< typename Type // Data type of the matrix
1420  , size_t M // Number of rows
1421  , size_t N // Number of columns
1422  , bool SO > // Storage order
1425 {
1426  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1427  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1428  return v_[i*NN+j];
1429 }
1430 //*************************************************************************************************
1431 
1432 
1433 //*************************************************************************************************
1443 template< typename Type // Data type of the matrix
1444  , size_t M // Number of rows
1445  , size_t N // Number of columns
1446  , bool SO > // Storage order
1448  StaticMatrix<Type,M,N,SO>::operator()( size_t i, size_t j ) const
1449 {
1450  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
1451  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
1452  return v_[i*NN+j];
1453 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1468 template< typename Type // Data type of the matrix
1469  , size_t M // Number of rows
1470  , size_t N // Number of columns
1471  , bool SO > // Storage order
1473  StaticMatrix<Type,M,N,SO>::at( size_t i, size_t j )
1474 {
1475  if( i >= M ) {
1476  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1477  }
1478  if( j >= N ) {
1479  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1480  }
1481  return (*this)(i,j);
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
1502  StaticMatrix<Type,M,N,SO>::at( size_t i, size_t j ) const
1503 {
1504  if( i >= M ) {
1505  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1506  }
1507  if( j >= N ) {
1508  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1509  }
1510  return (*this)(i,j);
1511 }
1512 //*************************************************************************************************
1513 
1514 
1515 //*************************************************************************************************
1527 template< typename Type // Data type of the matrix
1528  , size_t M // Number of rows
1529  , size_t N // Number of columns
1530  , bool SO > // Storage order
1531 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1533 {
1534  return v_;
1535 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1551 template< typename Type // Data type of the matrix
1552  , size_t M // Number of rows
1553  , size_t N // Number of columns
1554  , bool SO > // Storage order
1557 {
1558  return v_;
1559 }
1560 //*************************************************************************************************
1561 
1562 
1563 //*************************************************************************************************
1571 template< typename Type // Data type of the matrix
1572  , size_t M // Number of rows
1573  , size_t N // Number of columns
1574  , bool SO > // Storage order
1575 inline typename StaticMatrix<Type,M,N,SO>::Pointer
1577 {
1578  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1579  return v_ + i*NN;
1580 }
1581 //*************************************************************************************************
1582 
1583 
1584 //*************************************************************************************************
1592 template< typename Type // Data type of the matrix
1593  , size_t M // Number of rows
1594  , size_t N // Number of columns
1595  , bool SO > // Storage order
1598 {
1599  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1600  return v_ + i*NN;
1601 }
1602 //*************************************************************************************************
1603 
1604 
1605 //*************************************************************************************************
1616 template< typename Type // Data type of the matrix
1617  , size_t M // Number of rows
1618  , size_t N // Number of columns
1619  , bool SO > // Storage order
1622 {
1623  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1624  return Iterator( v_ + i*NN );
1625 }
1626 //*************************************************************************************************
1627 
1628 
1629 //*************************************************************************************************
1640 template< typename Type // Data type of the matrix
1641  , size_t M // Number of rows
1642  , size_t N // Number of columns
1643  , bool SO > // Storage order
1646 {
1647  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1648  return ConstIterator( v_ + i*NN );
1649 }
1650 //*************************************************************************************************
1651 
1652 
1653 //*************************************************************************************************
1664 template< typename Type // Data type of the matrix
1665  , size_t M // Number of rows
1666  , size_t N // Number of columns
1667  , bool SO > // Storage order
1670 {
1671  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1672  return ConstIterator( v_ + i*NN );
1673 }
1674 //*************************************************************************************************
1675 
1676 
1677 //*************************************************************************************************
1688 template< typename Type // Data type of the matrix
1689  , size_t M // Number of rows
1690  , size_t N // Number of columns
1691  , bool SO > // Storage order
1694 {
1695  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1696  return Iterator( v_ + i*NN + N );
1697 }
1698 //*************************************************************************************************
1699 
1700 
1701 //*************************************************************************************************
1712 template< typename Type // Data type of the matrix
1713  , size_t M // Number of rows
1714  , size_t N // Number of columns
1715  , bool SO > // Storage order
1718 {
1719  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1720  return ConstIterator( v_ + i*NN + N );
1721 }
1722 //*************************************************************************************************
1723 
1724 
1725 //*************************************************************************************************
1736 template< typename Type // Data type of the matrix
1737  , size_t M // Number of rows
1738  , size_t N // Number of columns
1739  , bool SO > // Storage order
1742 {
1743  BLAZE_USER_ASSERT( i < M, "Invalid dense matrix row access index" );
1744  return ConstIterator( v_ + i*NN + N );
1745 }
1746 //*************************************************************************************************
1747 
1748 
1749 
1750 
1751 //=================================================================================================
1752 //
1753 // ASSIGNMENT OPERATORS
1754 //
1755 //=================================================================================================
1756 
1757 //*************************************************************************************************
1778 template< typename Type // Data type of the matrix
1779  , size_t M // Number of rows
1780  , size_t N // Number of columns
1781  , bool SO > // Storage order
1782 template< typename Other > // Data type of the initialization array
1784 {
1785  for( size_t i=0UL; i<M; ++i )
1786  for( size_t j=0UL; j<N; ++j )
1787  v_[i*NN+j] = array[i][j];
1788 
1789  return *this;
1790 }
1791 //*************************************************************************************************
1792 
1793 
1794 //*************************************************************************************************
1800 template< typename Type // Data type of the matrix
1801  , size_t M // Number of rows
1802  , size_t N // Number of columns
1803  , bool SO > // Storage order
1805 {
1806  for( size_t i=0UL; i<M; ++i )
1807  for( size_t j=0UL; j<N; ++j )
1808  v_[i*NN+j] = set;
1809 
1810  return *this;
1811 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1823 template< typename Type // Data type of the matrix
1824  , size_t M // Number of rows
1825  , size_t N // Number of columns
1826  , bool SO > // Storage order
1828 {
1829  using blaze::assign;
1830 
1831  assign( *this, ~rhs );
1832  return *this;
1833 }
1834 //*************************************************************************************************
1835 
1836 
1837 //*************************************************************************************************
1843 template< typename Type // Data type of the matrix
1844  , size_t M // Number of rows
1845  , size_t N // Number of columns
1846  , bool SO > // Storage order
1847 template< typename Other // Data type of the foreign matrix
1848  , bool SO2 > // Storage order of the foreign matrix
1851 {
1852  using blaze::assign;
1853 
1854  assign( *this, ~rhs );
1855  return *this;
1856 }
1857 //*************************************************************************************************
1858 
1859 
1860 //*************************************************************************************************
1871 template< typename Type // Data type of the matrix
1872  , size_t M // Number of rows
1873  , size_t N // Number of columns
1874  , bool SO > // Storage order
1875 template< typename MT // Type of the right-hand side matrix
1876  , bool SO2 > // Storage order of the right-hand side matrix
1878 {
1879  using blaze::assign;
1880 
1881  typedef typename TransExprTrait<This>::Type TT;
1882  typedef typename CTransExprTrait<This>::Type CT;
1883 
1884  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
1885  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static matrix" );
1886  }
1887 
1888  if( IsSame<MT,TT>::value && (~rhs).isAliased( this ) ) {
1889  transpose( typename IsSquare<This>::Type() );
1890  }
1891  else if( IsSame<MT,CT>::value && (~rhs).isAliased( this ) ) {
1892  ctranspose( typename IsSquare<This>::Type() );
1893  }
1894  else if( (~rhs).canAlias( this ) ) {
1895  StaticMatrix tmp( ~rhs );
1896  assign( *this, tmp );
1897  }
1898  else {
1900  reset();
1901  assign( *this, ~rhs );
1902  }
1903 
1904  return *this;
1905 }
1906 //*************************************************************************************************
1907 
1908 
1909 //*************************************************************************************************
1919 template< typename Type // Data type of the matrix
1920  , size_t M // Number of rows
1921  , size_t N // Number of columns
1922  , bool SO > // Storage order
1923 template< typename MT // Type of the right-hand side matrix
1924  , bool SO2 > // Storage order of the right-hand side matrix
1926 {
1927  using blaze::addAssign;
1928 
1929  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
1930  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1931  }
1932 
1933  if( (~rhs).canAlias( this ) ) {
1934  const typename MT::ResultType tmp( ~rhs );
1935  addAssign( *this, tmp );
1936  }
1937  else {
1938  addAssign( *this, ~rhs );
1939  }
1940 
1941  return *this;
1942 }
1943 //*************************************************************************************************
1944 
1945 
1946 //*************************************************************************************************
1956 template< typename Type // Data type of the matrix
1957  , size_t M // Number of rows
1958  , size_t N // Number of columns
1959  , bool SO > // Storage order
1960 template< typename MT // Type of the right-hand side matrix
1961  , bool SO2 > // Storage order of the right-hand side matrix
1963 {
1964  using blaze::subAssign;
1965 
1966  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
1967  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
1968  }
1969 
1970  if( (~rhs).canAlias( this ) ) {
1971  const typename MT::ResultType tmp( ~rhs );
1972  subAssign( *this, tmp );
1973  }
1974  else {
1975  subAssign( *this, ~rhs );
1976  }
1977 
1978  return *this;
1979 }
1980 //*************************************************************************************************
1981 
1982 
1983 //*************************************************************************************************
1993 template< typename Type // Data type of the matrix
1994  , size_t M // Number of rows
1995  , size_t N // Number of columns
1996  , bool SO > // Storage order
1997 template< typename MT // Type of the right-hand side matrix
1998  , bool SO2 > // Storage order of the right-hand side matrix
2000 {
2001  if( M != N || (~rhs).rows() != M || (~rhs).columns() != N ) {
2002  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
2003  }
2004 
2005  const StaticMatrix tmp( *this * (~rhs) );
2006  return this->operator=( tmp );
2007 }
2008 //*************************************************************************************************
2009 
2010 
2011 //*************************************************************************************************
2018 template< typename Type // Data type of the matrix
2019  , size_t M // Number of rows
2020  , size_t N // Number of columns
2021  , bool SO > // Storage order
2022 template< typename Other > // Data type of the right-hand side scalar
2023 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
2025 {
2026  using blaze::assign;
2027 
2028  assign( *this, (*this) * rhs );
2029  return *this;
2030 }
2031 //*************************************************************************************************
2032 
2033 
2034 //*************************************************************************************************
2043 template< typename Type // Data type of the matrix
2044  , size_t M // Number of rows
2045  , size_t N // Number of columns
2046  , bool SO > // Storage order
2047 template< typename Other > // Data type of the right-hand side scalar
2048 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,SO> >::Type&
2050 {
2051  using blaze::assign;
2052 
2053  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2054 
2055  assign( *this, (*this) / rhs );
2056  return *this;
2057 }
2058 //*************************************************************************************************
2059 
2060 
2061 
2062 
2063 //=================================================================================================
2064 //
2065 // UTILITY FUNCTIONS
2066 //
2067 //=================================================================================================
2068 
2069 //*************************************************************************************************
2074 template< typename Type // Data type of the matrix
2075  , size_t M // Number of rows
2076  , size_t N // Number of columns
2077  , bool SO > // Storage order
2078 inline size_t StaticMatrix<Type,M,N,SO>::rows() const
2079 {
2080  return M;
2081 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2090 template< typename Type // Data type of the matrix
2091  , size_t M // Number of rows
2092  , size_t N // Number of columns
2093  , bool SO > // Storage order
2095 {
2096  return N;
2097 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2109 template< typename Type // Data type of the matrix
2110  , size_t M // Number of rows
2111  , size_t N // Number of columns
2112  , bool SO > // Storage order
2114 {
2115  return NN;
2116 }
2117 //*************************************************************************************************
2118 
2119 
2120 //*************************************************************************************************
2125 template< typename Type // Data type of the matrix
2126  , size_t M // Number of rows
2127  , size_t N // Number of columns
2128  , bool SO > // Storage order
2130 {
2131  return M*NN;
2132 }
2133 //*************************************************************************************************
2134 
2135 
2136 //*************************************************************************************************
2147 template< typename Type // Data type of the matrix
2148  , size_t M // Number of rows
2149  , size_t N // Number of columns
2150  , bool SO > // Storage order
2151 inline size_t StaticMatrix<Type,M,N,SO>::capacity( size_t i ) const
2152 {
2153  UNUSED_PARAMETER( i );
2154 
2155  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2156 
2157  return NN;
2158 }
2159 //*************************************************************************************************
2160 
2161 
2162 //*************************************************************************************************
2167 template< typename Type // Data type of the matrix
2168  , size_t M // Number of rows
2169  , size_t N // Number of columns
2170  , bool SO > // Storage order
2172 {
2173  size_t nonzeros( 0UL );
2174 
2175  for( size_t i=0UL; i<M; ++i )
2176  for( size_t j=0UL; j<N; ++j )
2177  if( !isDefault( v_[i*NN+j] ) )
2178  ++nonzeros;
2179 
2180  return nonzeros;
2181 }
2182 //*************************************************************************************************
2183 
2184 
2185 //*************************************************************************************************
2196 template< typename Type // Data type of the matrix
2197  , size_t M // Number of rows
2198  , size_t N // Number of columns
2199  , bool SO > // Storage order
2200 inline size_t StaticMatrix<Type,M,N,SO>::nonZeros( size_t i ) const
2201 {
2202  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2203 
2204  const size_t jend( i*NN + N );
2205  size_t nonzeros( 0UL );
2206 
2207  for( size_t j=i*NN; j<jend; ++j )
2208  if( !isDefault( v_[j] ) )
2209  ++nonzeros;
2210 
2211  return nonzeros;
2212 }
2213 //*************************************************************************************************
2214 
2215 
2216 //*************************************************************************************************
2221 template< typename Type // Data type of the matrix
2222  , size_t M // Number of rows
2223  , size_t N // Number of columns
2224  , bool SO > // Storage order
2226 {
2227  using blaze::clear;
2228 
2229  for( size_t i=0UL; i<M; ++i )
2230  for( size_t j=0UL; j<N; ++j )
2231  clear( v_[i*NN+j] );
2232 }
2233 //*************************************************************************************************
2234 
2235 
2236 //*************************************************************************************************
2247 template< typename Type // Data type of the matrix
2248  , size_t M // Number of rows
2249  , size_t N // Number of columns
2250  , bool SO > // Storage order
2251 inline void StaticMatrix<Type,M,N,SO>::reset( size_t i )
2252 {
2253  using blaze::clear;
2254 
2255  BLAZE_USER_ASSERT( i < rows(), "Invalid row access index" );
2256  for( size_t j=0UL; j<N; ++j )
2257  clear( v_[i*NN+j] );
2258 }
2259 //*************************************************************************************************
2260 
2261 
2262 //*************************************************************************************************
2270 template< typename Type // Data type of the matrix
2271  , size_t M // Number of rows
2272  , size_t N // Number of columns
2273  , bool SO > // Storage order
2275 {
2276  using std::swap;
2277 
2278  BLAZE_STATIC_ASSERT( M == N );
2279 
2280  for( size_t i=1UL; i<M; ++i )
2281  for( size_t j=0UL; j<i; ++j )
2282  swap( v_[i*NN+j], v_[j*NN+i] );
2283 
2284  return *this;
2285 }
2286 //*************************************************************************************************
2287 
2288 
2289 //*************************************************************************************************
2303 template< typename Type // Data type of the matrix
2304  , size_t M // Number of rows
2305  , size_t N // Number of columns
2306  , bool SO > // Storage order
2308 {
2309  transpose();
2310 }
2312 //*************************************************************************************************
2313 
2314 
2315 //*************************************************************************************************
2329 template< typename Type // Data type of the matrix
2330  , size_t M // Number of rows
2331  , size_t N // Number of columns
2332  , bool SO > // Storage order
2334 {}
2336 //*************************************************************************************************
2337 
2338 
2339 //*************************************************************************************************
2347 template< typename Type // Data type of the matrix
2348  , size_t M // Number of rows
2349  , size_t N // Number of columns
2350  , bool SO > // Storage order
2352 {
2353  BLAZE_STATIC_ASSERT( M == N );
2354 
2355  for( size_t i=0UL; i<M; ++i ) {
2356  for( size_t j=0UL; j<i; ++j ) {
2357  cswap( v_[i*NN+j], v_[j*NN+i] );
2358  }
2359  conjugate( v_[i*NN+i] );
2360  }
2361 
2362  return *this;
2363 }
2364 //*************************************************************************************************
2365 
2366 
2367 //*************************************************************************************************
2381 template< typename Type // Data type of the matrix
2382  , size_t M // Number of rows
2383  , size_t N // Number of columns
2384  , bool SO > // Storage order
2386 {
2387  ctranspose();
2388 }
2390 //*************************************************************************************************
2391 
2392 
2393 //*************************************************************************************************
2407 template< typename Type // Data type of the matrix
2408  , size_t M // Number of rows
2409  , size_t N // Number of columns
2410  , bool SO > // Storage order
2412 {}
2414 //*************************************************************************************************
2415 
2416 
2417 //*************************************************************************************************
2423 template< typename Type // Data type of the matrix
2424  , size_t M // Number of rows
2425  , size_t N // Number of columns
2426  , bool SO > // Storage order
2427 template< typename Other > // Data type of the scalar value
2429 {
2430  for( size_t i=0UL; i<M; ++i )
2431  for( size_t j=0UL; j<N; ++j )
2432  v_[i*NN+j] *= scalar;
2433 
2434  return *this;
2435 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2446 template< typename Type // Data type of the matrix
2447  , size_t M // Number of rows
2448  , size_t N // Number of columns
2449  , bool SO > // Storage order
2450 inline void StaticMatrix<Type,M,N,SO>::swap( StaticMatrix& m ) /* throw() */
2451 {
2452  using std::swap;
2453 
2454  for( size_t i=0UL; i<M; ++i ) {
2455  for( size_t j=0UL; j<N; ++j ) {
2456  swap( v_[i*NN+j], m(i,j) );
2457  }
2458  }
2459 }
2460 //*************************************************************************************************
2461 
2462 
2463 
2464 
2465 //=================================================================================================
2466 //
2467 // MEMORY FUNCTIONS
2468 //
2469 //=================================================================================================
2470 
2471 //*************************************************************************************************
2481 template< typename Type // Data type of the matrix
2482  , size_t M // Number of rows
2483  , size_t N // Number of columns
2484  , bool SO > // Storage order
2485 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size )
2486 {
2488 
2489  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2490 
2491  return allocate<StaticMatrix>( 1UL );
2492 }
2493 //*************************************************************************************************
2494 
2495 
2496 //*************************************************************************************************
2506 template< typename Type // Data type of the matrix
2507  , size_t M // Number of rows
2508  , size_t N // Number of columns
2509  , bool SO > // Storage order
2510 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size )
2511 {
2512  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2513  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2514 
2515  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2516 }
2517 //*************************************************************************************************
2518 
2519 
2520 //*************************************************************************************************
2530 template< typename Type // Data type of the matrix
2531  , size_t M // Number of rows
2532  , size_t N // Number of columns
2533  , bool SO > // Storage order
2534 inline void* StaticMatrix<Type,M,N,SO>::operator new( std::size_t size, const std::nothrow_t& )
2535 {
2536  UNUSED_PARAMETER( size );
2537 
2538  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
2539 
2540  return allocate<StaticMatrix>( 1UL );
2541 }
2542 //*************************************************************************************************
2543 
2544 
2545 //*************************************************************************************************
2555 template< typename Type // Data type of the matrix
2556  , size_t M // Number of rows
2557  , size_t N // Number of columns
2558  , bool SO > // Storage order
2559 inline void* StaticMatrix<Type,M,N,SO>::operator new[]( std::size_t size, const std::nothrow_t& )
2560 {
2561  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
2562  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
2563 
2564  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
2565 }
2566 //*************************************************************************************************
2567 
2568 
2569 //*************************************************************************************************
2575 template< typename Type // Data type of the matrix
2576  , size_t M // Number of rows
2577  , size_t N // Number of columns
2578  , bool SO > // Storage order
2579 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr )
2580 {
2581  deallocate( static_cast<StaticMatrix*>( ptr ) );
2582 }
2583 //*************************************************************************************************
2584 
2585 
2586 //*************************************************************************************************
2592 template< typename Type // Data type of the matrix
2593  , size_t M // Number of rows
2594  , size_t N // Number of columns
2595  , bool SO > // Storage order
2596 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr )
2597 {
2598  deallocate( static_cast<StaticMatrix*>( ptr ) );
2599 }
2600 //*************************************************************************************************
2601 
2602 
2603 //*************************************************************************************************
2609 template< typename Type // Data type of the matrix
2610  , size_t M // Number of rows
2611  , size_t N // Number of columns
2612  , bool SO > // Storage order
2613 inline void StaticMatrix<Type,M,N,SO>::operator delete( void* ptr, const std::nothrow_t& )
2614 {
2615  deallocate( static_cast<StaticMatrix*>( ptr ) );
2616 }
2617 //*************************************************************************************************
2618 
2619 
2620 //*************************************************************************************************
2626 template< typename Type // Data type of the matrix
2627  , size_t M // Number of rows
2628  , size_t N // Number of columns
2629  , bool SO > // Storage order
2630 inline void StaticMatrix<Type,M,N,SO>::operator delete[]( void* ptr, const std::nothrow_t& )
2631 {
2632  deallocate( static_cast<StaticMatrix*>( ptr ) );
2633 }
2634 //*************************************************************************************************
2635 
2636 
2637 
2638 
2639 //=================================================================================================
2640 //
2641 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2642 //
2643 //=================================================================================================
2644 
2645 //*************************************************************************************************
2655 template< typename Type // Data type of the matrix
2656  , size_t M // Number of rows
2657  , size_t N // Number of columns
2658  , bool SO > // Storage order
2659 template< typename Other > // Data type of the foreign expression
2660 inline bool StaticMatrix<Type,M,N,SO>::canAlias( const Other* alias ) const
2661 {
2662  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2663 }
2664 //*************************************************************************************************
2665 
2666 
2667 //*************************************************************************************************
2677 template< typename Type // Data type of the matrix
2678  , size_t M // Number of rows
2679  , size_t N // Number of columns
2680  , bool SO > // Storage order
2681 template< typename Other > // Data type of the foreign expression
2682 inline bool StaticMatrix<Type,M,N,SO>::isAliased( const Other* alias ) const
2683 {
2684  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
2685 }
2686 //*************************************************************************************************
2687 
2688 
2689 //*************************************************************************************************
2698 template< typename Type // Data type of the matrix
2699  , size_t M // Number of rows
2700  , size_t N // Number of columns
2701  , bool SO > // Storage order
2703 {
2704  return ( usePadding || columns() % IT::size == 0UL );
2705 }
2706 //*************************************************************************************************
2707 
2708 
2709 //*************************************************************************************************
2724 template< typename Type // Data type of the matrix
2725  , size_t M // Number of rows
2726  , size_t N // Number of columns
2727  , bool SO > // Storage order
2729  StaticMatrix<Type,M,N,SO>::load( size_t i, size_t j ) const
2730 {
2731  if( usePadding )
2732  return loada( i, j );
2733  else
2734  return loadu( i, j );
2735 }
2736 //*************************************************************************************************
2737 
2738 
2739 //*************************************************************************************************
2754 template< typename Type // Data type of the matrix
2755  , size_t M // Number of rows
2756  , size_t N // Number of columns
2757  , bool SO > // Storage order
2759  StaticMatrix<Type,M,N,SO>::loada( size_t i, size_t j ) const
2760 {
2761  using blaze::loada;
2762 
2764 
2765  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
2766  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
2767  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2768  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
2769  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i*NN+j] ), "Invalid alignment detected" );
2770 
2771  return loada( &v_[i*NN+j] );
2772 }
2773 //*************************************************************************************************
2774 
2775 
2776 //*************************************************************************************************
2791 template< typename Type // Data type of the matrix
2792  , size_t M // Number of rows
2793  , size_t N // Number of columns
2794  , bool SO > // Storage order
2796  StaticMatrix<Type,M,N,SO>::loadu( size_t i, size_t j ) const
2797 {
2798  using blaze::loadu;
2799 
2801 
2802  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
2803  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
2804  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2805 
2806  return loadu( &v_[i*NN+j] );
2807 }
2808 //*************************************************************************************************
2809 
2810 
2811 //*************************************************************************************************
2827 template< typename Type // Data type of the matrix
2828  , size_t M // Number of rows
2829  , size_t N // Number of columns
2830  , bool SO > // Storage order
2832  StaticMatrix<Type,M,N,SO>::store( size_t i, size_t j, const IntrinsicType& value )
2833 {
2834  if( usePadding )
2835  storea( i, j, value );
2836  else
2837  storeu( i, j, value );
2838 }
2839 //*************************************************************************************************
2840 
2841 
2842 //*************************************************************************************************
2858 template< typename Type // Data type of the matrix
2859  , size_t M // Number of rows
2860  , size_t N // Number of columns
2861  , bool SO > // Storage order
2863  StaticMatrix<Type,M,N,SO>::storea( size_t i, size_t j, const IntrinsicType& value )
2864 {
2865  using blaze::storea;
2866 
2868 
2869  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
2870  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
2871  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2872  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
2873  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i*NN+j] ), "Invalid alignment detected" );
2874 
2875  storea( &v_[i*NN+j], value );
2876 }
2877 //*************************************************************************************************
2878 
2879 
2880 //*************************************************************************************************
2896 template< typename Type // Data type of the matrix
2897  , size_t M // Number of rows
2898  , size_t N // Number of columns
2899  , bool SO > // Storage order
2901  StaticMatrix<Type,M,N,SO>::storeu( size_t i, size_t j, const IntrinsicType& value )
2902 {
2903  using blaze::storeu;
2904 
2906 
2907  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
2908  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
2909  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2910 
2911  storeu( &v_[i*NN+j], value );
2912 }
2913 //*************************************************************************************************
2914 
2915 
2916 //*************************************************************************************************
2932 template< typename Type // Data type of the matrix
2933  , size_t M // Number of rows
2934  , size_t N // Number of columns
2935  , bool SO > // Storage order
2937  StaticMatrix<Type,M,N,SO>::stream( size_t i, size_t j, const IntrinsicType& value )
2938 {
2939  using blaze::stream;
2940 
2942 
2943  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
2944  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
2945  BLAZE_INTERNAL_ASSERT( j + IT::size <= NN, "Invalid column access index" );
2946  BLAZE_INTERNAL_ASSERT( !usePadding || j % IT::size == 0UL, "Invalid column access index" );
2947  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i*NN+j] ), "Invalid alignment detected" );
2948 
2949  stream( &v_[i*NN+j], value );
2950 }
2951 //*************************************************************************************************
2952 
2953 
2954 //*************************************************************************************************
2965 template< typename Type // Data type of the matrix
2966  , size_t M // Number of rows
2967  , size_t N // Number of columns
2968  , bool SO > // Storage order
2969 template< typename MT // Type of the right-hand side dense matrix
2970  , bool SO2 > // Storage order of the right-hand side dense matrix
2971 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
2973 {
2974  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
2975 
2976  for( size_t i=0UL; i<M; ++i ) {
2977  for( size_t j=0UL; j<N; ++j ) {
2978  v_[i*NN+j] = (~rhs)(i,j);
2979  }
2980  }
2981 }
2982 //*************************************************************************************************
2983 
2984 
2985 //*************************************************************************************************
2996 template< typename Type // Data type of the matrix
2997  , size_t M // Number of rows
2998  , size_t N // Number of columns
2999  , bool SO > // Storage order
3000 template< typename MT // Type of the right-hand side dense matrix
3001  , bool SO2 > // Storage order of the right-hand side dense matrix
3002 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
3004 {
3006 
3007  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3008 
3009  const bool remainder( !usePadding || !IsPadded<MT>::value );
3010 
3011  const size_t jpos( ( remainder )?( N & size_t(-IT::size) ):( N ) );
3012  BLAZE_INTERNAL_ASSERT( !remainder || ( N - ( N % (IT::size) ) ) == jpos, "Invalid end calculation" );
3013 
3014  for( size_t i=0UL; i<M; ++i )
3015  {
3016  size_t j( 0UL );
3017 
3018  for( ; j<jpos; j+=IT::size ) {
3019  store( i, j, (~rhs).load(i,j) );
3020  }
3021  for( ; remainder && j<N; ++j ) {
3022  v_[i*NN+j] = (~rhs)(i,j);
3023  }
3024  }
3025 }
3026 //*************************************************************************************************
3027 
3028 
3029 //*************************************************************************************************
3040 template< typename Type // Data type of the matrix
3041  , size_t M // Number of rows
3042  , size_t N // Number of columns
3043  , bool SO > // Storage order
3044 template< typename MT > // Type of the right-hand side sparse matrix
3046 {
3047  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3048 
3049  typedef typename MT::ConstIterator RhsConstIterator;
3050 
3051  for( size_t i=0UL; i<M; ++i )
3052  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3053  v_[i*NN+element->index()] = element->value();
3054 }
3055 //*************************************************************************************************
3056 
3057 
3058 //*************************************************************************************************
3069 template< typename Type // Data type of the matrix
3070  , size_t M // Number of rows
3071  , size_t N // Number of columns
3072  , bool SO > // Storage order
3073 template< typename MT > // Type of the right-hand side sparse matrix
3075 {
3077 
3078  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3079 
3080  typedef typename MT::ConstIterator RhsConstIterator;
3081 
3082  for( size_t j=0UL; j<N; ++j )
3083  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
3084  v_[element->index()*NN+j] = element->value();
3085 }
3086 //*************************************************************************************************
3087 
3088 
3089 //*************************************************************************************************
3100 template< typename Type // Data type of the matrix
3101  , size_t M // Number of rows
3102  , size_t N // Number of columns
3103  , bool SO > // Storage order
3104 template< typename MT // Type of the right-hand side dense matrix
3105  , bool SO2 > // Storage order of the right-hand side dense matrix
3106 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
3108 {
3109  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3110 
3111  for( size_t i=0UL; i<M; ++i )
3112  {
3113  if( IsDiagonal<MT>::value )
3114  {
3115  v_[i*NN+i] += (~rhs)(i,i);
3116  }
3117  else
3118  {
3119  const size_t jbegin( ( IsUpper<MT>::value )
3120  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
3121  :( 0UL ) );
3122  const size_t jend ( ( IsLower<MT>::value )
3123  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
3124  :( N ) );
3125  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
3126 
3127  for( size_t j=jbegin; j<jend; ++j ) {
3128  v_[i*NN+j] += (~rhs)(i,j);
3129  }
3130  }
3131  }
3132 }
3133 //*************************************************************************************************
3134 
3135 
3136 //*************************************************************************************************
3147 template< typename Type // Data type of the matrix
3148  , size_t M // Number of rows
3149  , size_t N // Number of columns
3150  , bool SO > // Storage order
3151 template< typename MT // Type of the right-hand side dense matrix
3152  , bool SO2 > // Storage order of the right-hand side dense matrix
3153 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
3155 {
3158 
3159  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3160 
3161  const bool remainder( !usePadding || !IsPadded<MT>::value );
3162 
3163  for( size_t i=0UL; i<M; ++i )
3164  {
3165  const size_t jbegin( ( IsUpper<MT>::value )
3166  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
3167  :( 0UL ) );
3168  const size_t jend ( ( IsLower<MT>::value )
3169  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
3170  :( N ) );
3171  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
3172 
3173  const size_t jpos( ( remainder )?( jend & size_t(-IT::size) ):( jend ) );
3174  BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (IT::size) ) ) == jpos, "Invalid end calculation" );
3175 
3176  size_t j( jbegin );
3177 
3178  for( ; j<jpos; j+=IT::size ) {
3179  store( i, j, load(i,j) + (~rhs).load(i,j) );
3180  }
3181  for( ; remainder && j<jend; ++j ) {
3182  v_[i*NN+j] += (~rhs)(i,j);
3183  }
3184  }
3185 }
3186 //*************************************************************************************************
3187 
3188 
3189 //*************************************************************************************************
3200 template< typename Type // Data type of the matrix
3201  , size_t M // Number of rows
3202  , size_t N // Number of columns
3203  , bool SO > // Storage order
3204 template< typename MT > // Type of the right-hand side sparse matrix
3206 {
3207  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3208 
3209  typedef typename MT::ConstIterator RhsConstIterator;
3210 
3211  for( size_t i=0UL; i<M; ++i )
3212  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3213  v_[i*NN+element->index()] += element->value();
3214 }
3215 //*************************************************************************************************
3216 
3217 
3218 //*************************************************************************************************
3229 template< typename Type // Data type of the matrix
3230  , size_t M // Number of rows
3231  , size_t N // Number of columns
3232  , bool SO > // Storage order
3233 template< typename MT > // Type of the right-hand side sparse matrix
3235 {
3237 
3238  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3239 
3240  typedef typename MT::ConstIterator RhsConstIterator;
3241 
3242  for( size_t j=0UL; j<N; ++j )
3243  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
3244  v_[element->index()*NN+j] += element->value();
3245 }
3246 //*************************************************************************************************
3247 
3248 
3249 //*************************************************************************************************
3260 template< typename Type // Data type of the matrix
3261  , size_t M // Number of rows
3262  , size_t N // Number of columns
3263  , bool SO > // Storage order
3264 template< typename MT // Type of the right-hand side dense matrix
3265  , bool SO2 > // Storage order of the right-hand side dense matrix
3266 inline typename DisableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
3268 {
3269  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3270 
3271  for( size_t i=0UL; i<M; ++i )
3272  {
3273  if( IsDiagonal<MT>::value )
3274  {
3275  v_[i*NN+i] -= (~rhs)(i,i);
3276  }
3277  else
3278  {
3279  const size_t jbegin( ( IsUpper<MT>::value )
3280  ?( IsStrictlyUpper<MT>::value ? i+1UL : i )
3281  :( 0UL ) );
3282  const size_t jend ( ( IsLower<MT>::value )
3283  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
3284  :( N ) );
3285  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
3286 
3287  for( size_t j=jbegin; j<jend; ++j ) {
3288  v_[i*NN+j] -= (~rhs)(i,j);
3289  }
3290  }
3291  }
3292 }
3293 //*************************************************************************************************
3294 
3295 
3296 //*************************************************************************************************
3307 template< typename Type // Data type of the matrix
3308  , size_t M // Number of rows
3309  , size_t N // Number of columns
3310  , bool SO > // Storage order
3311 template< typename MT // Type of the right-hand side dense matrix
3312  , bool SO2 > // Storage order of the right-hand side dense matrix
3313 inline typename EnableIf< typename StaticMatrix<Type,M,N,SO>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
3315 {
3318 
3319  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3320 
3321  const bool remainder( !usePadding || !IsPadded<MT>::value );
3322 
3323  for( size_t i=0UL; i<M; ++i )
3324  {
3325  const size_t jbegin( ( IsUpper<MT>::value )
3326  ?( ( IsStrictlyUpper<MT>::value ? i+1UL : i ) & size_t(-IT::size) )
3327  :( 0UL ) );
3328  const size_t jend ( ( IsLower<MT>::value )
3329  ?( IsStrictlyLower<MT>::value ? i : i+1UL )
3330  :( N ) );
3331  BLAZE_INTERNAL_ASSERT( jbegin <= jend, "Invalid loop indices detected" );
3332 
3333  const size_t jpos( ( remainder )?( jend & size_t(-IT::size) ):( jend ) );
3334  BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (IT::size) ) ) == jpos, "Invalid end calculation" );
3335 
3336  size_t j( jbegin );
3337 
3338  for( ; j<jpos; j+=IT::size ) {
3339  store( i, j, load(i,j) - (~rhs).load(i,j) );
3340  }
3341  for( ; remainder && j<jend; ++j ) {
3342  v_[i*NN+j] -= (~rhs)(i,j);
3343  }
3344  }
3345 }
3346 //*************************************************************************************************
3347 
3348 
3349 //*************************************************************************************************
3360 template< typename Type // Data type of the matrix
3361  , size_t M // Number of rows
3362  , size_t N // Number of columns
3363  , bool SO > // Storage order
3364 template< typename MT > // Type of the right-hand side sparse matrix
3366 {
3367  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3368 
3369  typedef typename MT::ConstIterator RhsConstIterator;
3370 
3371  for( size_t i=0UL; i<M; ++i )
3372  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
3373  v_[i*NN+element->index()] -= element->value();
3374 }
3375 //*************************************************************************************************
3376 
3377 
3378 //*************************************************************************************************
3389 template< typename Type // Data type of the matrix
3390  , size_t M // Number of rows
3391  , size_t N // Number of columns
3392  , bool SO > // Storage order
3393 template< typename MT > // Type of the right-hand side sparse matrix
3395 {
3397 
3398  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
3399 
3400  typedef typename MT::ConstIterator RhsConstIterator;
3401 
3402  for( size_t j=0UL; j<N; ++j )
3403  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
3404  v_[element->index()*NN+j] -= element->value();
3405 }
3406 //*************************************************************************************************
3407 
3408 
3409 
3410 
3411 
3412 
3413 
3414 
3415 //=================================================================================================
3416 //
3417 // CLASS TEMPLATE SPECIALIZATION FOR COLUMN-MAJOR MATRICES
3418 //
3419 //=================================================================================================
3420 
3421 //*************************************************************************************************
3429 template< typename Type // Data type of the matrix
3430  , size_t M // Number of rows
3431  , size_t N > // Number of columns
3432 class StaticMatrix<Type,M,N,true> : public DenseMatrix< StaticMatrix<Type,M,N,true>, true >
3433 {
3434  private:
3435  //**Type definitions****************************************************************************
3436  typedef IntrinsicTrait<Type> IT;
3437  //**********************************************************************************************
3438 
3439  //**********************************************************************************************
3441  static const size_t MM = ( usePadding )?( NextMultiple< SizeT<M>, SizeT<IT::size> >::value ):( M );
3442  //**********************************************************************************************
3443 
3444  public:
3445  //**Type definitions****************************************************************************
3447  typedef This ResultType;
3450  typedef Type ElementType;
3451  typedef typename IT::Type IntrinsicType;
3452  typedef const Type& ReturnType;
3453  typedef const This& CompositeType;
3454 
3455  typedef Type& Reference;
3456  typedef const Type& ConstReference;
3457  typedef Type* Pointer;
3458  typedef const Type* ConstPointer;
3459 
3462  //**********************************************************************************************
3463 
3464  //**Rebind struct definition********************************************************************
3467  template< typename ET > // Data type of the other matrix
3468  struct Rebind {
3470  };
3471  //**********************************************************************************************
3472 
3473  //**Compilation flags***************************************************************************
3475 
3479  enum { vectorizable = IsVectorizable<Type>::value };
3480 
3482 
3485  enum { smpAssignable = 0 };
3486  //**********************************************************************************************
3487 
3488  //**Constructors********************************************************************************
3491  explicit inline StaticMatrix();
3492  explicit inline StaticMatrix( const Type& init );
3493 
3494  template< typename Other > explicit inline StaticMatrix( size_t m, size_t n, const Other* array );
3495  template< typename Other > explicit inline StaticMatrix( const Other (&array)[M][N] );
3496 
3497  inline StaticMatrix( const StaticMatrix& m );
3498  template< typename Other, bool SO > inline StaticMatrix( const StaticMatrix<Other,M,N,SO>& m );
3499  template< typename MT , bool SO > inline StaticMatrix( const Matrix<MT,SO>& m );
3500 
3501  inline StaticMatrix( const Type& v1, const Type& v2 );
3502  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3 );
3503  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4 );
3504  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5 );
3505  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3506  const Type& v6 );
3507  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3508  const Type& v6, const Type& v7 );
3509  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3510  const Type& v6, const Type& v7, const Type& v8 );
3511  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3512  const Type& v6, const Type& v7, const Type& v8, const Type& v9 );
3513  inline StaticMatrix( const Type& v1, const Type& v2, const Type& v3, const Type& v4, const Type& v5,
3514  const Type& v6, const Type& v7, const Type& v8, const Type& v9, const Type& v10 );
3516  //**********************************************************************************************
3517 
3518  //**Destructor**********************************************************************************
3519  // No explicitly declared destructor.
3520  //**********************************************************************************************
3521 
3522  //**Data access functions***********************************************************************
3525  inline Reference operator()( size_t i, size_t j );
3526  inline ConstReference operator()( size_t i, size_t j ) const;
3527  inline Reference at( size_t i, size_t j );
3528  inline ConstReference at( size_t i, size_t j ) const;
3529  inline Pointer data ();
3530  inline ConstPointer data () const;
3531  inline Pointer data ( size_t j );
3532  inline ConstPointer data ( size_t j ) const;
3533  inline Iterator begin ( size_t j );
3534  inline ConstIterator begin ( size_t j ) const;
3535  inline ConstIterator cbegin( size_t j ) const;
3536  inline Iterator end ( size_t j );
3537  inline ConstIterator end ( size_t j ) const;
3538  inline ConstIterator cend ( size_t j ) const;
3540  //**********************************************************************************************
3541 
3542  //**Assignment operators************************************************************************
3545  template< typename Other >
3546  inline StaticMatrix& operator=( const Other (&array)[M][N] );
3547 
3548  inline StaticMatrix& operator= ( const Type& set );
3549  inline StaticMatrix& operator= ( const StaticMatrix& rhs );
3550  template< typename Other, bool SO > inline StaticMatrix& operator= ( const StaticMatrix<Other,M,N,SO>& rhs );
3551  template< typename MT , bool SO > inline StaticMatrix& operator= ( const Matrix<MT,SO>& rhs );
3552  template< typename MT , bool SO > inline StaticMatrix& operator+=( const Matrix<MT,SO>& rhs );
3553  template< typename MT , bool SO > inline StaticMatrix& operator-=( const Matrix<MT,SO>& rhs );
3554  template< typename MT , bool SO > inline StaticMatrix& operator*=( const Matrix<MT,SO>& rhs );
3555 
3556  template< typename Other >
3557  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3558  operator*=( Other rhs );
3559 
3560  template< typename Other >
3561  inline typename EnableIf< IsNumeric<Other>, StaticMatrix >::Type&
3562  operator/=( Other rhs );
3564  //**********************************************************************************************
3565 
3566  //**Utility functions***************************************************************************
3569  inline size_t rows() const;
3570  inline size_t columns() const;
3571  inline size_t spacing() const;
3572  inline size_t capacity() const;
3573  inline size_t capacity( size_t j ) const;
3574  inline size_t nonZeros() const;
3575  inline size_t nonZeros( size_t j ) const;
3576  inline void reset();
3577  inline void reset( size_t i );
3578  inline StaticMatrix& transpose();
3579  inline StaticMatrix& ctranspose();
3580  template< typename Other > inline StaticMatrix& scale( const Other& scalar );
3581  inline void swap( StaticMatrix& m ) /* throw() */;
3583  //**********************************************************************************************
3584 
3585  //**Memory functions****************************************************************************
3588  static inline void* operator new ( std::size_t size );
3589  static inline void* operator new[]( std::size_t size );
3590  static inline void* operator new ( std::size_t size, const std::nothrow_t& );
3591  static inline void* operator new[]( std::size_t size, const std::nothrow_t& );
3592 
3593  static inline void operator delete ( void* ptr );
3594  static inline void operator delete[]( void* ptr );
3595  static inline void operator delete ( void* ptr, const std::nothrow_t& );
3596  static inline void operator delete[]( void* ptr, const std::nothrow_t& );
3598  //**********************************************************************************************
3599 
3600  private:
3601  //**********************************************************************************************
3603  template< typename MT >
3604  struct VectorizedAssign {
3605  enum { value = useOptimizedKernels &&
3606  vectorizable && MT::vectorizable &&
3607  IsSame<Type,typename MT::ElementType>::value &&
3608  IsColumnMajorMatrix<MT>::value };
3609  };
3610  //**********************************************************************************************
3611 
3612  //**********************************************************************************************
3614  template< typename MT >
3615  struct VectorizedAddAssign {
3616  enum { value = useOptimizedKernels &&
3617  vectorizable && MT::vectorizable &&
3618  IsSame<Type,typename MT::ElementType>::value &&
3619  IntrinsicTrait<Type>::addition &&
3620  IsColumnMajorMatrix<MT>::value &&
3621  !IsDiagonal<MT>::value };
3622  };
3623  //**********************************************************************************************
3624 
3625  //**********************************************************************************************
3627  template< typename MT >
3628  struct VectorizedSubAssign {
3629  enum { value = useOptimizedKernels &&
3630  vectorizable && MT::vectorizable &&
3631  IsSame<Type,typename MT::ElementType>::value &&
3632  IntrinsicTrait<Type>::subtraction &&
3633  IsColumnMajorMatrix<MT>::value &&
3634  !IsDiagonal<MT>::value };
3635  };
3636  //**********************************************************************************************
3637 
3638  public:
3639  //**Expression template evaluation functions****************************************************
3642  template< typename Other > inline bool canAlias ( const Other* alias ) const;
3643  template< typename Other > inline bool isAliased( const Other* alias ) const;
3644 
3645  inline bool isAligned() const;
3646 
3647  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
3648  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
3649  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
3650 
3651  BLAZE_ALWAYS_INLINE void store ( size_t i, size_t j, const IntrinsicType& value );
3652  BLAZE_ALWAYS_INLINE void storea( size_t i, size_t j, const IntrinsicType& value );
3653  BLAZE_ALWAYS_INLINE void storeu( size_t i, size_t j, const IntrinsicType& value );
3654  BLAZE_ALWAYS_INLINE void stream( size_t i, size_t j, const IntrinsicType& value );
3655 
3656  template< typename MT, bool SO >
3657  inline typename DisableIf< VectorizedAssign<MT> >::Type
3658  assign( const DenseMatrix<MT,SO>& rhs );
3659 
3660  template< typename MT, bool SO >
3661  inline typename EnableIf< VectorizedAssign<MT> >::Type
3662  assign( const DenseMatrix<MT,SO>& rhs );
3663 
3664  template< typename MT > inline void assign( const SparseMatrix<MT,true>& rhs );
3665  template< typename MT > inline void assign( const SparseMatrix<MT,false>& rhs );
3666 
3667  template< typename MT, bool SO >
3668  inline typename DisableIf< VectorizedAddAssign<MT> >::Type
3669  addAssign( const DenseMatrix<MT,SO>& rhs );
3670 
3671  template< typename MT, bool SO >
3672  inline typename EnableIf< VectorizedAddAssign<MT> >::Type
3673  addAssign( const DenseMatrix<MT,SO>& rhs );
3674 
3675  template< typename MT > inline void addAssign( const SparseMatrix<MT,true>& rhs );
3676  template< typename MT > inline void addAssign( const SparseMatrix<MT,false>& rhs );
3677 
3678  template< typename MT, bool SO >
3679  inline typename DisableIf< VectorizedSubAssign<MT> >::Type
3680  subAssign( const DenseMatrix<MT,SO>& rhs );
3681 
3682  template< typename MT, bool SO >
3683  inline typename EnableIf< VectorizedSubAssign<MT> >::Type
3684  subAssign( const DenseMatrix<MT,SO>& rhs );
3685 
3686  template< typename MT > inline void subAssign( const SparseMatrix<MT,true>& rhs );
3687  template< typename MT > inline void subAssign( const SparseMatrix<MT,false>& rhs );
3689  //**********************************************************************************************
3690 
3691  private:
3692  //**Utility functions***************************************************************************
3693  inline void transpose ( TrueType );
3694  inline void transpose ( FalseType );
3695  inline void ctranspose( TrueType );
3696  inline void ctranspose( FalseType );
3697  //**********************************************************************************************
3698 
3699  //**Member variables****************************************************************************
3702  AlignedArray<Type,MM*N> v_;
3703 
3706  //**********************************************************************************************
3707 
3708  //**Compile time checks*************************************************************************
3713  BLAZE_STATIC_ASSERT( !usePadding || MM % IT::size == 0UL );
3714  BLAZE_STATIC_ASSERT( MM >= M );
3715  //**********************************************************************************************
3716 };
3718 //*************************************************************************************************
3719 
3720 
3721 
3722 
3723 //=================================================================================================
3724 //
3725 // CONSTRUCTORS
3726 //
3727 //=================================================================================================
3728 
3729 //*************************************************************************************************
3735 template< typename Type // Data type of the matrix
3736  , size_t M // Number of rows
3737  , size_t N > // Number of columns
3739  : v_() // The statically allocated matrix elements
3740 {
3741  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3742 
3743  if( IsNumeric<Type>::value ) {
3744  for( size_t i=0UL; i<MM*N; ++i )
3745  v_[i] = Type();
3746  }
3747 }
3749 //*************************************************************************************************
3750 
3751 
3752 //*************************************************************************************************
3758 template< typename Type // Data type of the matrix
3759  , size_t M // Number of rows
3760  , size_t N > // Number of columns
3761 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& init )
3762  : v_() // The statically allocated matrix elements
3763 {
3764  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3765 
3766  for( size_t j=0UL; j<N; ++j ) {
3767  for( size_t i=0UL; i<M; ++i )
3768  v_[i+j*MM] = init;
3769 
3770  for( size_t i=M; i<MM; ++i )
3771  v_[i+j*MM] = Type();
3772  }
3773 }
3775 //*************************************************************************************************
3776 
3777 
3778 //*************************************************************************************************
3805 template< typename Type // Data type of the matrix
3806  , size_t M // Number of rows
3807  , size_t N > // Number of columns
3808 template< typename Other > // Data type of the initialization array
3809 inline StaticMatrix<Type,M,N,true>::StaticMatrix( size_t m, size_t n, const Other* array )
3810  : v_() // The statically allocated matrix elements
3811 {
3812  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3813 
3814  if( m > M || n > N ) {
3815  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static matrix" );
3816  }
3817 
3818  for( size_t j=0UL; j<n; ++j ) {
3819  for( size_t i=0UL; i<m; ++i )
3820  v_[i+j*MM] = array[i+j*m];
3821 
3822  if( IsNumeric<Type>::value ) {
3823  for( size_t i=m; i<MM; ++i )
3824  v_[i+j*MM] = Type();
3825  }
3826  }
3827 
3828  if( IsNumeric<Type>::value ) {
3829  for( size_t j=n; j<N; ++j ) {
3830  for( size_t i=0UL; i<M; ++i )
3831  v_[i+j*MM] = Type();
3832  }
3833  }
3834 }
3836 //*************************************************************************************************
3837 
3838 
3839 //*************************************************************************************************
3860 template< typename Type // Data type of the matrix
3861  , size_t M // Number of rows
3862  , size_t N > // Number of columns
3863 template< typename Other > // Data type of the initialization array
3864 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Other (&array)[M][N] )
3865  : v_() // The statically allocated matrix elements
3866 {
3867  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3868 
3869  for( size_t j=0UL; j<N; ++j ) {
3870  for( size_t i=0UL; i<M; ++i )
3871  v_[i+j*MM] = array[i][j];
3872 
3873  for( size_t i=M; i<MM; ++i )
3874  v_[i+j*MM] = Type();
3875  }
3876 }
3878 //*************************************************************************************************
3879 
3880 
3881 //*************************************************************************************************
3889 template< typename Type // Data type of the matrix
3890  , size_t M // Number of rows
3891  , size_t N > // Number of columns
3892 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix& m )
3893  : v_() // The statically allocated matrix elements
3894 {
3895  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3896 
3897  for( size_t i=0UL; i<MM*N; ++i )
3898  v_[i] = m.v_[i];
3899 }
3901 //*************************************************************************************************
3902 
3903 
3904 //*************************************************************************************************
3910 template< typename Type // Data type of the matrix
3911  , size_t M // Number of rows
3912  , size_t N > // Number of columns
3913 template< typename Other // Data type of the foreign matrix
3914  , bool SO > // Storage order of the foreign matrix
3915 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const StaticMatrix<Other,M,N,SO>& m )
3916  : v_() // The statically allocated matrix elements
3917 {
3918  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3919 
3920  for( size_t j=0UL; j<N; ++j ) {
3921  for( size_t i=0UL; i<M; ++i )
3922  v_[i+j*MM] = m(i,j);
3923 
3924  for( size_t i=M; i<MM; ++i )
3925  v_[i+j*MM] = Type();
3926  }
3927 }
3929 //*************************************************************************************************
3930 
3931 
3932 //*************************************************************************************************
3943 template< typename Type // Data type of the matrix
3944  , size_t M // Number of rows
3945  , size_t N > // Number of columns
3946 template< typename MT // Type of the foreign matrix
3947  , bool SO > // Storage order of the foreign matrix
3948 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Matrix<MT,SO>& m )
3949  : v_() // The statically allocated matrix elements
3950 {
3951  using blaze::assign;
3952 
3953  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3954 
3955  if( (~m).rows() != M || (~m).columns() != N ) {
3956  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of static matrix" );
3957  }
3958 
3959  for( size_t j=0UL; j<N; ++j ) {
3960  for( size_t i=( IsSparseMatrix<MT>::value ? 0UL : M ); i<MM; ++i ) {
3961  v_[i+j*MM] = Type();
3962  }
3963  }
3964 
3965  assign( *this, ~m );
3966 }
3968 //*************************************************************************************************
3969 
3970 
3971 //*************************************************************************************************
3989 template< typename Type // Data type of the matrix
3990  , size_t M // Number of rows
3991  , size_t N > // Number of columns
3992 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2 )
3993  : v_() // The statically allocated matrix elements
3994 {
3995  BLAZE_STATIC_ASSERT( M*N == 2UL );
3996  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
3997 
3998  // Initialization of a 2x1 matrix
3999  if( N == 1UL ) {
4000  v_[0UL] = v1;
4001  v_[1UL] = v2;
4002  }
4003 
4004  // Initialization of a 1x2 matrix
4005  else {
4006  v_[0UL] = v1;
4007  v_[ MM] = v2;
4008  }
4009 
4010  for( size_t j=0UL; j<N; ++j )
4011  for( size_t i=M; i<MM; ++i ) {
4012  v_[i+j*MM] = Type();
4013  }
4014 }
4016 //*************************************************************************************************
4017 
4018 
4019 //*************************************************************************************************
4038 template< typename Type // Data type of the matrix
4039  , size_t M // Number of rows
4040  , size_t N > // Number of columns
4041 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3 )
4042  : v_() // The statically allocated matrix elements
4043 {
4044  BLAZE_STATIC_ASSERT( M*N == 3UL );
4045  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4046 
4047  // Initialization of a 3x1 matrix
4048  if( N == 1UL ) {
4049  v_[0UL] = v1;
4050  v_[1UL] = v2;
4051  v_[2UL] = v3;
4052  }
4053 
4054  // Initialization of a 1x3 matrix
4055  else {
4056  v_[ 0UL] = v1;
4057  v_[ MM] = v2;
4058  v_[2UL*MM] = v3;
4059  }
4060 
4061  for( size_t j=0UL; j<N; ++j )
4062  for( size_t i=M; i<MM; ++i ) {
4063  v_[i+j*MM] = Type();
4064  }
4065 }
4067 //*************************************************************************************************
4068 
4069 
4070 //*************************************************************************************************
4092 template< typename Type // Data type of the matrix
4093  , size_t M // Number of rows
4094  , size_t N > // Number of columns
4095 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4096  const Type& v4 )
4097  : v_() // The statically allocated matrix elements
4098 {
4099  BLAZE_STATIC_ASSERT( M*N == 4UL );
4100  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4101 
4102  // Initialization of a 4x1 matrix
4103  if( N == 1UL ) {
4104  v_[0UL] = v1;
4105  v_[1UL] = v2;
4106  v_[2UL] = v3;
4107  v_[3UL] = v4;
4108  }
4109 
4110  // Initialization of a 2x2 matrix
4111  else if( N == 2UL ) {
4112  v_[ 0UL] = v1;
4113  v_[ 1UL] = v2;
4114  v_[MM ] = v3;
4115  v_[MM+1UL] = v4;
4116  }
4117 
4118  // Initialization of a 1x4 matrix
4119  else {
4120  v_[ 0UL] = v1;
4121  v_[ MM] = v2;
4122  v_[2UL*MM] = v3;
4123  v_[3UL*MM] = v4;
4124  }
4125 
4126  for( size_t j=0UL; j<N; ++j )
4127  for( size_t i=M; i<MM; ++i ) {
4128  v_[i+j*MM] = Type();
4129  }
4130 }
4132 //*************************************************************************************************
4133 
4134 
4135 //*************************************************************************************************
4156 template< typename Type // Data type of the matrix
4157  , size_t M // Number of rows
4158  , size_t N > // Number of columns
4159 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4160  const Type& v4, const Type& v5 )
4161  : v_() // The statically allocated matrix elements
4162 {
4163  BLAZE_STATIC_ASSERT( M*N == 5UL );
4164  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4165 
4166  // Initialization of a 5x1 matrix
4167  if( N == 1UL ) {
4168  v_[0UL] = v1;
4169  v_[1UL] = v2;
4170  v_[2UL] = v3;
4171  v_[3UL] = v4;
4172  v_[4UL] = v5;
4173  }
4174 
4175  // Initialization of a 1x5 matrix
4176  else {
4177  v_[ 0UL] = v1;
4178  v_[ MM] = v2;
4179  v_[2UL*MM] = v3;
4180  v_[3UL*MM] = v4;
4181  v_[4UL*MM] = v5;
4182  }
4183 
4184  for( size_t j=0UL; j<N; ++j )
4185  for( size_t i=M; i<MM; ++i ) {
4186  v_[i+j*MM] = Type();
4187  }
4188 }
4190 //*************************************************************************************************
4191 
4192 
4193 //*************************************************************************************************
4218 template< typename Type // Data type of the matrix
4219  , size_t M // Number of rows
4220  , size_t N > // Number of columns
4221 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4222  const Type& v4, const Type& v5, const Type& v6 )
4223  : v_() // The statically allocated matrix elements
4224 {
4225  BLAZE_STATIC_ASSERT( M*N == 6UL );
4226  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4227 
4228  // Initialization of a 6x1 matrix
4229  if( N == 1UL ) {
4230  v_[0UL] = v1;
4231  v_[1UL] = v2;
4232  v_[2UL] = v3;
4233  v_[3UL] = v4;
4234  v_[4UL] = v5;
4235  v_[5UL] = v6;
4236  }
4237 
4238  // Initialization of a 3x2 matrix
4239  else if( N == 2UL ) {
4240  v_[ 0UL] = v1;
4241  v_[ 1UL] = v2;
4242  v_[ 2UL] = v3;
4243  v_[MM ] = v4;
4244  v_[MM+1UL] = v5;
4245  v_[MM+2UL] = v6;
4246  }
4247 
4248  // Initialization of a 2x3 matrix
4249  else if( N == 3UL ) {
4250  v_[ 0UL] = v1;
4251  v_[ 1UL] = v2;
4252  v_[ MM ] = v3;
4253  v_[ MM+1UL] = v4;
4254  v_[2UL*MM ] = v5;
4255  v_[2UL*MM+1UL] = v6;
4256  }
4257 
4258  // Initialization of a 1x6 matrix
4259  else {
4260  v_[ 0UL] = v1;
4261  v_[ MM] = v2;
4262  v_[2UL*MM] = v3;
4263  v_[3UL*MM] = v4;
4264  v_[4UL*MM] = v5;
4265  v_[5UL*MM] = v6;
4266  }
4267 
4268  for( size_t j=0UL; j<N; ++j )
4269  for( size_t i=M; i<MM; ++i ) {
4270  v_[i+j*MM] = Type();
4271  }
4272 }
4274 //*************************************************************************************************
4275 
4276 
4277 //*************************************************************************************************
4300 template< typename Type // Data type of the matrix
4301  , size_t M // Number of rows
4302  , size_t N > // Number of columns
4303 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4304  const Type& v4, const Type& v5, const Type& v6,
4305  const Type& v7 )
4306  : v_() // The statically allocated matrix elements
4307 {
4308  BLAZE_STATIC_ASSERT( M*N == 7UL );
4309  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4310 
4311  // Initialization of a 7x1 matrix
4312  if( N == 1UL ) {
4313  v_[0UL] = v1;
4314  v_[1UL] = v2;
4315  v_[2UL] = v3;
4316  v_[3UL] = v4;
4317  v_[4UL] = v5;
4318  v_[5UL] = v6;
4319  v_[6UL] = v7;
4320  }
4321 
4322  // Initialization of a 1x7 matrix
4323  else {
4324  v_[ 0UL] = v1;
4325  v_[ MM] = v2;
4326  v_[2UL*MM] = v3;
4327  v_[3UL*MM] = v4;
4328  v_[4UL*MM] = v5;
4329  v_[5UL*MM] = v6;
4330  v_[6UL*MM] = v7;
4331  }
4332 
4333  for( size_t j=0UL; j<N; ++j )
4334  for( size_t i=M; i<MM; ++i ) {
4335  v_[i+j*MM] = Type();
4336  }
4337 }
4339 //*************************************************************************************************
4340 
4341 
4342 //*************************************************************************************************
4369 template< typename Type // Data type of the matrix
4370  , size_t M // Number of rows
4371  , size_t N > // Number of columns
4372 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4373  const Type& v4, const Type& v5, const Type& v6,
4374  const Type& v7, const Type& v8 )
4375  : v_() // The statically allocated matrix elements
4376 {
4377  BLAZE_STATIC_ASSERT( M*N == 8UL );
4378  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4379 
4380  // Initialization of a 8x1 matrix
4381  if( N == 1UL ) {
4382  v_[0UL] = v1;
4383  v_[1UL] = v2;
4384  v_[2UL] = v3;
4385  v_[3UL] = v4;
4386  v_[4UL] = v5;
4387  v_[5UL] = v6;
4388  v_[6UL] = v7;
4389  v_[7UL] = v8;
4390  }
4391 
4392  // Initialization of a 4x2 matrix
4393  else if( N == 2UL ) {
4394  v_[ 0UL] = v1;
4395  v_[ 1UL] = v2;
4396  v_[ 2UL] = v3;
4397  v_[ 3UL] = v4;
4398  v_[MM ] = v5;
4399  v_[MM+1UL] = v6;
4400  v_[MM+2UL] = v7;
4401  v_[MM+3UL] = v8;
4402  }
4403 
4404  // Initialization of a 2x4 matrix
4405  else if( N == 4UL ) {
4406  v_[ 0UL] = v1;
4407  v_[ 1UL] = v2;
4408  v_[ MM ] = v3;
4409  v_[ MM+1UL] = v4;
4410  v_[2UL*MM ] = v5;
4411  v_[2UL*MM+1UL] = v6;
4412  v_[3UL*MM ] = v7;
4413  v_[3UL*MM+1UL] = v8;
4414  }
4415 
4416  // Initialization of a 1x8 matrix
4417  else {
4418  v_[ 0UL] = v1;
4419  v_[ MM] = v2;
4420  v_[2UL*MM] = v3;
4421  v_[3UL*MM] = v4;
4422  v_[4UL*MM] = v5;
4423  v_[5UL*MM] = v6;
4424  v_[6UL*MM] = v7;
4425  v_[7UL*MM] = v8;
4426  }
4427 
4428  for( size_t j=0UL; j<N; ++j )
4429  for( size_t i=M; i<MM; ++i ) {
4430  v_[i+j*MM] = Type();
4431  }
4432 }
4434 //*************************************************************************************************
4435 
4436 
4437 //*************************************************************************************************
4465 template< typename Type // Data type of the matrix
4466  , size_t M // Number of rows
4467  , size_t N > // Number of columns
4468 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4469  const Type& v4, const Type& v5, const Type& v6,
4470  const Type& v7, const Type& v8, const Type& v9 )
4471  : v_() // The statically allocated matrix elements
4472 {
4473  BLAZE_STATIC_ASSERT( M*N == 9UL );
4474  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4475 
4476  // Initialization of a 9x1 matrix
4477  if( N == 1 ) {
4478  v_[0UL] = v1;
4479  v_[1UL] = v2;
4480  v_[2UL] = v3;
4481  v_[3UL] = v4;
4482  v_[4UL] = v5;
4483  v_[5UL] = v6;
4484  v_[6UL] = v7;
4485  v_[7UL] = v8;
4486  v_[8UL] = v9;
4487  }
4488 
4489  // Initialization of a 3x3 matrix
4490  else if( N == 3UL ) {
4491  v_[ 0UL] = v1;
4492  v_[ 1UL] = v2;
4493  v_[ 2UL] = v3;
4494  v_[ MM ] = v4;
4495  v_[ MM+1UL] = v5;
4496  v_[ MM+2UL] = v6;
4497  v_[2UL*MM ] = v7;
4498  v_[2UL*MM+1UL] = v8;
4499  v_[2UL*MM+2UL] = v9;
4500  }
4501 
4502  // Initialization of a 1x9 matrix
4503  else {
4504  v_[ 0UL] = v1;
4505  v_[ MM] = v2;
4506  v_[2UL*MM] = v3;
4507  v_[3UL*MM] = v4;
4508  v_[4UL*MM] = v5;
4509  v_[5UL*MM] = v6;
4510  v_[6UL*MM] = v7;
4511  v_[7UL*MM] = v8;
4512  v_[8UL*MM] = v9;
4513  }
4514 
4515  for( size_t j=0UL; j<N; ++j )
4516  for( size_t i=M; i<MM; ++i ) {
4517  v_[i+j*MM] = Type();
4518  }
4519 }
4521 //*************************************************************************************************
4522 
4523 
4524 //*************************************************************************************************
4553 template< typename Type // Data type of the matrix
4554  , size_t M // Number of rows
4555  , size_t N > // Number of columns
4556 inline StaticMatrix<Type,M,N,true>::StaticMatrix( const Type& v1, const Type& v2, const Type& v3,
4557  const Type& v4, const Type& v5, const Type& v6,
4558  const Type& v7, const Type& v8, const Type& v9,
4559  const Type& v10 )
4560  : v_() // The statically allocated matrix elements
4561 {
4562  BLAZE_STATIC_ASSERT( M*N == 10UL );
4563  BLAZE_STATIC_ASSERT( IsVectorizable<Type>::value || MM == M );
4564 
4565  // Initialization of a 10x1 matrix
4566  if( N == 1UL ) {
4567  v_[0UL] = v1;
4568  v_[1UL] = v2;
4569  v_[2UL] = v3;
4570  v_[3UL] = v4;
4571  v_[4UL] = v5;
4572  v_[5UL] = v6;
4573  v_[6UL] = v7;
4574  v_[7UL] = v8;
4575  v_[8UL] = v9;
4576  v_[9UL] = v10;
4577  }
4578 
4579  // Initialization of a 5x2 matrix
4580  else if( N == 2UL ) {
4581  v_[ 0UL] = v1;
4582  v_[ 1UL] = v2;
4583  v_[ 2UL] = v3;
4584  v_[ 3UL] = v4;
4585  v_[ 4UL] = v5;
4586  v_[MM ] = v6;
4587  v_[MM+1UL] = v7;
4588  v_[MM+2UL] = v8;
4589  v_[MM+3UL] = v9;
4590  v_[MM+4UL] = v10;
4591  }
4592 
4593  // Initialization of a 2x5 matrix
4594  else if( N == 5UL ) {
4595  v_[ 0UL] = v1;
4596  v_[ 1UL] = v2;
4597  v_[ MM ] = v3;
4598  v_[ MM+1UL] = v4;
4599  v_[2UL*MM ] = v5;
4600  v_[2UL*MM+1UL] = v6;
4601  v_[3UL*MM ] = v7;
4602  v_[3UL*MM+1UL] = v8;
4603  v_[4UL*MM ] = v9;
4604  v_[4UL*MM+1UL] = v10;
4605  }
4606 
4607  // Initialization of a 1x10 matrix
4608  else {
4609  v_[ 0UL] = v1;
4610  v_[ MM] = v2;
4611  v_[2UL*MM] = v3;
4612  v_[3UL*MM] = v4;
4613  v_[4UL*MM] = v5;
4614  v_[5UL*MM] = v6;
4615  v_[6UL*MM] = v7;
4616  v_[7UL*MM] = v8;
4617  v_[8UL*MM] = v9;
4618  v_[9UL*MM] = v10;
4619  }
4620 
4621  for( size_t j=0UL; j<N; ++j )
4622  for( size_t i=M; i<MM; ++i ) {
4623  v_[i+j*MM] = Type();
4624  }
4625 }
4627 //*************************************************************************************************
4628 
4629 
4630 
4631 
4632 //=================================================================================================
4633 //
4634 // DATA ACCESS FUNCTIONS
4635 //
4636 //=================================================================================================
4637 
4638 //*************************************************************************************************
4649 template< typename Type // Data type of the matrix
4650  , size_t M // Number of rows
4651  , size_t N > // Number of columns
4653  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j )
4654 {
4655  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4656  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4657  return v_[i+j*MM];
4658 }
4660 //*************************************************************************************************
4661 
4662 
4663 //*************************************************************************************************
4674 template< typename Type // Data type of the matrix
4675  , size_t M // Number of rows
4676  , size_t N > // Number of columns
4678  StaticMatrix<Type,M,N,true>::operator()( size_t i, size_t j ) const
4679 {
4680  BLAZE_USER_ASSERT( i<M, "Invalid row access index" );
4681  BLAZE_USER_ASSERT( j<N, "Invalid column access index" );
4682  return v_[i+j*MM];
4683 }
4685 //*************************************************************************************************
4686 
4687 
4688 //*************************************************************************************************
4700 template< typename Type // Data type of the matrix
4701  , size_t M // Number of rows
4702  , size_t N > // Number of columns
4704  StaticMatrix<Type,M,N,true>::at( size_t i, size_t j )
4705 {
4706  if( i >= M ) {
4707  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4708  }
4709  if( j >= N ) {
4710  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4711  }
4712  return (*this)(i,j);
4713 }
4715 //*************************************************************************************************
4716 
4717 
4718 //*************************************************************************************************
4730 template< typename Type // Data type of the matrix
4731  , size_t M // Number of rows
4732  , size_t N > // Number of columns
4734  StaticMatrix<Type,M,N,true>::at( size_t i, size_t j ) const
4735 {
4736  if( i >= M ) {
4737  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
4738  }
4739  if( j >= N ) {
4740  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
4741  }
4742  return (*this)(i,j);
4743 }
4745 //*************************************************************************************************
4746 
4747 
4748 //*************************************************************************************************
4760 template< typename Type // Data type of the matrix
4761  , size_t M // Number of rows
4762  , size_t N > // Number of columns
4763 inline typename StaticMatrix<Type,M,N,true>::Pointer
4765 {
4766  return v_;
4767 }
4769 //*************************************************************************************************
4770 
4771 
4772 //*************************************************************************************************
4784 template< typename Type // Data type of the matrix
4785  , size_t M // Number of rows
4786  , size_t N > // Number of columns
4787 inline typename StaticMatrix<Type,M,N,true>::ConstPointer
4789 {
4790  return v_;
4791 }
4793 //*************************************************************************************************
4794 
4795 
4796 //*************************************************************************************************
4805 template< typename Type // Data type of the matrix
4806  , size_t M // Number of rows
4807  , size_t N > // Number of columns
4808 inline typename StaticMatrix<Type,M,N,true>::Pointer
4810 {
4811  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4812  return v_ + j*MM;
4813 }
4815 //*************************************************************************************************
4816 
4817 
4818 //*************************************************************************************************
4827 template< typename Type // Data type of the matrix
4828  , size_t M // Number of rows
4829  , size_t N > // Number of columns
4830 inline typename StaticMatrix<Type,M,N,true>::ConstPointer
4831  StaticMatrix<Type,M,N,true>::data( size_t j ) const
4832 {
4833  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4834  return v_ + j*MM;
4835 }
4837 //*************************************************************************************************
4838 
4839 
4840 //*************************************************************************************************
4847 template< typename Type // Data type of the matrix
4848  , size_t M // Number of rows
4849  , size_t N > // Number of columns
4852 {
4853  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4854  return Iterator( v_ + j*MM );
4855 }
4857 //*************************************************************************************************
4858 
4859 
4860 //*************************************************************************************************
4867 template< typename Type // Data type of the matrix
4868  , size_t M // Number of rows
4869  , size_t N > // Number of columns
4871  StaticMatrix<Type,M,N,true>::begin( size_t j ) const
4872 {
4873  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4874  return ConstIterator( v_ + j*MM );
4875 }
4877 //*************************************************************************************************
4878 
4879 
4880 //*************************************************************************************************
4887 template< typename Type // Data type of the matrix
4888  , size_t M // Number of rows
4889  , size_t N > // Number of columns
4891  StaticMatrix<Type,M,N,true>::cbegin( size_t j ) const
4892 {
4893  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4894  return ConstIterator( v_ + j*MM );
4895 }
4897 //*************************************************************************************************
4898 
4899 
4900 //*************************************************************************************************
4907 template< typename Type // Data type of the matrix
4908  , size_t M // Number of rows
4909  , size_t N > // Number of columns
4912 {
4913  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4914  return Iterator( v_ + j*MM + M );
4915 }
4917 //*************************************************************************************************
4918 
4919 
4920 //*************************************************************************************************
4927 template< typename Type // Data type of the matrix
4928  , size_t M // Number of rows
4929  , size_t N > // Number of columns
4931  StaticMatrix<Type,M,N,true>::end( size_t j ) const
4932 {
4933  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4934  return ConstIterator( v_ + j*MM + M );
4935 }
4937 //*************************************************************************************************
4938 
4939 
4940 //*************************************************************************************************
4947 template< typename Type // Data type of the matrix
4948  , size_t M // Number of rows
4949  , size_t N > // Number of columns
4951  StaticMatrix<Type,M,N,true>::cend( size_t j ) const
4952 {
4953  BLAZE_USER_ASSERT( j < N, "Invalid dense matrix column access index" );
4954  return ConstIterator( v_ + j*MM + M );
4955 }
4957 //*************************************************************************************************
4958 
4959 
4960 
4961 
4962 //=================================================================================================
4963 //
4964 // ASSIGNMENT OPERATORS
4965 //
4966 //=================================================================================================
4967 
4968 //*************************************************************************************************
4990 template< typename Type // Data type of the matrix
4991  , size_t M // Number of rows
4992  , size_t N > // Number of columns
4993 template< typename Other > // Data type of the initialization array
4994 inline StaticMatrix<Type,M,N,true>&
4995  StaticMatrix<Type,M,N,true>::operator=( const Other (&array)[M][N] )
4996 {
4997  for( size_t j=0UL; j<N; ++j )
4998  for( size_t i=0UL; i<M; ++i )
4999  v_[i+j*MM] = array[i][j];
5000 
5001  return *this;
5002 }
5004 //*************************************************************************************************
5005 
5006 
5007 //*************************************************************************************************
5014 template< typename Type // Data type of the matrix
5015  , size_t M // Number of rows
5016  , size_t N > // Number of columns
5017 inline StaticMatrix<Type,M,N,true>&
5018  StaticMatrix<Type,M,N,true>::operator=( const Type& set )
5019 {
5020  for( size_t j=0UL; j<N; ++j )
5021  for( size_t i=0UL; i<M; ++i )
5022  v_[i+j*MM] = set;
5023 
5024  return *this;
5025 }
5027 //*************************************************************************************************
5028 
5029 
5030 //*************************************************************************************************
5039 template< typename Type // Data type of the matrix
5040  , size_t M // Number of rows
5041  , size_t N > // Number of columns
5042 inline StaticMatrix<Type,M,N,true>&
5043  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix& rhs )
5044 {
5045  using blaze::assign;
5046 
5047  assign( *this, ~rhs );
5048  return *this;
5049 }
5051 //*************************************************************************************************
5052 
5053 
5054 //*************************************************************************************************
5061 template< typename Type // Data type of the matrix
5062  , size_t M // Number of rows
5063  , size_t N > // Number of columns
5064 template< typename Other // Data type of the foreign matrix
5065  , bool SO > // Storage order of the foreign matrix
5066 inline StaticMatrix<Type,M,N,true>&
5067  StaticMatrix<Type,M,N,true>::operator=( const StaticMatrix<Other,M,N,SO>& rhs )
5068 {
5069  using blaze::assign;
5070 
5071  assign( *this, ~rhs );
5072  return *this;
5073 }
5075 //*************************************************************************************************
5076 
5077 
5078 //*************************************************************************************************
5090 template< typename Type // Data type of the matrix
5091  , size_t M // Number of rows
5092  , size_t N > // Number of columns
5093 template< typename MT // Type of the right-hand side matrix
5094  , bool SO > // Storage order of the right-hand side matrix
5095 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator=( const Matrix<MT,SO>& rhs )
5096 {
5097  using blaze::assign;
5098 
5099  typedef typename TransExprTrait<This>::Type TT;
5100  typedef typename CTransExprTrait<This>::Type CT;
5101 
5102  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
5103  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to static matrix" );
5104  }
5105 
5106  if( IsSame<MT,TT>::value && (~rhs).isAliased( this ) ) {
5107  transpose( typename IsSquare<This>::Type() );
5108  }
5109  else if( IsSame<MT,CT>::value && (~rhs).isAliased( this ) ) {
5110  ctranspose( typename IsSquare<This>::Type() );
5111  }
5112  else if( (~rhs).canAlias( this ) ) {
5113  StaticMatrix tmp( ~rhs );
5114  assign( *this, tmp );
5115  }
5116  else {
5117  if( IsSparseMatrix<MT>::value )
5118  reset();
5119  assign( *this, ~rhs );
5120  }
5121 
5122  return *this;
5123 }
5125 //*************************************************************************************************
5126 
5127 
5128 //*************************************************************************************************
5139 template< typename Type // Data type of the matrix
5140  , size_t M // Number of rows
5141  , size_t N > // Number of columns
5142 template< typename MT // Type of the right-hand side matrix
5143  , bool SO > // Storage order of the right-hand side matrix
5144 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator+=( const Matrix<MT,SO>& rhs )
5145 {
5146  using blaze::addAssign;
5147 
5148  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
5149  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
5150  }
5151 
5152  if( (~rhs).canAlias( this ) ) {
5153  const typename MT::ResultType tmp( ~rhs );
5154  addAssign( *this, tmp );
5155  }
5156  else {
5157  addAssign( *this, ~rhs );
5158  }
5159 
5160  return *this;
5161 }
5163 //*************************************************************************************************
5164 
5165 
5166 //*************************************************************************************************
5177 template< typename Type // Data type of the matrix
5178  , size_t M // Number of rows
5179  , size_t N > // Number of columns
5180 template< typename MT // Type of the right-hand side matrix
5181  , bool SO > // Storage order of the right-hand side matrix
5182 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator-=( const Matrix<MT,SO>& rhs )
5183 {
5184  using blaze::subAssign;
5185 
5186  if( (~rhs).rows() != M || (~rhs).columns() != N ) {
5187  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
5188  }
5189 
5190  if( (~rhs).canAlias( this ) ) {
5191  const typename MT::ResultType tmp( ~rhs );
5192  subAssign( *this, tmp );
5193  }
5194  else {
5195  subAssign( *this, ~rhs );
5196  }
5197 
5198  return *this;
5199 }
5201 //*************************************************************************************************
5202 
5203 
5204 //*************************************************************************************************
5215 template< typename Type // Data type of the matrix
5216  , size_t M // Number of rows
5217  , size_t N > // Number of columns
5218 template< typename MT // Type of the right-hand side matrix
5219  , bool SO > // Storage order of the right-hand side matrix
5220 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::operator*=( const Matrix<MT,SO>& rhs )
5221 {
5222  if( M != N || (~rhs).rows() != M || (~rhs).columns() != N ) {
5223  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
5224  }
5225 
5226  const StaticMatrix tmp( *this * (~rhs) );
5227  return this->operator=( tmp );
5228 }
5230 //*************************************************************************************************
5231 
5232 
5233 //*************************************************************************************************
5241 template< typename Type // Data type of the matrix
5242  , size_t M // Number of rows
5243  , size_t N > // Number of columns
5244 template< typename Other > // Data type of the right-hand side scalar
5245 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
5246  StaticMatrix<Type,M,N,true>::operator*=( Other rhs )
5247 {
5248  using blaze::assign;
5249 
5250  assign( *this, (*this) * rhs );
5251  return *this;
5252 }
5254 //*************************************************************************************************
5255 
5256 
5257 //*************************************************************************************************
5267 template< typename Type // Data type of the matrix
5268  , size_t M // Number of rows
5269  , size_t N > // Number of columns
5270 template< typename Other > // Data type of the right-hand side scalar
5271 inline typename EnableIf< IsNumeric<Other>, StaticMatrix<Type,M,N,true> >::Type&
5272  StaticMatrix<Type,M,N,true>::operator/=( Other rhs )
5273 {
5274  using blaze::assign;
5275 
5276  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
5277 
5278  assign( *this, (*this) / rhs );
5279  return *this;
5280 }
5282 //*************************************************************************************************
5283 
5284 
5285 
5286 
5287 //=================================================================================================
5288 //
5289 // UTILITY FUNCTIONS
5290 //
5291 //=================================================================================================
5292 
5293 //*************************************************************************************************
5299 template< typename Type // Data type of the matrix
5300  , size_t M // Number of rows
5301  , size_t N > // Number of columns
5302 inline size_t StaticMatrix<Type,M,N,true>::rows() const
5303 {
5304  return M;
5305 }
5307 //*************************************************************************************************
5308 
5309 
5310 //*************************************************************************************************
5316 template< typename Type // Data type of the matrix
5317  , size_t M // Number of rows
5318  , size_t N > // Number of columns
5319 inline size_t StaticMatrix<Type,M,N,true>::columns() const
5320 {
5321  return N;
5322 }
5324 //*************************************************************************************************
5325 
5326 
5327 //*************************************************************************************************
5336 template< typename Type // Data type of the matrix
5337  , size_t M // Number of rows
5338  , size_t N > // Number of columns
5339 inline size_t StaticMatrix<Type,M,N,true>::spacing() const
5340 {
5341  return MM;
5342 }
5344 //*************************************************************************************************
5345 
5346 
5347 //*************************************************************************************************
5353 template< typename Type // Data type of the matrix
5354  , size_t M // Number of rows
5355  , size_t N > // Number of columns
5356 inline size_t StaticMatrix<Type,M,N,true>::capacity() const
5357 {
5358  return MM*N;
5359 }
5361 //*************************************************************************************************
5362 
5363 
5364 //*************************************************************************************************
5371 template< typename Type // Data type of the matrix
5372  , size_t M // Number of rows
5373  , size_t N > // Number of columns
5374 inline size_t StaticMatrix<Type,M,N,true>::capacity( size_t j ) const
5375 {
5376  UNUSED_PARAMETER( j );
5377 
5378  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5379 
5380  return MM;
5381 }
5383 //*************************************************************************************************
5384 
5385 
5386 //*************************************************************************************************
5392 template< typename Type // Data type of the matrix
5393  , size_t M // Number of rows
5394  , size_t N > // Number of columns
5395 inline size_t StaticMatrix<Type,M,N,true>::nonZeros() const
5396 {
5397  size_t nonzeros( 0UL );
5398 
5399  for( size_t j=0UL; j<N; ++j )
5400  for( size_t i=0UL; i<M; ++i )
5401  if( !isDefault( v_[i+j*MM] ) )
5402  ++nonzeros;
5403 
5404  return nonzeros;
5405 }
5407 //*************************************************************************************************
5408 
5409 
5410 //*************************************************************************************************
5417 template< typename Type // Data type of the matrix
5418  , size_t M // Number of rows
5419  , size_t N > // Number of columns
5420 inline size_t StaticMatrix<Type,M,N,true>::nonZeros( size_t j ) const
5421 {
5422  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5423 
5424  const size_t iend( j*MM + M );
5425  size_t nonzeros( 0UL );
5426 
5427  for( size_t i=j*MM; i<iend; ++i )
5428  if( !isDefault( v_[i] ) )
5429  ++nonzeros;
5430 
5431  return nonzeros;
5432 }
5434 //*************************************************************************************************
5435 
5436 
5437 //*************************************************************************************************
5443 template< typename Type // Data type of the matrix
5444  , size_t M // Number of rows
5445  , size_t N > // Number of columns
5447 {
5448  using blaze::clear;
5449 
5450  for( size_t j=0UL; j<N; ++j )
5451  for( size_t i=0UL; i<M; ++i )
5452  clear( v_[i+j*MM] );
5453 }
5455 //*************************************************************************************************
5456 
5457 
5458 //*************************************************************************************************
5468 template< typename Type // Data type of the matrix
5469  , size_t M // Number of rows
5470  , size_t N > // Number of columns
5471 inline void StaticMatrix<Type,M,N,true>::reset( size_t j )
5472 {
5473  using blaze::clear;
5474 
5475  BLAZE_USER_ASSERT( j < columns(), "Invalid column access index" );
5476  for( size_t i=0UL; i<M; ++i )
5477  clear( v_[i+j*MM] );
5478 }
5480 //*************************************************************************************************
5481 
5482 
5483 //*************************************************************************************************
5492 template< typename Type // Data type of the matrix
5493  , size_t M // Number of rows
5494  , size_t N > // Number of columns
5495 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::transpose()
5496 {
5497  using std::swap;
5498 
5499  BLAZE_STATIC_ASSERT( M == N );
5500 
5501  for( size_t j=1UL; j<N; ++j )
5502  for( size_t i=0UL; i<j; ++i )
5503  swap( v_[i+j*MM], v_[j+i*MM] );
5504 
5505  return *this;
5506 }
5508 //*************************************************************************************************
5509 
5510 
5511 //*************************************************************************************************
5525 template< typename Type // Data type of the matrix
5526  , size_t M // Number of rows
5527  , size_t N > // Number of columns
5529 {
5530  transpose();
5531 }
5533 //*************************************************************************************************
5534 
5535 
5536 //*************************************************************************************************
5550 template< typename Type // Data type of the matrix
5551  , size_t M // Number of rows
5552  , size_t N > // Number of columns
5554 {}
5556 //*************************************************************************************************
5557 
5558 
5559 //*************************************************************************************************
5568 template< typename Type // Data type of the matrix
5569  , size_t M // Number of rows
5570  , size_t N > // Number of columns
5571 inline StaticMatrix<Type,M,N,true>& StaticMatrix<Type,M,N,true>::ctranspose()
5572 {
5573  BLAZE_STATIC_ASSERT( M == N );
5574 
5575  for( size_t j=0UL; j<N; ++j ) {
5576  for( size_t i=0UL; i<j; ++i ) {
5577  cswap( v_[i+j*MM], v_[j+i*MM] );
5578  }
5579  conjugate( v_[j+j*MM] );
5580  }
5581 
5582  return *this;
5583 }
5585 //*************************************************************************************************
5586 
5587 
5588 //*************************************************************************************************
5602 template< typename Type // Data type of the matrix
5603  , size_t M // Number of rows
5604  , size_t N > // Number of columns
5606 {
5607  ctranspose();
5608 }
5610 //*************************************************************************************************
5611 
5612 
5613 //*************************************************************************************************
5627 template< typename Type // Data type of the matrix
5628  , size_t M // Number of rows
5629  , size_t N > // Number of columns
5631 {}
5633 //*************************************************************************************************
5634 
5635 
5636 //*************************************************************************************************
5643 template< typename Type // Data type of the matrix
5644  , size_t M // Number of rows
5645  , size_t N > // Number of columns
5646 template< typename Other > // Data type of the scalar value
5647 inline StaticMatrix<Type,M,N,true>&
5648  StaticMatrix<Type,M,N,true>::scale( const Other& scalar )
5649 {
5650  for( size_t j=0UL; j<N; ++j )
5651  for( size_t i=0UL; i<M; ++i )
5652  v_[i+j*MM] *= scalar;
5653 
5654  return *this;
5655 }
5657 //*************************************************************************************************
5658 
5659 
5660 //*************************************************************************************************
5668 template< typename Type // Data type of the matrix
5669  , size_t M // Number of rows
5670  , size_t N > // Number of columns
5671 inline void StaticMatrix<Type,M,N,true>::swap( StaticMatrix& m ) /* throw() */
5672 {
5673  using std::swap;
5674 
5675  for( size_t j=0UL; j<N; ++j ) {
5676  for( size_t i=0UL; i<M; ++i ) {
5677  swap( v_[i+j*MM], m(i,j) );
5678  }
5679  }
5680 }
5682 //*************************************************************************************************
5683 
5684 
5685 
5686 
5687 //=================================================================================================
5688 //
5689 // MEMORY FUNCTIONS
5690 //
5691 //=================================================================================================
5692 
5693 //*************************************************************************************************
5704 template< typename Type // Data type of the matrix
5705  , size_t M // Number of rows
5706  , size_t N > // Number of columns
5707 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size )
5708 {
5709  UNUSED_PARAMETER( size );
5710 
5711  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5712 
5713  return allocate<StaticMatrix>( 1UL );
5714 }
5716 //*************************************************************************************************
5717 
5718 
5719 //*************************************************************************************************
5730 template< typename Type // Data type of the matrix
5731  , size_t M // Number of rows
5732  , size_t N > // Number of columns
5733 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size )
5734 {
5735  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5736  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5737 
5738  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5739 }
5741 //*************************************************************************************************
5742 
5743 
5744 //*************************************************************************************************
5755 template< typename Type // Data type of the matrix
5756  , size_t M // Number of rows
5757  , size_t N > // Number of columns
5758 inline void* StaticMatrix<Type,M,N,true>::operator new( std::size_t size, const std::nothrow_t& )
5759 {
5760  UNUSED_PARAMETER( size );
5761 
5762  BLAZE_INTERNAL_ASSERT( size == sizeof( StaticMatrix ), "Invalid number of bytes detected" );
5763 
5764  return allocate<StaticMatrix>( 1UL );
5765 }
5767 //*************************************************************************************************
5768 
5769 
5770 //*************************************************************************************************
5781 template< typename Type // Data type of the matrix
5782  , size_t M // Number of rows
5783  , size_t N > // Number of columns
5784 inline void* StaticMatrix<Type,M,N,true>::operator new[]( std::size_t size, const std::nothrow_t& )
5785 {
5786  BLAZE_INTERNAL_ASSERT( size >= sizeof( StaticMatrix ) , "Invalid number of bytes detected" );
5787  BLAZE_INTERNAL_ASSERT( size % sizeof( StaticMatrix ) == 0UL, "Invalid number of bytes detected" );
5788 
5789  return allocate<StaticMatrix>( size/sizeof(StaticMatrix) );
5790 }
5792 //*************************************************************************************************
5793 
5794 
5795 //*************************************************************************************************
5802 template< typename Type // Data type of the matrix
5803  , size_t M // Number of rows
5804  , size_t N > // Number of columns
5805 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr )
5806 {
5807  deallocate( static_cast<StaticMatrix*>( ptr ) );
5808 }
5810 //*************************************************************************************************
5811 
5812 
5813 //*************************************************************************************************
5820 template< typename Type // Data type of the matrix
5821  , size_t M // Number of rows
5822  , size_t N > // Number of columns
5823 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr )
5824 {
5825  deallocate( static_cast<StaticMatrix*>( ptr ) );
5826 }
5828 //*************************************************************************************************
5829 
5830 
5831 //*************************************************************************************************
5838 template< typename Type // Data type of the matrix
5839  , size_t M // Number of rows
5840  , size_t N > // Number of columns
5841 inline void StaticMatrix<Type,M,N,true>::operator delete( void* ptr, const std::nothrow_t& )
5842 {
5843  deallocate( static_cast<StaticMatrix*>( ptr ) );
5844 }
5846 //*************************************************************************************************
5847 
5848 
5849 //*************************************************************************************************
5856 template< typename Type // Data type of the matrix
5857  , size_t M // Number of rows
5858  , size_t N > // Number of columns
5859 inline void StaticMatrix<Type,M,N,true>::operator delete[]( void* ptr, const std::nothrow_t& )
5860 {
5861  deallocate( static_cast<StaticMatrix*>( ptr ) );
5862 }
5864 //*************************************************************************************************
5865 
5866 
5867 
5868 
5869 //=================================================================================================
5870 //
5871 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
5872 //
5873 //=================================================================================================
5874 
5875 //*************************************************************************************************
5886 template< typename Type // Data type of the matrix
5887  , size_t M // Number of rows
5888  , size_t N > // Number of columns
5889 template< typename Other > // Data type of the foreign expression
5890 inline bool StaticMatrix<Type,M,N,true>::canAlias( const Other* alias ) const
5891 {
5892  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5893 }
5895 //*************************************************************************************************
5896 
5897 
5898 //*************************************************************************************************
5909 template< typename Type // Data type of the matrix
5910  , size_t M // Number of rows
5911  , size_t N > // Number of columns
5912 template< typename Other > // Data type of the foreign expression
5913 inline bool StaticMatrix<Type,M,N,true>::isAliased( const Other* alias ) const
5914 {
5915  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
5916 }
5918 //*************************************************************************************************
5919 
5920 
5921 //*************************************************************************************************
5931 template< typename Type // Data type of the matrix
5932  , size_t M // Number of rows
5933  , size_t N > // Number of columns
5934 inline bool StaticMatrix<Type,M,N,true>::isAligned() const
5935 {
5936  return ( usePadding || rows() % IT::size == 0UL );
5937 }
5939 //*************************************************************************************************
5940 
5941 
5942 //*************************************************************************************************
5957 template< typename Type // Data type of the matrix
5958  , size_t M // Number of rows
5959  , size_t N > // Number of columns
5960 BLAZE_ALWAYS_INLINE typename StaticMatrix<Type,M,N,true>::IntrinsicType
5961  StaticMatrix<Type,M,N,true>::load( size_t i, size_t j ) const
5962 {
5963  if( usePadding )
5964  return loada( i, j );
5965  else
5966  return loadu( i, j );
5967 }
5969 //*************************************************************************************************
5970 
5971 
5972 //*************************************************************************************************
5987 template< typename Type // Data type of the matrix
5988  , size_t M // Number of rows
5989  , size_t N > // Number of columns
5990 BLAZE_ALWAYS_INLINE typename StaticMatrix<Type,M,N,true>::IntrinsicType
5991  StaticMatrix<Type,M,N,true>::loada( size_t i, size_t j ) const
5992 {
5993  using blaze::loada;
5994 
5996 
5997  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
5998  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
5999  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
6000  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
6001  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i+j*MM] ), "Invalid alignment detected" );
6002 
6003  return loada( &v_[i+j*MM] );
6004 }
6006 //*************************************************************************************************
6007 
6008 
6009 //*************************************************************************************************
6024 template< typename Type // Data type of the matrix
6025  , size_t M // Number of rows
6026  , size_t N > // Number of columns
6027 BLAZE_ALWAYS_INLINE typename StaticMatrix<Type,M,N,true>::IntrinsicType
6028  StaticMatrix<Type,M,N,true>::loadu( size_t i, size_t j ) const
6029 {
6030  using blaze::loadu;
6031 
6033 
6034  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
6035  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
6036  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
6037 
6038  return loadu( &v_[i+j*MM] );
6039 }
6041 //*************************************************************************************************
6042 
6043 
6044 //*************************************************************************************************
6060 template< typename Type // Data type of the matrix
6061  , size_t M // Number of rows
6062  , size_t N > // Number of columns
6064  StaticMatrix<Type,M,N,true>::store( size_t i, size_t j, const IntrinsicType& value )
6065 {
6066  if( usePadding )
6067  storea( i, j, value );
6068  else
6069  storeu( i, j, value );
6070 }
6072 //*************************************************************************************************
6073 
6074 
6075 //*************************************************************************************************
6091 template< typename Type // Data type of the matrix
6092  , size_t M // Number of rows
6093  , size_t N > // Number of columns
6095  StaticMatrix<Type,M,N,true>::storea( size_t i, size_t j, const IntrinsicType& value )
6096 {
6097  using blaze::storea;
6098 
6100 
6101  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
6102  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
6103  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
6104  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
6105  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i+j*MM] ), "Invalid alignment detected" );
6106 
6107  storea( &v_[i+j*MM], value );
6108 }
6110 //*************************************************************************************************
6111 
6112 
6113 //*************************************************************************************************
6129 template< typename Type // Data type of the matrix
6130  , size_t M // Number of rows
6131  , size_t N > // Number of columns
6133  StaticMatrix<Type,M,N,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
6134 {
6135  using blaze::storeu;
6136 
6138 
6139  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
6140  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
6141  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
6142 
6143  storeu( &v_[i+j*MM], value );
6144 }
6146 //*************************************************************************************************
6147 
6148 
6149 //*************************************************************************************************
6165 template< typename Type // Data type of the matrix
6166  , size_t M // Number of rows
6167  , size_t N > // Number of columns
6169  StaticMatrix<Type,M,N,true>::stream( size_t i, size_t j, const IntrinsicType& value )
6170 {
6171  using blaze::stream;
6172 
6174 
6175  BLAZE_INTERNAL_ASSERT( i < M, "Invalid row access index" );
6176  BLAZE_INTERNAL_ASSERT( i + IT::size <= MM, "Invalid row access index" );
6177  BLAZE_INTERNAL_ASSERT( !usePadding || i % IT::size == 0UL, "Invalid row access index" );
6178  BLAZE_INTERNAL_ASSERT( j < N, "Invalid column access index" );
6179  BLAZE_INTERNAL_ASSERT( checkAlignment( &v_[i+j*MM] ), "Invalid alignment detected" );
6180 
6181  stream( &v_[i+j*MM], value );
6182 }
6184 //*************************************************************************************************
6185 
6186 
6187 //*************************************************************************************************
6199 template< typename Type // Data type of the matrix
6200  , size_t M // Number of rows
6201  , size_t N > // Number of columns
6202 template< typename MT // Type of the right-hand side dense matrix
6203  , bool SO > // Storage order of the right-hand side dense matrix
6204 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
6205  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
6206 {
6207  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6208 
6209  for( size_t j=0UL; j<N; ++j ) {
6210  for( size_t i=0UL; i<M; ++i ) {
6211  v_[i+j*MM] = (~rhs)(i,j);
6212  }
6213  }
6214 }
6216 //*************************************************************************************************
6217 
6218 
6219 //*************************************************************************************************
6231 template< typename Type // Data type of the matrix
6232  , size_t M // Number of rows
6233  , size_t N > // Number of columns
6234 template< typename MT // Type of the right-hand side dense matrix
6235  , bool SO > // Storage order of the right-hand side dense matrix
6236 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
6237  StaticMatrix<Type,M,N,true>::assign( const DenseMatrix<MT,SO>& rhs )
6238 {
6240 
6241  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6242 
6243  const bool remainder( !usePadding || !IsPadded<MT>::value );
6244 
6245  const size_t ipos( ( remainder )?( M & size_t(-IT::size) ):( M ) );
6246  BLAZE_INTERNAL_ASSERT( !remainder || ( M - ( M % (IT::size) ) ) == ipos, "Invalid end calculation" );
6247 
6248  for( size_t j=0UL; j<N; ++j )
6249  {
6250  size_t i( 0UL );
6251 
6252  for( ; i<ipos; i+=IT::size ) {
6253  store( i, j, (~rhs).load(i,j) );
6254  }
6255  for( ; remainder && i<M; ++i ) {
6256  v_[i+j*MM] = (~rhs)(i,j);
6257  }
6258  }
6259 }
6261 //*************************************************************************************************
6262 
6263 
6264 //*************************************************************************************************
6276 template< typename Type // Data type of the matrix
6277  , size_t M // Number of rows
6278  , size_t N > // Number of columns
6279 template< typename MT > // Type of the right-hand side sparse matrix
6280 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,true>& rhs )
6281 {
6282  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6283 
6284  typedef typename MT::ConstIterator RhsConstIterator;
6285 
6286  for( size_t j=0UL; j<N; ++j )
6287  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6288  v_[element->index()+j*MM] = element->value();
6289 }
6291 //*************************************************************************************************
6292 
6293 
6294 //*************************************************************************************************
6306 template< typename Type // Data type of the matrix
6307  , size_t M // Number of rows
6308  , size_t N > // Number of columns
6309 template< typename MT > // Type of the right-hand side sparse matrix
6310 inline void StaticMatrix<Type,M,N,true>::assign( const SparseMatrix<MT,false>& rhs )
6311 {
6313 
6314  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6315 
6316  typedef typename MT::ConstIterator RhsConstIterator;
6317 
6318  for( size_t i=0UL; i<M; ++i )
6319  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6320  v_[i+element->index()*MM] = element->value();
6321 }
6323 //*************************************************************************************************
6324 
6325 
6326 //*************************************************************************************************
6338 template< typename Type // Data type of the matrix
6339  , size_t M // Number of rows
6340  , size_t N > // Number of columns
6341 template< typename MT // Type of the right-hand side dense matrix
6342  , bool SO > // Storage order of the right-hand side dense matrix
6343 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
6344  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
6345 {
6346  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6347 
6348  for( size_t j=0UL; j<N; ++j )
6349  {
6350  if( IsDiagonal<MT>::value )
6351  {
6352  v_[j+j*MM] += (~rhs)(j,j);
6353  }
6354  else
6355  {
6356  const size_t ibegin( ( IsLower<MT>::value )
6357  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
6358  :( 0UL ) );
6359  const size_t iend ( ( IsUpper<MT>::value )
6360  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6361  :( M ) );
6362  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
6363 
6364  for( size_t i=ibegin; i<iend; ++i ) {
6365  v_[i+j*MM] += (~rhs)(i,j);
6366  }
6367  }
6368  }
6369 }
6371 //*************************************************************************************************
6372 
6373 
6374 //*************************************************************************************************
6386 template< typename Type // Data type of the matrix
6387  , size_t M // Number of rows
6388  , size_t N > // Number of columns
6389 template< typename MT // Type of the right-hand side dense matrix
6390  , bool SO > // Storage order of the right-hand side dense matrix
6391 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
6392  StaticMatrix<Type,M,N,true>::addAssign( const DenseMatrix<MT,SO>& rhs )
6393 {
6396 
6397  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6398 
6399  const bool remainder( !usePadding || !IsPadded<MT>::value );
6400 
6401  for( size_t j=0UL; j<N; ++j )
6402  {
6403  const size_t ibegin( ( IsLower<MT>::value )
6404  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
6405  :( 0UL ) );
6406  const size_t iend ( ( IsUpper<MT>::value )
6407  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6408  :( M ) );
6409  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
6410 
6411  const size_t ipos( ( remainder )?( iend & size_t(-IT::size) ):( iend ) );
6412  BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (IT::size) ) ) == ipos, "Invalid end calculation" );
6413 
6414  size_t i( ibegin );
6415 
6416  for( ; i<ipos; i+=IT::size ) {
6417  store( i, j, load(i,j) + (~rhs).load(i,j) );
6418  }
6419  for( ; remainder && i<iend; ++i ) {
6420  v_[i+j*MM] += (~rhs)(i,j);
6421  }
6422  }
6423 }
6425 //*************************************************************************************************
6426 
6427 
6428 //*************************************************************************************************
6440 template< typename Type // Data type of the matrix
6441  , size_t M // Number of rows
6442  , size_t N > // Number of columns
6443 template< typename MT > // Type of the right-hand side sparse matrix
6444 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,true>& rhs )
6445 {
6446  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6447 
6448  typedef typename MT::ConstIterator RhsConstIterator;
6449 
6450  for( size_t j=0UL; j<N; ++j )
6451  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6452  v_[element->index()+j*MM] += element->value();
6453 }
6455 //*************************************************************************************************
6456 
6457 
6458 //*************************************************************************************************
6470 template< typename Type // Data type of the matrix
6471  , size_t M // Number of rows
6472  , size_t N > // Number of columns
6473 template< typename MT > // Type of the right-hand side sparse matrix
6474 inline void StaticMatrix<Type,M,N,true>::addAssign( const SparseMatrix<MT,false>& rhs )
6475 {
6477 
6478  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6479 
6480  typedef typename MT::ConstIterator RhsConstIterator;
6481 
6482  for( size_t i=0UL; i<M; ++i )
6483  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6484  v_[i+element->index()*MM] += element->value();
6485 }
6487 //*************************************************************************************************
6488 
6489 
6490 //*************************************************************************************************
6502 template< typename Type // Data type of the matrix
6503  , size_t M // Number of rows
6504  , size_t N > // Number of columns
6505 template< typename MT // Type of the right-hand side dense matrix
6506  , bool SO > // Storage order of the right-hand side dense matrix
6507 inline typename DisableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
6508  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
6509 {
6510  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6511 
6512  for( size_t j=0UL; j<N; ++j )
6513  {
6514  if( IsDiagonal<MT>::value )
6515  {
6516  v_[j+j*MM] -= (~rhs)(j,j);
6517  }
6518  else
6519  {
6520  const size_t ibegin( ( IsLower<MT>::value )
6521  ?( IsStrictlyLower<MT>::value ? j+1UL : j )
6522  :( 0UL ) );
6523  const size_t iend ( ( IsUpper<MT>::value )
6524  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6525  :( M ) );
6526  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
6527 
6528  for( size_t i=ibegin; i<iend; ++i ) {
6529  v_[i+j*MM] -= (~rhs)(i,j);
6530  }
6531  }
6532  }
6533 }
6535 //*************************************************************************************************
6536 
6537 
6538 //*************************************************************************************************
6550 template< typename Type // Data type of the matrix
6551  , size_t M // Number of rows
6552  , size_t N > // Number of columns
6553 template< typename MT // Type of the right-hand side dense matrix
6554  , bool SO > // Storage order of the right-hand side dense matrix
6555 inline typename EnableIf< typename StaticMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
6556  StaticMatrix<Type,M,N,true>::subAssign( const DenseMatrix<MT,SO>& rhs )
6557 {
6560 
6561  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6562 
6563  const bool remainder( !usePadding || !IsPadded<MT>::value );
6564 
6565  for( size_t j=0UL; j<N; ++j )
6566  {
6567  const size_t ibegin( ( IsLower<MT>::value )
6568  ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) & size_t(-IT::size) )
6569  :( 0UL ) );
6570  const size_t iend ( ( IsUpper<MT>::value )
6571  ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
6572  :( M ) );
6573  BLAZE_INTERNAL_ASSERT( ibegin <= iend, "Invalid loop indices detected" );
6574 
6575  const size_t ipos( ( remainder )?( iend & size_t(-IT::size) ):( iend ) );
6576  BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (IT::size) ) ) == ipos, "Invalid end calculation" );
6577 
6578  size_t i( ibegin );
6579 
6580  for( ; i<ipos; i+=IT::size ) {
6581  store( i, j, load(i,j) - (~rhs).load(i,j) );
6582  }
6583  for( ; remainder && i<iend; ++i ) {
6584  v_[i+j*MM] -= (~rhs)(i,j);
6585  }
6586  }
6587 }
6589 //*************************************************************************************************
6590 
6591 
6592 //*************************************************************************************************
6604 template< typename Type // Data type of the matrix
6605  , size_t M // Number of rows
6606  , size_t N > // Number of columns
6607 template< typename MT > // Type of the right-hand side sparse matrix
6608 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,true>& rhs )
6609 {
6610  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6611 
6612  typedef typename MT::ConstIterator RhsConstIterator;
6613 
6614  for( size_t j=0UL; j<N; ++j )
6615  for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6616  v_[element->index()+j*MM] -= element->value();
6617 }
6619 //*************************************************************************************************
6620 
6621 
6622 //*************************************************************************************************
6634 template< typename Type // Data type of the matrix
6635  , size_t M // Number of rows
6636  , size_t N > // Number of columns
6637 template< typename MT > // Type of the right-hand side sparse matrix
6638 inline void StaticMatrix<Type,M,N,true>::subAssign( const SparseMatrix<MT,false>& rhs )
6639 {
6641 
6642  BLAZE_INTERNAL_ASSERT( (~rhs).rows() == M && (~rhs).columns() == N, "Invalid matrix size" );
6643 
6644  typedef typename MT::ConstIterator RhsConstIterator;
6645 
6646  for( size_t i=0UL; i<M; ++i )
6647  for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6648  v_[i+element->index()*MM] -= element->value();
6649 }
6651 //*************************************************************************************************
6652 
6653 
6654 
6655 
6656 
6657 
6658 
6659 
6660 //=================================================================================================
6661 //
6662 // UNDEFINED CLASS TEMPLATE SPECIALIZATIONS
6663 //
6664 //=================================================================================================
6665 
6666 //*************************************************************************************************
6674 template< typename Type // Data type of the matrix
6675  , size_t M // Number of rows
6676  , bool SO > // Storage order
6677 class StaticMatrix<Type,M,0UL,SO>;
6679 //*************************************************************************************************
6680 
6681 
6682 //*************************************************************************************************
6690 template< typename Type // Data type of the matrix
6691  , size_t N // Number of columns
6692  , bool SO > // Storage order
6693 class StaticMatrix<Type,0UL,N,SO>;
6695 //*************************************************************************************************
6696 
6697 
6698 //*************************************************************************************************
6706 template< typename Type // Data type of the matrix
6707  , bool SO > // Storage order
6708 class StaticMatrix<Type,0UL,0UL,SO>;
6710 //*************************************************************************************************
6711 
6712 
6713 
6714 
6715 
6716 
6717 
6718 
6719 //=================================================================================================
6720 //
6721 // STATICMATRIX OPERATORS
6722 //
6723 //=================================================================================================
6724 
6725 //*************************************************************************************************
6728 template< typename Type, size_t M, size_t N, bool SO >
6729 inline void reset( StaticMatrix<Type,M,N,SO>& m );
6730 
6731 template< typename Type, size_t M, size_t N, bool SO >
6732 inline void reset( StaticMatrix<Type,M,N,SO>& m, size_t i );
6733 
6734 template< typename Type, size_t M, size_t N, bool SO >
6735 inline void clear( StaticMatrix<Type,M,N,SO>& m );
6736 
6737 template< typename Type, size_t M, size_t N, bool SO >
6738 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m );
6739 
6740 template< typename Type, size_t M, size_t N, bool SO >
6741 inline bool isIntact( const StaticMatrix<Type,M,N,SO>& m );
6742 
6743 template< typename Type, size_t M, size_t N, bool SO >
6744 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */;
6745 
6746 template< typename Type, size_t M, size_t N, bool SO >
6747 inline void move( StaticMatrix<Type,M,N,SO>& dst, StaticMatrix<Type,M,N,SO>& src ) /* throw() */;
6749 //*************************************************************************************************
6750 
6751 
6752 //*************************************************************************************************
6759 template< typename Type // Data type of the matrix
6760  , size_t M // Number of rows
6761  , size_t N // Number of columns
6762  , bool SO > // Storage order
6764 {
6765  m.reset();
6766 }
6767 //*************************************************************************************************
6768 
6769 
6770 //*************************************************************************************************
6783 template< typename Type // Data type of the matrix
6784  , size_t M // Number of rows
6785  , size_t N // Number of columns
6786  , bool SO > // Storage order
6787 inline void reset( StaticMatrix<Type,M,N,SO>& m, size_t i )
6788 {
6789  m.reset( i );
6790 }
6791 //*************************************************************************************************
6792 
6793 
6794 //*************************************************************************************************
6803 template< typename Type // Data type of the matrix
6804  , size_t M // Number of rows
6805  , size_t N // Number of columns
6806  , bool SO > // Storage order
6808 {
6809  m.reset();
6810 }
6811 //*************************************************************************************************
6812 
6813 
6814 //*************************************************************************************************
6831 template< typename Type // Data type of the matrix
6832  , size_t M // Number of rows
6833  , size_t N // Number of columns
6834  , bool SO > // Storage order
6835 inline bool isDefault( const StaticMatrix<Type,M,N,SO>& m )
6836 {
6837  if( SO == rowMajor ) {
6838  for( size_t i=0UL; i<M; ++i )
6839  for( size_t j=0UL; j<N; ++j )
6840  if( !isDefault( m(i,j) ) ) return false;
6841  }
6842  else {
6843  for( size_t j=0UL; j<N; ++j )
6844  for( size_t i=0UL; i<M; ++i )
6845  if( !isDefault( m(i,j) ) ) return false;
6846  }
6847 
6848  return true;
6849 }
6850 //*************************************************************************************************
6851 
6852 
6853 //*************************************************************************************************
6871 template< typename Type // Data type of the matrix
6872  , size_t M // Number of rows
6873  , size_t N // Number of columns
6874  , bool SO > // Storage order
6875 inline bool isIntact( const StaticMatrix<Type,M,N,SO>& m )
6876 {
6877  UNUSED_PARAMETER( m );
6878 
6879  return true;
6880 }
6881 //*************************************************************************************************
6882 
6883 
6884 //*************************************************************************************************
6893 template< typename Type // Data type of the matrix
6894  , size_t M // Number of rows
6895  , size_t N // Number of columns
6896  , bool SO > // Storage order
6897 inline void swap( StaticMatrix<Type,M,N,SO>& a, StaticMatrix<Type,M,N,SO>& b ) /* throw() */
6898 {
6899  a.swap( b );
6900 }
6901 //*************************************************************************************************
6902 
6903 
6904 //*************************************************************************************************
6913 template< typename Type // Data type of the matrix
6914  , size_t M // Number of rows
6915  , size_t N // Number of columns
6916  , bool SO > // Storage order
6917 inline void move( StaticMatrix<Type,M,N,SO>& dst, StaticMatrix<Type,M,N,SO>& src ) /* throw() */
6918 {
6919  dst = src;
6920 }
6921 //*************************************************************************************************
6922 
6923 
6924 
6925 
6926 //=================================================================================================
6927 //
6928 // ROWS SPECIALIZATIONS
6929 //
6930 //=================================================================================================
6931 
6932 //*************************************************************************************************
6934 template< typename T, size_t M, size_t N, bool SO >
6935 struct Rows< StaticMatrix<T,M,N,SO> > : public SizeT<M>
6936 {};
6938 //*************************************************************************************************
6939 
6940 
6941 
6942 
6943 //=================================================================================================
6944 //
6945 // COLUMNS SPECIALIZATIONS
6946 //
6947 //=================================================================================================
6948 
6949 //*************************************************************************************************
6951 template< typename T, size_t M, size_t N, bool SO >
6952 struct Columns< StaticMatrix<T,M,N,SO> > : public SizeT<N>
6953 {};
6955 //*************************************************************************************************
6956 
6957 
6958 
6959 
6960 //=================================================================================================
6961 //
6962 // ISSQUARE SPECIALIZATIONS
6963 //
6964 //=================================================================================================
6965 
6966 //*************************************************************************************************
6968 template< typename T, size_t N, bool SO >
6969 struct IsSquare< StaticMatrix<T,N,N,SO> > : public IsTrue<true>
6970 {};
6972 //*************************************************************************************************
6973 
6974 
6975 
6976 
6977 //=================================================================================================
6978 //
6979 // HASCONSTDATAACCESS SPECIALIZATIONS
6980 //
6981 //=================================================================================================
6982 
6983 //*************************************************************************************************
6985 template< typename T, size_t M, size_t N, bool SO >
6986 struct HasConstDataAccess< StaticMatrix<T,M,N,SO> > : public IsTrue<true>
6987 {};
6989 //*************************************************************************************************
6990 
6991 
6992 
6993 
6994 //=================================================================================================
6995 //
6996 // HASMUTABLEDATAACCESS SPECIALIZATIONS
6997 //
6998 //=================================================================================================
6999 
7000 //*************************************************************************************************
7002 template< typename T, size_t M, size_t N, bool SO >
7003 struct HasMutableDataAccess< StaticMatrix<T,M,N,SO> > : public IsTrue<true>
7004 {};
7006 //*************************************************************************************************
7007 
7008 
7009 
7010 
7011 //=================================================================================================
7012 //
7013 // ISALIGNED SPECIALIZATIONS
7014 //
7015 //=================================================================================================
7016 
7017 //*************************************************************************************************
7019 template< typename T, size_t M, size_t N, bool SO >
7020 struct IsAligned< StaticMatrix<T,M,N,SO> > : public IsTrue<usePadding>
7021 {};
7023 //*************************************************************************************************
7024 
7025 
7026 
7027 
7028 //=================================================================================================
7029 //
7030 // ISPADDED SPECIALIZATIONS
7031 //
7032 //=================================================================================================
7033 
7034 //*************************************************************************************************
7036 template< typename T, size_t M, size_t N, bool SO >
7037 struct IsPadded< StaticMatrix<T,M,N,SO> > : public IsTrue<usePadding>
7038 {};
7040 //*************************************************************************************************
7041 
7042 
7043 
7044 
7045 //=================================================================================================
7046 //
7047 // ADDTRAIT SPECIALIZATIONS
7048 //
7049 //=================================================================================================
7050 
7051 //*************************************************************************************************
7053 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7054 struct AddTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
7055 {
7056  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
7057 };
7058 
7059 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
7060 struct AddTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
7061 {
7062  typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, false > Type;
7063 };
7065 //*************************************************************************************************
7066 
7067 
7068 
7069 
7070 //=================================================================================================
7071 //
7072 // SUBTRAIT SPECIALIZATIONS
7073 //
7074 //=================================================================================================
7075 
7076 //*************************************************************************************************
7078 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7079 struct SubTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
7080 {
7081  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
7082 };
7083 
7084 template< typename T1, size_t M, size_t N, bool SO1, typename T2, bool SO2 >
7085 struct SubTrait< StaticMatrix<T1,M,N,SO1>, StaticMatrix<T2,M,N,SO2> >
7086 {
7087  typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, false > Type;
7088 };
7090 //*************************************************************************************************
7091 
7092 
7093 
7094 
7095 //=================================================================================================
7096 //
7097 // MULTTRAIT SPECIALIZATIONS
7098 //
7099 //=================================================================================================
7100 
7101 //*************************************************************************************************
7103 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7104 struct MultTrait< StaticMatrix<T1,M,N,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
7105 {
7106  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
7107 };
7108 
7109 template< typename T1, typename T2, size_t M, size_t N, bool SO >
7110 struct MultTrait< T1, StaticMatrix<T2,M,N,SO>, typename EnableIf< IsNumeric<T1> >::Type >
7111 {
7112  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
7113 };
7114 
7115 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7116 struct MultTrait< StaticMatrix<T1,M,N,SO>, StaticVector<T2,N,false> >
7117 {
7118  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
7119 };
7120 
7121 template< typename T1, size_t M, typename T2, size_t N, bool SO >
7122 struct MultTrait< StaticVector<T1,M,true>, StaticMatrix<T2,M,N,SO> >
7123 {
7124  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
7125 };
7126 
7127 template< typename T1, size_t M, size_t N, bool SO, typename T2, size_t L >
7128 struct MultTrait< StaticMatrix<T1,M,N,SO>, HybridVector<T2,L,false> >
7129 {
7130  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
7131 };
7132 
7133 template< typename T1, size_t L, typename T2, size_t M, size_t N, bool SO >
7134 struct MultTrait< HybridVector<T1,L,true>, StaticMatrix<T2,M,N,SO> >
7135 {
7136  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
7137 };
7138 
7139 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7140 struct MultTrait< StaticMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
7141 {
7142  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
7143 };
7144 
7145 template< typename T1, typename T2, size_t M, size_t N, bool SO >
7146 struct MultTrait< DynamicVector<T1,true>, StaticMatrix<T2,M,N,SO> >
7147 {
7148  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
7149 };
7150 
7151 template< typename T1, size_t M, size_t N, bool SO, typename T2, bool AF, bool PF >
7152 struct MultTrait< StaticMatrix<T1,M,N,SO>, CustomVector<T2,AF,PF,false> >
7153 {
7154  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
7155 };
7156 
7157 template< typename T1, bool AF, bool PF, typename T2, size_t M, size_t N, bool SO >
7158 struct MultTrait< CustomVector<T1,AF,PF,true>, StaticMatrix<T2,M,N,SO> >
7159 {
7160  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
7161 };
7162 
7163 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7164 struct MultTrait< StaticMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
7165 {
7166  typedef StaticVector< typename MultTrait<T1,T2>::Type, M, false > Type;
7167 };
7168 
7169 template< typename T1, typename T2, size_t M, size_t N, bool SO >
7170 struct MultTrait< CompressedVector<T1,true>, StaticMatrix<T2,M,N,SO> >
7171 {
7172  typedef StaticVector< typename MultTrait<T1,T2>::Type, N, true > Type;
7173 };
7174 
7175 template< typename T1, size_t M, size_t K, bool SO1, typename T2, size_t N, bool SO2 >
7176 struct MultTrait< StaticMatrix<T1,M,K,SO1>, StaticMatrix<T2,K,N,SO2> >
7177 {
7178  typedef StaticMatrix< typename MultTrait<T1,T2>::Type, M, N, SO1 > Type;
7179 };
7181 //*************************************************************************************************
7182 
7183 
7184 
7185 
7186 //=================================================================================================
7187 //
7188 // DIVTRAIT SPECIALIZATIONS
7189 //
7190 //=================================================================================================
7191 
7192 //*************************************************************************************************
7194 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7195 struct DivTrait< StaticMatrix<T1,M,N,SO>, T2, typename EnableIf< IsNumeric<T2> >::Type >
7196 {
7197  typedef StaticMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
7198 };
7200 //*************************************************************************************************
7201 
7202 
7203 
7204 
7205 //=================================================================================================
7206 //
7207 // MATHTRAIT SPECIALIZATIONS
7208 //
7209 //=================================================================================================
7210 
7211 //*************************************************************************************************
7213 template< typename T1, size_t M, size_t N, bool SO, typename T2 >
7214 struct MathTrait< StaticMatrix<T1,M,N,SO>, StaticMatrix<T2,M,N,SO> >
7215 {
7216  typedef StaticMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
7217  typedef StaticMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
7218 };
7220 //*************************************************************************************************
7221 
7222 
7223 
7224 
7225 //=================================================================================================
7226 //
7227 // SUBMATRIXTRAIT SPECIALIZATIONS
7228 //
7229 //=================================================================================================
7230 
7231 //*************************************************************************************************
7233 template< typename T1, size_t M, size_t N, bool SO >
7234 struct SubmatrixTrait< StaticMatrix<T1,M,N,SO> >
7235 {
7236  typedef HybridMatrix<T1,M,N,SO> Type;
7237 };
7239 //*************************************************************************************************
7240 
7241 
7242 
7243 
7244 //=================================================================================================
7245 //
7246 // ROWTRAIT SPECIALIZATIONS
7247 //
7248 //=================================================================================================
7249 
7250 //*************************************************************************************************
7252 template< typename T1, size_t M, size_t N, bool SO >
7253 struct RowTrait< StaticMatrix<T1,M,N,SO> >
7254 {
7255  typedef StaticVector<T1,N,true> Type;
7256 };
7258 //*************************************************************************************************
7259 
7260 
7261 
7262 
7263 //=================================================================================================
7264 //
7265 // COLUMNTRAIT SPECIALIZATIONS
7266 //
7267 //=================================================================================================
7268 
7269 //*************************************************************************************************
7271 template< typename T1, size_t M, size_t N, bool SO >
7272 struct ColumnTrait< StaticMatrix<T1,M,N,SO> >
7273 {
7274  typedef StaticVector<T1,M,false> Type;
7275 };
7277 //*************************************************************************************************
7278 
7279 } // namespace blaze
7280 
7281 #endif
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:118
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
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2796
Header file for the NextMultiple class template.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the alignment flag values.
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: StaticMatrix.h:2171
Header file for basic type definitions.
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: StaticMatrix.h:208
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:252
DenseIterator< const Type, usePadding > ConstIterator
Iterator over constant elements.
Definition: StaticMatrix.h:233
Header file for the row trait.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: StaticMatrix.h:2660
BLAZE_ALWAYS_INLINE void storea(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2863
Header file for the IsSparseMatrix type trait.
Header file for the FalseType type/value trait base class.
Header file for the IsDiagonal type trait.
StaticMatrix()
The default constructor for StaticMatrix.
Definition: StaticMatrix.h:526
StaticMatrix< ET, M, N, SO > Other
The type of the other StaticMatrix.
Definition: StaticMatrix.h:241
Header file for the IsSame and IsStrictlySame type traits.
StaticMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: StaticMatrix.h:221
Header file for the IsColumnMajorMatrix type trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
StaticMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: StaticMatrix.h:220
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:584
static const size_t NN
Alignment adjustment.
Definition: StaticMatrix.h:213
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
Header file for the SizeT class template.
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1693
Header file for memory allocation and deallocation functionality.
void move(CustomMatrix< Type, AF, PF, SO > &dst, CustomMatrix< Type, AF, PF, SO > &src)
Moving the contents of one custom matrix to another.
Definition: CustomMatrix.h:6085
System settings for performance optimizations.
This ResultType
Result type for expression template evaluations.
Definition: StaticMatrix.h:219
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: StaticMatrix.h:482
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:117
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: StaticMatrix.h:2702
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: StaticMatrix.h:230
Header file for the SparseMatrix base class.
Header file for the IsSquare type trait.
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const IntrinsicType &value)
Store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2832
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: StaticMatrix.h:1741
const Type & ConstReference
Reference to a constant matrix value.
Definition: StaticMatrix.h:228
Header file for the DisableIf class template.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:74
StaticMatrix & transpose()
In-place transpose of the matrix.
Definition: StaticMatrix.h:2274
void swap(StaticMatrix &m)
Swapping the contents of two static matrices.
Definition: StaticMatrix.h:2450
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for nested template disabiguation.
Compile time assertion.
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: StaticMatrix.h:223
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const simd_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:75
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2901
#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
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:75
Type & Reference
Reference to a non-constant matrix value.
Definition: StaticMatrix.h:227
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Efficient implementation of a fixed-sized matrix.The StaticMatrix class template is the representatio...
Definition: Forward.h:60
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:227
Header file for the DenseIterator class template.
BLAZE_ALWAYS_INLINE void conjugate(T &a)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
void reset()
Reset to the default initial values.
Definition: StaticMatrix.h:2225
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2729
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2937
Constraint on the data type.
StaticMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: StaticMatrix.h:2351
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:116
size_t columns() const
Returns the current number of columns of the matrix.
Definition: StaticMatrix.h:2094
Header file for the IsLower type trait.
Compile time check for square matrices.This type trait tests whether or not the given template parame...
Definition: IsSquare.h:87
Header file for the IsAligned type trait.
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:92
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: StaticMatrix.h:1473
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:2129
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: StaticMatrix.h:2682
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1669
Header file for the IsPadded type trait.
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: StaticMatrix.h:1621
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: StaticMatrix.h:1424
Header file for the IsVectorizable type trait.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Type ElementType
Type of the matrix elements.
Definition: StaticMatrix.h:222
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loada(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loada.h:77
const This & CompositeType
Data type for composite expression templates.
Definition: StaticMatrix.h:225
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Compile time integral constant wrapper for size_t.The SizeT class template represents an integral wra...
Definition: SizeT.h:72
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:1232
Header file for run time assertion macros.
Pointer data()
Low-level data access to the matrix elements.
Definition: StaticMatrix.h:1532
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
Type * Pointer
Pointer to a non-constant matrix value.
Definition: StaticMatrix.h:229
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.
const bool useOptimizedKernels
Configuration switch for optimized kernels.This configuration switch enables/disables all optimized c...
Definition: Optimizations.h:84
Header file for the AlignedArray implementation.
const bool usePadding
Configuration of the padding of dense vectors and matrices.This configuration switch enables/disables...
Definition: Optimizations.h:52
#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:2591
Header file for the column trait.
Header file for the isDefault shim.
Header file for the TransExprTrait class template.
Constraint on the data type.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
Constraint on the data type.
Constraint on the data type.
Header file for the HasMutableDataAccess type trait.
Evaluation of the return type of a conjugate transpose expression.Via this type trait it is possible ...
Definition: CTransExprTrait.h:87
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:59
Header file for all intrinsic functionality.
Header file for the mathematical trait.
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
Evaluation of the return type of a transpose expression.Via this type trait it is possible to evaluat...
Definition: TransExprTrait.h:87
Header file for the IsRowMajorMatrix type trait.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: StaticMatrix.h:2113
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
BLAZE_ALWAYS_INLINE IntrinsicType loada(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: StaticMatrix.h:2759
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
size_t rows() const
Returns the current number of rows of the matrix.
Definition: StaticMatrix.h:2078
Header file for the alignment check function.
BLAZE_ALWAYS_INLINE void cswap(T &a, T &b)
Swapping two conjugated values/objects.
Definition: Conjugate.h:197
Rebind mechanism to obtain a StaticMatrix with different data/element type.
Definition: StaticMatrix.h:240
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
Header file for the IsTrue value trait.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const simd_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:74
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
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:2589
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2599
Header file for the IsUpper type trait.
Header file for exception macros.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for the CTransExprTrait class template.
StaticMatrix< Type, M, N, SO > This
Type of this StaticMatrix instance.
Definition: StaticMatrix.h:218
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
System settings for the inline keywords.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storea(T *address, const simd_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Storea.h:78
Header file for the TrueType type/value trait base class.
DenseIterator< Type, usePadding > Iterator
Iterator over non-constant elements.
Definition: StaticMatrix.h:232
Compile time integral round up operation.The NextMultiple class template rounds up the given template...
Definition: NextMultiple.h:81
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558
const Type & ReturnType
Return type for expression template evaluations.
Definition: StaticMatrix.h:224