Blaze  3.6
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>
50 #include <blaze/math/Forward.h>
51 #include <blaze/math/shims/Clear.h>
54 #include <blaze/math/shims/Reset.h>
55 #include <blaze/math/SIMD.h>
83 #include <blaze/system/Inline.h>
86 #include <blaze/util/Assert.h>
92 #include <blaze/util/EnableIf.h>
94 #include <blaze/util/MaybeUnused.h>
95 #include <blaze/util/Types.h>
100 
101 
102 namespace blaze {
103 
104 //=================================================================================================
105 //
106 // CLASS DEFINITION
107 //
108 //=================================================================================================
109 
110 //*************************************************************************************************
183 template< typename Type // Data type of the matrix
184  , bool SO = defaultStorageOrder > // Storage order
185 class UniformMatrix
186  : public Expression< DenseMatrix< UniformMatrix<Type,SO>, SO > >
187 {
188  public:
189  //**Type definitions****************************************************************************
192  using ResultType = This;
195  using ElementType = Type;
197  using ReturnType = const Type&;
198  using CompositeType = const This&;
199 
200  using Reference = const Type&;
201  using ConstReference = const Type&;
202  using Pointer = const Type*;
203  using ConstPointer = const Type*;
204 
207  //**********************************************************************************************
208 
209  //**Rebind struct definition********************************************************************
212  template< typename NewType > // Data type of the other matrix
213  struct Rebind {
215  };
216  //**********************************************************************************************
217 
218  //**Resize struct definition********************************************************************
221  template< size_t NewM // Number of rows of the other matrix
222  , size_t NewN > // Number of columns of the other matrix
223  struct Resize {
225  };
226  //**********************************************************************************************
227 
228  //**Compilation flags***************************************************************************
230 
234  static constexpr bool simdEnabled = IsVectorizable_v<Type>;
235 
237 
240  static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
241  //**********************************************************************************************
242 
243  //**Constructors********************************************************************************
246  explicit inline constexpr UniformMatrix() noexcept;
247  explicit inline constexpr UniformMatrix( size_t m, size_t n );
248  explicit inline constexpr UniformMatrix( size_t m, size_t n, const Type& init );
249 
250  template< typename MT, bool SO2 >
251  inline UniformMatrix( const Matrix<MT,SO2>& m );
252 
253  inline UniformMatrix( const UniformMatrix& m ) = default;
254  inline UniformMatrix( UniformMatrix&& m ) = default;
255 
257  //**********************************************************************************************
258 
259  //**Destructor**********************************************************************************
262  ~UniformMatrix() = default;
264  //**********************************************************************************************
265 
266  //**Data access functions***********************************************************************
269  inline constexpr ConstReference operator()( size_t i, size_t j ) const noexcept;
270  inline ConstReference at( size_t i, size_t j ) const;
271  inline constexpr ConstPointer data () const noexcept;
272  inline constexpr ConstPointer data ( size_t i ) const noexcept;
273  inline constexpr ConstIterator begin ( size_t i ) const noexcept;
274  inline constexpr ConstIterator cbegin( size_t i ) const noexcept;
275  inline constexpr ConstIterator end ( size_t i ) const noexcept;
276  inline constexpr ConstIterator cend ( size_t i ) const noexcept;
278  //**********************************************************************************************
279 
280  //**Assignment operators************************************************************************
283  inline constexpr UniformMatrix& operator=( const Type& rhs );
284 
285  UniformMatrix& operator=( const UniformMatrix& ) = default;
286  UniformMatrix& operator=( UniformMatrix&& ) = default;
287 
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  template< typename MT, bool SO2 > inline UniformMatrix& operator-=( const Matrix<MT,SO2>& rhs );
291  template< typename MT, bool SO2 > inline UniformMatrix& operator%=( const Matrix<MT,SO2>& rhs );
292  template< typename MT, bool SO2 > inline UniformMatrix& operator*=( const Matrix<MT,SO2>& rhs );
293 
294  template< typename ST >
295  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, UniformMatrix& >;
296 
297  template< typename ST >
298  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, UniformMatrix& >;
300  //**********************************************************************************************
301 
302  //**Utility functions***************************************************************************
305  inline constexpr size_t rows() const noexcept;
306  inline constexpr size_t columns() const noexcept;
307  inline constexpr size_t spacing() const noexcept;
308  inline constexpr size_t capacity() const noexcept;
309  inline constexpr size_t capacity( size_t i ) const noexcept;
310  inline size_t nonZeros() const;
311  inline size_t nonZeros( size_t i ) const;
312  inline constexpr void reset();
313  inline constexpr void clear();
314  constexpr void resize ( size_t m, size_t n, bool preserve=true );
315  inline constexpr void extend ( size_t m, size_t n, bool preserve=true );
316  inline constexpr void swap( UniformMatrix& m ) noexcept;
318  //**********************************************************************************************
319 
320  //**Numeric functions***************************************************************************
323  inline constexpr UniformMatrix& transpose();
324  inline constexpr UniformMatrix& ctranspose();
325 
326  template< typename Other > inline UniformMatrix& scale( const Other& scalar );
328  //**********************************************************************************************
329 
330  private:
331  //**********************************************************************************************
333  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
334  //**********************************************************************************************
335 
336  public:
337  //**Expression template evaluation functions****************************************************
340  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
341  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
342 
343  inline bool isAligned () const noexcept;
344  inline bool canSMPAssign() const noexcept;
345 
346  BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
347  BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
348  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
350  //**********************************************************************************************
351 
352  private:
353  //**Member variables****************************************************************************
356  size_t m_;
357  size_t n_;
358  Type value_;
359 
360  //**********************************************************************************************
361 
362  //**Compile time checks*************************************************************************
369  //**********************************************************************************************
370 };
371 //*************************************************************************************************
372 
373 
374 
375 
376 //=================================================================================================
377 //
378 // CONSTRUCTORS
379 //
380 //=================================================================================================
381 
382 //*************************************************************************************************
385 template< typename Type // Data type of the matrix
386  , bool SO > // Storage order
387 inline constexpr UniformMatrix<Type,SO>::UniformMatrix() noexcept
388  : m_ ( 0UL ) // The current number of rows of the matrix
389  , n_ ( 0UL ) // The current number of columns of the matrix
390  , value_() // The value of all elements of the uniform matrix
391 {}
392 //*************************************************************************************************
393 
394 
395 //*************************************************************************************************
401 template< typename Type // Data type of the matrix
402  , bool SO > // Storage order
403 inline constexpr UniformMatrix<Type,SO>::UniformMatrix( size_t m, size_t n )
404  : m_ ( m ) // The current number of rows of the matrix
405  , n_ ( n ) // The current number of columns of the matrix
406  , value_() // The value of all elements of the uniform matrix
407 {}
408 //*************************************************************************************************
409 
410 
411 //*************************************************************************************************
420 template< typename Type // Data type of the matrix
421  , bool SO > // Storage order
422 inline constexpr UniformMatrix<Type,SO>::UniformMatrix( size_t m, size_t n, const Type& init )
423  : m_ ( m ) // The current number of rows of the matrix
424  , n_ ( n ) // The current number of columns of the matrix
425  , value_( init ) // The value of all elements of the uniform matrix
426 {}
427 //*************************************************************************************************
428 
429 
430 //*************************************************************************************************
439 template< typename Type // Data type of the matrix
440  , bool SO > // Storage order
441 template< typename MT // Type of the foreign matrix
442  , bool SO2 > // Storage order of the foreign matrix
444  : m_ ( (~m).rows() ) // The current number of rows of the matrix
445  , n_ ( (~m).columns() ) // The current number of columns of the matrix
446  , value_() // The value of all elements of the uniform vector
447 {
448  if( !IsUniform_v<MT> && !isUniform( ~m ) ) {
449  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniform matrix" );
450  }
451 
452  if( m_ > 0UL && n_ > 0UL ) {
453  value_ = (~m)(0UL,0UL);
454  }
455 }
456 //*************************************************************************************************
457 
458 
459 
460 
461 //=================================================================================================
462 //
463 // DATA ACCESS FUNCTIONS
464 //
465 //=================================================================================================
466 
467 //*************************************************************************************************
477 template< typename Type // Data type of the matrix
478  , bool SO > // Storage order
479 inline constexpr typename UniformMatrix<Type,SO>::ConstReference
480  UniformMatrix<Type,SO>::operator()( size_t i, size_t j ) const noexcept
481 {
482  MAYBE_UNUSED( i, j );
483 
484  BLAZE_USER_ASSERT( i < m_, "Invalid row access index" );
485  BLAZE_USER_ASSERT( j < n_, "Invalid column access index" );
486 
487  return value_;
488 }
489 //*************************************************************************************************
490 
491 
492 //*************************************************************************************************
503 template< typename Type // Data type of the matrix
504  , bool SO > // Storage order
506  UniformMatrix<Type,SO>::at( size_t i, size_t j ) const
507 {
508  if( i >= m_ ) {
509  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
510  }
511  if( j >= n_ ) {
512  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
513  }
514 
515  return (*this)(i,j);
516 }
517 //*************************************************************************************************
518 
519 
520 //*************************************************************************************************
532 template< typename Type // Data type of the matrix
533  , bool SO > // Storage order
534 inline constexpr typename UniformMatrix<Type,SO>::ConstPointer
536 {
537  return &value_;
538 }
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
550 template< typename Type // Data type of the matrix
551  , bool SO > // Storage order
552 inline constexpr typename UniformMatrix<Type,SO>::ConstPointer
553  UniformMatrix<Type,SO>::data( size_t i ) const noexcept
554 {
555  MAYBE_UNUSED( i );
556 
557  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
558  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
559 
560  return &value_;
561 }
562 //*************************************************************************************************
563 
564 
565 //*************************************************************************************************
576 template< typename Type // Data type of the matrix
577  , bool SO > // Storage order
578 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
579  UniformMatrix<Type,SO>::begin( size_t i ) const noexcept
580 {
581  MAYBE_UNUSED( i );
582 
583  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
584  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
585 
586  return ConstIterator( &value_, 0UL );
587 }
588 //*************************************************************************************************
589 
590 
591 //*************************************************************************************************
602 template< typename Type // Data type of the matrix
603  , bool SO > // Storage order
604 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
605  UniformMatrix<Type,SO>::cbegin( size_t i ) const noexcept
606 {
607  MAYBE_UNUSED( i );
608 
609  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
610  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
611 
612  return ConstIterator( &value_, 0UL );
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
628 template< typename Type // Data type of the matrix
629  , bool SO > // Storage order
630 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
631  UniformMatrix<Type,SO>::end( size_t i ) const noexcept
632 {
633  MAYBE_UNUSED( i );
634 
635  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
636  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
637 
638  return ConstIterator( &value_, SO ? m_ : n_ );
639 }
640 //*************************************************************************************************
641 
642 
643 //*************************************************************************************************
654 template< typename Type // Data type of the matrix
655  , bool SO > // Storage order
656 inline constexpr typename UniformMatrix<Type,SO>::ConstIterator
657  UniformMatrix<Type,SO>::cend( size_t i ) const noexcept
658 {
659  MAYBE_UNUSED( i );
660 
661  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
662  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
663 
664  return ConstIterator( &value_, SO ? m_ : n_ );
665 }
666 //*************************************************************************************************
667 
668 
669 
670 
671 //=================================================================================================
672 //
673 // ASSIGNMENT OPERATORS
674 //
675 //=================================================================================================
676 
677 //*************************************************************************************************
683 template< typename Type // Data type of the matrix
684  , bool SO > // Storage order
685 inline constexpr UniformMatrix<Type,SO>& UniformMatrix<Type,SO>::operator=( const Type& rhs )
686 {
687  value_ = rhs;
688 
689  return *this;
690 }
691 //*************************************************************************************************
692 
693 
694 //*************************************************************************************************
703 template< typename Type // Data type of the matrix
704  , bool SO > // Storage order
705 template< typename MT // Type of the right-hand side matrix
706  , bool SO2 > // Storage order of the right-hand side matrix
708 {
709  using TT = decltype( trans( *this ) );
710  using CT = decltype( ctrans( *this ) );
711 
712  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
713  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of uniform matrix" );
714  }
715 
716  if( IsSame_v<MT,TT> && (~rhs).isAliased( this ) ) {
717  transpose();
718  }
719  else if( IsSame_v<MT,CT> && (~rhs).isAliased( this ) ) {
720  ctranspose();
721  }
722  else {
723  m_ = (~rhs).rows();
724  n_ = (~rhs).columns();
725 
726  if( (~rhs).rows() > 0UL && (~rhs).columns() > 0UL ) {
727  value_ = (~rhs)(0UL,0UL);
728  }
729  }
730 
731  return *this;
732 }
733 //*************************************************************************************************
734 
735 
736 //*************************************************************************************************
746 template< typename Type // Data type of the matrix
747  , bool SO > // Storage order
748 template< typename MT // Type of the right-hand side matrix
749  , bool SO2 > // Storage order of the right-hand side matrix
751 {
752  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
753  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
754  }
755 
756  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
757  BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition assignment to uniform matrix" );
758  }
759 
760  if( m_ > 0UL && n_ > 0UL ) {
761  value_ += (~rhs)(0UL,0UL);
762  }
763 
764  return *this;
765 }
766 //*************************************************************************************************
767 
768 
769 //*************************************************************************************************
779 template< typename Type // Data type of the matrix
780  , bool SO > // Storage order
781 template< typename MT // Type of the right-hand side matrix
782  , bool SO2 > // Storage order of the right-hand side matrix
784 {
785  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
786  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
787  }
788 
789  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
790  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction assignment to uniform matrix" );
791  }
792 
793  if( m_ > 0UL && n_ > 0UL ) {
794  value_ -= (~rhs)(0UL,0UL);
795  }
796 
797  return *this;
798 }
799 //*************************************************************************************************
800 
801 
802 //*************************************************************************************************
812 template< typename Type // Data type of the matrix
813  , bool SO > // Storage order
814 template< typename MT // Type of the right-hand side matrix
815  , bool SO2 > // Storage order of the right-hand side matrix
817 {
818  if( (~rhs).rows() != m_ || (~rhs).columns() != n_ ) {
819  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
820  }
821 
822  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
823  BLAZE_THROW_INVALID_ARGUMENT( "Invalid Schur product assignment to uniform matrix" );
824  }
825 
826  if( m_ > 0UL && n_ > 0UL ) {
827  value_ *= (~rhs)(0UL,0UL);
828  }
829 
830  return *this;
831 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
845 template< typename Type // Data type of the matrix
846  , bool SO > // Storage order
847 template< typename MT // Type of the right-hand side matrix
848  , bool SO2 > // Storage order of the right-hand side matrix
850 {
851  if( (~rhs).rows() != n_ ) {
852  BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
853  }
854 
855  if( !IsUniform_v<MT> && !isUniform( ~rhs ) ) {
856  BLAZE_THROW_INVALID_ARGUMENT( "Invalid multiplication assignment to uniform matrix" );
857  }
858 
859  n_ = (~rhs).columns();
860 
861  if( m_ > 0UL && n_ > 0UL ) {
862  value_ = ( value_ * (~rhs)(0UL,0UL) ) * Type( (~rhs).rows() );
863  }
864 
865  return *this;
866 }
867 //*************************************************************************************************
868 
869 
870 //*************************************************************************************************
877 template< typename Type // Data type of the matrix
878  , bool SO > // Storage order
879 template< typename ST > // Data type of the right-hand side scalar
880 inline auto UniformMatrix<Type,SO>::operator*=( ST scalar )
882 {
883  if( rows() > 0UL && columns() > 0UL ) {
884  value_ *= scalar;
885  }
886 
887  return *this;
888 }
889 //*************************************************************************************************
890 
891 
892 //*************************************************************************************************
899 template< typename Type // Data type of the matrix
900  , bool SO > // Storage order
901 template< typename ST > // Data type of the right-hand side scalar
902 inline auto UniformMatrix<Type,SO>::operator/=( ST scalar )
904 {
905  if( rows() > 0UL && columns() > 0UL ) {
906  value_ /= scalar;
907  }
908 
909  return *this;
910 }
911 //*************************************************************************************************
912 
913 
914 
915 
916 //=================================================================================================
917 //
918 // UTILITY FUNCTIONS
919 //
920 //=================================================================================================
921 
922 //*************************************************************************************************
927 template< typename Type // Data type of the matrix
928  , bool SO > // Storage order
929 inline constexpr size_t UniformMatrix<Type,SO>::rows() const noexcept
930 {
931  return m_;
932 }
933 //*************************************************************************************************
934 
935 
936 //*************************************************************************************************
941 template< typename Type // Data type of the matrix
942  , bool SO > // Storage order
943 inline constexpr size_t UniformMatrix<Type,SO>::columns() const noexcept
944 {
945  return n_;
946 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
960 template< typename Type // Data type of the matrix
961  , bool SO > // Storage order
962 inline constexpr size_t UniformMatrix<Type,SO>::spacing() const noexcept
963 {
964  return SO ? m_ : n_;
965 }
966 //*************************************************************************************************
967 
968 
969 //*************************************************************************************************
974 template< typename Type // Data type of the matrix
975  , bool SO > // Storage order
976 inline constexpr size_t UniformMatrix<Type,SO>::capacity() const noexcept
977 {
978  return m_ * n_;
979 }
980 //*************************************************************************************************
981 
982 
983 //*************************************************************************************************
994 template< typename Type // Data type of the matrix
995  , bool SO > // Storage order
996 inline constexpr size_t UniformMatrix<Type,SO>::capacity( size_t i ) const noexcept
997 {
998  MAYBE_UNUSED( i );
999  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
1000  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
1001  return SO ? m_ : n_;
1002 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1011 template< typename Type // Data type of the matrix
1012  , bool SO > // Storage order
1014 {
1015  if( m_ == 0UL || n_ == 0UL || isDefault( value_ ) )
1016  return 0UL;
1017  else
1018  return m_ * n_;
1019 }
1020 //*************************************************************************************************
1021 
1022 
1023 //*************************************************************************************************
1034 template< typename Type // Data type of the matrix
1035  , bool SO > // Storage order
1036 inline size_t UniformMatrix<Type,SO>::nonZeros( size_t i ) const
1037 {
1038  MAYBE_UNUSED( i );
1039 
1040  BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
1041  BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
1042 
1043  const size_t tmp( SO ? m_ : n_ );
1044  if( tmp == 0UL || isDefault( value_ ) )
1045  return 0UL;
1046  else
1047  return tmp;
1048 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1057 template< typename Type // Data type of the matrix
1058  , bool SO > // Storage order
1059 inline constexpr void UniformMatrix<Type,SO>::reset()
1060 {
1061  using blaze::clear;
1062 
1063  clear( value_ );
1064 }
1065 //*************************************************************************************************
1066 
1067 
1068 //*************************************************************************************************
1075 template< typename Type // Data type of the matrix
1076  , bool SO > // Storage order
1077 inline constexpr void UniformMatrix<Type,SO>::clear()
1078 {
1079  m_ = 0UL;
1080  n_ = 0UL;
1081 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1099 template< typename Type // Data type of the matrix
1100  , bool SO > // Storage order
1101 void constexpr UniformMatrix<Type,SO>::resize( size_t m, size_t n, bool preserve )
1102 {
1103  MAYBE_UNUSED( preserve );
1104 
1105  m_ = m;
1106  n_ = n;
1107 }
1108 //*************************************************************************************************
1109 
1110 
1111 //*************************************************************************************************
1123 template< typename Type // Data type of the matrix
1124  , bool SO > // Storage order
1125 inline constexpr void UniformMatrix<Type,SO>::extend( size_t m, size_t n, bool preserve )
1126 {
1127  resize( m_+m, n_+n, preserve );
1128 }
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1138 template< typename Type // Data type of the matrix
1139  , bool SO > // Storage order
1140 inline constexpr void UniformMatrix<Type,SO>::swap( UniformMatrix& m ) noexcept
1141 {
1142  using std::swap;
1143 
1144  swap( m_, m.m_ );
1145  swap( n_, m.n_ );
1146  swap( value_, m.value_ );
1147 }
1148 //*************************************************************************************************
1149 
1150 
1151 
1152 
1153 //=================================================================================================
1154 //
1155 // NUMERIC FUNCTIONS
1156 //
1157 //=================================================================================================
1158 
1159 //*************************************************************************************************
1164 template< typename Type // Data type of the matrix
1165  , bool SO > // Storage order
1167 {
1168  using std::swap;
1169 
1170  swap( m_, n_ );
1171 
1172  return *this;
1173 }
1174 //*************************************************************************************************
1175 
1176 
1177 //*************************************************************************************************
1182 template< typename Type // Data type of the matrix
1183  , bool SO > // Storage order
1185 {
1186  using std::swap;
1187 
1188  swap( m_, n_ );
1189  conjugate( value_ );
1190 
1191  return *this;
1192 }
1193 //*************************************************************************************************
1194 
1195 
1196 //*************************************************************************************************
1213 template< typename Type // Data type of the matrix
1214  , bool SO > // Storage order
1215 template< typename Other > // Data type of the scalar value
1217 {
1218  if( m_ > 0UL && n_ > 0UL ) {
1219  value_ *= scalar;
1220  }
1221 
1222  return *this;
1223 }
1224 //*************************************************************************************************
1225 
1226 
1227 
1228 
1229 //=================================================================================================
1230 //
1231 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1232 //
1233 //=================================================================================================
1234 
1235 //*************************************************************************************************
1245 template< typename Type // Data type of the matrix
1246  , bool SO > // Storage order
1247 template< typename Other > // Data type of the foreign expression
1248 inline bool UniformMatrix<Type,SO>::canAlias( const Other* alias ) const noexcept
1249 {
1250  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1251 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1265 template< typename Type // Data type of the matrix
1266  , bool SO > // Storage order
1267 template< typename Other > // Data type of the foreign expression
1268 inline bool UniformMatrix<Type,SO>::isAliased( const Other* alias ) const noexcept
1269 {
1270  return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1271 }
1272 //*************************************************************************************************
1273 
1274 
1275 //*************************************************************************************************
1284 template< typename Type // Data type of the matrix
1285  , bool SO > // Storage order
1286 inline bool UniformMatrix<Type,SO>::isAligned() const noexcept
1287 {
1288  return true;
1289 }
1290 //*************************************************************************************************
1291 
1292 
1293 //*************************************************************************************************
1303 template< typename Type // Data type of the matrix
1304  , bool SO > // Storage order
1305 inline bool UniformMatrix<Type,SO>::canSMPAssign() const noexcept
1306 {
1307  return ( rows() * columns() >= SMP_DMATASSIGN_THRESHOLD );
1308 }
1309 //*************************************************************************************************
1310 
1311 
1312 //*************************************************************************************************
1327 template< typename Type // Data type of the matrix
1328  , bool SO > // Storage order
1330  UniformMatrix<Type,SO>::load( size_t i, size_t j ) const noexcept
1331 {
1332  return loada( i, j );
1333 }
1334 //*************************************************************************************************
1335 
1336 
1337 //*************************************************************************************************
1352 template< typename Type // Data type of the matrix
1353  , bool SO > // Storage order
1355  UniformMatrix<Type,SO>::loada( size_t i, size_t j ) const noexcept
1356 {
1357  MAYBE_UNUSED( i, j );
1358 
1360 
1361  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1362  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1363  BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1364  BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1365 
1366  return set( value_ );
1367 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1386 template< typename Type // Data type of the matrix
1387  , bool SO > // Storage order
1389  UniformMatrix<Type,SO>::loadu( size_t i, size_t j ) const noexcept
1390 {
1391  MAYBE_UNUSED( i, j );
1392 
1394 
1395  BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1396  BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1397  BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1398  BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1399 
1400  return set( value_ );
1401 }
1402 //*************************************************************************************************
1403 
1404 
1405 
1406 
1407 
1408 
1409 
1410 
1411 //=================================================================================================
1412 //
1413 // UNIFORMMATRIX OPERATORS
1414 //
1415 //=================================================================================================
1416 
1417 //*************************************************************************************************
1420 template< typename Type, bool SO >
1421 constexpr void reset( UniformMatrix<Type,SO>& m );
1422 
1423 template< typename Type, bool SO >
1424 constexpr void clear( UniformMatrix<Type,SO>& m );
1425 
1426 template< bool RF, typename Type, bool SO >
1427 constexpr bool isDefault( const UniformMatrix<Type,SO>& m );
1428 
1429 template< typename Type, bool SO >
1430 constexpr bool isIntact( const UniformMatrix<Type,SO>& m ) noexcept;
1431 
1432 template< typename Type, bool SO >
1433 constexpr void swap( UniformMatrix<Type,SO>& a, UniformMatrix<Type,SO>& b ) noexcept;
1435 //*************************************************************************************************
1436 
1437 
1438 //*************************************************************************************************
1445 template< typename Type // Data type of the matrix
1446  , bool SO > // Storage order
1447 inline constexpr void reset( UniformMatrix<Type,SO>& m )
1448 {
1449  m.reset();
1450 }
1451 //*************************************************************************************************
1452 
1453 
1454 //*************************************************************************************************
1461 template< typename Type // Data type of the matrix
1462  , bool SO > // Storage order
1463 inline constexpr void clear( UniformMatrix<Type,SO>& m )
1464 {
1465  m.clear();
1466 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1495 template< bool RF // Relaxation flag
1496  , typename Type // Data type of the matrix
1497  , bool SO > // Storage order
1498 inline constexpr bool isDefault( const UniformMatrix<Type,SO>& m )
1499 {
1500  return ( m.rows() == 0UL && m.columns() == 0UL );
1501 }
1502 //*************************************************************************************************
1503 
1504 
1505 //*************************************************************************************************
1523 template< typename Type // Data type of the matrix
1524  , bool SO > // Storage order
1525 inline constexpr bool isIntact( const UniformMatrix<Type,SO>& m ) noexcept
1526 {
1527  MAYBE_UNUSED( m );
1528 
1529  return true;
1530 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1542 template< typename Type // Data type of the matrix
1543  , bool SO > // Storage order
1544 inline constexpr void swap( UniformMatrix<Type,SO>& a, UniformMatrix<Type,SO>& b ) noexcept
1545 {
1546  a.swap( b );
1547 }
1548 //*************************************************************************************************
1549 
1550 
1551 
1552 
1553 //=================================================================================================
1554 //
1555 // GLOBAL FUNCTIONS
1556 //
1557 //=================================================================================================
1558 
1559 //*************************************************************************************************
1593 template< bool SO = defaultStorageOrder, typename T >
1594 inline constexpr decltype(auto) uniform( size_t m, size_t n, T&& init )
1595 {
1596  return UniformMatrix< RemoveCVRef_t<T>, SO >( m, n, std::forward<T>( init ) );
1597 }
1598 //*************************************************************************************************
1599 
1600 
1601 
1602 
1603 //=================================================================================================
1604 //
1605 // ISUNIFORM SPECIALIZATIONS
1606 //
1607 //=================================================================================================
1608 
1609 //*************************************************************************************************
1611 template< typename Type, bool SO >
1612 struct IsUniform< UniformMatrix<Type,SO> >
1613  : public TrueType
1614 {};
1616 //*************************************************************************************************
1617 
1618 
1619 
1620 
1621 //=================================================================================================
1622 //
1623 // ISALIGNED SPECIALIZATIONS
1624 //
1625 //=================================================================================================
1626 
1627 //*************************************************************************************************
1629 template< typename Type, bool SO >
1630 struct IsAligned< UniformMatrix<Type,SO> >
1631  : public TrueType
1632 {};
1634 //*************************************************************************************************
1635 
1636 
1637 
1638 
1639 //=================================================================================================
1640 //
1641 // ISRESIZABLE SPECIALIZATIONS
1642 //
1643 //=================================================================================================
1644 
1645 //*************************************************************************************************
1647 template< typename Type, bool SO >
1648 struct IsResizable< UniformMatrix<Type,SO> >
1649  : public TrueType
1650 {};
1652 //*************************************************************************************************
1653 
1654 
1655 
1656 
1657 //=================================================================================================
1658 //
1659 // ADDTRAIT SPECIALIZATIONS
1660 //
1661 //=================================================================================================
1662 
1663 //*************************************************************************************************
1665 template< typename T1, typename T2 >
1666 struct AddTraitEval1< T1, T2
1667  , EnableIf_t< IsMatrix_v<T1> &&
1668  IsMatrix_v<T2> &&
1669  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1670  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1671 {
1672  using ET1 = ElementType_t<T1>;
1673  using ET2 = ElementType_t<T2>;
1674 
1675  static constexpr bool SO1 = StorageOrder_v<T1>;
1676  static constexpr bool SO2 = StorageOrder_v<T2>;
1677 
1678  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1679  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1680  ? ( IsSymmetric_v<T1>
1681  ? SO2
1682  : SO1 )
1683  : SO1 && SO2 )
1684  : ( IsDenseMatrix_v<T1>
1685  ? SO1
1686  : SO2 ) );
1687 
1688  using Type = UniformMatrix< AddTrait_t<ET1,ET2>, SO >;
1689 };
1691 //*************************************************************************************************
1692 
1693 
1694 
1695 
1696 //=================================================================================================
1697 //
1698 // SUBTRAIT SPECIALIZATIONS
1699 //
1700 //=================================================================================================
1701 
1702 //*************************************************************************************************
1704 template< typename T1, typename T2 >
1705 struct SubTraitEval1< T1, T2
1706  , EnableIf_t< IsMatrix_v<T1> &&
1707  IsMatrix_v<T2> &&
1708  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1709  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1710 {
1711  using ET1 = ElementType_t<T1>;
1712  using ET2 = ElementType_t<T2>;
1713 
1714  static constexpr bool SO1 = StorageOrder_v<T1>;
1715  static constexpr bool SO2 = StorageOrder_v<T2>;
1716 
1717  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1718  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1719  ? ( IsSymmetric_v<T1>
1720  ? SO2
1721  : SO1 )
1722  : SO1 && SO2 )
1723  : ( IsDenseMatrix_v<T1>
1724  ? SO1
1725  : SO2 ) );
1726 
1727  using Type = UniformMatrix< SubTrait_t<ET1,ET2>, SO >;
1728 };
1730 //*************************************************************************************************
1731 
1732 
1733 
1734 
1735 //=================================================================================================
1736 //
1737 // SCHURTRAIT SPECIALIZATIONS
1738 //
1739 //=================================================================================================
1740 
1741 //*************************************************************************************************
1743 template< typename T1, typename T2 >
1744 struct SchurTraitEval1< T1, T2
1745  , EnableIf_t< IsMatrix_v<T1> &&
1746  IsMatrix_v<T2> &&
1747  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1748  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1749 {
1750  using ET1 = ElementType_t<T1>;
1751  using ET2 = ElementType_t<T2>;
1752 
1753  static constexpr bool SO1 = StorageOrder_v<T1>;
1754  static constexpr bool SO2 = StorageOrder_v<T2>;
1755 
1756  static constexpr bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1757  ? ( IsSymmetric_v<T1>
1758  ? SO2
1759  : SO1 )
1760  : SO1 && SO2 );
1761 
1762  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, SO >;
1763 };
1765 //*************************************************************************************************
1766 
1767 
1768 
1769 
1770 //=================================================================================================
1771 //
1772 // MULTTRAIT SPECIALIZATIONS
1773 //
1774 //=================================================================================================
1775 
1776 //*************************************************************************************************
1778 template< typename T1, typename T2 >
1779 struct MultTraitEval1< T1, T2
1780  , EnableIf_t< IsMatrix_v<T1> &&
1781  IsUniform_v<T1> &&
1782  !IsZero_v<T1> &&
1783  IsNumeric_v<T2> > >
1784 {
1785  using ET1 = ElementType_t<T1>;
1786 
1787  using Type = UniformMatrix< MultTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1788 };
1789 
1790 template< typename T1, typename T2 >
1791 struct MultTraitEval1< T1, T2
1792  , EnableIf_t< IsNumeric_v<T1> &&
1793  IsMatrix_v<T2> &&
1794  IsUniform_v<T2> &&
1795  !IsZero_v<T2> > >
1796 {
1797  using ET2 = ElementType_t<T2>;
1798 
1799  using Type = UniformMatrix< MultTrait_t<T1,ET2>, StorageOrder_v<T2> >;
1800 };
1801 
1802 template< typename T1, typename T2 >
1803 struct MultTraitEval1< T1, T2
1804  , EnableIf_t< IsColumnVector_v<T1> &&
1805  IsRowVector_v<T2> &&
1806  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1807  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1808 {
1809  using ET1 = ElementType_t<T1>;
1810  using ET2 = ElementType_t<T2>;
1811 
1812  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, false >;
1813 };
1814 
1815 template< typename T1, typename T2 >
1816 struct MultTraitEval1< T1, T2
1817  , EnableIf_t< IsMatrix_v<T1> &&
1818  IsMatrix_v<T2> &&
1819  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1820  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1821 {
1822  using ET1 = ElementType_t<T1>;
1823  using ET2 = ElementType_t<T2>;
1824 
1825  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T1> >;
1826 };
1828 //*************************************************************************************************
1829 
1830 
1831 
1832 
1833 //=================================================================================================
1834 //
1835 // KRONTRAIT SPECIALIZATIONS
1836 //
1837 //=================================================================================================
1838 
1839 //*************************************************************************************************
1841 template< typename T1, typename T2 >
1842 struct KronTraitEval1< T1, T2
1843  , EnableIf_t< IsMatrix_v<T1> &&
1844  IsMatrix_v<T2> &&
1845  ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1846  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1847 {
1848  using ET1 = ElementType_t<T1>;
1849  using ET2 = ElementType_t<T2>;
1850 
1851  using Type = UniformMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T2> >;
1852 };
1854 //*************************************************************************************************
1855 
1856 
1857 
1858 
1859 //=================================================================================================
1860 //
1861 // DIVTRAIT SPECIALIZATIONS
1862 //
1863 //=================================================================================================
1864 
1865 //*************************************************************************************************
1867 template< typename T1, typename T2 >
1868 struct DivTraitEval1< T1, T2
1869  , EnableIf_t< IsMatrix_v<T1> &&
1870  IsNumeric_v<T2> &&
1871  IsUniform_v<T1> && !IsZero_v<T1> > >
1872 {
1873  using ET1 = ElementType_t<T1>;
1874 
1875  using Type = UniformMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
1876 };
1878 //*************************************************************************************************
1879 
1880 
1881 
1882 
1883 //=================================================================================================
1884 //
1885 // MAPTRAIT SPECIALIZATIONS
1886 //
1887 //=================================================================================================
1888 
1889 //*************************************************************************************************
1891 template< typename T, typename OP >
1892 struct UnaryMapTraitEval1< T, OP
1893  , EnableIf_t< IsMatrix_v<T> &&
1894  YieldsUniform_v<OP,T> &&
1895  !YieldsZero_v<OP,T> > >
1896 {
1897  using ET = ElementType_t<T>;
1898 
1899  using Type = UniformMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
1900 };
1902 //*************************************************************************************************
1903 
1904 
1905 //*************************************************************************************************
1907 template< typename T1, typename T2, typename OP >
1908 struct BinaryMapTraitEval1< T1, T2, OP
1909  , EnableIf_t< IsMatrix_v<T1> &&
1910  IsMatrix_v<T2> &&
1911  YieldsUniform_v<OP,T1,T2> &&
1912  !YieldsZero_v<OP,T1,T2> > >
1913 {
1914  using ET1 = ElementType_t<T1>;
1915  using ET2 = ElementType_t<T2>;
1916 
1917  static constexpr bool SO1 = StorageOrder_v<T1>;
1918  static constexpr bool SO2 = StorageOrder_v<T2>;
1919 
1920  static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1921  ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1922  ? ( IsSymmetric_v<T1>
1923  ? SO2
1924  : SO1 )
1925  : SO1 && SO2 )
1926  : ( IsDenseMatrix_v<T1>
1927  ? SO1
1928  : SO2 ) );
1929 
1930  using Type = UniformMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
1931 };
1933 //*************************************************************************************************
1934 
1935 
1936 
1937 
1938 //=================================================================================================
1939 //
1940 // EXPANDTRAIT SPECIALIZATIONS
1941 //
1942 //=================================================================================================
1943 
1944 //*************************************************************************************************
1946 template< typename T // Type to be expanded
1947  , size_t E > // Compile time expansion
1948 struct ExpandTraitEval1< T, E
1949  , EnableIf_t< IsVector_v<T> &&
1950  IsUniform_v<T> && !IsZero_v<T> > >
1951 {
1952  static constexpr bool TF = ( IsColumnVector_v<T> ? columnMajor : rowMajor );
1953 
1954  using Type = UniformMatrix< ElementType_t<T>, TF >;
1955 };
1957 //*************************************************************************************************
1958 
1959 
1960 
1961 
1962 //=================================================================================================
1963 //
1964 // HIGHTYPE SPECIALIZATIONS
1965 //
1966 //=================================================================================================
1967 
1968 //*************************************************************************************************
1970 template< typename T1, bool SO, typename T2 >
1971 struct HighType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1972 {
1973  using Type = UniformMatrix< typename HighType<T1,T2>::Type, SO >;
1974 };
1976 //*************************************************************************************************
1977 
1978 
1979 
1980 
1981 //=================================================================================================
1982 //
1983 // LOWTYPE SPECIALIZATIONS
1984 //
1985 //=================================================================================================
1986 
1987 //*************************************************************************************************
1989 template< typename T1, bool SO, typename T2 >
1990 struct LowType< UniformMatrix<T1,SO>, UniformMatrix<T2,SO> >
1991 {
1992  using Type = UniformMatrix< typename LowType<T1,T2>::Type, SO >;
1993 };
1995 //*************************************************************************************************
1996 
1997 
1998 
1999 
2000 //=================================================================================================
2001 //
2002 // SUBMATRIXTRAIT SPECIALIZATIONS
2003 //
2004 //=================================================================================================
2005 
2006 //*************************************************************************************************
2008 template< typename MT, size_t I, size_t J, size_t M, size_t N >
2009 struct SubmatrixTraitEval1< MT, I, J, M, N
2010  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2011 {
2012  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
2013 };
2015 //*************************************************************************************************
2016 
2017 
2018 
2019 
2020 //=================================================================================================
2021 //
2022 // ROWSTRAIT SPECIALIZATIONS
2023 //
2024 //=================================================================================================
2025 
2026 //*************************************************************************************************
2028 template< typename MT, size_t M >
2029 struct RowsTraitEval1< MT, M
2030  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2031 {
2032  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, false >;
2033 };
2035 //*************************************************************************************************
2036 
2037 
2038 
2039 
2040 //=================================================================================================
2041 //
2042 // COLUMNSTRAIT SPECIALIZATIONS
2043 //
2044 //=================================================================================================
2045 
2046 //*************************************************************************************************
2048 template< typename MT, size_t N >
2049 struct ColumnsTraitEval1< MT, N
2050  , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2051 {
2052  using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >, true >;
2053 };
2055 //*************************************************************************************************
2056 
2057 } // namespace blaze
2058 
2059 #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,...
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.
constexpr void swap(UniformMatrix< Type, SO > &a, UniformMatrix< Type, SO > &b) noexcept
Swapping the contents of two uniform matrices.
Definition: UniformMatrix.h:1544
Header file for the Schur product trait.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
constexpr size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: UniformMatrix.h:929
Header file for the alignment flag values.
Header file for the subtraction trait.
Header file for basic type definitions.
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:605
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: UniformMatrix.h:506
constexpr void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: UniformMatrix.h:1125
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
const Type & ConstReference
Reference to a constant matrix value.
Definition: UniformMatrix.h:201
Header file for the RemoveCVRef type trait.
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:356
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
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: IntegralConstant.h:132
Header file for all forward declarations of the math module.
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: UniformMatrix.h:234
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the matrix.
Definition: UniformMatrix.h:976
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:202
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
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:138
Header file for the IsMatrix type trait.
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: UniformMatrix.h:240
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:196
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: UniformMatrix.h:1305
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:902
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:1355
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:358
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:1361
#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:579
Header file for the expand trait.
#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:203
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:1389
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.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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:657
Header file for the default storage order for all vectors of the Blaze library.
Header file for the Kron product trait.
#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:1059
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:1638
const Type & Reference
Reference to a non-constant matrix value.
Definition: UniformMatrix.h:200
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:615
constexpr size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: UniformMatrix.h:943
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:962
Header file for the IsNumeric type trait.
Resize mechanism to obtain a UniformMatrix with different fixed dimensions.
Definition: UniformMatrix.h:223
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: UniformMatrix.h:1013
constexpr void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: UniformMatrix.h:1101
Header file for the RemoveConst type trait.
constexpr UniformMatrix & transpose()
In-place transpose of the matrix.
Definition: UniformMatrix.h:1166
Header file for the YieldsUniform type trait.
size_t n_
The current number of columns of the matrix.
Definition: UniformMatrix.h:357
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:1184
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:1248
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:685
Header file for the columns trait.
Header file for the IsZero type trait.
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:139
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:1140
#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,...
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:282
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
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:114
Constraint on the data type.
constexpr void clear()
Clearing the matrix.
Definition: UniformMatrix.h:1077
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:387
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: UniformMatrix.h:333
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:480
Header file for the rows trait.
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: UniformMatrix.h:1286
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: UniformMatrix.h:1268
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:197
Header file for the StorageOrder type trait.
Header file for the IntegralConstant class template.
UniformMatrix< Type, SO > This
Type of this UniformMatrix instance.
Definition: UniformMatrix.h:190
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:264
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.The IsColumnVector_v variable template ...
Definition: IsColumnVector.h:142
Type ElementType
Type of the matrix elements.
Definition: UniformMatrix.h:195
Header file for the IsColumnVector type trait.
decltype(auto) constexpr uniform(size_t m, size_t n, T &&init)
Creating a uniform matrix.
Definition: UniformMatrix.h:1594
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.The IsUniform_v variable template provides a...
Definition: IsUniform.h:164
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,...
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:631
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: UniformMatrix.h:1330
Header file for the Expression base class.
Header file for the HighType type trait.
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:535
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:213