Blaze 3.9
HermitianMatrix.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_H_
36#define _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
50#include <blaze/math/Forward.h>
102#include <blaze/util/Assert.h>
103#include <blaze/util/EnableIf.h>
108
109
110namespace blaze {
111
112//=================================================================================================
113//
114// HERMITIANMATRIX OPERATORS
115//
116//=================================================================================================
117
118//*************************************************************************************************
121template< RelaxationFlag RF, typename MT, bool SO, bool DF >
122bool isDefault( const HermitianMatrix<MT,SO,DF>& m );
123
124template< typename MT, bool SO, bool DF >
125bool isIntact( const HermitianMatrix<MT,SO,DF>& m );
126
127template< typename MT, bool SO, bool DF >
128void swap( HermitianMatrix<MT,SO,DF>& a, HermitianMatrix<MT,SO,DF>& b ) noexcept;
130//*************************************************************************************************
131
132
133//*************************************************************************************************
158template< RelaxationFlag RF // Relaxation flag
159 , typename MT // Type of the adapted matrix
160 , bool SO // Storage order of the adapted matrix
161 , bool DF > // Density flag
162inline bool isDefault( const HermitianMatrix<MT,SO,DF>& m )
163{
164 if( Size_v<MT,0UL> == DefaultSize_v )
165 return m.rows() == 0UL;
166 else return isStrictlyLower<RF>( m );
167}
168//*************************************************************************************************
169
170
171//*************************************************************************************************
192template< typename MT // Type of the adapted matrix
193 , bool SO // Storage order of the adapted matrix
194 , bool DF > // Density flag
195inline bool isIntact( const HermitianMatrix<MT,SO,DF>& m )
196{
197 return m.isIntact();
198}
199//*************************************************************************************************
200
201
202//*************************************************************************************************
210template< typename MT // Type of the adapted matrix
211 , bool SO // Storage order of the adapted matrix
212 , bool DF > // Density flag
213inline void swap( HermitianMatrix<MT,SO,DF>& a, HermitianMatrix<MT,SO,DF>& b ) noexcept
214{
215 a.swap( b );
216}
217//*************************************************************************************************
218
219
220//*************************************************************************************************
243template< InversionFlag IF // Inversion algorithm
244 , typename MT // Type of the dense matrix
245 , bool SO > // Storage order of the dense matrix
246inline void invert( HermitianMatrix<MT,SO,true>& m )
247{
249
250 if( IF == asUniLower || IF == asUniUpper ) {
251 BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
252 return;
253 }
254
255 constexpr InversionFlag flag( ( IF == byLU || IF == byLDLT || IF == byLDLH ||
256 IF == asGeneral || IF == asSymmetric || IF == asHermitian )
257 ? ( byLDLH )
258 : ( ( IF == byLLH )
259 ?( byLLH )
260 :( asDiagonal ) ) );
261
262 MT tmp( m.matrix_ );
263 invert<flag>( tmp );
264 m.matrix_ = std::move( tmp );
265
266 BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
267}
269//*************************************************************************************************
270
271
272//*************************************************************************************************
288template< typename MT // Type of the adapted matrix
289 , bool SO // Storage order of the adapted matrix
290 , bool DF // Density flag
291 , typename ET > // Type of the element
292inline bool trySet( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
293{
294 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
295 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
296
297 MAYBE_UNUSED( mat );
298
299 return ( i != j || isReal( value ) );
300}
302//*************************************************************************************************
303
304
305//*************************************************************************************************
323template< typename MT // Type of the adapted matrix
324 , bool SO // Storage order of the adapted matrix
325 , bool DF // Density flag
326 , typename ET > // Type of the element
328 trySet( const HermitianMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
329{
330 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
331 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
332 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
333 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
334
335 MAYBE_UNUSED( mat );
336
337 return ( m == 0UL ) ||
338 ( n == 0UL ) ||
339 ( row >= column + n ) ||
340 ( column >= row + m ) ||
341 isReal( value );
342}
344//*************************************************************************************************
345
346
347//*************************************************************************************************
363template< typename MT // Type of the adapted matrix
364 , bool SO // Storage order of the adapted matrix
365 , bool DF // Density flag
366 , typename ET > // Type of the element
367inline bool tryAdd( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
368{
369 return trySet( mat, i, j, value );
370}
372//*************************************************************************************************
373
374
375//*************************************************************************************************
393template< typename MT // Type of the adapted matrix
394 , bool SO // Storage order of the adapted matrix
395 , bool DF // Density flag
396 , typename ET > // Type of the element
398 tryAdd( const HermitianMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
399{
400 return trySet( mat, row, column, m, n, value );
401}
403//*************************************************************************************************
404
405
406//*************************************************************************************************
422template< typename MT // Type of the adapted matrix
423 , bool SO // Storage order of the adapted matrix
424 , bool DF // Density flag
425 , typename ET > // Type of the element
426inline bool trySub( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
427{
428 return trySet( mat, i, j, value );
429}
431//*************************************************************************************************
432
433
434//*************************************************************************************************
452template< typename MT // Type of the adapted matrix
453 , bool SO // Storage order of the adapted matrix
454 , bool DF // Density flag
455 , typename ET > // Type of the element
457 trySub( const HermitianMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
458{
459 return trySet( mat, row, column, m, n, value );
460}
462//*************************************************************************************************
463
464
465//*************************************************************************************************
481template< typename MT // Type of the adapted matrix
482 , bool SO // Storage order of the adapted matrix
483 , bool DF // Density flag
484 , typename ET > // Type of the element
485inline bool tryMult( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
486{
487 return trySet( mat, i, j, value );
488}
490//*************************************************************************************************
491
492
493//*************************************************************************************************
511template< typename MT // Type of the adapted matrix
512 , bool SO // Storage order of the adapted matrix
513 , bool DF // Density flag
514 , typename ET > // Type of the element
516 tryMult( const HermitianMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
517{
518 return trySet( mat, row, column, m, n, value );
519}
521//*************************************************************************************************
522
523
524//*************************************************************************************************
540template< typename MT // Type of the adapted matrix
541 , bool SO // Storage order of the adapted matrix
542 , bool DF // Density flag
543 , typename ET > // Type of the element
544inline bool tryDiv( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
545{
546 return trySet( mat, i, j, value );
547}
549//*************************************************************************************************
550
551
552//*************************************************************************************************
570template< typename MT // Type of the adapted matrix
571 , bool SO // Storage order of the adapted matrix
572 , bool DF // Density flag
573 , typename ET > // Type of the element
575 tryDiv( const HermitianMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
576{
577 return trySet( mat, row, column, m, n, value );
578}
580//*************************************************************************************************
581
582
583//*************************************************************************************************
599template< typename MT // Type of the adapted matrix
600 , bool SO // Storage order of the adapted matrix
601 , bool DF // Density flag
602 , typename VT > // Type of the right-hand side vector
603inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs,
604 const Vector<VT,false>& rhs, size_t row, size_t column )
605{
607
608 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
609 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
610 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
611
612 MAYBE_UNUSED( lhs );
613
614 using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
615
616 return ( IsBuiltin_v<ET> ||
617 column < row ||
618 (*rhs).size() <= column - row ||
619 isReal( (*rhs)[column-row] ) );
620
621 return true;
622}
624//*************************************************************************************************
625
626
627//*************************************************************************************************
643template< typename MT // Type of the adapted matrix
644 , bool SO // Storage order of the adapted matrix
645 , bool DF // Density flag
646 , typename VT > // Type of the right-hand side vector
647inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs,
648 const Vector<VT,true>& rhs, size_t row, size_t column )
649{
651
652 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
653 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
654 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
655
656 MAYBE_UNUSED( lhs );
657
658 using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
659
660 return ( IsBuiltin_v<ET> ||
661 row < column ||
662 (*rhs).size() <= row - column ||
663 isReal( (*rhs)[row-column] ) );
664
665 return true;
666}
668//*************************************************************************************************
669
670
671//*************************************************************************************************
689template< typename MT // Type of the adapted matrix
690 , bool SO // Storage order of the adapted matrix
691 , bool DF // Density flag
692 , typename VT // Type of the right-hand side dense vector
693 , bool TF > // Transpose flag of the right-hand side dense vector
694inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
695 ptrdiff_t band, size_t row, size_t column )
696{
698
699 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
700 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
701 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
702 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
703
704 MAYBE_UNUSED( lhs, row, column );
705
706 if( band == 0L ) {
707 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
708 if( !isReal( (*rhs)[i] ) )
709 return false;
710 }
711 }
712
713 return true;
714}
716//*************************************************************************************************
717
718
719//*************************************************************************************************
737template< typename MT // Type of the adapted matrix
738 , bool SO // Storage order of the adapted matrix
739 , bool DF // Density flag
740 , typename VT // Type of the right-hand side sparse vector
741 , bool TF > // Transpose flag of the right-hand side sparse vector
742inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
743 ptrdiff_t band, size_t row, size_t column )
744{
746
747 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
748 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
749 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
750 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
751
752 MAYBE_UNUSED( lhs, row, column );
753
754 if( band == 0L ) {
755 for( const auto& element : *rhs ) {
756 if( !isReal( element.value() ) )
757 return false;
758 }
759 }
760
761 return true;
762}
764//*************************************************************************************************
765
766
767//*************************************************************************************************
783template< typename MT1 // Type of the adapted matrix
784 , bool SO1 // Storage order of the adapted matrix
785 , bool DF // Density flag
786 , typename MT2 // Type of the right-hand side matrix
787 , bool SO2 > // Storage order of the right-hand side matrix
788inline bool tryAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
789 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
790{
792
793 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
794 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
795 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
796 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
797
798 MAYBE_UNUSED( lhs );
799
800 const size_t M( (*rhs).rows() );
801 const size_t N( (*rhs).columns() );
802
803 if( ( row + M <= column ) || ( column + N <= row ) )
804 return true;
805
806 const bool lower( row > column );
807 const size_t size ( min( row + M, column + N ) - ( lower ? row : column ) );
808
809 if( size < 2UL )
810 return true;
811
812 const size_t subrow( lower ? 0UL : column - row );
813 const size_t subcol( lower ? row - column : 0UL );
814
815 return isHermitian( submatrix( *rhs, subrow, subcol, size, size ) );
816}
818//*************************************************************************************************
819
820
821//*************************************************************************************************
837template< typename MT // Type of the adapted matrix
838 , bool SO // Storage order of the adapted matrix
839 , bool DF // Density flag
840 , typename VT // Type of the right-hand side vector
841 , bool TF > // Transpose flag of the right-hand side vector
842inline bool tryAddAssign( const HermitianMatrix<MT,SO,DF>& lhs,
843 const Vector<VT,TF>& rhs, size_t row, size_t column )
844{
845 return tryAssign( lhs, *rhs, row, column );
846}
848//*************************************************************************************************
849
850
851//*************************************************************************************************
869template< typename MT // Type of the adapted matrix
870 , bool SO // Storage order of the adapted matrix
871 , bool DF // Density flag
872 , typename VT // Type of the right-hand side vector
873 , bool TF > // Transpose flag of the right-hand side vector
874inline bool tryAddAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
875 ptrdiff_t band, size_t row, size_t column )
876{
877 return tryAssign( lhs, *rhs, band, row, column );
878}
880//*************************************************************************************************
881
882
883//*************************************************************************************************
899template< typename MT1 // Type of the adapted matrix
900 , bool SO1 // Storage order of the adapted matrix
901 , bool DF // Density flag
902 , typename MT2 // Type of the right-hand side matrix
903 , bool SO2 > // Storage order of the right-hand side matrix
904inline bool tryAddAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
905 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
906{
907 return tryAssign( lhs, *rhs, row, column );
908}
910//*************************************************************************************************
911
912
913//*************************************************************************************************
930template< typename MT // Type of the adapted matrix
931 , bool SO // Storage order of the adapted matrix
932 , bool DF // Density flag
933 , typename VT // Type of the right-hand side vector
934 , bool TF > // Transpose flag of the right-hand side vector
935inline bool trySubAssign( const HermitianMatrix<MT,SO,DF>& lhs,
936 const Vector<VT,TF>& rhs, size_t row, size_t column )
937{
938 return tryAssign( lhs, *rhs, row, column );
939}
941//*************************************************************************************************
942
943
944//*************************************************************************************************
962template< typename MT // Type of the adapted matrix
963 , bool SO // Storage order of the adapted matrix
964 , bool DF // Density flag
965 , typename VT // Type of the right-hand side vector
966 , bool TF > // Transpose flag of the right-hand side vector
967inline bool trySubAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
968 ptrdiff_t band, size_t row, size_t column )
969{
970 return tryAssign( lhs, *rhs, band, row, column );
971}
973//*************************************************************************************************
974
975
976//*************************************************************************************************
993template< typename MT1 // Type of the adapted matrix
994 , bool SO1 // Storage order of the adapted matrix
995 , bool DF // Density flag
996 , typename MT2 // Type of the right-hand side matrix
997 , bool SO2 > // Storage order of the right-hand side matrix
998inline bool trySubAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
999 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1000{
1001 return tryAssign( lhs, *rhs, row, column );
1002}
1004//*************************************************************************************************
1005
1006
1007//*************************************************************************************************
1024template< typename MT // Type of the adapted matrix
1025 , bool SO // Storage order of the adapted matrix
1026 , bool DF // Density flag
1027 , typename VT // Type of the right-hand side vector
1028 , bool TF > // Transpose flag of the right-hand side vector
1029inline bool tryMultAssign( const HermitianMatrix<MT,SO,DF>& lhs,
1030 const Vector<VT,TF>& rhs, size_t row, size_t column )
1031{
1032 return tryAssign( lhs, *rhs, row, column );
1033}
1035//*************************************************************************************************
1036
1037
1038//*************************************************************************************************
1056template< typename MT // Type of the adapted matrix
1057 , bool SO // Storage order of the adapted matrix
1058 , bool DF // Density flag
1059 , typename VT // Type of the right-hand side vector
1060 , bool TF > // Transpose flag of the right-hand side vector
1061inline bool tryMultAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1062 ptrdiff_t band, size_t row, size_t column )
1063{
1064 return tryAssign( lhs, *rhs, band, row, column );
1065}
1067//*************************************************************************************************
1068
1069
1070//*************************************************************************************************
1087template< typename MT1 // Type of the adapted matrix
1088 , bool SO1 // Storage order of the adapted matrix
1089 , bool DF // Density flag
1090 , typename MT2 // Type of the right-hand side matrix
1091 , bool SO2 > // Storage order of the right-hand side matrix
1092inline bool trySchurAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
1093 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1094{
1095 return tryAssign( lhs, *rhs, row, column );
1096}
1098//*************************************************************************************************
1099
1100
1101//*************************************************************************************************
1117template< typename MT // Type of the adapted matrix
1118 , bool SO // Storage order of the adapted matrix
1119 , bool DF // Density flag
1120 , typename VT // Type of the right-hand side vector
1121 , bool TF > // Transpose flag of the right-hand side vector
1122inline bool tryDivAssign( const HermitianMatrix<MT,SO,DF>& lhs,
1123 const Vector<VT,TF>& rhs, size_t row, size_t column )
1124{
1125 return tryAssign( lhs, *rhs, row, column );
1126}
1128//*************************************************************************************************
1129
1130
1131//*************************************************************************************************
1149template< typename MT // Type of the adapted matrix
1150 , bool SO // Storage order of the adapted matrix
1151 , bool DF // Density flag
1152 , typename VT // Type of the right-hand side vector
1153 , bool TF > // Transpose flag of the right-hand side vector
1154inline bool tryDivAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1155 ptrdiff_t band, size_t row, size_t column )
1156{
1157 return tryAssign( lhs, *rhs, band, row, column );
1158}
1160//*************************************************************************************************
1161
1162
1163
1164
1165//=================================================================================================
1166//
1167// SIZE SPECIALIZATIONS
1168//
1169//=================================================================================================
1170
1171//*************************************************************************************************
1173template< typename MT, bool SO, bool DF >
1174struct Size< HermitianMatrix<MT,SO,DF>, 0UL >
1175 : public Size<MT,0UL>
1176{};
1177
1178template< typename MT, bool SO, bool DF >
1179struct Size< HermitianMatrix<MT,SO,DF>, 1UL >
1180 : public Size<MT,1UL>
1181{};
1183//*************************************************************************************************
1184
1185
1186
1187
1188//=================================================================================================
1189//
1190// MAXSIZE SPECIALIZATIONS
1191//
1192//=================================================================================================
1193
1194//*************************************************************************************************
1196template< typename MT, bool SO, bool DF >
1197struct MaxSize< HermitianMatrix<MT,SO,DF>, 0UL >
1198 : public MaxSize<MT,0UL>
1199{};
1200
1201template< typename MT, bool SO, bool DF >
1202struct MaxSize< HermitianMatrix<MT,SO,DF>, 1UL >
1203 : public MaxSize<MT,1UL>
1204{};
1206//*************************************************************************************************
1207
1208
1209
1210
1211//=================================================================================================
1212//
1213// ISSQUARE SPECIALIZATIONS
1214//
1215//=================================================================================================
1216
1217//*************************************************************************************************
1219template< typename MT, bool SO, bool DF >
1220struct IsSquare< HermitianMatrix<MT,SO,DF> >
1221 : public TrueType
1222{};
1224//*************************************************************************************************
1225
1226
1227
1228
1229//=================================================================================================
1230//
1231// ISUNIFORM SPECIALIZATIONS
1232//
1233//=================================================================================================
1234
1235//*************************************************************************************************
1237template< typename MT, bool SO, bool DF >
1238struct IsUniform< HermitianMatrix<MT,SO,DF> >
1239 : public IsUniform<MT>
1240{};
1242//*************************************************************************************************
1243
1244
1245
1246
1247//=================================================================================================
1248//
1249// ISSYMMETRIC SPECIALIZATIONS
1250//
1251//=================================================================================================
1252
1253//*************************************************************************************************
1255template< typename MT, bool SO, bool DF >
1256struct IsSymmetric< HermitianMatrix<MT,SO,DF> >
1257 : public IsBuiltin< ElementType_t<MT> >
1258{};
1260//*************************************************************************************************
1261
1262
1263
1264
1265//=================================================================================================
1266//
1267// ISHERMITIAN SPECIALIZATIONS
1268//
1269//=================================================================================================
1270
1271//*************************************************************************************************
1273template< typename MT, bool SO, bool DF >
1274struct IsHermitian< HermitianMatrix<MT,SO,DF> >
1275 : public TrueType
1276{};
1278//*************************************************************************************************
1279
1280
1281
1282
1283//=================================================================================================
1284//
1285// ISSTRICTLYLOWER SPECIALIZATIONS
1286//
1287//=================================================================================================
1288
1289//*************************************************************************************************
1291template< typename MT, bool SO, bool DF >
1292struct IsStrictlyLower< HermitianMatrix<MT,SO,DF> >
1293 : public IsZero<MT>
1294{};
1296//*************************************************************************************************
1297
1298
1299
1300
1301//=================================================================================================
1302//
1303// ISSTRICTLYUPPER SPECIALIZATIONS
1304//
1305//=================================================================================================
1306
1307//*************************************************************************************************
1309template< typename MT, bool SO, bool DF >
1310struct IsStrictlyUpper< HermitianMatrix<MT,SO,DF> >
1311 : public IsZero<MT>
1312{};
1314//*************************************************************************************************
1315
1316
1317
1318
1319//=================================================================================================
1320//
1321// ISADAPTOR SPECIALIZATIONS
1322//
1323//=================================================================================================
1324
1325//*************************************************************************************************
1327template< typename MT, bool SO, bool DF >
1328struct IsAdaptor< HermitianMatrix<MT,SO,DF> >
1329 : public TrueType
1330{};
1332//*************************************************************************************************
1333
1334
1335
1336
1337//=================================================================================================
1338//
1339// ISRESTRICTED SPECIALIZATIONS
1340//
1341//=================================================================================================
1342
1343//*************************************************************************************************
1345template< typename MT, bool SO, bool DF >
1346struct IsRestricted< HermitianMatrix<MT,SO,DF> >
1347 : public TrueType
1348{};
1350//*************************************************************************************************
1351
1352
1353
1354
1355//=================================================================================================
1356//
1357// HASCONSTDATAACCESS SPECIALIZATIONS
1358//
1359//=================================================================================================
1360
1361//*************************************************************************************************
1363template< typename MT, bool SO >
1364struct HasConstDataAccess< HermitianMatrix<MT,SO,true> >
1365 : public TrueType
1366{};
1368//*************************************************************************************************
1369
1370
1371
1372
1373//=================================================================================================
1374//
1375// ISALIGNED SPECIALIZATIONS
1376//
1377//=================================================================================================
1378
1379//*************************************************************************************************
1381template< typename MT, bool SO, bool DF >
1382struct IsAligned< HermitianMatrix<MT,SO,DF> >
1383 : public IsAligned<MT>
1384{};
1386//*************************************************************************************************
1387
1388
1389
1390
1391//=================================================================================================
1392//
1393// ISCONTIGUOUS SPECIALIZATIONS
1394//
1395//=================================================================================================
1396
1397//*************************************************************************************************
1399template< typename MT, bool SO, bool DF >
1400struct IsContiguous< HermitianMatrix<MT,SO,DF> >
1401 : public IsContiguous<MT>
1402{};
1404//*************************************************************************************************
1405
1406
1407
1408
1409//=================================================================================================
1410//
1411// ISPADDED SPECIALIZATIONS
1412//
1413//=================================================================================================
1414
1415//*************************************************************************************************
1417template< typename MT, bool SO, bool DF >
1418struct IsPadded< HermitianMatrix<MT,SO,DF> >
1419 : public IsPadded<MT>
1420{};
1422//*************************************************************************************************
1423
1424
1425
1426
1427//=================================================================================================
1428//
1429// REMOVEADAPTOR SPECIALIZATIONS
1430//
1431//=================================================================================================
1432
1433//*************************************************************************************************
1435template< typename MT, bool SO, bool DF >
1436struct RemoveAdaptor< HermitianMatrix<MT,SO,DF> >
1437{
1438 using Type = MT;
1439};
1441//*************************************************************************************************
1442
1443
1444
1445
1446//=================================================================================================
1447//
1448// ADDTRAIT SPECIALIZATIONS
1449//
1450//=================================================================================================
1451
1452//*************************************************************************************************
1454template< typename T1, typename T2 >
1455struct AddTraitEval1< T1, T2
1456 , EnableIf_t< IsMatrix_v<T1> &&
1457 IsMatrix_v<T2> &&
1458 ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1459 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1460 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1461 IsSymmetric_v<T2> && !IsComplex_v< UnderlyingScalar_t<T2> > ) ||
1462 ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingScalar_t<T1> > &&
1463 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1464 !( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1465 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1466{
1467 using Type = HermitianMatrix< typename AddTraitEval2<T1,T2>::Type >;
1468};
1470//*************************************************************************************************
1471
1472
1473
1474
1475//=================================================================================================
1476//
1477// SUBTRAIT SPECIALIZATIONS
1478//
1479//=================================================================================================
1480
1481//*************************************************************************************************
1483template< typename T1, typename T2 >
1484struct SubTraitEval1< T1, T2
1485 , EnableIf_t< IsMatrix_v<T1> &&
1486 IsMatrix_v<T2> &&
1487 ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1488 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1489 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1490 IsSymmetric_v<T2> && !IsComplex_v< UnderlyingScalar_t<T2> > ) ||
1491 ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingScalar_t<T1> > &&
1492 IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1493 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1494{
1495 using Type = HermitianMatrix< typename SubTraitEval2<T1,T2>::Type >;
1496};
1498//*************************************************************************************************
1499
1500
1501
1502
1503//=================================================================================================
1504//
1505// SCHURTRAIT SPECIALIZATIONS
1506//
1507//=================================================================================================
1508
1509//*************************************************************************************************
1511template< typename T1, typename T2 >
1512struct SchurTraitEval1< T1, T2
1513 , EnableIf_t< IsMatrix_v<T1> &&
1514 IsMatrix_v<T2> &&
1515 ( IsHermitian_v<T1> && IsHermitian_v<T2> ) &&
1516 !( IsSymmetric_v<T1> && IsSymmetric_v<T2> ) &&
1517 !( IsDiagonal_v<T1> || IsZero_v<T1> ) &&
1518 !( IsDiagonal_v<T2> || IsZero_v<T2> ) > >
1519{
1520 using Type = HermitianMatrix< typename SchurTraitEval2<T1,T2>::Type >;
1521};
1523//*************************************************************************************************
1524
1525
1526
1527
1528//=================================================================================================
1529//
1530// MULTTRAIT SPECIALIZATIONS
1531//
1532//=================================================================================================
1533
1534//*************************************************************************************************
1536template< typename T1, typename T2 >
1537struct MultTraitEval1< T1, T2
1538 , EnableIf_t< IsMatrix_v<T1> &&
1539 IsScalar_v<T2> &&
1540 ( IsHermitian_v<T1> && !IsSymmetric_v<T1> && !IsUniform_v<T1> ) > >
1541{
1542 using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1543};
1544
1545template< typename T1, typename T2 >
1546struct MultTraitEval1< T1, T2
1547 , EnableIf_t< IsScalar_v<T1> &&
1548 IsMatrix_v<T2> &&
1549 ( IsHermitian_v<T2> && !IsSymmetric_v<T2> && !IsUniform_v<T2> ) > >
1550{
1551 using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1552};
1554//*************************************************************************************************
1555
1556
1557
1558
1559//=================================================================================================
1560//
1561// KRONTRAIT SPECIALIZATIONS
1562//
1563//=================================================================================================
1564
1565//*************************************************************************************************
1567template< typename T1, typename T2 >
1568struct KronTraitEval1< T1, T2
1569 , EnableIf_t< IsMatrix_v<T1> &&
1570 IsMatrix_v<T2> &&
1571 ( IsHermitian_v<T1> && IsHermitian_v<T2> ) &&
1572 !( IsSymmetric_v<T1> && IsSymmetric_v<T2> ) &&
1573 !( IsZero_v<T1> || IsZero_v<T2> ) > >
1574{
1575 using Type = HermitianMatrix< typename KronTraitEval2<T1,T2>::Type >;
1576};
1578//*************************************************************************************************
1579
1580
1581
1582
1583//=================================================================================================
1584//
1585// DIVTRAIT SPECIALIZATIONS
1586//
1587//=================================================================================================
1588
1589//*************************************************************************************************
1591template< typename T1, typename T2 >
1592struct DivTraitEval1< T1, T2
1593 , EnableIf_t< IsHermitian_v<T1> && !IsSymmetric_v<T1> && IsScalar_v<T2> > >
1594{
1595 using Type = HermitianMatrix< typename DivTraitEval2<T1,T2>::Type >;
1596};
1598//*************************************************************************************************
1599
1600
1601
1602
1603//=================================================================================================
1604//
1605// MAPTRAIT SPECIALIZATIONS
1606//
1607//=================================================================================================
1608
1609//*************************************************************************************************
1611template< typename T, typename OP >
1612struct UnaryMapTraitEval1< T, OP
1613 , EnableIf_t< YieldsHermitian_v<OP,T> &&
1614 !YieldsSymmetric_v<OP,T> &&
1615 !YieldsIdentity_v<OP,T> > >
1616{
1617 using Type = HermitianMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
1618};
1620//*************************************************************************************************
1621
1622
1623//*************************************************************************************************
1625template< typename T1, typename T2, typename OP >
1626struct BinaryMapTraitEval1< T1, T2, OP
1627 , EnableIf_t< YieldsHermitian_v<OP,T1,T2> &&
1628 !YieldsSymmetric_v<OP,T1,T2> &&
1629 !YieldsIdentity_v<OP,T1,T2> > >
1630{
1631 using Type = HermitianMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
1632};
1634//*************************************************************************************************
1635
1636
1637
1638
1639//=================================================================================================
1640//
1641// REPEATTRAIT SPECIALIZATIONS
1642//
1643//=================================================================================================
1644
1645//*************************************************************************************************
1647template< typename T, size_t R0, size_t R1 >
1648struct RepeatTraitEval1< T, R0, R1, inf
1649 , EnableIf_t< R0 != inf && R1 != inf && R0 == R1 &&
1650 IsHermitian_v<T> && !IsSymmetric_v<T> > >
1651{
1652 using Type = HermitianMatrix< typename RepeatTraitEval2<T,R0,R1,inf>::Type >;
1653};
1655//*************************************************************************************************
1656
1657
1658
1659
1660//=================================================================================================
1661//
1662// DECLSYMTRAIT SPECIALIZATIONS
1663//
1664//=================================================================================================
1665
1666//*************************************************************************************************
1668template< typename MT, bool SO, bool DF >
1669struct DeclSymTrait< HermitianMatrix<MT,SO,DF> >
1670{
1671 using Type = SymmetricMatrix<MT,SO,DF>;
1672};
1674//*************************************************************************************************
1675
1676
1677
1678
1679//=================================================================================================
1680//
1681// DECLHERMTRAIT SPECIALIZATIONS
1682//
1683//=================================================================================================
1684
1685//*************************************************************************************************
1687template< typename MT, bool SO, bool DF >
1688struct DeclHermTrait< HermitianMatrix<MT,SO,DF> >
1689{
1690 using Type = HermitianMatrix<MT,SO,DF>;
1691};
1693//*************************************************************************************************
1694
1695
1696
1697
1698//=================================================================================================
1699//
1700// DECLLOWTRAIT SPECIALIZATIONS
1701//
1702//=================================================================================================
1703
1704//*************************************************************************************************
1706template< typename MT, bool SO, bool DF >
1707struct DeclLowTrait< HermitianMatrix<MT,SO,DF> >
1708{
1709 using Type = DiagonalMatrix<MT,SO,DF>;
1710};
1712//*************************************************************************************************
1713
1714
1715
1716
1717//=================================================================================================
1718//
1719// DECLUNILOWTRAIT SPECIALIZATIONS
1720//
1721//=================================================================================================
1722
1723//*************************************************************************************************
1725template< typename MT, bool SO, bool DF >
1726struct DeclUniLowTrait< HermitianMatrix<MT,SO,DF> >
1727{
1728 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
1729};
1731//*************************************************************************************************
1732
1733
1734
1735
1736//=================================================================================================
1737//
1738// DECLSTRLOWTRAIT SPECIALIZATIONS
1739//
1740//=================================================================================================
1741
1742//*************************************************************************************************
1744template< typename MT, bool SO, bool DF >
1745struct DeclStrLowTrait< HermitianMatrix<MT,SO,DF> >
1746{
1747 using Type = ZeroMatrix< ElementType_t<MT>, SO >;
1748};
1750//*************************************************************************************************
1751
1752
1753
1754
1755//=================================================================================================
1756//
1757// DECLUPPTRAIT SPECIALIZATIONS
1758//
1759//=================================================================================================
1760
1761//*************************************************************************************************
1763template< typename MT, bool SO, bool DF >
1764struct DeclUppTrait< HermitianMatrix<MT,SO,DF> >
1765{
1766 using Type = DiagonalMatrix<MT,SO,DF>;
1767};
1769//*************************************************************************************************
1770
1771
1772
1773
1774//=================================================================================================
1775//
1776// DECLUNIUPPTRAIT SPECIALIZATIONS
1777//
1778//=================================================================================================
1779
1780//*************************************************************************************************
1782template< typename MT, bool SO, bool DF >
1783struct DeclUniUppTrait< HermitianMatrix<MT,SO,DF> >
1784{
1785 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
1786};
1788//*************************************************************************************************
1789
1790
1791
1792
1793//=================================================================================================
1794//
1795// DECLSTRUPPTRAIT SPECIALIZATIONS
1796//
1797//=================================================================================================
1798
1799//*************************************************************************************************
1801template< typename MT, bool SO, bool DF >
1802struct DeclStrUppTrait< HermitianMatrix<MT,SO,DF> >
1803{
1804 using Type = ZeroMatrix< ElementType_t<MT>, SO >;
1805};
1807//*************************************************************************************************
1808
1809
1810
1811
1812//=================================================================================================
1813//
1814// DECLDIAGTRAIT SPECIALIZATIONS
1815//
1816//=================================================================================================
1817
1818//*************************************************************************************************
1820template< typename MT, bool SO, bool DF >
1821struct DeclDiagTrait< HermitianMatrix<MT,SO,DF> >
1822{
1823 using Type = DiagonalMatrix<MT,SO,DF>;
1824};
1826//*************************************************************************************************
1827
1828
1829
1830
1831//=================================================================================================
1832//
1833// HIGHTYPE SPECIALIZATIONS
1834//
1835//=================================================================================================
1836
1837//*************************************************************************************************
1839template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1840struct HighType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1841{
1842 using Type = HermitianMatrix< typename HighType<MT1,MT2>::Type >;
1843};
1845//*************************************************************************************************
1846
1847
1848
1849
1850//=================================================================================================
1851//
1852// LOWTYPE SPECIALIZATIONS
1853//
1854//=================================================================================================
1855
1856//*************************************************************************************************
1858template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1859struct LowType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1860{
1861 using Type = HermitianMatrix< typename LowType<MT1,MT2>::Type >;
1862};
1864//*************************************************************************************************
1865
1866
1867
1868
1869//=================================================================================================
1870//
1871// SUBMATRIXTRAIT SPECIALIZATIONS
1872//
1873//=================================================================================================
1874
1875//*************************************************************************************************
1877template< typename MT, size_t I, size_t N >
1878struct SubmatrixTraitEval1< MT, I, I, N, N
1879 , EnableIf_t< I != inf && N != inf &&
1880 IsHermitian_v<MT> &&
1881 !IsSymmetric_v<MT> > >
1882{
1883 using Type = HermitianMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
1884};
1886//*************************************************************************************************
1887
1888} // namespace blaze
1889
1890#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Constraint on the data type.
Header file for the conjugate shim.
Header file for the decldiag trait.
Header file for the declherm trait.
Header file for the decllow trait.
Header file for the declstrlow trait.
Header file for the declstrupp trait.
Header file for the declsym trait.
Header file for the declunilow trait.
Header file for the decluniupp trait.
Header file for the declupp trait.
Header file for the division trait.
Header file for the EnableIf class template.
Header file for the HasConstDataAccess type trait.
Header file for the HighType type trait.
Header file for the IntegralConstant class template.
Header file for the dense matrix inversion flags.
Header file for the IsAdaptor type trait.
Header file for the IsAligned type trait.
Header file for the IsBuiltin type trait.
Header file for the IsComplex type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsDiagonal type trait.
Header file for the isDivisor shim.
Header file for the IsHermitian type trait.
Header file for the IsMatrix type trait.
Header file for the IsPadded type trait.
Header file for the isReal shim.
Header file for the IsRestricted type trait.
Header file for the IsScalar type trait.
Header file for the IsSquare type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the IsUniform 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 MaxSize type trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Header file for the relaxation flag enumeration.
Header file for the RemoveAdaptor type trait.
Header file for the repeat trait.
Header file for the Schur product trait.
Header file for the subtraction trait.
Header file for the submatrix trait.
Header file for the UnderlyingScalar type trait.
Header file for the YieldsHermitian type trait.
Header file for the YieldsIdentity type trait.
Header file for the YieldsSymmetric type trait.
Header file for the implementation of the base template of the HeritianMatrix.
HermitianMatrix specialization for dense matrices.
HermitianMatrix specialization for sparse matrices.
Pointer difference type of the Blaze library.
Constraint on the data type.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1339
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:1534
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an identity matrix.
Definition: DenseMatrix.h:2561
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:225
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:693
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
constexpr bool IsHermitian_v
Auxiliary variable template for the IsHermitian type trait.
Definition: IsHermitian.h:172
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition: Size.h:72
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
constexpr bool YieldsHermitian_v
Auxiliary variable template for the YieldsHermitian type trait.
Definition: YieldsHermitian.h:124
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
bool isReal(const Proxy< PT, RT > &proxy)
Returns whether the element represents a real number.
Definition: Proxy.h:2297
InversionFlag
Inversion flag.
Definition: InversionFlag.h:102
@ byLDLT
Flag for the Bunch-Kaufman-based inversion for symmetric matrices.
Definition: InversionFlag.h:104
@ asHermitian
Flag for the inversion of a Hermitian matrix (same as byLDLH).
Definition: InversionFlag.h:110
@ asUniLower
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
@ asSymmetric
Flag for the inversion of a symmetric matrix (same as byLDLT).
Definition: InversionFlag.h:109
@ asUniUpper
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
@ byLDLH
Flag for the Bunch-Kaufman-based inversion for Hermitian matrices.
Definition: InversionFlag.h:105
@ asDiagonal
Flag for the inversion of a diagonal matrix.
Definition: InversionFlag.h:115
@ byLU
Flag for the LU-based matrix inversion.
Definition: InversionFlag.h:103
@ byLLH
Flag for the Cholesky-based inversion for positive-definite matrices.
Definition: InversionFlag.h:106
@ asGeneral
Flag for the inversion of a general matrix (same as byLU).
Definition: InversionFlag.h:108
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
constexpr bool IsComplex_v
Auxiliary variable template for the IsComplex type trait.
Definition: IsComplex.h:139
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
Header file for the exception macros of the math module.
Header file for all forward declarations of the math module.
Header file for the Size type trait.
Header file for the StorageOrder type trait.
Header file for the IsZero type trait.
Header file for the generic min algorithm.