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>
49 #include <blaze/math/Exception.h>
50 #include <blaze/math/Forward.h>
96 #include <blaze/util/Assert.h>
97 #include <blaze/util/EnableIf.h>
98 #include <blaze/util/TrueType.h>
102 #include <blaze/util/Unused.h>
103 
104 
105 namespace blaze {
106 
107 //=================================================================================================
108 //
109 // HERMITIANMATRIX OPERATORS
110 //
111 //=================================================================================================
112 
113 //*************************************************************************************************
116 template< typename MT, bool SO, bool DF >
117 void reset( HermitianMatrix<MT,SO,DF>& m );
118 
119 template< typename MT, bool SO, bool DF >
120 void reset( HermitianMatrix<MT,SO,DF>& m, size_t i );
121 
122 template< typename MT, bool SO, bool DF >
123 void clear( HermitianMatrix<MT,SO,DF>& m );
124 
125 template< bool RF, typename MT, bool SO, bool DF >
126 bool isDefault( const HermitianMatrix<MT,SO,DF>& m );
127 
128 template< typename MT, bool SO, bool DF >
129 bool isIntact( const HermitianMatrix<MT,SO,DF>& m );
130 
131 template< typename MT, bool SO, bool DF >
132 void swap( HermitianMatrix<MT,SO,DF>& a, HermitianMatrix<MT,SO,DF>& b ) noexcept;
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
144 template< typename MT // Type of the adapted matrix
145  , bool SO // Storage order of the adapted matrix
146  , bool DF > // Density flag
148 {
149  m.reset();
150 }
151 //*************************************************************************************************
152 
153 
154 //*************************************************************************************************
167 template< typename MT // Type of the adapted matrix
168  , bool SO // Storage order of the adapted matrix
169  , bool DF > // Density flag
170 inline void reset( HermitianMatrix<MT,SO,DF>& m, size_t i )
171 {
172  m.reset( i );
173 }
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
184 template< typename MT // Type of the adapted matrix
185  , bool SO // Storage order of the adapted matrix
186  , bool DF > // Density flag
188 {
189  m.clear();
190 }
191 //*************************************************************************************************
192 
193 
194 //*************************************************************************************************
219 template< bool RF // Relaxation flag
220  , typename MT // Type of the adapted matrix
221  , bool SO // Storage order of the adapted matrix
222  , bool DF > // Density flag
223 inline bool isDefault( const HermitianMatrix<MT,SO,DF>& m )
224 {
225  return isDefault<RF>( m.matrix_ );
226 }
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
251 template< typename MT // Type of the adapted matrix
252  , bool SO // Storage order of the adapted matrix
253  , bool DF > // Density flag
254 inline bool isIntact( const HermitianMatrix<MT,SO,DF>& m )
255 {
256  return m.isIntact();
257 }
258 //*************************************************************************************************
259 
260 
261 //*************************************************************************************************
269 template< typename MT // Type of the adapted matrix
270  , bool SO // Storage order of the adapted matrix
271  , bool DF > // Density flag
273 {
274  a.swap( b );
275 }
276 //*************************************************************************************************
277 
278 
279 //*************************************************************************************************
302 template< InversionFlag IF // Inversion algorithm
303  , typename MT // Type of the dense matrix
304  , bool SO > // Storage order of the dense matrix
305 inline void invert( HermitianMatrix<MT,SO,true>& m )
306 {
308 
309  if( IF == asUniLower || IF == asUniUpper ) {
310  BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
311  return;
312  }
313 
314  constexpr InversionFlag flag( ( IF == byLU || IF == byLDLT || IF == byLDLH ||
315  IF == asGeneral || IF == asSymmetric || IF == asHermitian )
316  ? ( byLDLH )
317  : ( ( IF == byLLH )
318  ?( byLLH )
319  :( asDiagonal ) ) );
320 
321  MT tmp( m.matrix_ );
322  invert<flag>( tmp );
323  m.matrix_ = std::move( tmp );
324 
325  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
326 }
328 //*************************************************************************************************
329 
330 
331 //*************************************************************************************************
347 template< typename MT // Type of the adapted matrix
348  , bool SO // Storage order of the adapted matrix
349  , bool DF // Density flag
350  , typename ET > // Type of the element
351 inline bool trySet( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
352 {
353  BLAZE_INTERNAL_ASSERT( i < (~mat).rows(), "Invalid row access index" );
354  BLAZE_INTERNAL_ASSERT( j < (~mat).columns(), "Invalid column access index" );
355 
356  UNUSED_PARAMETER( mat );
357 
358  return ( i != j || isReal( value ) );
359 }
361 //*************************************************************************************************
362 
363 
364 //*************************************************************************************************
380 template< typename MT // Type of the adapted matrix
381  , bool SO // Storage order of the adapted matrix
382  , bool DF // Density flag
383  , typename ET > // Type of the element
384 inline bool tryAdd( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
385 {
386  return trySet( mat, i, j, value );
387 }
389 //*************************************************************************************************
390 
391 
392 //*************************************************************************************************
408 template< typename MT // Type of the adapted matrix
409  , bool SO // Storage order of the adapted matrix
410  , bool DF // Density flag
411  , typename ET > // Type of the element
412 inline bool trySub( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
413 {
414  return trySet( mat, i, j, value );
415 }
417 //*************************************************************************************************
418 
419 
420 //*************************************************************************************************
436 template< typename MT // Type of the adapted matrix
437  , bool SO // Storage order of the adapted matrix
438  , bool DF // Density flag
439  , typename ET > // Type of the element
440 inline bool tryMult( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
441 {
442  return trySet( mat, i, j, value );
443 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
464 template< typename MT // Type of the adapted matrix
465  , bool SO // Storage order of the adapted matrix
466  , bool DF // Density flag
467  , typename ET > // Type of the element
468 inline bool tryDiv( const HermitianMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
469 {
470  return trySet( mat, i, j, value );
471 }
473 //*************************************************************************************************
474 
475 
476 //*************************************************************************************************
492 template< typename MT // Type of the adapted matrix
493  , bool SO // Storage order of the adapted matrix
494  , bool DF // Density flag
495  , typename VT > // Type of the right-hand side vector
496 inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs,
497  const Vector<VT,false>& rhs, size_t row, size_t column )
498 {
500 
501  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
502  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
503  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
504 
505  UNUSED_PARAMETER( lhs );
506 
507  using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
508 
509  return ( IsBuiltin_v<ET> ||
510  column < row ||
511  (~rhs).size() <= column - row ||
512  isReal( (~rhs)[column-row] ) );
513 
514  return true;
515 }
517 //*************************************************************************************************
518 
519 
520 //*************************************************************************************************
536 template< typename MT // Type of the adapted matrix
537  , bool SO // Storage order of the adapted matrix
538  , bool DF // Density flag
539  , typename VT > // Type of the right-hand side vector
540 inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs,
541  const Vector<VT,true>& rhs, size_t row, size_t column )
542 {
544 
545  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
546  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
547  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
548 
549  UNUSED_PARAMETER( lhs );
550 
551  using ET = ElementType_t< HermitianMatrix<MT,SO,DF> >;
552 
553  return ( IsBuiltin_v<ET> ||
554  row < column ||
555  (~rhs).size() <= row - column ||
556  isReal( (~rhs)[row-column] ) );
557 
558  return true;
559 }
561 //*************************************************************************************************
562 
563 
564 //*************************************************************************************************
582 template< typename MT // Type of the adapted matrix
583  , bool SO // Storage order of the adapted matrix
584  , bool DF // Density flag
585  , typename VT // Type of the right-hand side dense vector
586  , bool TF > // Transpose flag of the right-hand side dense vector
587 inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
588  ptrdiff_t band, size_t row, size_t column )
589 {
591 
592  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
593  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
594  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
595  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
596 
597  UNUSED_PARAMETER( lhs, row, column );
598 
599  if( band == 0L ) {
600  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
601  if( !isReal( (~rhs)[i] ) )
602  return false;
603  }
604  }
605 
606  return true;
607 }
609 //*************************************************************************************************
610 
611 
612 //*************************************************************************************************
630 template< typename MT // Type of the adapted matrix
631  , bool SO // Storage order of the adapted matrix
632  , bool DF // Density flag
633  , typename VT // Type of the right-hand side sparse vector
634  , bool TF > // Transpose flag of the right-hand side sparse vector
635 inline bool tryAssign( const HermitianMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
636  ptrdiff_t band, size_t row, size_t column )
637 {
639 
640  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
641  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
642  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
643  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
644 
645  UNUSED_PARAMETER( lhs, row, column );
646 
647  if( band == 0L ) {
648  for( const auto& element : ~rhs ) {
649  if( !isReal( element.value() ) )
650  return false;
651  }
652  }
653 
654  return true;
655 }
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
676 template< typename MT1 // Type of the adapted matrix
677  , bool SO1 // Storage order of the adapted matrix
678  , bool DF // Density flag
679  , typename MT2 // Type of the right-hand side matrix
680  , bool SO2 > // Storage order of the right-hand side matrix
681 inline bool tryAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
682  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
683 {
685 
686  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
687  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
688  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
689  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
690 
691  UNUSED_PARAMETER( lhs );
692 
693  const size_t M( (~rhs).rows() );
694  const size_t N( (~rhs).columns() );
695 
696  if( ( row + M <= column ) || ( column + N <= row ) )
697  return true;
698 
699  const bool lower( row > column );
700  const size_t size ( min( row + M, column + N ) - ( lower ? row : column ) );
701 
702  if( size < 2UL )
703  return true;
704 
705  const size_t subrow( lower ? 0UL : column - row );
706  const size_t subcol( lower ? row - column : 0UL );
707 
708  return isHermitian( submatrix( ~rhs, subrow, subcol, size, size ) );
709 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
730 template< typename MT // Type of the adapted matrix
731  , bool SO // Storage order of the adapted matrix
732  , bool DF // Density flag
733  , typename VT // Type of the right-hand side vector
734  , bool TF > // Transpose flag of the right-hand side vector
735 inline bool tryAddAssign( const HermitianMatrix<MT,SO,DF>& lhs,
736  const Vector<VT,TF>& rhs, size_t row, size_t column )
737 {
738  return tryAssign( lhs, ~rhs, row, column );
739 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
762 template< typename MT // Type of the adapted matrix
763  , bool SO // Storage order of the adapted matrix
764  , bool DF // Density flag
765  , typename VT // Type of the right-hand side vector
766  , bool TF > // Transpose flag of the right-hand side vector
767 inline bool tryAddAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
768  ptrdiff_t band, size_t row, size_t column )
769 {
770  return tryAssign( lhs, ~rhs, band, row, column );
771 }
773 //*************************************************************************************************
774 
775 
776 //*************************************************************************************************
792 template< typename MT1 // Type of the adapted matrix
793  , bool SO1 // Storage order of the adapted matrix
794  , bool DF // Density flag
795  , typename MT2 // Type of the right-hand side matrix
796  , bool SO2 > // Storage order of the right-hand side matrix
797 inline bool tryAddAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
798  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
799 {
800  return tryAssign( lhs, ~rhs, row, column );
801 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
823 template< typename MT // Type of the adapted matrix
824  , bool SO // Storage order of the adapted matrix
825  , bool DF // Density flag
826  , typename VT // Type of the right-hand side vector
827  , bool TF > // Transpose flag of the right-hand side vector
828 inline bool trySubAssign( const HermitianMatrix<MT,SO,DF>& lhs,
829  const Vector<VT,TF>& rhs, size_t row, size_t column )
830 {
831  return tryAssign( lhs, ~rhs, row, column );
832 }
834 //*************************************************************************************************
835 
836 
837 //*************************************************************************************************
855 template< typename MT // Type of the adapted matrix
856  , bool SO // Storage order of the adapted matrix
857  , bool DF // Density flag
858  , typename VT // Type of the right-hand side vector
859  , bool TF > // Transpose flag of the right-hand side vector
860 inline bool trySubAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
861  ptrdiff_t band, size_t row, size_t column )
862 {
863  return tryAssign( lhs, ~rhs, band, row, column );
864 }
866 //*************************************************************************************************
867 
868 
869 //*************************************************************************************************
886 template< typename MT1 // Type of the adapted matrix
887  , bool SO1 // Storage order of the adapted matrix
888  , bool DF // Density flag
889  , typename MT2 // Type of the right-hand side matrix
890  , bool SO2 > // Storage order of the right-hand side matrix
891 inline bool trySubAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
892  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
893 {
894  return tryAssign( lhs, ~rhs, row, column );
895 }
897 //*************************************************************************************************
898 
899 
900 //*************************************************************************************************
917 template< typename MT // Type of the adapted matrix
918  , bool SO // Storage order of the adapted matrix
919  , bool DF // Density flag
920  , typename VT // Type of the right-hand side vector
921  , bool TF > // Transpose flag of the right-hand side vector
922 inline bool tryMultAssign( const HermitianMatrix<MT,SO,DF>& lhs,
923  const Vector<VT,TF>& rhs, size_t row, size_t column )
924 {
925  return tryAssign( lhs, ~rhs, row, column );
926 }
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
949 template< typename MT // Type of the adapted matrix
950  , bool SO // Storage order of the adapted matrix
951  , bool DF // Density flag
952  , typename VT // Type of the right-hand side vector
953  , bool TF > // Transpose flag of the right-hand side vector
954 inline bool tryMultAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
955  ptrdiff_t band, size_t row, size_t column )
956 {
957  return tryAssign( lhs, ~rhs, band, row, column );
958 }
960 //*************************************************************************************************
961 
962 
963 //*************************************************************************************************
980 template< typename MT1 // Type of the adapted matrix
981  , bool SO1 // Storage order of the adapted matrix
982  , bool DF // Density flag
983  , typename MT2 // Type of the right-hand side matrix
984  , bool SO2 > // Storage order of the right-hand side matrix
985 inline bool trySchurAssign( const HermitianMatrix<MT1,SO1,DF>& lhs,
986  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
987 {
988  return tryAssign( lhs, ~rhs, row, column );
989 }
991 //*************************************************************************************************
992 
993 
994 //*************************************************************************************************
1010 template< typename MT // Type of the adapted matrix
1011  , bool SO // Storage order of the adapted matrix
1012  , bool DF // Density flag
1013  , typename VT // Type of the right-hand side vector
1014  , bool TF > // Transpose flag of the right-hand side vector
1015 inline bool tryDivAssign( const HermitianMatrix<MT,SO,DF>& lhs,
1016  const Vector<VT,TF>& rhs, size_t row, size_t column )
1017 {
1018  return tryAssign( lhs, ~rhs, row, column );
1019 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1042 template< typename MT // Type of the adapted matrix
1043  , bool SO // Storage order of the adapted matrix
1044  , bool DF // Density flag
1045  , typename VT // Type of the right-hand side vector
1046  , bool TF > // Transpose flag of the right-hand side vector
1047 inline bool tryDivAssign( const HermitianMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1048  ptrdiff_t band, size_t row, size_t column )
1049 {
1050  return tryAssign( lhs, ~rhs, band, row, column );
1051 }
1053 //*************************************************************************************************
1054 
1055 
1056 
1057 
1058 //=================================================================================================
1059 //
1060 // SIZE SPECIALIZATIONS
1061 //
1062 //=================================================================================================
1063 
1064 //*************************************************************************************************
1066 template< typename MT, bool SO, bool DF >
1067 struct Size< HermitianMatrix<MT,SO,DF>, 0UL >
1068  : public Size<MT,0UL>
1069 {};
1070 
1071 template< typename MT, bool SO, bool DF >
1072 struct Size< HermitianMatrix<MT,SO,DF>, 1UL >
1073  : public Size<MT,1UL>
1074 {};
1076 //*************************************************************************************************
1077 
1078 
1079 
1080 
1081 //=================================================================================================
1082 //
1083 // MAXSIZE SPECIALIZATIONS
1084 //
1085 //=================================================================================================
1086 
1087 //*************************************************************************************************
1089 template< typename MT, bool SO, bool DF >
1090 struct MaxSize< HermitianMatrix<MT,SO,DF>, 0UL >
1091  : public MaxSize<MT,0UL>
1092 {};
1093 
1094 template< typename MT, bool SO, bool DF >
1095 struct MaxSize< HermitianMatrix<MT,SO,DF>, 1UL >
1096  : public MaxSize<MT,1UL>
1097 {};
1099 //*************************************************************************************************
1100 
1101 
1102 
1103 
1104 //=================================================================================================
1105 //
1106 // ISSQUARE SPECIALIZATIONS
1107 //
1108 //=================================================================================================
1109 
1110 //*************************************************************************************************
1112 template< typename MT, bool SO, bool DF >
1113 struct IsSquare< HermitianMatrix<MT,SO,DF> >
1114  : public TrueType
1115 {};
1117 //*************************************************************************************************
1118 
1119 
1120 
1121 
1122 //=================================================================================================
1123 //
1124 // ISUNIFORM SPECIALIZATIONS
1125 //
1126 //=================================================================================================
1127 
1128 //*************************************************************************************************
1130 template< typename MT, bool SO, bool DF >
1131 struct IsUniform< HermitianMatrix<MT,SO,DF> >
1132  : public IsUniform<MT>
1133 {};
1135 //*************************************************************************************************
1136 
1137 
1138 
1139 
1140 //=================================================================================================
1141 //
1142 // ISSYMMETRIC SPECIALIZATIONS
1143 //
1144 //=================================================================================================
1145 
1146 //*************************************************************************************************
1148 template< typename MT, bool SO, bool DF >
1149 struct IsSymmetric< HermitianMatrix<MT,SO,DF> >
1150  : public IsBuiltin< ElementType_t<MT> >
1151 {};
1153 //*************************************************************************************************
1154 
1155 
1156 
1157 
1158 //=================================================================================================
1159 //
1160 // ISHERMITIAN SPECIALIZATIONS
1161 //
1162 //=================================================================================================
1163 
1164 //*************************************************************************************************
1166 template< typename MT, bool SO, bool DF >
1167 struct IsHermitian< HermitianMatrix<MT,SO,DF> >
1168  : public TrueType
1169 {};
1171 //*************************************************************************************************
1172 
1173 
1174 
1175 
1176 //=================================================================================================
1177 //
1178 // ISSTRICTLYLOWER SPECIALIZATIONS
1179 //
1180 //=================================================================================================
1181 
1182 //*************************************************************************************************
1184 template< typename MT, bool SO, bool DF >
1185 struct IsStrictlyLower< HermitianMatrix<MT,SO,DF> >
1186  : public IsZero<MT>
1187 {};
1189 //*************************************************************************************************
1190 
1191 
1192 
1193 
1194 //=================================================================================================
1195 //
1196 // ISSTRICTLYUPPER SPECIALIZATIONS
1197 //
1198 //=================================================================================================
1199 
1200 //*************************************************************************************************
1202 template< typename MT, bool SO, bool DF >
1203 struct IsStrictlyUpper< HermitianMatrix<MT,SO,DF> >
1204  : public IsZero<MT>
1205 {};
1207 //*************************************************************************************************
1208 
1209 
1210 
1211 
1212 //=================================================================================================
1213 //
1214 // ISADAPTOR SPECIALIZATIONS
1215 //
1216 //=================================================================================================
1217 
1218 //*************************************************************************************************
1220 template< typename MT, bool SO, bool DF >
1221 struct IsAdaptor< HermitianMatrix<MT,SO,DF> >
1222  : public TrueType
1223 {};
1225 //*************************************************************************************************
1226 
1227 
1228 
1229 
1230 //=================================================================================================
1231 //
1232 // ISRESTRICTED SPECIALIZATIONS
1233 //
1234 //=================================================================================================
1235 
1236 //*************************************************************************************************
1238 template< typename MT, bool SO, bool DF >
1239 struct IsRestricted< HermitianMatrix<MT,SO,DF> >
1240  : public TrueType
1241 {};
1243 //*************************************************************************************************
1244 
1245 
1246 
1247 
1248 //=================================================================================================
1249 //
1250 // HASCONSTDATAACCESS SPECIALIZATIONS
1251 //
1252 //=================================================================================================
1253 
1254 //*************************************************************************************************
1256 template< typename MT, bool SO >
1257 struct HasConstDataAccess< HermitianMatrix<MT,SO,true> >
1258  : public TrueType
1259 {};
1261 //*************************************************************************************************
1262 
1263 
1264 
1265 
1266 //=================================================================================================
1267 //
1268 // ISALIGNED SPECIALIZATIONS
1269 //
1270 //=================================================================================================
1271 
1272 //*************************************************************************************************
1274 template< typename MT, bool SO, bool DF >
1275 struct IsAligned< HermitianMatrix<MT,SO,DF> >
1276  : public IsAligned<MT>
1277 {};
1279 //*************************************************************************************************
1280 
1281 
1282 
1283 
1284 //=================================================================================================
1285 //
1286 // ISCONTIGUOUS SPECIALIZATIONS
1287 //
1288 //=================================================================================================
1289 
1290 //*************************************************************************************************
1292 template< typename MT, bool SO, bool DF >
1293 struct IsContiguous< HermitianMatrix<MT,SO,DF> >
1294  : public IsContiguous<MT>
1295 {};
1297 //*************************************************************************************************
1298 
1299 
1300 
1301 
1302 //=================================================================================================
1303 //
1304 // ISPADDED SPECIALIZATIONS
1305 //
1306 //=================================================================================================
1307 
1308 //*************************************************************************************************
1310 template< typename MT, bool SO, bool DF >
1311 struct IsPadded< HermitianMatrix<MT,SO,DF> >
1312  : public IsPadded<MT>
1313 {};
1315 //*************************************************************************************************
1316 
1317 
1318 
1319 
1320 //=================================================================================================
1321 //
1322 // ISRESIZABLE SPECIALIZATIONS
1323 //
1324 //=================================================================================================
1325 
1326 //*************************************************************************************************
1328 template< typename MT, bool SO, bool DF >
1329 struct IsResizable< HermitianMatrix<MT,SO,DF> >
1330  : public IsResizable<MT>
1331 {};
1333 //*************************************************************************************************
1334 
1335 
1336 
1337 
1338 //=================================================================================================
1339 //
1340 // ISSHRINKABLE SPECIALIZATIONS
1341 //
1342 //=================================================================================================
1343 
1344 //*************************************************************************************************
1346 template< typename MT, bool SO, bool DF >
1347 struct IsShrinkable< HermitianMatrix<MT,SO,DF> >
1348  : public IsShrinkable<MT>
1349 {};
1351 //*************************************************************************************************
1352 
1353 
1354 
1355 
1356 //=================================================================================================
1357 //
1358 // REMOVEADAPTOR SPECIALIZATIONS
1359 //
1360 //=================================================================================================
1361 
1362 //*************************************************************************************************
1364 template< typename MT, bool SO, bool DF >
1365 struct RemoveAdaptor< HermitianMatrix<MT,SO,DF> >
1366 {
1367  using Type = MT;
1368 };
1370 //*************************************************************************************************
1371 
1372 
1373 
1374 
1375 //=================================================================================================
1376 //
1377 // ADDTRAIT SPECIALIZATIONS
1378 //
1379 //=================================================================================================
1380 
1381 //*************************************************************************************************
1383 template< typename T1, typename T2 >
1384 struct AddTraitEval1< T1, T2
1385  , EnableIf_t< IsMatrix_v<T1> &&
1386  IsMatrix_v<T2> &&
1387  ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1388  IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1389  ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1390  IsSymmetric_v<T2> && !IsComplex_v< UnderlyingNumeric_t<T2> > ) ||
1391  ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingNumeric_t<T1> > &&
1392  IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1393  !( IsUniform_v<T1> && IsUniform_v<T2> ) &&
1394  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1395 {
1396  using Type = HermitianMatrix< typename AddTraitEval2<T1,T2>::Type >;
1397 };
1399 //*************************************************************************************************
1400 
1401 
1402 
1403 
1404 //=================================================================================================
1405 //
1406 // SUBTRAIT SPECIALIZATIONS
1407 //
1408 //=================================================================================================
1409 
1410 //*************************************************************************************************
1412 template< typename T1, typename T2 >
1413 struct SubTraitEval1< T1, T2
1414  , EnableIf_t< IsMatrix_v<T1> &&
1415  IsMatrix_v<T2> &&
1416  ( ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1417  IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ||
1418  ( IsHermitian_v<T1> && !IsSymmetric_v<T1> &&
1419  IsSymmetric_v<T2> && !IsComplex_v< UnderlyingNumeric_t<T2> > ) ||
1420  ( IsSymmetric_v<T1> && !IsComplex_v< UnderlyingNumeric_t<T1> > &&
1421  IsHermitian_v<T2> && !IsSymmetric_v<T2> ) ) &&
1422  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1423 {
1424  using Type = HermitianMatrix< typename SubTraitEval2<T1,T2>::Type >;
1425 };
1427 //*************************************************************************************************
1428 
1429 
1430 
1431 
1432 //=================================================================================================
1433 //
1434 // SCHURTRAIT SPECIALIZATIONS
1435 //
1436 //=================================================================================================
1437 
1438 //*************************************************************************************************
1440 template< typename T1, typename T2 >
1441 struct SchurTraitEval1< T1, T2
1442  , EnableIf_t< IsMatrix_v<T1> &&
1443  IsMatrix_v<T2> &&
1444  ( IsHermitian_v<T1> && IsHermitian_v<T2> ) &&
1445  !( IsSymmetric_v<T1> && IsSymmetric_v<T2> ) &&
1446  !( IsDiagonal_v<T1> || IsZero_v<T1> ) &&
1447  !( IsDiagonal_v<T2> || IsZero_v<T2> ) > >
1448 {
1449  using Type = HermitianMatrix< typename SchurTraitEval2<T1,T2>::Type >;
1450 };
1452 //*************************************************************************************************
1453 
1454 
1455 
1456 
1457 //=================================================================================================
1458 //
1459 // MULTTRAIT SPECIALIZATIONS
1460 //
1461 //=================================================================================================
1462 
1463 //*************************************************************************************************
1465 template< typename T1, typename T2 >
1466 struct MultTraitEval1< T1, T2
1467  , EnableIf_t< IsMatrix_v<T1> &&
1468  IsNumeric_v<T2> &&
1469  ( IsHermitian_v<T1> && !IsSymmetric_v<T1> && !IsUniform_v<T1> ) > >
1470 {
1471  using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1472 };
1473 
1474 template< typename T1, typename T2 >
1475 struct MultTraitEval1< T1, T2
1476  , EnableIf_t< IsNumeric_v<T1> &&
1477  IsMatrix_v<T2> &&
1478  ( IsHermitian_v<T2> && !IsSymmetric_v<T2> && !IsUniform_v<T2> ) > >
1479 {
1480  using Type = HermitianMatrix< typename MultTraitEval2<T1,T2>::Type >;
1481 };
1483 //*************************************************************************************************
1484 
1485 
1486 
1487 
1488 //=================================================================================================
1489 //
1490 // DIVTRAIT SPECIALIZATIONS
1491 //
1492 //=================================================================================================
1493 
1494 //*************************************************************************************************
1496 template< typename T1, typename T2 >
1497 struct DivTraitEval1< T1, T2
1498  , EnableIf_t< IsHermitian_v<T1> && !IsSymmetric_v<T1> && IsNumeric_v<T2> > >
1499 {
1500  using Type = HermitianMatrix< typename DivTraitEval2<T1,T2>::Type >;
1501 };
1503 //*************************************************************************************************
1504 
1505 
1506 
1507 
1508 //=================================================================================================
1509 //
1510 // MAPTRAIT SPECIALIZATIONS
1511 //
1512 //=================================================================================================
1513 
1514 //*************************************************************************************************
1516 template< typename T, typename OP >
1517 struct UnaryMapTraitEval1< T, OP
1518  , EnableIf_t< YieldsHermitian_v<OP,T> &&
1519  !YieldsSymmetric_v<OP,T> &&
1520  !YieldsIdentity_v<OP,T> > >
1521 {
1522  using Type = HermitianMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
1523 };
1525 //*************************************************************************************************
1526 
1527 
1528 //*************************************************************************************************
1530 template< typename T1, typename T2, typename OP >
1531 struct BinaryMapTraitEval1< T1, T2, OP
1532  , EnableIf_t< YieldsHermitian_v<OP,T1,T2> &&
1533  !YieldsSymmetric_v<OP,T1,T2> &&
1534  !YieldsIdentity_v<OP,T1,T2> > >
1535 {
1536  using Type = HermitianMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
1537 };
1539 //*************************************************************************************************
1540 
1541 
1542 
1543 
1544 //=================================================================================================
1545 //
1546 // DECLSYMTRAIT SPECIALIZATIONS
1547 //
1548 //=================================================================================================
1549 
1550 //*************************************************************************************************
1552 template< typename MT, bool SO, bool DF >
1553 struct DeclSymTrait< HermitianMatrix<MT,SO,DF> >
1554 {
1555  using Type = SymmetricMatrix<MT,SO,DF>;
1556 };
1558 //*************************************************************************************************
1559 
1560 
1561 
1562 
1563 //=================================================================================================
1564 //
1565 // DECLHERMTRAIT SPECIALIZATIONS
1566 //
1567 //=================================================================================================
1568 
1569 //*************************************************************************************************
1571 template< typename MT, bool SO, bool DF >
1572 struct DeclHermTrait< HermitianMatrix<MT,SO,DF> >
1573 {
1574  using Type = HermitianMatrix<MT,SO,DF>;
1575 };
1577 //*************************************************************************************************
1578 
1579 
1580 
1581 
1582 //=================================================================================================
1583 //
1584 // DECLLOWTRAIT SPECIALIZATIONS
1585 //
1586 //=================================================================================================
1587 
1588 //*************************************************************************************************
1590 template< typename MT, bool SO, bool DF >
1591 struct DeclLowTrait< HermitianMatrix<MT,SO,DF> >
1592 {
1593  using Type = DiagonalMatrix<MT,SO,DF>;
1594 };
1596 //*************************************************************************************************
1597 
1598 
1599 
1600 
1601 //=================================================================================================
1602 //
1603 // DECLUPPTRAIT SPECIALIZATIONS
1604 //
1605 //=================================================================================================
1606 
1607 //*************************************************************************************************
1609 template< typename MT, bool SO, bool DF >
1610 struct DeclUppTrait< HermitianMatrix<MT,SO,DF> >
1611 {
1612  using Type = DiagonalMatrix<MT,SO,DF>;
1613 };
1615 //*************************************************************************************************
1616 
1617 
1618 
1619 
1620 //=================================================================================================
1621 //
1622 // DECLDIAGTRAIT SPECIALIZATIONS
1623 //
1624 //=================================================================================================
1625 
1626 //*************************************************************************************************
1628 template< typename MT, bool SO, bool DF >
1629 struct DeclDiagTrait< HermitianMatrix<MT,SO,DF> >
1630 {
1631  using Type = DiagonalMatrix<MT,SO,DF>;
1632 };
1634 //*************************************************************************************************
1635 
1636 
1637 
1638 
1639 //=================================================================================================
1640 //
1641 // HIGHTYPE SPECIALIZATIONS
1642 //
1643 //=================================================================================================
1644 
1645 //*************************************************************************************************
1647 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1648 struct HighType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1649 {
1650  using Type = HermitianMatrix< typename HighType<MT1,MT2>::Type >;
1651 };
1653 //*************************************************************************************************
1654 
1655 
1656 
1657 
1658 //=================================================================================================
1659 //
1660 // LOWTYPE SPECIALIZATIONS
1661 //
1662 //=================================================================================================
1663 
1664 //*************************************************************************************************
1666 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1667 struct LowType< HermitianMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1668 {
1669  using Type = HermitianMatrix< typename LowType<MT1,MT2>::Type >;
1670 };
1672 //*************************************************************************************************
1673 
1674 
1675 
1676 
1677 //=================================================================================================
1678 //
1679 // SUBMATRIXTRAIT SPECIALIZATIONS
1680 //
1681 //=================================================================================================
1682 
1683 //*************************************************************************************************
1685 template< typename MT, size_t I, size_t N >
1686 struct SubmatrixTraitEval1< MT, I, I, N, N
1687  , EnableIf_t< IsHermitian_v<MT> &&
1688  !IsSymmetric_v<MT> > >
1689 {
1690  using Type = HermitianMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
1691 };
1693 //*************************************************************************************************
1694 
1695 } // namespace blaze
1696 
1697 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:653
Header file for the UnderlyingNumeric type trait.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the decldiag trait.
Header file for the Schur product trait.
constexpr bool IsComplex_v
Auxiliary variable template for the IsComplex type trait.The IsComplex_v variable template provides a...
Definition: IsComplex.h:140
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Flag for the inversion of a diagonal matrix.
Definition: InversionFlag.h:115
Flag for the inversion of a general matrix (same as byLU).
Definition: InversionFlag.h:108
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the declherm trait.
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
Header file for the IsDiagonal type trait.
Header file for the dense matrix inversion flags.
Flag for the Bunch-Kaufman-based inversion for Hermitian matrices.
Definition: InversionFlag.h:105
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
Header file for the YieldsIdentity type trait.
constexpr bool IsHermitian_v
Auxiliary variable template for the IsHermitian type trait.The IsHermitian_v variable template provid...
Definition: IsHermitian.h:171
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1644
Header file for the IsMatrix type trait.
Header file for the IsSquare type trait.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
Constraint on the data type.
Header file for the LowType type trait.
Header file for the IsUniform type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Flag for the LU-based matrix inversion.
Definition: InversionFlag.h:103
Header file for the IsShrinkable type trait.
Header file for all forward declarations of the math module.
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:1147
Header file for the decllow trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Flag for the inversion of a Hermitian matrix (same as byLDLH).
Definition: InversionFlag.h:110
constexpr bool YieldsHermitian_v
Auxiliary variable template for the YieldsHermitian type trait.The YieldsHermitian_v variable templat...
Definition: YieldsHermitian.h:125
Header file for the IsAligned type trait.
Flag for the Bunch-Kaufman-based inversion for symmetric matrices.
Definition: InversionFlag.h:104
HermitianMatrix specialization for sparse matrices.
Header file for the exception macros of the math module.
Header file for the RemoveAdaptor type trait.
Header file for the implementation of the base template of the HeritianMatrix.
Constraint on the data type.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Header file for the declupp trait.
Flag for the inversion of a symmetric matrix (same as byLDLT).
Definition: InversionFlag.h:109
Header file for run time assertion macros.
Header file for the YieldsSymmetric type trait.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Header file for the IsContiguous type trait.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsZero type trait.
Header file for the declsym trait.
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:617
Matrix adapter for Hermitian matrices.
Definition: BaseTemplate.h:611
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i...
Definition: BLASCompatible.h:61
Flag for the Cholesky-based inversion for positive-definite matrices.
Definition: InversionFlag.h:106
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the IsBuiltin type trait.
Header file for the isDivisor shim.
Header file for the StorageOrder type trait.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
Header file for the IsComplex type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the YieldsHermitian type trait.
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
Header file for the isReal shim.
HermitianMatrix specialization for dense matrices.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.