Blaze 3.9
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>
52#include <blaze/math/Forward.h>
58#include <blaze/math/SIMD.h>
88#include <blaze/system/Inline.h>
90#include <blaze/util/Assert.h>
96#include <blaze/util/EnableIf.h>
99#include <blaze/util/Types.h>
103
104
105namespace blaze {
106
107//=================================================================================================
108//
109// CLASS DEFINITION
110//
111//=================================================================================================
112
113//*************************************************************************************************
192template< typename Type // Data type of the matrix
193 , bool SO // Storage order
194 , typename Tag > // Tag type
196 : public Expression< DenseMatrix< UniformMatrix<Type,SO,Tag>, SO > >
197{
198 public:
199 //**Type definitions****************************************************************************
202
205
208
211
212 using ElementType = Type;
214 using TagType = Tag;
215 using ReturnType = const Type&;
216 using CompositeType = const This&;
217
218 using Reference = const Type&;
219 using ConstReference = const Type&;
220 using Pointer = const Type*;
221 using ConstPointer = const Type*;
222
225 //**********************************************************************************************
226
227 //**Rebind struct definition********************************************************************
230 template< typename NewType > // Data type of the other matrix
231 struct Rebind {
233 };
234 //**********************************************************************************************
235
236 //**Resize struct definition********************************************************************
239 template< size_t NewM // Number of rows of the other matrix
240 , size_t NewN > // Number of columns of the other matrix
241 struct Resize {
243 };
244 //**********************************************************************************************
245
246 //**Compilation flags***************************************************************************
248
252 static constexpr bool simdEnabled = IsVectorizable_v<Type>;
253
255
258 static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
259 //**********************************************************************************************
260
261 //**Constructors********************************************************************************
264 constexpr UniformMatrix() noexcept;
265 constexpr UniformMatrix( size_t m, size_t n );
266 constexpr UniformMatrix( size_t m, size_t n, const Type& init );
267
268 template< typename MT, bool SO2 >
269 inline UniformMatrix( const Matrix<MT,SO2>& m );
270
271 inline UniformMatrix( const UniformMatrix& m ) = default;
272 inline UniformMatrix( UniformMatrix&& m ) = default;
273
275 //**********************************************************************************************
276
277 //**Destructor**********************************************************************************
280 ~UniformMatrix() = default;
282 //**********************************************************************************************
283
284 //**Data access functions***********************************************************************
287 constexpr ConstReference operator()( size_t i, size_t j ) const noexcept;
288 inline ConstReference at( size_t i, size_t j ) const;
289 constexpr ConstPointer data () const noexcept;
290 constexpr ConstPointer data ( size_t i ) const noexcept;
291 constexpr ConstIterator begin ( size_t i ) const noexcept;
292 constexpr ConstIterator cbegin( size_t i ) const noexcept;
293 constexpr ConstIterator end ( size_t i ) const noexcept;
294 constexpr ConstIterator cend ( size_t i ) const noexcept;
296 //**********************************************************************************************
297
298 //**Assignment operators************************************************************************
301 constexpr UniformMatrix& operator=( const Type& rhs ) &;
302
303 UniformMatrix& operator=( const UniformMatrix& ) & = default;
304 UniformMatrix& operator=( UniformMatrix&& ) & = default;
305
306 template< typename MT, bool SO2 > inline UniformMatrix& operator= ( const Matrix<MT,SO2>& rhs ) &;
307 template< typename MT, bool SO2 > inline UniformMatrix& operator+=( const Matrix<MT,SO2>& rhs ) &;
308 template< typename MT, bool SO2 > inline UniformMatrix& operator-=( const Matrix<MT,SO2>& rhs ) &;
309 template< typename MT, bool SO2 > inline UniformMatrix& operator%=( const Matrix<MT,SO2>& rhs ) &;
310 template< typename MT, bool SO2 > inline UniformMatrix& operator*=( const Matrix<MT,SO2>& rhs ) &;
311
312 template< typename ST >
313 inline auto operator*=( ST rhs ) & -> EnableIf_t< IsScalar_v<ST>, UniformMatrix& >;
314
315 template< typename ST >
316 inline auto operator/=( ST rhs ) & -> EnableIf_t< IsScalar_v<ST>, UniformMatrix& >;
318 //**********************************************************************************************
319
320 //**Utility functions***************************************************************************
323 constexpr size_t rows() const noexcept;
324 constexpr size_t columns() const noexcept;
325 constexpr size_t spacing() const noexcept;
326 constexpr size_t capacity() const noexcept;
327 constexpr size_t capacity( size_t i ) const noexcept;
328 inline size_t nonZeros() const;
329 inline size_t nonZeros( size_t i ) const;
330 constexpr void reset();
331 constexpr void clear();
332 constexpr void resize ( size_t m, size_t n, bool preserve=true );
333 constexpr void extend ( size_t m, size_t n, bool preserve=true );
334 constexpr void swap( UniformMatrix& m ) noexcept;
336 //**********************************************************************************************
337
338 //**Numeric functions***************************************************************************
341 constexpr UniformMatrix& transpose();
342 constexpr UniformMatrix& ctranspose();
343
344 template< typename Other > inline UniformMatrix& scale( const Other& scalar );
346 //**********************************************************************************************
347
348 private:
349 //**********************************************************************************************
351 static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
352 //**********************************************************************************************
353
354 public:
355 //**Expression template evaluation functions****************************************************
358 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
359 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
360
361 inline bool isAligned () const noexcept;
362 inline bool canSMPAssign() const noexcept;
363
364 BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
365 BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
366 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
368 //**********************************************************************************************
369
370 private:
371 //**Member variables****************************************************************************
374 size_t m_;
375 size_t n_;
376 Type value_;
378 //**********************************************************************************************
379
380 //**Compile time checks*************************************************************************
387 //**********************************************************************************************
388};
389//*************************************************************************************************
390
391
392
393
394//=================================================================================================
395//
396// CONSTRUCTORS
397//
398//=================================================================================================
399
400//*************************************************************************************************
403template< typename Type // Data type of the matrix
404 , bool SO // Storage order
405 , typename Tag > // Tag type
406constexpr UniformMatrix<Type,SO,Tag>::UniformMatrix() noexcept
407 : m_ ( 0UL ) // The current number of rows of the matrix
408 , n_ ( 0UL ) // The current number of columns of the matrix
409 , value_() // The value of all elements of the uniform matrix
410{}
411//*************************************************************************************************
412
413
414//*************************************************************************************************
420template< typename Type // Data type of the matrix
421 , bool SO // Storage order
422 , typename Tag > // Tag type
423constexpr UniformMatrix<Type,SO,Tag>::UniformMatrix( size_t m, size_t n )
424 : m_ ( m ) // The current number of rows of the matrix
425 , n_ ( n ) // The current number of columns of the matrix
426 , value_() // The value of all elements of the uniform matrix
427{}
428//*************************************************************************************************
429
430
431//*************************************************************************************************
440template< typename Type // Data type of the matrix
441 , bool SO // Storage order
442 , typename Tag > // Tag type
443constexpr UniformMatrix<Type,SO,Tag>::UniformMatrix( size_t m, size_t n, const Type& init )
444 : m_ ( m ) // The current number of rows of the matrix
445 , n_ ( n ) // The current number of columns of the matrix
446 , value_( init ) // The value of all elements of the uniform matrix
447{}
448//*************************************************************************************************
449
450
451//*************************************************************************************************
460template< typename Type // Data type of the matrix
461 , bool SO // Storage order
462 , typename Tag > // Tag type
463template< typename MT // Type of the foreign matrix
464 , bool SO2 > // Storage order of the foreign matrix
466 : m_ ( (*m).rows() ) // The current number of rows of the matrix
467 , n_ ( (*m).columns() ) // The current number of columns of the matrix
468 , value_() // The value of all elements of the uniform vector
469{
470 if( !IsUniform_v<MT> && !isUniform( *m ) ) {
471 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniform matrix" );
472 }
473
474 if( m_ > 0UL && n_ > 0UL ) {
475 value_ = (*m)(0UL,0UL);
476 }
477}
478//*************************************************************************************************
479
480
481
482
483//=================================================================================================
484//
485// DATA ACCESS FUNCTIONS
486//
487//=================================================================================================
488
489//*************************************************************************************************
499template< typename Type // Data type of the matrix
500 , bool SO // Storage order
501 , typename Tag > // Type tag
503 UniformMatrix<Type,SO,Tag>::operator()( size_t i, size_t j ) const noexcept
504{
505 MAYBE_UNUSED( i, j );
506
507 BLAZE_USER_ASSERT( i < m_, "Invalid row access index" );
508 BLAZE_USER_ASSERT( j < n_, "Invalid column access index" );
509
510 return value_;
511}
512//*************************************************************************************************
513
514
515//*************************************************************************************************
526template< typename Type // Data type of the matrix
527 , bool SO // Storage order
528 , typename Tag > // Type tag
530 UniformMatrix<Type,SO,Tag>::at( size_t i, size_t j ) const
531{
532 if( i >= m_ ) {
533 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
534 }
535 if( j >= n_ ) {
536 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
537 }
538
539 return (*this)(i,j);
540}
541//*************************************************************************************************
542
543
544//*************************************************************************************************
556template< typename Type // Data type of the matrix
557 , bool SO // Storage order
558 , typename Tag > // Type tag
561{
562 return &value_;
563}
564//*************************************************************************************************
565
566
567//*************************************************************************************************
575template< typename Type // Data type of the matrix
576 , bool SO // Storage order
577 , typename Tag > // Type tag
579 UniformMatrix<Type,SO,Tag>::data( 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 &value_;
587}
588//*************************************************************************************************
589
590
591//*************************************************************************************************
602template< typename Type // Data type of the matrix
603 , bool SO // Storage order
604 , typename Tag > // Type tag
606 UniformMatrix<Type,SO,Tag>::begin( size_t i ) const noexcept
607{
608 MAYBE_UNUSED( i );
609
610 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
611 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
612
613 return ConstIterator( &value_, 0UL );
614}
615//*************************************************************************************************
616
617
618//*************************************************************************************************
629template< typename Type // Data type of the matrix
630 , bool SO // Storage order
631 , typename Tag > // Type tag
633 UniformMatrix<Type,SO,Tag>::cbegin( size_t i ) const noexcept
634{
635 MAYBE_UNUSED( i );
636
637 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
638 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
639
640 return ConstIterator( &value_, 0UL );
641}
642//*************************************************************************************************
643
644
645//*************************************************************************************************
656template< typename Type // Data type of the matrix
657 , bool SO // Storage order
658 , typename Tag > // Type tag
660 UniformMatrix<Type,SO,Tag>::end( size_t i ) const noexcept
661{
662 MAYBE_UNUSED( i );
663
664 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
665 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
666
667 return ConstIterator( &value_, SO ? m_ : n_ );
668}
669//*************************************************************************************************
670
671
672//*************************************************************************************************
683template< typename Type // Data type of the matrix
684 , bool SO // Storage order
685 , typename Tag > // Type tag
687 UniformMatrix<Type,SO,Tag>::cend( size_t i ) const noexcept
688{
689 MAYBE_UNUSED( i );
690
691 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
692 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
693
694 return ConstIterator( &value_, SO ? m_ : n_ );
695}
696//*************************************************************************************************
697
698
699
700
701//=================================================================================================
702//
703// ASSIGNMENT OPERATORS
704//
705//=================================================================================================
706
707//*************************************************************************************************
713template< typename Type // Data type of the matrix
714 , bool SO // Storage order
715 , typename Tag > // Type tag
718{
719 value_ = rhs;
720
721 return *this;
722}
723//*************************************************************************************************
724
725
726//*************************************************************************************************
735template< typename Type // Data type of the matrix
736 , bool SO // Storage order
737 , typename Tag > // Type tag
738template< typename MT // Type of the right-hand side matrix
739 , bool SO2 > // Storage order of the right-hand side matrix
742{
743 using TT = decltype( trans( *this ) );
744 using CT = decltype( ctrans( *this ) );
745
747
748 if( !IsUniform_v<MT> && !isUniform( *rhs ) ) {
749 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of uniform matrix" );
750 }
751
752 if( IsSame_v<MT,TT> && (*rhs).isAliased( this ) ) {
753 transpose();
754 }
755 else if( IsSame_v<MT,CT> && (*rhs).isAliased( this ) ) {
756 ctranspose();
757 }
758 else {
759 m_ = (*rhs).rows();
760 n_ = (*rhs).columns();
761
762 if( (*rhs).rows() > 0UL && (*rhs).columns() > 0UL ) {
763 value_ = (*rhs)(0UL,0UL);
764 }
765 }
766
767 return *this;
768}
769//*************************************************************************************************
770
771
772//*************************************************************************************************
782template< typename Type // Data type of the matrix
783 , bool SO // Storage order
784 , typename Tag > // Type tag
785template< typename MT // Type of the right-hand side matrix
786 , bool SO2 > // Storage order of the right-hand side matrix
789{
791
792 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
793 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
794 }
795
796 if( !IsUniform_v<MT> && !isUniform( *rhs ) ) {
797 BLAZE_THROW_INVALID_ARGUMENT( "Invalid addition assignment to uniform matrix" );
798 }
799
800 if( m_ > 0UL && n_ > 0UL ) {
801 value_ += (*rhs)(0UL,0UL);
802 }
803
804 return *this;
805}
806//*************************************************************************************************
807
808
809//*************************************************************************************************
819template< typename Type // Data type of the matrix
820 , bool SO // Storage order
821 , typename Tag > // Type tag
822template< typename MT // Type of the right-hand side matrix
823 , bool SO2 > // Storage order of the right-hand side matrix
826{
828
829 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
830 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
831 }
832
833 if( !IsUniform_v<MT> && !isUniform( *rhs ) ) {
834 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subtraction assignment to uniform matrix" );
835 }
836
837 if( m_ > 0UL && n_ > 0UL ) {
838 value_ -= (*rhs)(0UL,0UL);
839 }
840
841 return *this;
842}
843//*************************************************************************************************
844
845
846//*************************************************************************************************
856template< typename Type // Data type of the matrix
857 , bool SO // Storage order
858 , typename Tag > // Type tag
859template< typename MT // Type of the right-hand side matrix
860 , bool SO2 > // Storage order of the right-hand side matrix
863{
865
866 if( (*rhs).rows() != m_ || (*rhs).columns() != n_ ) {
867 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
868 }
869
870 if( !IsUniform_v<MT> && !isUniform( *rhs ) ) {
871 BLAZE_THROW_INVALID_ARGUMENT( "Invalid Schur product assignment to uniform matrix" );
872 }
873
874 if( m_ > 0UL && n_ > 0UL ) {
875 value_ *= (*rhs)(0UL,0UL);
876 }
877
878 return *this;
879}
880//*************************************************************************************************
881
882
883//*************************************************************************************************
893template< typename Type // Data type of the matrix
894 , bool SO // Storage order
895 , typename Tag > // Type tag
896template< typename MT // Type of the right-hand side matrix
897 , bool SO2 > // Storage order of the right-hand side matrix
900{
902
903 if( (*rhs).rows() != n_ ) {
904 BLAZE_THROW_INVALID_ARGUMENT( "Matrix sizes do not match" );
905 }
906
907 if( !IsUniform_v<MT> && !isUniform( *rhs ) ) {
908 BLAZE_THROW_INVALID_ARGUMENT( "Invalid multiplication assignment to uniform matrix" );
909 }
910
911 n_ = (*rhs).columns();
912
913 if( m_ > 0UL && n_ > 0UL ) {
914 value_ = ( value_ * (*rhs)(0UL,0UL) ) * Type( (*rhs).rows() );
915 }
916
917 return *this;
918}
919//*************************************************************************************************
920
921
922//*************************************************************************************************
929template< typename Type // Data type of the matrix
930 , bool SO // Storage order
931 , typename Tag > // Type tag
932template< typename ST > // Data type of the right-hand side scalar
935{
936 if( rows() > 0UL && columns() > 0UL ) {
937 value_ *= scalar;
938 }
939
940 return *this;
941}
942//*************************************************************************************************
943
944
945//*************************************************************************************************
952template< typename Type // Data type of the matrix
953 , bool SO // Storage order
954 , typename Tag > // Type tag
955template< typename ST > // Data type of the right-hand side scalar
958{
959 if( rows() > 0UL && columns() > 0UL ) {
960 value_ /= scalar;
961 }
962
963 return *this;
964}
965//*************************************************************************************************
966
967
968
969
970//=================================================================================================
971//
972// UTILITY FUNCTIONS
973//
974//=================================================================================================
975
976//*************************************************************************************************
981template< typename Type // Data type of the matrix
982 , bool SO // Storage order
983 , typename Tag > // Type tag
984constexpr size_t UniformMatrix<Type,SO,Tag>::rows() const noexcept
985{
986 return m_;
987}
988//*************************************************************************************************
989
990
991//*************************************************************************************************
996template< typename Type // Data type of the matrix
997 , bool SO // Storage order
998 , typename Tag > // Type tag
999constexpr size_t UniformMatrix<Type,SO,Tag>::columns() const noexcept
1000{
1001 return n_;
1002}
1003//*************************************************************************************************
1004
1005
1006//*************************************************************************************************
1016template< typename Type // Data type of the matrix
1017 , bool SO // Storage order
1018 , typename Tag > // Type tag
1019constexpr size_t UniformMatrix<Type,SO,Tag>::spacing() const noexcept
1020{
1021 return SO ? m_ : n_;
1022}
1023//*************************************************************************************************
1024
1025
1026//*************************************************************************************************
1031template< typename Type // Data type of the matrix
1032 , bool SO // Storage order
1033 , typename Tag > // Type tag
1034constexpr size_t UniformMatrix<Type,SO,Tag>::capacity() const noexcept
1035{
1036 return m_ * n_;
1037}
1038//*************************************************************************************************
1039
1040
1041//*************************************************************************************************
1052template< typename Type // Data type of the matrix
1053 , bool SO // Storage order
1054 , typename Tag > // Type tag
1055constexpr size_t UniformMatrix<Type,SO,Tag>::capacity( size_t i ) const noexcept
1056{
1057 MAYBE_UNUSED( i );
1058 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
1059 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
1060 return SO ? m_ : n_;
1061}
1062//*************************************************************************************************
1063
1064
1065//*************************************************************************************************
1074template< typename Type // Data type of the matrix
1075 , bool SO // Storage order
1076 , typename Tag > // Type tag
1078{
1079 if( m_ == 0UL || n_ == 0UL || isDefault<strict>( value_ ) )
1080 return 0UL;
1081 else
1082 return m_ * n_;
1083}
1084//*************************************************************************************************
1085
1086
1087//*************************************************************************************************
1099template< typename Type // Data type of the matrix
1100 , bool SO // Storage order
1101 , typename Tag > // Type tag
1102inline size_t UniformMatrix<Type,SO,Tag>::nonZeros( size_t i ) const
1103{
1104 MAYBE_UNUSED( i );
1105
1106 BLAZE_USER_ASSERT( SO || i < m_, "Invalid dense matrix row access index" );
1107 BLAZE_USER_ASSERT( !SO || i < n_, "Invalid dense matrix row access index" );
1108
1109 const size_t tmp( SO ? m_ : n_ );
1110 if( tmp == 0UL || isDefault<strict>( value_ ) )
1111 return 0UL;
1112 else
1113 return tmp;
1114}
1115//*************************************************************************************************
1116
1117
1118//*************************************************************************************************
1123template< typename Type // Data type of the matrix
1124 , bool SO // Storage order
1125 , typename Tag > // Type tag
1127{
1128 using blaze::clear;
1129
1130 clear( value_ );
1131}
1132//*************************************************************************************************
1133
1134
1135//*************************************************************************************************
1142template< typename Type // Data type of the matrix
1143 , bool SO // Storage order
1144 , typename Tag > // Type tag
1146{
1147 m_ = 0UL;
1148 n_ = 0UL;
1149}
1150//*************************************************************************************************
1151
1152
1153//*************************************************************************************************
1167template< typename Type // Data type of the matrix
1168 , bool SO // Storage order
1169 , typename Tag > // Type tag
1170void constexpr UniformMatrix<Type,SO,Tag>::resize( size_t m, size_t n, bool preserve )
1171{
1172 MAYBE_UNUSED( preserve );
1173
1174 m_ = m;
1175 n_ = n;
1176}
1177//*************************************************************************************************
1178
1179
1180//*************************************************************************************************
1192template< typename Type // Data type of the matrix
1193 , bool SO // Storage order
1194 , typename Tag > // Type tag
1195constexpr void UniformMatrix<Type,SO,Tag>::extend( size_t m, size_t n, bool preserve )
1196{
1197 resize( m_+m, n_+n, preserve );
1198}
1199//*************************************************************************************************
1200
1201
1202//*************************************************************************************************
1208template< typename Type // Data type of the matrix
1209 , bool SO // Storage order
1210 , typename Tag > // Type tag
1212{
1213 using std::swap;
1214
1215 swap( m_, m.m_ );
1216 swap( n_, m.n_ );
1217 swap( value_, m.value_ );
1218}
1219//*************************************************************************************************
1220
1221
1222
1223
1224//=================================================================================================
1225//
1226// NUMERIC FUNCTIONS
1227//
1228//=================================================================================================
1229
1230//*************************************************************************************************
1235template< typename Type // Data type of the matrix
1236 , bool SO // Storage order
1237 , typename Tag > // Type tag
1239{
1240 using std::swap;
1241
1242 swap( m_, n_ );
1243
1244 return *this;
1245}
1246//*************************************************************************************************
1247
1248
1249//*************************************************************************************************
1254template< typename Type // Data type of the matrix
1255 , bool SO // Storage order
1256 , typename Tag > // Type tag
1258{
1259 using std::swap;
1260
1261 swap( m_, n_ );
1262 conjugate( value_ );
1263
1264 return *this;
1265}
1266//*************************************************************************************************
1267
1268
1269//*************************************************************************************************
1286template< typename Type // Data type of the matrix
1287 , bool SO // Storage order
1288 , typename Tag > // Type tag
1289template< typename Other > // Data type of the scalar value
1291{
1292 if( m_ > 0UL && n_ > 0UL ) {
1293 value_ *= scalar;
1294 }
1295
1296 return *this;
1297}
1298//*************************************************************************************************
1299
1300
1301
1302
1303//=================================================================================================
1304//
1305// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1306//
1307//=================================================================================================
1308
1309//*************************************************************************************************
1319template< typename Type // Data type of the matrix
1320 , bool SO // Storage order
1321 , typename Tag > // Type tag
1322template< typename Other > // Data type of the foreign expression
1323inline bool UniformMatrix<Type,SO,Tag>::canAlias( const Other* alias ) const noexcept
1324{
1325 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1326}
1327//*************************************************************************************************
1328
1329
1330//*************************************************************************************************
1340template< typename Type // Data type of the matrix
1341 , bool SO // Storage order
1342 , typename Tag > // Type tag
1343template< typename Other > // Data type of the foreign expression
1344inline bool UniformMatrix<Type,SO,Tag>::isAliased( const Other* alias ) const noexcept
1345{
1346 return static_cast<const void*>( this ) == static_cast<const void*>( alias );
1347}
1348//*************************************************************************************************
1349
1350
1351//*************************************************************************************************
1360template< typename Type // Data type of the matrix
1361 , bool SO // Storage order
1362 , typename Tag > // Type tag
1363inline bool UniformMatrix<Type,SO,Tag>::isAligned() const noexcept
1364{
1365 return true;
1366}
1367//*************************************************************************************************
1368
1369
1370//*************************************************************************************************
1380template< typename Type // Data type of the matrix
1381 , bool SO // Storage order
1382 , typename Tag > // Type tag
1384{
1385 return ( rows() * columns() >= SMP_DMATASSIGN_THRESHOLD );
1386}
1387//*************************************************************************************************
1388
1389
1390//*************************************************************************************************
1405template< typename Type // Data type of the matrix
1406 , bool SO // Storage order
1407 , typename Tag > // Type tag
1409 UniformMatrix<Type,SO,Tag>::load( size_t i, size_t j ) const noexcept
1410{
1411 return loada( i, j );
1412}
1413//*************************************************************************************************
1414
1415
1416//*************************************************************************************************
1431template< typename Type // Data type of the matrix
1432 , bool SO // Storage order
1433 , typename Tag > // Type tag
1435 UniformMatrix<Type,SO,Tag>::loada( size_t i, size_t j ) const noexcept
1436{
1437 MAYBE_UNUSED( i, j );
1438
1440
1441 BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1442 BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1443 BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1444 BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1445
1446 return set( value_ );
1447}
1448//*************************************************************************************************
1449
1450
1451//*************************************************************************************************
1466template< typename Type // Data type of the matrix
1467 , bool SO // Storage order
1468 , typename Tag > // Type tag
1470 UniformMatrix<Type,SO,Tag>::loadu( size_t i, size_t j ) const noexcept
1471{
1472 MAYBE_UNUSED( i, j );
1473
1475
1476 BLAZE_INTERNAL_ASSERT( i < m_, "Invalid row access index" );
1477 BLAZE_INTERNAL_ASSERT( j < n_, "Invalid column access index" );
1478 BLAZE_INTERNAL_ASSERT( SO || j + SIMDSIZE <= n_, "Invalid column access index" );
1479 BLAZE_INTERNAL_ASSERT( !SO || i + SIMDSIZE <= m_, "Invalid row access index" );
1480
1481 return set( value_ );
1482}
1483//*************************************************************************************************
1484
1485
1486
1487
1488
1489
1490
1491
1492//=================================================================================================
1493//
1494// UNIFORMMATRIX OPERATORS
1495//
1496//=================================================================================================
1497
1498//*************************************************************************************************
1501template< RelaxationFlag RF, typename Type, bool SO, typename Tag >
1502constexpr bool isDefault( const UniformMatrix<Type,SO,Tag>& m );
1503
1504template< typename Type, bool SO, typename Tag >
1505constexpr bool isIntact( const UniformMatrix<Type,SO,Tag>& m ) noexcept;
1506
1507template< typename Type, bool SO, typename Tag >
1508constexpr void swap( UniformMatrix<Type,SO,Tag>& a, UniformMatrix<Type,SO,Tag>& b ) noexcept;
1510//*************************************************************************************************
1511
1512
1513//*************************************************************************************************
1538template< RelaxationFlag RF // Relaxation flag
1539 , typename Type // Data type of the matrix
1540 , bool SO // Storage order
1541 , typename Tag > // Type tag
1542constexpr bool isDefault( const UniformMatrix<Type,SO,Tag>& m )
1543{
1544 return ( m.rows() == 0UL && m.columns() == 0UL );
1545}
1546//*************************************************************************************************
1547
1548
1549//*************************************************************************************************
1567template< typename Type // Data type of the matrix
1568 , bool SO // Storage order
1569 , typename Tag > // Type tag
1570constexpr bool isIntact( const UniformMatrix<Type,SO,Tag>& m ) noexcept
1571{
1572 MAYBE_UNUSED( m );
1573
1574 return true;
1575}
1576//*************************************************************************************************
1577
1578
1579//*************************************************************************************************
1587template< typename Type // Data type of the matrix
1588 , bool SO // Storage order
1589 , typename Tag > // Type tag
1591{
1592 a.swap( b );
1593}
1594//*************************************************************************************************
1595
1596
1597
1598
1599//=================================================================================================
1600//
1601// GLOBAL FUNCTIONS
1602//
1603//=================================================================================================
1604
1605//*************************************************************************************************
1639template< bool SO = defaultStorageOrder, typename T >
1640constexpr decltype(auto) uniform( size_t m, size_t n, T&& init )
1641{
1642 return UniformMatrix< RemoveCVRef_t<T>, SO >( m, n, std::forward<T>( init ) );
1643}
1644//*************************************************************************************************
1645
1646
1647
1648
1649//=================================================================================================
1650//
1651// ISUNIFORM SPECIALIZATIONS
1652//
1653//=================================================================================================
1654
1655//*************************************************************************************************
1657template< typename Type, bool SO, typename Tag >
1658struct IsUniform< UniformMatrix<Type,SO,Tag> >
1659 : public TrueType
1660{};
1662//*************************************************************************************************
1663
1664
1665
1666
1667//=================================================================================================
1668//
1669// ISALIGNED SPECIALIZATIONS
1670//
1671//=================================================================================================
1672
1673//*************************************************************************************************
1675template< typename Type, bool SO, typename Tag >
1676struct IsAligned< UniformMatrix<Type,SO,Tag> >
1677 : public TrueType
1678{};
1680//*************************************************************************************************
1681
1682
1683
1684
1685//=================================================================================================
1686//
1687// ADDTRAIT SPECIALIZATIONS
1688//
1689//=================================================================================================
1690
1691//*************************************************************************************************
1693template< typename T1, typename T2 >
1694struct AddTraitEval1< T1, T2
1695 , EnableIf_t< IsMatrix_v<T1> &&
1696 IsMatrix_v<T2> &&
1697 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1698 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1699{
1700 static constexpr bool SO1 = StorageOrder_v<T1>;
1701 static constexpr bool SO2 = StorageOrder_v<T2>;
1702
1703 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1704 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1705 ? ( IsSymmetric_v<T1>
1706 ? SO2
1707 : SO1 )
1708 : SO1 && SO2 )
1709 : ( IsDenseMatrix_v<T1>
1710 ? SO1
1711 : SO2 ) );
1712
1713 using Type = UniformMatrix< AddTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1714 , SO
1715 , AddTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1716};
1718//*************************************************************************************************
1719
1720
1721
1722
1723//=================================================================================================
1724//
1725// SUBTRAIT SPECIALIZATIONS
1726//
1727//=================================================================================================
1728
1729//*************************************************************************************************
1731template< typename T1, typename T2 >
1732struct SubTraitEval1< T1, T2
1733 , EnableIf_t< IsMatrix_v<T1> &&
1734 IsMatrix_v<T2> &&
1735 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1736 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1737{
1738 static constexpr bool SO1 = StorageOrder_v<T1>;
1739 static constexpr bool SO2 = StorageOrder_v<T2>;
1740
1741 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1742 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1743 ? ( IsSymmetric_v<T1>
1744 ? SO2
1745 : SO1 )
1746 : SO1 && SO2 )
1747 : ( IsDenseMatrix_v<T1>
1748 ? SO1
1749 : SO2 ) );
1750
1751 using Type = UniformMatrix< SubTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1752 , SO
1753 , SubTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1754};
1756//*************************************************************************************************
1757
1758
1759
1760
1761//=================================================================================================
1762//
1763// SCHURTRAIT SPECIALIZATIONS
1764//
1765//=================================================================================================
1766
1767//*************************************************************************************************
1769template< typename T1, typename T2 >
1770struct SchurTraitEval1< T1, T2
1771 , EnableIf_t< IsMatrix_v<T1> &&
1772 IsMatrix_v<T2> &&
1773 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1774 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1775{
1776 static constexpr bool SO1 = StorageOrder_v<T1>;
1777 static constexpr bool SO2 = StorageOrder_v<T2>;
1778
1779 static constexpr bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1780 ? ( IsSymmetric_v<T1>
1781 ? SO2
1782 : SO1 )
1783 : SO1 && SO2 );
1784
1785 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1786 , SO
1787 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1788};
1790//*************************************************************************************************
1791
1792
1793
1794
1795//=================================================================================================
1796//
1797// MULTTRAIT SPECIALIZATIONS
1798//
1799//=================================================================================================
1800
1801//*************************************************************************************************
1803template< typename T1, typename T2 >
1804struct MultTraitEval1< T1, T2
1805 , EnableIf_t< IsMatrix_v<T1> &&
1806 IsUniform_v<T1> &&
1807 !IsZero_v<T1> &&
1808 IsScalar_v<T2> > >
1809{
1810 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, T2 >
1811 , StorageOrder_v<T1>
1812 , MultTrait_t< TagType_t<T1>, T2 > >;
1813};
1814
1815template< typename T1, typename T2 >
1816struct MultTraitEval1< T1, T2
1817 , EnableIf_t< IsScalar_v<T1> &&
1818 IsMatrix_v<T2> &&
1819 IsUniform_v<T2> &&
1820 !IsZero_v<T2> > >
1821{
1822 using Type = UniformMatrix< MultTrait_t< T1, ElementType_t<T2> >
1823 , StorageOrder_v<T2>
1824 , MultTrait_t< T1, TagType_t<T2> > >;
1825};
1826
1827template< typename T1, typename T2 >
1828struct MultTraitEval1< T1, T2
1830 IsRowVector_v<T2> &&
1831 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1832 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1833{
1834 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1835 , false
1836 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1837};
1838
1839template< typename T1, typename T2 >
1840struct MultTraitEval1< T1, T2
1841 , EnableIf_t< IsMatrix_v<T1> &&
1842 IsMatrix_v<T2> &&
1843 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1844 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1845{
1846 using MultType = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1847 using MultTag = MultTrait_t< TagType_t<T1>, TagType_t<T2> >;
1848
1849 using Type = UniformMatrix< AddTrait_t<MultType,MultType>
1850 , StorageOrder_v<T1>
1851 , AddTrait_t<MultTag,MultTag> >;
1852};
1854//*************************************************************************************************
1855
1856
1857
1858
1859//=================================================================================================
1860//
1861// KRONTRAIT SPECIALIZATIONS
1862//
1863//=================================================================================================
1864
1865//*************************************************************************************************
1867template< typename T1, typename T2 >
1868struct KronTraitEval1< T1, T2
1869 , EnableIf_t< IsMatrix_v<T1> &&
1870 IsMatrix_v<T2> &&
1871 ( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1872 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1873{
1874 using Type = UniformMatrix< MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >
1875 , StorageOrder_v<T2>
1876 , MultTrait_t< TagType_t<T1>, TagType_t<T2> > >;
1877};
1879//*************************************************************************************************
1880
1881
1882
1883
1884//=================================================================================================
1885//
1886// DIVTRAIT SPECIALIZATIONS
1887//
1888//=================================================================================================
1889
1890//*************************************************************************************************
1892template< typename T1, typename T2 >
1893struct DivTraitEval1< T1, T2
1894 , EnableIf_t< IsMatrix_v<T1> &&
1895 IsScalar_v<T2> &&
1896 IsUniform_v<T1> && !IsZero_v<T1> > >
1897{
1898 using Type = UniformMatrix< DivTrait_t< ElementType_t<T1>, T2 >
1899 , StorageOrder_v<T1>
1900 , DivTrait_t< TagType_t<T1>, T2 > >;
1901};
1903//*************************************************************************************************
1904
1905
1906
1907
1908//=================================================================================================
1909//
1910// MAPTRAIT SPECIALIZATIONS
1911//
1912//=================================================================================================
1913
1914//*************************************************************************************************
1916template< typename T, typename OP >
1917struct UnaryMapTraitEval1< T, OP
1918 , EnableIf_t< IsMatrix_v<T> &&
1919 YieldsUniform_v<OP,T> &&
1920 !YieldsZero_v<OP,T> > >
1921{
1922 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T> >() ) );
1923
1924 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1925 , StorageOrder_v<T>
1926 , MapTrait_t< TagType_t<T>, OP > >;
1927};
1929//*************************************************************************************************
1930
1931
1932//*************************************************************************************************
1934template< typename T1, typename T2, typename OP >
1935struct BinaryMapTraitEval1< T1, T2, OP
1937 IsRowVector_v<T2> &&
1938 YieldsUniform_v<OP,T1,T2> &&
1939 !YieldsZero_v<OP,T1,T2> > >
1940{
1941 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1942 , std::declval< ElementType_t<T2> >() ) );
1943
1944 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1945 , false
1946 , MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
1947};
1948
1949template< typename T1, typename T2, typename OP >
1950struct BinaryMapTraitEval1< T1, T2, OP
1951 , EnableIf_t< IsMatrix_v<T1> &&
1952 IsMatrix_v<T2> &&
1953 YieldsUniform_v<OP,T1,T2> &&
1954 !YieldsZero_v<OP,T1,T2> > >
1955{
1956 using ElementType = decltype( std::declval<OP>()( std::declval< ElementType_t<T1> >()
1957 , std::declval< ElementType_t<T2> >() ) );
1958
1959 static constexpr bool SO1 = StorageOrder_v<T1>;
1960 static constexpr bool SO2 = StorageOrder_v<T2>;
1961
1962 static constexpr bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
1963 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
1964 ? ( IsSymmetric_v<T1>
1965 ? SO2
1966 : SO1 )
1967 : SO1 && SO2 )
1968 : ( IsDenseMatrix_v<T1>
1969 ? SO1
1970 : SO2 ) );
1971
1972 using Type = UniformMatrix< EvaluateTrait_t<ElementType>
1973 , SO
1974 , MapTrait_t< TagType_t<T1>, TagType_t<T2>, OP > >;
1975};
1977//*************************************************************************************************
1978
1979
1980
1981
1982//=================================================================================================
1983//
1984// EXPANDTRAIT SPECIALIZATIONS
1985//
1986//=================================================================================================
1987
1988//*************************************************************************************************
1990template< typename T, size_t E >
1991struct ExpandTraitEval1< T, E
1992 , EnableIf_t< IsVector_v<T> &&
1993 IsUniform_v<T> && !IsZero_v<T> > >
1994{
1995 using Type = UniformMatrix< ElementType_t<T>
1996 , ( IsColumnVector_v<T> ? columnMajor : rowMajor )
1997 , TagType_t<T> >;
1998};
2000//*************************************************************************************************
2001
2002
2003
2004
2005//=================================================================================================
2006//
2007// REPEATTRAIT SPECIALIZATIONS
2008//
2009//=================================================================================================
2010
2011//*************************************************************************************************
2013template< typename T, size_t R0, size_t R1 >
2014struct RepeatTraitEval1< T, R0, R1, inf
2015 , EnableIf_t< IsMatrix_v<T> &&
2016 IsUniform_v<T> && !IsZero_v<T> > >
2017{
2018 using Type = UniformMatrix< ElementType_t<T>
2019 , StorageOrder_v<T>
2020 , TagType_t<T> >;
2021};
2023//*************************************************************************************************
2024
2025
2026
2027
2028//=================================================================================================
2029//
2030// HIGHTYPE SPECIALIZATIONS
2031//
2032//=================================================================================================
2033
2034//*************************************************************************************************
2036template< typename T1, bool SO, typename Tag, typename T2 >
2037struct HighType< UniformMatrix<T1,SO,Tag>, UniformMatrix<T2,SO,Tag> >
2038{
2039 using Type = UniformMatrix< typename HighType<T1,T2>::Type, SO, Tag >;
2040};
2042//*************************************************************************************************
2043
2044
2045
2046
2047//=================================================================================================
2048//
2049// LOWTYPE SPECIALIZATIONS
2050//
2051//=================================================================================================
2052
2053//*************************************************************************************************
2055template< typename T1, bool SO, typename Tag, typename T2 >
2056struct LowType< UniformMatrix<T1,SO,Tag>, UniformMatrix<T2,SO,Tag> >
2057{
2058 using Type = UniformMatrix< typename LowType<T1,T2>::Type, SO, Tag >;
2059};
2061//*************************************************************************************************
2062
2063
2064
2065
2066//=================================================================================================
2067//
2068// SUBMATRIXTRAIT SPECIALIZATIONS
2069//
2070//=================================================================================================
2071
2072//*************************************************************************************************
2074template< typename MT, size_t I, size_t J, size_t M, size_t N >
2075struct SubmatrixTraitEval1< MT, I, J, M, N
2076 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2077{
2078 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >
2079 , StorageOrder_v<MT>
2080 , TagType_t<MT> >;
2081};
2083//*************************************************************************************************
2084
2085
2086
2087
2088//=================================================================================================
2089//
2090// ROWSTRAIT SPECIALIZATIONS
2091//
2092//=================================================================================================
2093
2094//*************************************************************************************************
2096template< typename MT, size_t M >
2097struct RowsTraitEval1< MT, M
2098 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2099{
2100 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >
2101 , false
2102 , TagType_t<MT> >;
2103};
2105//*************************************************************************************************
2106
2107
2108
2109
2110//=================================================================================================
2111//
2112// COLUMNSTRAIT SPECIALIZATIONS
2113//
2114//=================================================================================================
2115
2116//*************************************************************************************************
2118template< typename MT, size_t N >
2119struct ColumnsTraitEval1< MT, N
2120 , EnableIf_t< IsUniform_v<MT> && !IsZero_v<MT> > >
2121{
2122 using Type = UniformMatrix< RemoveConst_t< ElementType_t<MT> >
2123 , true
2124 , TagType_t<MT> >;
2125};
2127//*************************************************************************************************
2128
2129} // namespace blaze
2130
2131#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
typename ResultType_t< T >::TagType TagType_t
Alias declaration for nested TagType type definitions.
Definition: Aliases.h:530
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the columns trait.
Header file for the conjugate shim.
Constraint on the data type.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the EvaluateTrait class template.
Header file for the expand trait.
Header file for the HighType type trait.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsColumnVector type trait.
Header file for the isDefault shim.
Header file for the IsDenseMatrix type trait.
Header file for the IsMatrix type trait.
Header file for the IsRowVector type trait.
Header file for the IsSMPAssignable type trait.
Header file for the IsScalar type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUniform type trait.
Header file for the IsVector type trait.
Header file for the IsVectorizable type trait.
Header file for the Kron product trait.
Header file for the LowType type trait.
Header file for the map trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Header file for the RemoveCVRef type trait.
Header file for the RemoveConst type trait.
Header file for the repeat trait.
Header file for the rows trait.
Header file for all SIMD functionality.
Data type constraint.
Header file for the Schur product trait.
Header file for the subtraction trait.
Header file for the submatrix trait.
Header file for the UniformIterator class template.
Constraint on the data type.
Constraint on the data type.
Header file for the YieldsUniform type trait.
Header file for the YieldsZero type trait.
Base class for matrices.
Definition: Matrix.h:85
SIMD characteristics of data types.
Definition: SIMDTrait.h:297
Implementation of a generic iterator for uniform vectors and matrices.
Definition: UniformIterator.h:60
Efficient implementation of a uniform matrix.
Definition: UniformMatrix.h:197
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: UniformMatrix.h:351
constexpr UniformMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: UniformMatrix.h:1257
size_t m_
The current number of rows of the matrix.
Definition: UniformMatrix.h:374
ConstReference at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: UniformMatrix.h:530
constexpr size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: UniformMatrix.h:999
UniformMatrix< Type, SO, Tag > This
Type of this UniformMatrix instance.
Definition: UniformMatrix.h:200
Tag TagType
Tag type of this UniformMatrix instance.
Definition: UniformMatrix.h:214
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:1435
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: UniformMatrix.h:1363
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: UniformMatrix.h:252
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:1470
Type value_
The value of all elements of the uniform matrix.
Definition: UniformMatrix.h:376
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: UniformMatrix.h:1409
constexpr UniformMatrix() noexcept
The default constructor for UniformMatrix.
Definition: UniformMatrix.h:406
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: UniformMatrix.h:1344
constexpr UniformMatrix & transpose()
In-place transpose of the matrix.
Definition: UniformMatrix.h:1238
constexpr void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: UniformMatrix.h:1170
constexpr size_t spacing() const noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: UniformMatrix.h:1019
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: UniformMatrix.h:1383
constexpr void swap(UniformMatrix &m) noexcept
Swapping the contents of two matrices.
Definition: UniformMatrix.h:1211
constexpr ConstReference operator()(size_t i, size_t j) const noexcept
2D-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:1195
constexpr ConstIterator end(size_t i) const noexcept
Returns an iterator just past the last element of row/column i.
Definition: UniformMatrix.h:660
constexpr UniformMatrix & operator=(const Type &rhs) &
Homogenous assignment to all matrix elements.
Definition: UniformMatrix.h:717
const Type & Reference
Reference to a non-constant matrix value.
Definition: UniformMatrix.h:218
size_t n_
The current number of columns of the matrix.
Definition: UniformMatrix.h:375
constexpr ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first element of row/column i.
Definition: UniformMatrix.h:633
const Type & ConstReference
Reference to a constant matrix value.
Definition: UniformMatrix.h:219
constexpr void reset()
Reset to the default initial values.
Definition: UniformMatrix.h:1126
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: UniformMatrix.h:221
constexpr ConstPointer data() const noexcept
Low-level data access to the matrix elements.
Definition: UniformMatrix.h:560
constexpr size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: UniformMatrix.h:984
Type ElementType
Type of the matrix elements.
Definition: UniformMatrix.h:212
constexpr void clear()
Clearing the matrix.
Definition: UniformMatrix.h:1145
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the matrix.
Definition: UniformMatrix.h:1034
constexpr ConstIterator begin(size_t i) const noexcept
Returns an iterator to the first element of row/column i.
Definition: UniformMatrix.h:606
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: UniformMatrix.h:1323
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: UniformMatrix.h:1077
constexpr ConstIterator cend(size_t i) const noexcept
Returns an iterator just past the last element of row/column i.
Definition: UniformMatrix.h:687
const Type * Pointer
Pointer to a non-constant matrix value.
Definition: UniformMatrix.h:220
const Type & ReturnType
Return type for expression template evaluations.
Definition: UniformMatrix.h:215
SIMDTrait_t< ElementType > SIMDType
SIMD type of the matrix elements.
Definition: UniformMatrix.h:213
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: UniformMatrix.h:258
Header file for the DenseMatrix base class.
Header file for the Expression base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.
Definition: Vectorizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TAG(A, B)
Data type constraint.
Definition: SameTag.h:68
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1501
bool isUniform(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a uniform matrix.
Definition: DenseMatrix.h:1766
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:118
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr bool IsUniform_v
Auxiliary variable template for the IsUniform type trait.
Definition: IsUniform.h:164
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.
Definition: IsVector.h:125
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
constexpr bool IsColumnVector_v
Auxiliary variable template for the IsColumnVector type trait.
Definition: IsColumnVector.h:126
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.
Definition: IsDenseMatrix.h:124
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:1221
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:1195
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
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
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.
Definition: SIMDTrait.h:315
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
constexpr bool isDefault(const UniformMatrix< Type, SO, Tag > &m)
Returns whether the given uniform matrix is in default state.
Definition: UniformMatrix.h:1542
constexpr bool isIntact(const UniformMatrix< Type, SO, Tag > &m) noexcept
Returns whether the invariants of the given uniform matrix are intact.
Definition: UniformMatrix.h:1570
constexpr void swap(UniformMatrix< Type, SO, Tag > &a, UniformMatrix< Type, SO, Tag > &b) noexcept
Swapping the contents of two uniform matrices.
Definition: UniformMatrix.h:1590
constexpr decltype(auto) uniform(size_t m, size_t n, T &&init)
Creating a uniform matrix.
Definition: UniformMatrix.h:1640
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for all forward declarations of the math module.
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Header file for all forward declarations for dense vectors and matrices.
Header file for the StorageOrder type trait.
Header file for the clear shim.
Header file for the reset shim.
Base class for all expression templates.
Definition: Expression.h:60
Rebind mechanism to obtain a UniformMatrix with different data/element type.
Definition: UniformMatrix.h:231
Resize mechanism to obtain a UniformMatrix with different fixed dimensions.
Definition: UniformMatrix.h:241
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the IsZero type trait.
Header file for basic type definitions.