UniformMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_
36 #define _BLAZE_MATH_DENSE_UNIFORMMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/Aliases.h>
47 #include <blaze/math/Exception.h>
49 #include <blaze/math/Forward.h>
50 #include <blaze/math/shims/Clear.h>
53 #include <blaze/math/shims/Reset.h>
54 #include <blaze/math/SIMD.h>
81 #include <blaze/system/Inline.h>
84 #include <blaze/util/Assert.h>
90 #include <blaze/util/EnableIf.h>
91 #include <blaze/util/TrueType.h>
92 #include <blaze/util/Types.h>
96 #include <blaze/util/Unused.h>
97 
98 
99 namespace blaze {
100 
101 //=================================================================================================
102 //
103 // CLASS DEFINITION
104 //
105 //=================================================================================================
106 
107 //*************************************************************************************************
180 template< typename Type // Data type of the matrix
181  , bool SO = defaultStorageOrder > // Storage order
182 class UniformMatrix
183  : public DenseMatrix< UniformMatrix<Type,SO>, SO >
184 {
185  public:
186  //**Type definitions****************************************************************************
189  using ResultType = This;
192  using ElementType = Type;
194  using ReturnType = const Type&;
195  using CompositeType = const This&;
196 
197  using Reference = const Type&;
198  using ConstReference = const Type&;
199  using Pointer = const Type*;
200  using ConstPointer = const Type*;
201 
204  //**********************************************************************************************
205 
206  //**Rebind struct definition********************************************************************
209  template< typename NewType > // Data type of the other matrix
210  struct Rebind {
212  };
213  //**********************************************************************************************
214 
215  //**Resize struct definition********************************************************************
218  template< size_t NewM // Number of rows of the other matrix
219  , size_t NewN > // Number of columns of the other matrix
220  struct Resize {
222  };
223  //**********************************************************************************************
224 
225  //**Compilation flags***************************************************************************
227 
231  static constexpr bool simdEnabled = IsVectorizable_v<Type>;
232 
234 
237  static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
238  //**********************************************************************************************
239 
240  //**Constructors********************************************************************************
243  explicit inline constexpr UniformMatrix() noexcept;
244  explicit inline constexpr UniformMatrix( size_t m, size_t n );
245  explicit inline constexpr UniformMatrix( size_t m, size_t n, const Type& init );
246 
247  template< typename MT, bool SO2 >
248  inline UniformMatrix( const Matrix<MT,SO2>& m );
249 
250  inline UniformMatrix( const UniformMatrix& m ) = default;
251  inline UniformMatrix( UniformMatrix&& m ) = default;
252 
254  //**********************************************************************************************
255 
256  //**Destructor**********************************************************************************
259  ~UniformMatrix() = default;
261  //**********************************************************************************************
262 
263  //**Data access functions***********************************************************************
266  inline constexpr ConstReference operator()( size_t i, size_t j ) const noexcept;
267  inline ConstReference at( size_t i, size_t j ) const;
268  inline constexpr ConstPointer data () const noexcept;
269  inline constexpr ConstPointer data ( size_t i ) const noexcept;
270  inline constexpr ConstIterator begin ( size_t i ) const noexcept;
271  inline constexpr ConstIterator cbegin( size_t i ) const noexcept;
272  inline constexpr ConstIterator end ( size_t i ) const noexcept;
273  inline constexpr ConstIterator cend ( size_t i ) const noexcept;
275  //**********************************************************************************************
276 
277  //**Assignment operators************************************************************************
280  inline constexpr UniformMatrix& operator=( const Type& rhs );
281 
282  UniformMatrix& operator=( const UniformMatrix& ) = default;
283  UniformMatrix& operator=( UniformMatrix&& ) = default;
284 
285  template< typename MT, bool SO2 > inline UniformMatrix& operator= ( const Matrix<MT,SO2>& rhs );
286  template< typename MT, bool SO2 > inline UniformMatrix& operator+=( const Matrix<MT,SO2>& rhs );
287  template< typename MT, bool SO2 > inline UniformMatrix& operator-=( const Matrix<MT,SO2>& rhs );
288  template< typename MT, bool SO2 > inline UniformMatrix& operator%=( const Matrix<MT,SO2>& rhs );
289  template< typename MT, bool SO2 > inline UniformMatrix& operator*=( const Matrix<MT,SO2>& rhs );
290 
291  template< typename ST >
292  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, UniformMatrix& >;
293 
294  template< typename ST >
295  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, UniformMatrix& >;
297  //**********************************************************************************************
298 
299  //**Utility functions***************************************************************************
302  inline constexpr size_t rows() const noexcept;
303  inline constexpr size_t columns() const noexcept;
304  inline constexpr size_t spacing() const noexcept;
305  inline constexpr size_t capacity() const noexcept;
306  inline constexpr size_t capacity( size_t i ) const noexcept;
307  inline size_t nonZeros() const;
308  inline size_t nonZeros( size_t i ) const;
309  inline constexpr void reset();
310  inline constexpr void clear();
311  constexpr void resize ( size_t m, size_t n, bool preserve=true );
312  inline constexpr void extend ( size_t m, size_t n, bool preserve=true );
313  inline constexpr void swap( UniformMatrix& m ) noexcept;
315  //**********************************************************************************************
316 
317  //**Numeric functions***************************************************************************
320  inline constexpr UniformMatrix& transpose();
321  inline constexpr UniformMatrix& ctranspose();
322 
323  template< typename Other > inline UniformMatrix& scale( const Other& scalar );
325  //**********************************************************************************************
326 
327  private:
328  //**********************************************************************************************
330  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
331  //**********************************************************************************************
332 
333  public:
334  //**Expression template evaluation functions****************************************************
337  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
338  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
339 
340  inline bool isAligned () const noexcept;
341  inline bool canSMPAssign() const noexcept;
342 
343  BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
344  BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
345  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
347  //**********************************************************************************************
348 
349  private:
350  //**Member variables****************************************************************************
353  size_t m_;
354  size_t n_;
355  Type value_;
356 
357  //**********************************************************************************************
358 
359  //**Compile time checks*************************************************************************
366  //**********************************************************************************************
367 };
368 //*************************************************************************************************
369 
370 
371 
372 
373 //=================================================================================================
374 //
375 // CONSTRUCTORS
376 //
377 //=================================================================================================
378 
379 //*************************************************************************************************
382 template< typename Type // Data type of the matrix
383  , bool SO > // Storage order
384 inline constexpr UniformMatrix<Type,SO>::UniformMatrix() noexcept
385  : m_ ( 0UL ) // The current number of rows of the matrix
386  , n_ ( 0UL ) // The current number of columns of the matrix
387  , value_() // The value of all elements of the uniform matrix
388 {}
389 //*************************************************************************************************
390 
391 
392 //*************************************************************************************************
398 template< typename Type // Data type of the matrix
399  , bool SO > // Storage order
400 inline constexpr UniformMatrix<Type,SO>::UniformMatrix( size_t m, size_t n )
401  : m_ ( m ) // The current number of rows of the matrix
402  , n_ ( n ) // The current number of columns of the matrix
403  , value_() // The value of all elements of the uniform matrix
404 {}
405 //*************************************************************************************************
406 
407 
408 //*************************************************************************************************
417 template< typename Type // Data type of the matrix
418  , bool SO > // Storage order
419 inline constexpr UniformMatrix<Type,SO>::UniformMatrix( size_t m, size_t n, const Type& init )
420  : m_ ( m ) // The current number of rows of the matrix
421  , n_ ( n ) // The current number of columns of the matrix
422  , value_( init ) // The value of all elements of the uniform matrix
423 {}
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
436 template< typename Type // Data type of the matrix
437  , bool SO > // Storage order
438 template< typename MT // Type of the foreign matrix
439  , bool SO2 > // Storage order of the foreign matrix
441  : m_ ( (~m).rows() ) // The current number of rows of the matrix
442  , n_ ( (~m).columns() ) // The current number of columns of the matrix
443  , value_() // The value of all elements of the uniform vector
444 {
445  if( !IsUniform_v<MT> && !isUniform( ~m ) ) {
446  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniform matrix" );
447  }
448 
449  if( m_ > 0UL && n_ > 0UL ) {
450  value_ = (~m)(0UL,0UL);
451  }
452 }
453 //*************************************************************************************************
454 
455 
456 
457 
458 //=================================================================================================
459 //
460 // DATA ACCESS FUNCTIONS
461 //
462 //=================================================================================================
463 
464 //*************************************************************************************************
474 template< typename Type // Data type of the matrix
475  , bool SO > // Storage order
476 inline constexpr typename UniformMatrix<Type,SO>::ConstReference
477  UniformMatrix<Type,SO>::operator()( size_t i, size_t j ) const noexcept
478 {
479  UNUSED_PARAMETER( i, j );
480 
481  BLAZE_USER_ASSERT( i < m_, "Invalid row access index" );
482  BLAZE_USER_ASSERT( j < n_, "Invalid column access index" );
483 
484  return value_;
485 }
486 //*************************************************************************************************
487 
488 
489 //*************************************************************************************************
500 template< typename Type // Data type of the matrix
501  , bool SO > // Storage order
503  UniformMatrix<Type,SO>::at( size_t i, size_t j ) const
504 {
505  if( i >= m_ ) {
506  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
507  }
508  if( j >= n_ ) {
509  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
510  }
511 
512  return (*this)(i,j);
513 }
514 //*************************************************************************************************
515 
516 
517 //*************************************************************************************************
529 template< typename Type // Data type of the matrix
530  , bool SO > // Storage order
531 inline constexpr typename UniformMatrix<Type,SO>::ConstPointer
533 {
534  return &value_;
535 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
547 template< typename Type // Data type of the matrix
548  , bool SO > // Storage order
549 inline constexpr typename UniformMatrix<Type,SO>::ConstPointer
550  UniformMatrix<Type,SO>::data( size_t i ) const noexcept
551 {
552  UNUSED_PARAMETER( i );
553 
554  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
555  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
556 
557  return &value_;
558 }
559 //*************************************************************************************************
560 
561 
562 //*************************************************************************************************
573 template< typename Type // Data type of the matrix
574  , bool SO > // Storage order
575 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
576  UniformMatrix<Type,SO>::begin( size_t i ) const noexcept
577 {
578  UNUSED_PARAMETER( i );
579 
580  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
581  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
582 
583  return ConstIterator( &value_, 0UL );
584 }
585 //*************************************************************************************************
586 
587 
588 //*************************************************************************************************
599 template< typename Type // Data type of the matrix
600  , bool SO > // Storage order
601 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
602  UniformMatrix<Type,SO>::cbegin( size_t i ) const noexcept
603 {
604  UNUSED_PARAMETER( i );
605 
606  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
607  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
608 
609  return ConstIterator( &value_, 0UL );
610 }
611 //*************************************************************************************************
612 
613 
614 //*************************************************************************************************
625 template< typename Type // Data type of the matrix
626  , bool SO > // Storage order
627 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
628  UniformMatrix<Type,SO>::end( size_t i ) const noexcept
629 {
630  UNUSED_PARAMETER( i );
631 
632  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
633  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
634 
635  return ConstIterator( &value_, SO ? m_ : n_ );
636 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
651 template< typename Type // Data type of the matrix
652  , bool SO > // Storage order
653 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
654  UniformMatrix<Type,SO>::cend( size_t i ) const noexcept
655 {
656  UNUSED_PARAMETER( i );
657 
658  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
659  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
660 
661  return ConstIterator( &value_, SO ? m_ : n_ );
662 }
663 //*************************************************************************************************
664 
665 
666 
667 
668 //=================================================================================================
669 //
670 // ASSIGNMENT OPERATORS
671 //
672 //=================================================================================================
673 
674 //*************************************************************************************************
680 template< typename Type // Data type of the matrix
681  , bool SO > // Storage order
682 inline constexpr UniformMatrix<Type,SO>& UniformMatrix<Type,SO>::operator=( const Type& rhs )
683 {
684  value_ = rhs;
685 
686  return *this;
687 }
688 //*************************************************************************************************
689 
690 
691 //*************************************************************************************************
700 template< typename Type // Data type of the matrix
701  , bool SO > // Storage order
702 template< typename MT // Type of the right-hand side matrix
703  , bool SO2 > // Storage order of the right-hand side matrix
705 {
706  using TT = decltype( trans( *this ) );
707  using CT = decltype( ctrans( *this ) );
708 
709  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
710  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of uniform matrix" );
711  }
712 
713  if( IsSame_v<MT,TT> && (~rhs).isAliased( this ) ) {
714  transpose();
715  }
716  else if( IsSame_v<MT,CT> && (~rhs).isAliased( this ) ) {
717  ctranspose();
718  }
719  else {
720  m_ = (~rhs).rows();
721  n_ = (~rhs).columns();
722 
723  if( (~rhs).rows() > 0UL && (~rhs).columns() > 0UL ) {
724  value_ = (~rhs)(0UL,0UL);
725  }
726  }
727 
728  return *this;
729 }
730 //*************************************************************************************************
731 
732 
733 //*************************************************************************************************
743 template< typename Type // Data type of the matrix
744  , bool SO > // Storage order
745 template< typename MT // Type of the right-hand side matrix
746  , bool SO2 > // Storage order of the right-hand side matrix
748 {
749  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
750  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
751  }
752 
753  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
754  BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition assignment to uniform matrix" );
755  }
756 
757  if( m_ > 0UL && n_ > 0UL ) {
758  value_ += (~rhs)(0UL,0UL);
759  }
760 
761  return *this;
762 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
776 template< typename Type // Data type of the matrix
777  , bool SO > // Storage order
778 template< typename MT // Type of the right-hand side matrix
779  , bool SO2 > // Storage order of the right-hand side matrix
781 {
782  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
783  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
784  }
785 
786  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
787  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction assignment to uniform matrix" );
788  }
789 
790  if( m_ > 0UL && n_ > 0UL ) {
791  value_ -= (~rhs)(0UL,0UL);
792  }
793 
794  return *this;
795 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
809 template< typename Type // Data type of the matrix
810  , bool SO > // Storage order
811 template< typename MT // Type of the right-hand side matrix
812  , bool SO2 > // Storage order of the right-hand side matrix
814 {
815  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
816  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
817  }
818 
819  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
820  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Schur product assignment to uniform matrix" );
821  }
822 
823  if( m_ > 0UL && n_ > 0UL ) {
824  value_ *= (~rhs)(0UL,0UL);
825  }
826 
827  return *this;
828 }
829 //*************************************************************************************************
830 
831 
832 //*************************************************************************************************
842 template< typename Type // Data type of the matrix
843  , bool SO > // Storage order
844 template< typename MT // Type of the right-hand side matrix
845  , bool SO2 > // Storage order of the right-hand side matrix
847 {
848  if( (~rhs).rows() != n_ ) {
849  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
850  }
851 
852  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
853  BLAZE_THROW_INVALID_ARGUMENT( "Invalid multiplication assignment to uniform matrix" );
854  }
855 
856  n_ = (~rhs).columns();
857 
858  if( m_ > 0UL && n_ > 0UL ) {
859  value_ = ( value_ * (~rhs)(0UL,0UL) ) * Type( (~rhs).rows() );
860  }
861 
862  return *this;
863 }
864 //*************************************************************************************************
865 
866 
867 //*************************************************************************************************
874 template< typename Type // Data type of the matrix
875  , bool SO > // Storage order
876 template< typename ST > // Data type of the right-hand side scalar
877 inline auto UniformMatrix<Type,SO>::operator*=( ST scalar )
879 {
880  if( rows() > 0UL && columns() > 0UL ) {
881  value_ *= scalar;
882  }
883 
884  return *this;
885 }
886 //*************************************************************************************************
887 
888 
889 //*************************************************************************************************
896 template< typename Type // Data type of the matrix
897  , bool SO > // Storage order
898 template< typename ST > // Data type of the right-hand side scalar
899 inline auto UniformMatrix<Type,SO>::operator/=( ST scalar )
901 {
902  if( rows() > 0UL && columns() > 0UL ) {
903  value_ /= scalar;
904  }
905 
906  return *this;
907 }
908 //*************************************************************************************************
909 
910 
911 
912 
913 //=================================================================================================
914 //
915 // UTILITY FUNCTIONS
916 //
917 //=================================================================================================
918 
919 //*************************************************************************************************
924 template< typename Type // Data type of the matrix
925  , bool SO > // Storage order
926 inline constexpr size_t UniformMatrix<Type,SO>::rows() const noexcept
927 {
928  return m_;
929 }
930 //*************************************************************************************************
931 
932 
933 //*************************************************************************************************
938 template< typename Type // Data type of the matrix
939  , bool SO > // Storage order
940 inline constexpr size_t UniformMatrix<Type,SO>::columns() const noexcept
941 {
942  return n_;
943 }
944 //*************************************************************************************************
945 
946 
947 //*************************************************************************************************
957 template< typename Type // Data type of the matrix
958  , bool SO > // Storage order
959 inline constexpr size_t UniformMatrix<Type,SO>::spacing() const noexcept
960 {
961  return SO ? m_ : n_;
962 }
963 //*************************************************************************************************
964 
965 
966 //*************************************************************************************************
971 template< typename Type // Data type of the matrix
972  , bool SO > // Storage order
973 inline constexpr size_t UniformMatrix<Type,SO>::capacity() const noexcept
974 {
975  return m_ * n_;
976 }
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
991 template< typename Type // Data type of the matrix
992  , bool SO > // Storage order
993 inline constexpr size_t UniformMatrix<Type,SO>::capacity( size_t i ) const noexcept
994 {
995  UNUSED_PARAMETER( i );
996  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
997  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
998  return SO ? m_ : n_;
999 }
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1008 template< typename Type // Data type of the matrix
1009  , bool SO > // Storage order
1011 {
1012  if( m_ == 0UL || n_ == 0UL || isDefault( value_ ) )
1013  return 0UL;
1014  else
1015  return m_ * n_;
1016 }
1017 //*************************************************************************************************
1018 
1019 
1020 //*************************************************************************************************
1031 template< typename Type // Data type of the matrix
1032  , bool SO > // Storage order
1033 inline size_t UniformMatrix<Type,SO>::nonZeros( size_t i ) const
1034 {
1035  UNUSED_PARAMETER( i );
1036 
1037  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
1038  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
1039 
1040  const size_t tmp( SO ? m_ : n_ );
1041  if( tmp == 0UL || isDefault( value_ ) )
1042  return 0UL;
1043  else
1044  return tmp;
1045 }
1046 //*************************************************************************************************
1047 
1048 
1049 //*************************************************************************************************
1054 template< typename Type // Data type of the matrix
1055  , bool SO > // Storage order
1056 inline constexpr void UniformMatrix<Type,SO>::reset()
1057 {
1058  using blaze::clear;
1059 
1060  clear( value_ );
1061 }
1062 //*************************************************************************************************
1063 
1064 
1065 //*************************************************************************************************
1072 template< typename Type // Data type of the matrix
1073  , bool SO > // Storage order
1074 inline constexpr void UniformMatrix<Type,SO>::clear()
1075 {
1076  m_ = 0UL;
1077  n_ = 0UL;
1078 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1096 template< typename Type // Data type of the matrix
1097  , bool SO > // Storage order
1098 void constexpr UniformMatrix<Type,SO>::resize( size_t m, size_t n, bool preserve )
1099 {
1100  UNUSED_PARAMETER( preserve );
1101 
1102  m_ = m;
1103  n_ = n;
1104 }
1105 //*************************************************************************************************
1106 
1107 
1108 //*************************************************************************************************
1120 template< typename Type // Data type of the matrix
1121  , bool SO > // Storage order
1122 inline constexpr void UniformMatrix<Type,SO>::extend( size_t m, size_t n, bool preserve )
1123 {
1124  resize( m_+m, n_+n, preserve );
1125 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1135 template< typename Type // Data type of the matrix
1136  , bool SO > // Storage order
1137 inline constexpr void UniformMatrix<Type,SO>::swap( UniformMatrix& m ) noexcept
1138 {
1139  using std::swap;
1140 
1141  swap( m_, m.m_ );
1142  swap( n_, m.n_ );
1143  swap( value_, m.value_ );
1144 }
1145 //*************************************************************************************************
1146 
1147 
1148 
1149 
1150 //=================================================================================================
1151 //
1152 // NUMERIC FUNCTIONS
1153 //
1154 //=================================================================================================
1155 
1156 //*************************************************************************************************
1161 template< typename Type // Data type of the matrix
1162  , bool SO > // Storage order
1164 {
1165  using std::swap;
1166 
1167  swap( m_, n_ );
1168 
1169  return *this;
1170 }
1171 //*************************************************************************************************
1172 
1173 
1174 //*************************************************************************************************
1179 template< typename Type // Data type of the matrix
1180  , bool SO > // Storage order
1182 {
1183  using std::swap;
1184 
1185  swap( m_, n_ );
1186  conjugate( value_ );
1187 
1188  return *this;
1189 }
1190 //*************************************************************************************************
1191 
1192 
1193 //*************************************************************************************************
1210 template< typename Type // Data type of the matrix
1211  , bool SO > // Storage order
1212 template< typename Other > // Data type of the scalar value
1214 {
1215  if( m_ > 0UL && n_ > 0UL ) {
1216  value_ *= scalar;
1217  }
1218 
1219  return *this;
1220 }
1221 //*************************************************************************************************
1222 
1223 
1224 
1225 
1226 //=================================================================================================
1227 //
1228 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1229 //
1230 //=================================================================================================
1231 
1232 //*************************************************************************************************
1242 template< typename Type // Data type of the matrix
1243  , bool SO > // Storage order
1244 template< typename Other > // Data type of the foreign expression
1245 inline bool UniformMatrix<Type,SO>::canAlias( const Other* alias ) const noexcept
1246 {
1247  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1248 }
1249 //*************************************************************************************************
1250 
1251 
1252 //*************************************************************************************************
1262 template< typename Type // Data type of the matrix
1263  , bool SO > // Storage order
1264 template< typename Other > // Data type of the foreign expression
1265 inline bool UniformMatrix<Type,SO>::isAliased( const Other* alias ) const noexcept
1266 {
1267  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1268 }
1269 //*************************************************************************************************
1270 
1271 
1272 //*************************************************************************************************
1281 template< typename Type // Data type of the matrix
1282  , bool SO > // Storage order
1283 inline bool UniformMatrix<Type,SO>::isAligned() const noexcept
1284 {
1285  return true;
1286 }
1287 //*************************************************************************************************
1288 
1289 
1290 //*************************************************************************************************
1300 template< typename Type // Data type of the matrix
1301  , bool SO > // Storage order
1302 inline bool UniformMatrix<Type,SO>::canSMPAssign() const noexcept
1303 {
1304  return ( rows() * columns() >= SMP_DMATASSIGN_THRESHOLD );
1305 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1324 template< typename Type // Data type of the matrix
1325  , bool SO > // Storage order
1327  UniformMatrix<Type,SO>::load( size_t i, size_t j ) const noexcept
1328 {
1329  return loada( i, j );
1330 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1349 template< typename Type // Data type of the matrix
1350  , bool SO > // Storage order
1352  UniformMatrix<Type,SO>::loada( size_t i, size_t j ) const noexcept
1353 {
1354  UNUSED_PARAMETER( i, j );
1355 
1357 
1358  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1359  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1360  BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1361  BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1362 
1363  return set( value_ );
1364 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1383 template< typename Type // Data type of the matrix
1384  , bool SO > // Storage order
1386  UniformMatrix<Type,SO>::loadu( size_t i, size_t j ) const noexcept
1387 {
1388  UNUSED_PARAMETER( i, j );
1389 
1391 
1392  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1393  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1394  BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1395  BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1396 
1397  return set( value_ );
1398 }
1399 //*************************************************************************************************
1400 
1401 
1402 
1403 
1404 
1405 
1406 
1407 
1408 //=================================================================================================
1409 //
1410 // UNIFORMMATRIX OPERATORS
1411 //
1412 //=================================================================================================
1413 
1414 //*************************************************************************************************
1417 template< typename Type, bool SO >
1418 constexpr void reset( UniformMatrix<Type,SO>& m );
1419 
1420 template< typename Type, bool SO >
1421 constexpr void clear( UniformMatrix<Type,SO>& m );
1422 
1423 template< bool RF, typename Type, bool SO >
1424 constexpr bool isDefault( const UniformMatrix<Type,SO>& m );
1425 
1426 template< typename Type, bool SO >
1427 constexpr bool isIntact( const UniformMatrix<Type,SO>& m ) noexcept;
1428 
1429 template< typename Type, bool SO >
1430 constexpr void swap( UniformMatrix<Type,SO>& a, UniformMatrix<Type,SO>& b ) noexcept;
1432 //*************************************************************************************************
1433 
1434 
1435 //*************************************************************************************************
1442 template< typename Type // Data type of the matrix
1443  , bool SO > // Storage order
1444 inline constexpr void reset( UniformMatrix<Type,SO>& m )
1445 {
1446  m.reset();
1447 }
1448 //*************************************************************************************************
1449 
1450 
1451 //*************************************************************************************************
1458 template< typename Type // Data type of the matrix
1459  , bool SO > // Storage order
1460 inline constexpr void clear( UniformMatrix<Type,SO>& m )
1461 {
1462  m.clear();
1463 }
1464 //*************************************************************************************************
1465 
1466 
1467 //*************************************************************************************************
1492 template< bool RF // Relaxation flag
1493  , typename Type // Data type of the matrix
1494  , bool SO > // Storage order
1495 inline constexpr bool isDefault( const UniformMatrix<Type,SO>& m )
1496 {
1497  return ( m.rows() == 0UL && m.columns() == 0UL );
1498 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1520 template< typename Type // Data type of the matrix
1521  , bool SO > // Storage order
1522 inline constexpr bool isIntact( const UniformMatrix<Type,SO>& m ) noexcept
1523 {
1524  UNUSED_PARAMETER( m );
1525 
1526  return true;
1527 }
1528 //*************************************************************************************************
1529 
1530 
1531 //*************************************************************************************************
1539 template< typename Type // Data type of the matrix
1540  , bool SO > // Storage order
1541 inline constexpr void swap( UniformMatrix<Type,SO>& a, UniformMatrix<Type,SO>& b ) noexcept
1542 {
1543  a.swap( b );
1544 }
1545 //*************************************************************************************************
1546 
1547 
1548 
1549 
1550 //=================================================================================================
1551 //
1552 // ISUNIFORM SPECIALIZATIONS
1553 //
1554 //=================================================================================================
1555 
1556 //*************************************************************************************************
1558 template< typename Type, bool SO >
1559 struct IsUniform< UniformMatrix<Type,SO> >
1560  : public TrueType
1561 {};
1563 //*************************************************************************************************
1564 
1565 
1566 
1567 
1568 //=================================================================================================
1569 //
1570 // ISALIGNED SPECIALIZATIONS
1571 //
1572 //=================================================================================================
1573 
1574 //*************************************************************************************************
1576 template< typename Type, bool SO >
1577 struct IsAligned< UniformMatrix<Type,SO> >
1578  : public TrueType
1579 {};
1581 //*************************************************************************************************
1582 
1583 
1584 
1585 
1586 //=================================================================================================
1587 //
1588 // ISRESIZABLE SPECIALIZATIONS
1589 //
1590 //=================================================================================================
1591 
1592 //*************************************************************************************************
1594 template< typename Type, bool SO >
1595 struct IsResizable< UniformMatrix<Type,SO> >
1596  : public TrueType
1597 {};
1599 //*************************************************************************************************
1600 
1601 
1602 
1603 
1604 //=================================================================================================
1605 //
1606 // ADDTRAIT SPECIALIZATIONS
1607 //
1608 //=================================================================================================
1609 
1610 //*************************************************************************************************
1612 template< typename T1, typename T2 >
1613 struct AddTraitEval1< T1, T2
1614  , EnableIf_t< IsMatrix_v<T1> &&
1615  IsMatrix_v<T2> &&
1616  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1617  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1618 {
1619  using ET1 = ElementType_t<T1>;
1620  using ET2 = ElementType_t<T2>;
1621 
1622  static constexpr bool SO1 = StorageOrder_v<T1>;
1623  static constexpr bool SO2 = StorageOrder_v<T2>;
1624 
1625  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1626  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1627  ? ( IsSymmetric_v<T1>
1628  ? SO2
1629  : SO1 )
1630  : SO1 && SO2 )
1631  : ( IsDenseMatrix_v<T1>
1632  ? SO1
1633  : SO2 ) );
1634 
1635  using Type = UniformMatrix< AddTrait_t<ET1,ET2>, SO >;
1636 };
1638 //*************************************************************************************************
1639 
1640 
1641 
1642 
1643 //=================================================================================================
1644 //
1645 // SUBTRAIT SPECIALIZATIONS
1646 //
1647 //=================================================================================================
1648 
1649 //*************************************************************************************************
1651 template< typename T1, typename T2 >
1652 struct SubTraitEval1< T1, T2
1653  , EnableIf_t< IsMatrix_v<T1> &&
1654  IsMatrix_v<T2> &&
1655  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1656  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1657 {
1658  using ET1 = ElementType_t<T1>;
1659  using ET2 = ElementType_t<T2>;
1660 
1661  static constexpr bool SO1 = StorageOrder_v<T1>;
1662  static constexpr bool SO2 = StorageOrder_v<T2>;
1663 
1664  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1665  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1666  ? ( IsSymmetric_v<T1>
1667  ? SO2
1668  : SO1 )
1669  : SO1 && SO2 )
1670  : ( IsDenseMatrix_v<T1>
1671  ? SO1
1672  : SO2 ) );
1673 
1674  using Type = UniformMatrix< SubTrait_t<ET1,ET2>, SO >;
1675 };
1677 //*************************************************************************************************
1678 
1679 
1680 
1681 
1682 //=================================================================================================
1683 //
1684 // SCHURTRAIT SPECIALIZATIONS
1685 //
1686 //=================================================================================================
1687 
1688 //*************************************************************************************************
1690 template< typename T1, typename T2 >
1691 struct SchurTraitEval1< T1, T2
1692  , EnableIf_t< IsMatrix_v<T1> &&
1693  IsMatrix_v<T2> &&
1694  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1695  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1696 {
1697  using ET1 = ElementType_t<T1>;
1698  using ET2 = ElementType_t<T2>;
1699 
1700  static constexpr bool SO1 = StorageOrder_v<T1>;
1701  static constexpr bool SO2 = StorageOrder_v<T2>;
1702 
1703  static constexpr bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1704  ? ( IsSymmetric_v<T1>
1705  ? SO2
1706  : SO1 )
1707  : SO1 && SO2 );
1708 
1709  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, SO >;
1710 };
1712 //*************************************************************************************************
1713 
1714 
1715 
1716 
1717 //=================================================================================================
1718 //
1719 // MULTTRAIT SPECIALIZATIONS
1720 //
1721 //=================================================================================================
1722 
1723 //*************************************************************************************************
1725 template< typename T1, typename T2 >
1726 struct MultTraitEval1< T1, T2
1727  , EnableIf_t< IsMatrix_v<T1> &&
1728  IsUniform_v<T1> &&
1729  !IsZero_v<T1> &&
1730  IsNumeric_v<T2> > >
1731 {
1732  using ET1 = ElementType_t<T1>;
1733 
1734  using Type = UniformMatrix< MultTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1735 };
1736 
1737 template< typename T1, typename T2 >
1738 struct MultTraitEval1< T1, T2
1739  , EnableIf_t< IsNumeric_v<T1> &&
1740  IsMatrix_v<T2> &&
1741  IsUniform_v<T2> &&
1742  !IsZero_v<T2> > >
1743 {
1744  using ET2 = ElementType_t<T2>;
1745 
1746  using Type = UniformMatrix< MultTrait_t<T1,ET2>, StorageOrder_v<T2> >;
1747 };
1748 
1749 template< typename T1, typename T2 >
1750 struct MultTraitEval1< T1, T2
1751  , EnableIf_t< IsColumnVector_v<T1> &&
1752  IsRowVector_v<T2> &&
1753  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1754  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1755 {
1756  using ET1 = ElementType_t<T1>;
1757  using ET2 = ElementType_t<T2>;
1758 
1759  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, false >;
1760 };
1761 
1762 template< typename T1, typename T2 >
1763 struct MultTraitEval1< T1, T2
1764  , EnableIf_t< IsMatrix_v<T1> &&
1765  IsMatrix_v<T2> &&
1766  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1767  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1768 {
1769  using ET1 = ElementType_t<T1>;
1770  using ET2 = ElementType_t<T2>;
1771 
1772  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T1> >;
1773 };
1775 //*************************************************************************************************
1776 
1777 
1778 
1779 
1780 //=================================================================================================
1781 //
1782 // DIVTRAIT SPECIALIZATIONS
1783 //
1784 //=================================================================================================
1785 
1786 //*************************************************************************************************
1788 template< typename T1, typename T2 >
1789 struct DivTraitEval1< T1, T2
1790  , EnableIf_t< IsMatrix_v<T1> &&
1791  IsNumeric_v<T2> &&
1792  IsUniform_v<T1> && !IsZero_v<T1> > >
1793 {
1794  using ET1 = ElementType_t<T1>;
1795 
1796  using Type = UniformMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1797 };
1799 //*************************************************************************************************
1800 
1801 
1802 
1803 
1804 //=================================================================================================
1805 //
1806 // MAPTRAIT SPECIALIZATIONS
1807 //
1808 //=================================================================================================
1809 
1810 //*************************************************************************************************
1812 template< typename T, typename OP >
1813 struct UnaryMapTraitEval1< T, OP
1814  , EnableIf_t< IsMatrix_v<T> &&
1815  YieldsUniform_v<OP,T> &&
1816  !YieldsZero_v<OP,T> > >
1817 {
1818  using ET = ElementType_t<T>;
1819 
1820  using Type = UniformMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
1821 };
1823 //*************************************************************************************************
1824 
1825 
1826 //*************************************************************************************************
1828 template< typename T1, typename T2, typename OP >
1829 struct BinaryMapTraitEval1< T1, T2, OP
1830  , EnableIf_t< IsMatrix_v<T1> &&
1831  IsMatrix_v<T2> &&
1832  YieldsUniform_v<OP,T1,T2> &&
1833  !YieldsZero_v<OP,T1,T2> > >
1834 {
1835  using ET1 = ElementType_t<T1>;
1836  using ET2 = ElementType_t<T2>;
1837 
1838  static constexpr bool SO1 = StorageOrder_v<T1>;
1839  static constexpr bool SO2 = StorageOrder_v<T2>;
1840 
1841  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1842  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1843  ? ( IsSymmetric_v<T1>
1844  ? SO2
1845  : SO1 )
1846  : SO1 && SO2 )
1847  : ( IsDenseMatrix_v<T1>
1848  ? SO1
1849  : SO2 ) );
1850 
1851  using Type = UniformMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
1852 };
1854 //*************************************************************************************************
1855 
1856 
1857 
1858 
1859 //=================================================================================================
1860 //
1861 // EXPANDTRAIT SPECIALIZATIONS
1862 //
1863 //=================================================================================================
1864 
1865 //*************************************************************************************************
1867 template< typename T // Type to be expanded
1868  , size_t E > // Compile time expansion
1869 struct ExpandTraitEval1< T, E
1870  , EnableIf_t< IsVector_v<T> &&
1871  IsUniform_v<T> && !IsZero_v<T> > >
1872 {
1873  static constexpr bool TF = ( IsColumnVector_v<T> ? columnMajor : rowMajor );
1874 
1875  using Type = UniformMatrix< ElementType_t<T>, TF >;
1876 };
1878 //*************************************************************************************************
1879 
1880 
1881 
1882 
1883 //=================================================================================================
1884 //
1885 // HIGHTYPE SPECIALIZATIONS
1886 //
1887 //=================================================================================================
1888 
1889 //*************************************************************************************************
1891 template< typename T1, bool SO, typename T2 >
1892 struct HighType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1893 {
1894  using Type = UniformMatrix< typename HighType<T1,T2>::Type, SO >;
1895 };
1897 //*************************************************************************************************
1898 
1899 
1900 
1901 
1902 //=================================================================================================
1903 //
1904 // LOWTYPE SPECIALIZATIONS
1905 //
1906 //=================================================================================================
1907 
1908 //*************************************************************************************************
1910 template< typename T1, bool SO, typename T2 >
1911 struct LowType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1912 {
1913  using Type = UniformMatrix< typename LowType<T1,T2>::Type, SO >;
1914 };
1916 //*************************************************************************************************
1917 
1918 
1919 
1920 
1921 //=================================================================================================
1922 //
1923 // SUBMATRIXTRAIT SPECIALIZATIONS
1924 //
1925 //=================================================================================================
1926 
1927 //*************************************************************************************************
1929 template< typename MT, size_t I, size_t J, size_t M, size_t N >
1930 struct SubmatrixTraitEval1< MT, I, J, M, N
1931  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1932 {
1933  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
1934 };
1936 //*************************************************************************************************
1937 
1938 
1939 
1940 
1941 //=================================================================================================
1942 //
1943 // ROWSTRAIT SPECIALIZATIONS
1944 //
1945 //=================================================================================================
1946 
1947 //*************************************************************************************************
1949 template< typename MT, size_t M >
1950 struct RowsTraitEval1< MT, M
1951  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1952 {
1953  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, false >;
1954 };
1956 //*************************************************************************************************
1957 
1958 
1959 
1960 
1961 //=================================================================================================
1962 //
1963 // COLUMNSTRAIT SPECIALIZATIONS
1964 //
1965 //=================================================================================================
1966 
1967 //*************************************************************************************************
1969 template< typename MT, size_t N >
1970 struct ColumnsTraitEval1< MT, N
1971  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
1972 {
1973  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, true >;
1974 };
1976 //*************************************************************************************************
1977 
1978 } // namespace blaze
1979 
1980 #endif
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:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Header file for the Schur product trait.
#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
constexpr size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: UniformMatrix.h:926
Header file for the alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the YieldsZero type trait.
constexpr ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first element of row/column i.
Definition: UniformMatrix.h:602
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: UniformMatrix.h:503
constexpr void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: UniformMatrix.h:1122
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
const Type & ConstReference
Reference to a constant matrix value.
Definition: UniformMatrix.h:198
size_t m_
The current number of rows of the compressed matrix.
Definition: CompressedMatrix.h:3289
Header file for the IsRowVector type trait.
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
size_t m_
The current number of rows of the matrix.
Definition: UniformMatrix.h:353
#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:79
Header file for the reset shim.
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: UniformMatrix.h:231
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the matrix.
Definition: UniformMatrix.h:973
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
const Type * Pointer
Pointer to a non-constant matrix value.
Definition: UniformMatrix.h:199
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Constraint on the data type.
Header file for the IsMatrix type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: UniformMatrix.h:237
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
SIMDTrait_t< ElementType > SIMDType
SIMD type of the matrix elements.
Definition: UniformMatrix.h:193
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: UniformMatrix.h:1302
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
auto operator/=(ST rhs) -> EnableIf_t< IsNumeric_v< ST >, UniformMatrix & >
Division assignment operator for the division between a matrix and a scalar value ( )...
Definition: UniformMatrix.h:899
Header file for the LowType type trait.
BLAZE_ALWAYS_INLINE SIMDType loada(size_t i, size_t j) const noexcept
Aligned load of a SIMD element of the matrix.
Definition: UniformMatrix.h:1352
Header file for the IsUniform type trait.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Type value_
The value of all elements of the uniform matrix.
Definition: UniformMatrix.h:355
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1364
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
Header file for all forward declarations of the math module.
#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:79
Header file for the IsSMPAssignable type trait.
constexpr ConstIterator begin(size_t i) const noexcept
Returns an iterator to the first element of row/column i.
Definition: UniformMatrix.h:576
Header file for the expand trait.
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.The IsColumnVector_v variable template ...
Definition: IsColumnVector.h:143
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: UniformMatrix.h:200
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t i, size_t j) const noexcept
Unaligned load of a SIMD element of the matrix.
Definition: UniformMatrix.h:1386
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Header file for all SIMD functionality.
Constraint on the data type.
Header file for the IsAligned type trait.
constexpr ConstIterator cend(size_t i) const noexcept
Returns an iterator just past the last element of row/column i.
Definition: UniformMatrix.h:654
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:140
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:61
constexpr void reset()
Reset to the default initial values.
Definition: UniformMatrix.h:1056
Header file for the exception macros of the math module.
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:849
const Type & Reference
Reference to a non-constant matrix value.
Definition: UniformMatrix.h:197
Header file for the IsVector type trait.
Header file for the IsDenseMatrix type trait.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
constexpr size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: UniformMatrix.h:940
Header file for the IsVectorizable type trait.
Header file for the conjugate shim.
constexpr size_t spacing() const noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: UniformMatrix.h:959
Header file for the IsNumeric type trait.
Resize mechanism to obtain a UniformMatrix with different fixed dimensions.
Definition: UniformMatrix.h:220
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: UniformMatrix.h:1010
constexpr void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: UniformMatrix.h:1098
Header file for the RemoveConst type trait.
constexpr UniformMatrix & transpose()
In-place transpose of the matrix.
Definition: UniformMatrix.h:1163
Header file for the YieldsUniform type trait.
size_t n_
The current number of columns of the matrix.
Definition: UniformMatrix.h:354
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Header file for run time assertion macros.
Header file for the addition trait.
constexpr UniformMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: UniformMatrix.h:1181
Header file for the division trait.
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: UniformMatrix.h:1245
Header file for the submatrix trait.
Constraint on the data type.
constexpr UniformMatrix & operator=(const Type &rhs)
Homogenous assignment to all matrix elements.
Definition: UniformMatrix.h:682
Header file for the columns trait.
Header file for the IsZero type trait.
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
constexpr void swap(UniformMatrix &m) noexcept
Swapping the contents of two matrices.
Definition: UniformMatrix.h:1137
#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:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
Constraint on the data type.
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.The IsDenseMatrix_v variable template pr...
Definition: IsDenseMatrix.h:139
constexpr void clear()
Clearing the matrix.
Definition: UniformMatrix.h:1074
Efficient implementation of a uniform matrix.The UniformMatrix class template is the representation o...
Definition: Forward.h:62
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
constexpr UniformMatrix() noexcept
The default constructor for UniformMatrix.
Definition: UniformMatrix.h:384
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: UniformMatrix.h:330
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
constexpr ConstReference operator()(size_t i, size_t j) const noexcept
2D-access to the matrix elements.
Definition: UniformMatrix.h:477
Header file for the rows trait.
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: UniformMatrix.h:1283
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
size_t n_
The current number of columns of the compressed matrix.
Definition: CompressedMatrix.h:3290
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: UniformMatrix.h:1265
Implementation of a generic iterator for uniform vectors and matrices.The UniformIterator represents ...
Definition: UniformIterator.h:58
const Type & ReturnType
Return type for expression template evaluations.
Definition: UniformMatrix.h:194
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.The IsUniform_v variable template provides a...
Definition: IsUniform.h:163
Header file for the StorageOrder type trait.
UniformMatrix< Type, SO > This
Type of this UniformMatrix instance.
Definition: UniformMatrix.h:187
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Type ElementType
Type of the matrix elements.
Definition: UniformMatrix.h:192
Header file for the IsColumnVector type trait.
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#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
constexpr ConstIterator end(size_t i) const noexcept
Returns an iterator just past the last element of row/column i.
Definition: UniformMatrix.h:628
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: UniformMatrix.h:1327
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.
Header file for the clear shim.
Header file for the UniformIterator class template.
constexpr ConstPointer data() const noexcept
Low-level data access to the matrix elements.
Definition: UniformMatrix.h:532
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825
Rebind mechanism to obtain a UniformMatrix with different data/element type.
Definition: UniformMatrix.h:210