DiagonalMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_H_
36 #define _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
58 #include <blaze/math/Exception.h>
59 #include <blaze/math/Forward.h>
87 #include <blaze/util/Assert.h>
88 #include <blaze/util/EnableIf.h>
90 #include <blaze/util/TrueType.h>
93 #include <blaze/util/Unused.h>
94 
95 
96 namespace blaze {
97 
98 //=================================================================================================
99 //
100 // DIAGONALMATRIX OPERATORS
101 //
102 //=================================================================================================
103 
104 //*************************************************************************************************
107 template< typename MT, bool SO, bool DF >
108 inline void reset( DiagonalMatrix<MT,SO,DF>& m );
109 
110 template< typename MT, bool SO, bool DF >
111 inline void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i );
112 
113 template< typename MT, bool SO, bool DF >
114 inline void clear( DiagonalMatrix<MT,SO,DF>& m );
115 
116 template< typename MT, bool SO, bool DF >
117 inline bool isDefault( const DiagonalMatrix<MT,SO,DF>& m );
118 
119 template< typename MT, bool SO, bool DF >
120 inline bool isIntact( const DiagonalMatrix<MT,SO,DF>& m );
121 
122 template< typename MT, bool SO, bool DF >
123 inline void swap( DiagonalMatrix<MT,SO,DF>& a, DiagonalMatrix<MT,SO,DF>& b ) noexcept;
125 //*************************************************************************************************
126 
127 
128 //*************************************************************************************************
135 template< typename MT // Type of the adapted matrix
136  , bool SO // Storage order of the adapted matrix
137  , bool DF > // Density flag
139 {
140  m.reset();
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
158 template< typename MT // Type of the adapted matrix
159  , bool SO // Storage order of the adapted matrix
160  , bool DF > // Density flag
161 inline void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i )
162 {
163  m.reset( i );
164 }
165 //*************************************************************************************************
166 
167 
168 //*************************************************************************************************
175 template< typename MT // Type of the adapted matrix
176  , bool SO // Storage order of the adapted matrix
177  , bool DF > // Density flag
179 {
180  m.clear();
181 }
182 //*************************************************************************************************
183 
184 
185 //*************************************************************************************************
206 template< typename MT // Type of the adapted matrix
207  , bool SO // Storage order of the adapted matrix
208  , bool DF > // Density flag
209 inline bool isDefault( const DiagonalMatrix<MT,SO,DF>& m )
210 {
211  return isDefault( m.matrix_ );
212 }
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
237 template< typename MT // Type of the adapted matrix
238  , bool SO // Storage order of the adapted matrix
239  , bool DF > // Density flag
240 inline bool isIntact( const DiagonalMatrix<MT,SO,DF>& m )
241 {
242  return m.isIntact();
243 }
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
255 template< typename MT // Type of the adapted matrix
256  , bool SO // Storage order of the adapted matrix
257  , bool DF > // Density flag
259 {
260  a.swap( b );
261 }
262 //*************************************************************************************************
263 
264 
265 //*************************************************************************************************
288 template< InversionFlag IF // Inversion algorithm
289  , typename MT // Type of the dense matrix
290  , bool SO > // Storage order of the dense matrix
291 inline void invert( DiagonalMatrix<MT,SO,true>& m )
292 {
294 
295  if( IF == asUniLower || IF == asUniUpper ) {
296  BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
297  return;
298  }
299 
300  invert<asDiagonal>( derestrict( m ) );
301 
302  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
303 }
305 //*************************************************************************************************
306 
307 
308 //*************************************************************************************************
327 template< typename MT1, bool SO1, typename MT2, typename MT3, typename MT4, bool SO2 >
328 inline void lu( const DiagonalMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
329  DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P )
330 {
332 
337 
342 
343  typedef ElementType_<MT3> ET3;
344  typedef ElementType_<MT4> ET4;
345 
346  const size_t n( (~A).rows() );
347 
348  DerestrictTrait_<MT3> U2( derestrict( ~U ) );
349 
350  (~L) = A;
351 
352  resize( ~U, n, n );
353  reset( U2 );
354 
355  resize( ~P, n, n );
356  reset( ~P );
357 
358  for( size_t i=0UL; i<n; ++i ) {
359  U2(i,i) = ET3(1);
360  (~P)(i,i) = ET4(1);
361  }
362 }
364 //*************************************************************************************************
365 
366 
367 //*************************************************************************************************
383 template< typename MT // Type of the adapted matrix
384  , bool SO // Storage order of the adapted matrix
385  , bool DF // Density flag
386  , typename VT > // Type of the right-hand side dense vector
387 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
388  const DenseVector<VT,false>& rhs, size_t row, size_t column )
389 {
391 
392  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
393  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
394  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
395 
396  UNUSED_PARAMETER( lhs );
397 
398  const size_t index( ( column <= row )?( 0UL ):( column - row ) );
399 
400  for( size_t i=0UL; i<index; ++i ) {
401  if( !isDefault( (~rhs)[i] ) )
402  return false;
403  }
404 
405  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
406  if( !isDefault( (~rhs)[i] ) )
407  return false;
408  }
409 
410  return true;
411 }
413 //*************************************************************************************************
414 
415 
416 //*************************************************************************************************
432 template< typename MT // Type of the adapted matrix
433  , bool SO // Storage order of the adapted matrix
434  , bool DF // Density flag
435  , typename VT > // Type of the right-hand side dense vector
436 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
437  const DenseVector<VT,true>& rhs, size_t row, size_t column )
438 {
440 
441  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
442  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
443  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
444 
445  UNUSED_PARAMETER( lhs );
446 
447  const size_t index( ( row <= column )?( 0UL ):( row - column ) );
448 
449  for( size_t i=0UL; i<index; ++i ) {
450  if( !isDefault( (~rhs)[i] ) )
451  return false;
452  }
453 
454  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
455  if( !isDefault( (~rhs)[i] ) )
456  return false;
457  }
458 
459  return true;
460 }
462 //*************************************************************************************************
463 
464 
465 //*************************************************************************************************
481 template< typename MT // Type of the adapted matrix
482  , bool SO // Storage order of the adapted matrix
483  , bool DF // Density flag
484  , typename VT > // Type of the right-hand side sparse vector
485 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
486  const SparseVector<VT,false>& rhs, size_t row, size_t column )
487 {
489 
490  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
491  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
492  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
493 
494  UNUSED_PARAMETER( lhs );
495 
496  typedef typename VT::ConstIterator RhsIterator;
497 
498  const size_t index( column - row );
499 
500  for( RhsIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
501  if( element->index() != index && !isDefault( element->value() ) )
502  return false;
503  }
504 
505  return true;
506 }
508 //*************************************************************************************************
509 
510 
511 //*************************************************************************************************
527 template< typename MT // Type of the adapted matrix
528  , bool SO // Storage order of the adapted matrix
529  , bool DF // Density flag
530  , typename VT > // Type of the right-hand side sparse vector
531 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
532  const SparseVector<VT,true>& rhs, size_t row, size_t column )
533 {
535 
536  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
537  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
538  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
539 
540  UNUSED_PARAMETER( lhs );
541 
542  typedef typename VT::ConstIterator RhsIterator;
543 
544  const size_t index( row - column );
545 
546  for( RhsIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
547  if( element->index() != index && !isDefault( element->value() ) )
548  return false;
549  }
550 
551  return true;
552 }
554 //*************************************************************************************************
555 
556 
557 //*************************************************************************************************
573 template< typename MT1 // Type of the adapted matrix
574  , bool SO // Storage order of the adapted matrix
575  , bool DF // Density flag
576  , typename MT2 > // Type of the right-hand side dense matrix
577 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
578  const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
579 {
581 
582  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
583  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
584  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
585  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
586 
587  UNUSED_PARAMETER( lhs );
588 
589  const size_t M( (~rhs).rows() );
590  const size_t N( (~rhs).columns() );
591 
592  for( size_t i=0UL; i<M; ++i ) {
593  for( size_t j=0UL; j<N; ++j ) {
594  if( ( row + i != column + j ) && !isDefault( (~rhs)(i,j) ) )
595  return false;
596  }
597  }
598 
599  return true;
600 }
602 //*************************************************************************************************
603 
604 
605 //*************************************************************************************************
621 template< typename MT1 // Type of the adapted matrix
622  , bool SO // Storage order of the adapted matrix
623  , bool DF // Density flag
624  , typename MT2 > // Type of the right-hand side dense matrix
625 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
626  const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
627 {
629 
630  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
631  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
632  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
633  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
634 
635  UNUSED_PARAMETER( lhs );
636 
637  const size_t M( (~rhs).rows() );
638  const size_t N( (~rhs).columns() );
639 
640  for( size_t j=0UL; j<N; ++j ) {
641  for( size_t i=0UL; i<M; ++i ) {
642  if( ( column + j != row + i ) && !isDefault( (~rhs)(i,j) ) )
643  return false;
644  }
645  }
646 
647  return true;
648 }
650 //*************************************************************************************************
651 
652 
653 //*************************************************************************************************
669 template< typename MT1 // Type of the adapted matrix
670  , bool SO // Storage order of the adapted matrix
671  , bool DF // Density flag
672  , typename MT2 > // Type of the right-hand side sparse matrix
673 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
674  const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
675 {
677 
678  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
679  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
680  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
681  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
682 
683  UNUSED_PARAMETER( lhs );
684 
685  typedef typename MT2::ConstIterator RhsIterator;
686 
687  const size_t M( (~rhs).rows() );
688 
689  for( size_t i=0UL; i<M; ++i ) {
690  for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
691  if( ( row + i != column + element->index() ) && !isDefault( element->value() ) )
692  return false;
693  }
694  }
695 
696  return true;
697 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
718 template< typename MT1 // Type of the adapted matrix
719  , bool SO // Storage order of the adapted matrix
720  , bool DF // Density flag
721  , typename MT2 > // Type of the right-hand side sparse matrix
722 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
723  const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
724 {
726 
727  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
728  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
729  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
730  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
731 
732  UNUSED_PARAMETER( lhs );
733 
734  typedef typename MT2::ConstIterator RhsIterator;
735 
736  const size_t N( (~rhs).columns() );
737 
738  for( size_t j=0UL; j<N; ++j ) {
739  for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
740  if( ( column + j != row + element->index() ) && !isDefault( element->value() ) )
741  return false;
742  }
743  }
744 
745  return true;
746 }
748 //*************************************************************************************************
749 
750 
751 //*************************************************************************************************
767 template< typename MT // Type of the adapted matrix
768  , bool SO // Storage order of the adapted matrix
769  , bool DF // Density flag
770  , typename VT // Type of the right-hand side vector
771  , bool TF > // Transpose flag of the right-hand side vector
772 inline bool tryAddAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
773  const Vector<VT,TF>& rhs, size_t row, size_t column )
774 {
775  return tryAssign( lhs, ~rhs, row, column );
776 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
797 template< typename MT1 // Type of the adapted matrix
798  , bool SO1 // Storage order of the adapted matrix
799  , bool DF // Density flag
800  , typename MT2 // Type of the right-hand side matrix
801  , bool SO2 > // Storage order of the right-hand side matrix
802 inline bool tryAddAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
803  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
804 {
805  return tryAssign( lhs, ~rhs, row, column );
806 }
808 //*************************************************************************************************
809 
810 
811 //*************************************************************************************************
828 template< typename MT // Type of the adapted matrix
829  , bool SO // Storage order of the adapted matrix
830  , bool DF // Density flag
831  , typename VT // Type of the right-hand side vector
832  , bool TF > // Transpose flag of the right-hand side vector
833 inline bool trySubAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
834  const Vector<VT,TF>& rhs, size_t row, size_t column )
835 {
836  return tryAssign( lhs, ~rhs, row, column );
837 }
839 //*************************************************************************************************
840 
841 
842 //*************************************************************************************************
859 template< typename MT1 // Type of the adapted matrix
860  , bool SO1 // Storage order of the adapted matrix
861  , bool DF // Density flag
862  , typename MT2 // Type of the right-hand side matrix
863  , bool SO2 > // Storage order of the right-hand side matrix
864 inline bool trySubAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
865  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
866 {
867  return tryAssign( lhs, ~rhs, row, column );
868 }
870 //*************************************************************************************************
871 
872 
873 //*************************************************************************************************
888 template< typename MT // Type of the adapted matrix
889  , bool SO // Storage order of the adapted matrix
890  , bool DF > // Density flag
891 inline MT& derestrict( DiagonalMatrix<MT,SO,DF>& m )
892 {
893  return m.matrix_;
894 }
896 //*************************************************************************************************
897 
898 
899 
900 
901 //=================================================================================================
902 //
903 // ROWS SPECIALIZATIONS
904 //
905 //=================================================================================================
906 
907 //*************************************************************************************************
909 template< typename MT, bool SO, bool DF >
910 struct Rows< DiagonalMatrix<MT,SO,DF> > : public Rows<MT>
911 {};
913 //*************************************************************************************************
914 
915 
916 
917 
918 //=================================================================================================
919 //
920 // COLUMNS SPECIALIZATIONS
921 //
922 //=================================================================================================
923 
924 //*************************************************************************************************
926 template< typename MT, bool SO, bool DF >
927 struct Columns< DiagonalMatrix<MT,SO,DF> > : public Columns<MT>
928 {};
930 //*************************************************************************************************
931 
932 
933 
934 
935 //=================================================================================================
936 //
937 // ISSQUARE SPECIALIZATIONS
938 //
939 //=================================================================================================
940 
941 //*************************************************************************************************
943 template< typename MT, bool SO, bool DF >
944 struct IsSquare< DiagonalMatrix<MT,SO,DF> > : public TrueType
945 {};
947 //*************************************************************************************************
948 
949 
950 
951 
952 //=================================================================================================
953 //
954 // ISSYMMETRIC SPECIALIZATIONS
955 //
956 //=================================================================================================
957 
958 //*************************************************************************************************
960 template< typename MT, bool SO, bool DF >
961 struct IsSymmetric< DiagonalMatrix<MT,SO,DF> > : public TrueType
962 {};
964 //*************************************************************************************************
965 
966 
967 
968 
969 //=================================================================================================
970 //
971 // ISHERMITIAN SPECIALIZATIONS
972 //
973 //=================================================================================================
974 
975 //*************************************************************************************************
977 template< typename MT, bool SO, bool DF >
978 struct IsHermitian< DiagonalMatrix<MT,SO,DF> >
979  : public BoolConstant< IsBuiltin< ElementType_<MT> >::value >
980 {};
982 //*************************************************************************************************
983 
984 
985 
986 
987 //=================================================================================================
988 //
989 // ISLOWER SPECIALIZATIONS
990 //
991 //=================================================================================================
992 
993 //*************************************************************************************************
995 template< typename MT, bool SO, bool DF >
996 struct IsLower< DiagonalMatrix<MT,SO,DF> > : public TrueType
997 {};
999 //*************************************************************************************************
1000 
1001 
1002 
1003 
1004 //=================================================================================================
1005 //
1006 // ISUPPER SPECIALIZATIONS
1007 //
1008 //=================================================================================================
1009 
1010 //*************************************************************************************************
1012 template< typename MT, bool SO, bool DF >
1013 struct IsUpper< DiagonalMatrix<MT,SO,DF> > : public TrueType
1014 {};
1016 //*************************************************************************************************
1017 
1018 
1019 
1020 
1021 //=================================================================================================
1022 //
1023 // ISADAPTOR SPECIALIZATIONS
1024 //
1025 //=================================================================================================
1026 
1027 //*************************************************************************************************
1029 template< typename MT, bool SO, bool DF >
1030 struct IsAdaptor< DiagonalMatrix<MT,SO,DF> > : public TrueType
1031 {};
1033 //*************************************************************************************************
1034 
1035 
1036 
1037 
1038 //=================================================================================================
1039 //
1040 // ISRESTRICTED SPECIALIZATIONS
1041 //
1042 //=================================================================================================
1043 
1044 //*************************************************************************************************
1046 template< typename MT, bool SO, bool DF >
1047 struct IsRestricted< DiagonalMatrix<MT,SO,DF> > : public TrueType
1048 {};
1050 //*************************************************************************************************
1051 
1052 
1053 
1054 
1055 //=================================================================================================
1056 //
1057 // HASCONSTDATAACCESS SPECIALIZATIONS
1058 //
1059 //=================================================================================================
1060 
1061 //*************************************************************************************************
1063 template< typename MT, bool SO >
1064 struct HasConstDataAccess< DiagonalMatrix<MT,SO,true> > : public TrueType
1065 {};
1067 //*************************************************************************************************
1068 
1069 
1070 
1071 
1072 //=================================================================================================
1073 //
1074 // ISALIGNED SPECIALIZATIONS
1075 //
1076 //=================================================================================================
1077 
1078 //*************************************************************************************************
1080 template< typename MT, bool SO, bool DF >
1081 struct IsAligned< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsAligned<MT>::value >
1082 {};
1084 //*************************************************************************************************
1085 
1086 
1087 
1088 
1089 //=================================================================================================
1090 //
1091 // ISPADDED SPECIALIZATIONS
1092 //
1093 //=================================================================================================
1094 
1095 //*************************************************************************************************
1097 template< typename MT, bool SO, bool DF >
1098 struct IsPadded< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsPadded<MT>::value >
1099 {};
1101 //*************************************************************************************************
1102 
1103 
1104 
1105 
1106 //=================================================================================================
1107 //
1108 // ISRESIZABLE SPECIALIZATIONS
1109 //
1110 //=================================================================================================
1111 
1112 //*************************************************************************************************
1114 template< typename MT, bool SO, bool DF >
1115 struct IsResizable< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsResizable<MT>::value >
1116 {};
1118 //*************************************************************************************************
1119 
1120 
1121 
1122 
1123 //=================================================================================================
1124 //
1125 // REMOVEADAPTOR SPECIALIZATIONS
1126 //
1127 //=================================================================================================
1128 
1129 //*************************************************************************************************
1131 template< typename MT, bool SO, bool DF >
1132 struct RemoveAdaptor< DiagonalMatrix<MT,SO,DF> >
1133 {
1134  using Type = MT;
1135 };
1137 //*************************************************************************************************
1138 
1139 
1140 
1141 
1142 //=================================================================================================
1143 //
1144 // DERESTRICTTRAIT SPECIALIZATIONS
1145 //
1146 //=================================================================================================
1147 
1148 //*************************************************************************************************
1150 template< typename MT, bool SO, bool DF >
1151 struct DerestrictTrait< DiagonalMatrix<MT,SO,DF> >
1152 {
1153  using Type = MT&;
1154 };
1156 //*************************************************************************************************
1157 
1158 
1159 
1160 
1161 //=================================================================================================
1162 //
1163 // ADDTRAIT SPECIALIZATIONS
1164 //
1165 //=================================================================================================
1166 
1167 //*************************************************************************************************
1169 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1170 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1171 {
1172  using Type = AddTrait_< MT, StaticMatrix<T,M,N,SO2> >;
1173 };
1174 
1175 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1176 struct AddTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1177 {
1178  using Type = AddTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1179 };
1180 
1181 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1182 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1183 {
1184  using Type = AddTrait< MT, HybridMatrix<T,M,N,SO2> >;
1185 };
1186 
1187 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1188 struct AddTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1189 {
1190  using Type = AddTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1191 };
1192 
1193 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1194 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1195 {
1196  using Type = AddTrait_< MT, DynamicMatrix<T,SO2> >;
1197 };
1198 
1199 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1200 struct AddTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1201 {
1202  using Type = AddTrait_< DynamicMatrix<T,SO1>, MT >;
1203 };
1204 
1205 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1206 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1207 {
1208  using Type = AddTrait_< MT, CustomMatrix<T,AF,PF,SO2> >;
1209 };
1210 
1211 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1212 struct AddTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1213 {
1214  using Type = AddTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1215 };
1216 
1217 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1218 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1219 {
1220  using Type = AddTrait_< MT, CompressedMatrix<T,SO2> >;
1221 };
1222 
1223 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1224 struct AddTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1225 {
1226  using Type = AddTrait_< CompressedMatrix<T,SO1>, MT >;
1227 };
1228 
1229 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1230 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1231 {
1232  using Type = AddTrait_<MT1,MT2>;
1233 };
1234 
1235 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1236 struct AddTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1237 {
1238  using Type = AddTrait_<MT1,MT2>;
1239 };
1240 
1241 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1242 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1243 {
1244  using Type = AddTrait_<MT1,MT2>;
1245 };
1246 
1247 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1248 struct AddTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1249 {
1250  using Type = AddTrait_<MT1,MT2>;
1251 };
1252 
1253 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1254 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1255 {
1256  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1257 };
1258 
1259 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1260 struct AddTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1261 {
1262  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1263 };
1264 
1265 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1266 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1267 {
1268  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1269 };
1270 
1271 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1272 struct AddTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1273 {
1274  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1275 };
1276 
1277 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1278 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyLowerMatrix<MT2,SO2,DF2> >
1279 {
1280  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1281 };
1282 
1283 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1284 struct AddTrait< StrictlyLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1285 {
1286  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1287 };
1288 
1289 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1290 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1291 {
1292  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1293 };
1294 
1295 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1296 struct AddTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1297 {
1298  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1299 };
1300 
1301 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1302 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1303 {
1304  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1305 };
1306 
1307 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1308 struct AddTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1309 {
1310  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1311 };
1312 
1313 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1314 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1315 {
1316  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1317 };
1318 
1319 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1320 struct AddTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1321 {
1322  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1323 };
1324 
1325 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1326 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1327 {
1328  using Type = DiagonalMatrix< AddTrait_<MT1,MT2> >;
1329 };
1331 //*************************************************************************************************
1332 
1333 
1334 
1335 
1336 //=================================================================================================
1337 //
1338 // SUBTRAIT SPECIALIZATIONS
1339 //
1340 //=================================================================================================
1341 
1342 //*************************************************************************************************
1344 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1345 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1346 {
1347  using Type = SubTrait_< MT, StaticMatrix<T,M,N,SO2> >;
1348 };
1349 
1350 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1351 struct SubTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1352 {
1353  using Type = SubTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1354 };
1355 
1356 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1357 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1358 {
1359  using Type = SubTrait_< MT, HybridMatrix<T,M,N,SO2> >;
1360 };
1361 
1362 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1363 struct SubTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1364 {
1365  using Type = SubTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1366 };
1367 
1368 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1369 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1370 {
1371  using Type = SubTrait_< MT, DynamicMatrix<T,SO2> >;
1372 };
1373 
1374 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1375 struct SubTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1376 {
1377  using Type = SubTrait_< DynamicMatrix<T,SO1>, MT >;
1378 };
1379 
1380 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1381 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1382 {
1383  using Type = SubTrait_< MT, CustomMatrix<T,AF,PF,SO2> >;
1384 };
1385 
1386 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1387 struct SubTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1388 {
1389  using Type = SubTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1390 };
1391 
1392 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1393 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1394 {
1395  using Type = SubTrait_< MT, CompressedMatrix<T,SO2> >;
1396 };
1397 
1398 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1399 struct SubTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1400 {
1401  using Type = SubTrait_< CompressedMatrix<T,SO1>, MT >;
1402 };
1403 
1404 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1405 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1406 {
1407  using Type = SubTrait_<MT1,MT2>;
1408 };
1409 
1410 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1411 struct SubTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1412 {
1413  using Type = SubTrait_<MT1,MT2>;
1414 };
1415 
1416 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1417 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1418 {
1419  using Type = SubTrait_<MT1,MT2>;
1420 };
1421 
1422 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1423 struct SubTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1424 {
1425  using Type = SubTrait_<MT1,MT2>;
1426 };
1427 
1428 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1429 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1430 {
1431  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1432 };
1433 
1434 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1435 struct SubTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1436 {
1437  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1438 };
1439 
1440 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1441 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1442 {
1443  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1444 };
1445 
1446 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1447 struct SubTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1448 {
1449  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1450 };
1451 
1452 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1453 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1454 {
1455  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1456 };
1457 
1458 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1459 struct SubTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1460 {
1461  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1462 };
1463 
1464 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1465 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1466 {
1467  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1468 };
1469 
1470 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1471 struct SubTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1472 {
1473  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1474 };
1475 
1476 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1477 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1478 {
1479  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1480 };
1481 
1482 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1483 struct SubTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1484 {
1485  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1486 };
1487 
1488 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1489 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1490 {
1491  using Type = DiagonalMatrix< SubTrait_<MT1,MT2> >;
1492 };
1494 //*************************************************************************************************
1495 
1496 
1497 
1498 
1499 //=================================================================================================
1500 //
1501 // MULTTRAIT SPECIALIZATIONS
1502 //
1503 //=================================================================================================
1504 
1505 //*************************************************************************************************
1507 template< typename MT, bool SO, bool DF, typename T >
1508 struct MultTrait< DiagonalMatrix<MT,SO,DF>, T, EnableIf_< IsNumeric<T> > >
1509 {
1510  using Type = DiagonalMatrix< MultTrait_<MT,T> >;
1511 };
1512 
1513 template< typename T, typename MT, bool SO, bool DF >
1514 struct MultTrait< T, DiagonalMatrix<MT,SO,DF>, EnableIf_< IsNumeric<T> > >
1515 {
1516  using Type = DiagonalMatrix< MultTrait_<T,MT> >;
1517 };
1518 
1519 template< typename MT, bool SO, bool DF, typename T, size_t N >
1520 struct MultTrait< DiagonalMatrix<MT,SO,DF>, StaticVector<T,N,false> >
1521 {
1522  using Type = MultTrait_< MT, StaticVector<T,N,false> >;
1523 };
1524 
1525 template< typename T, size_t N, typename MT, bool SO, bool DF >
1526 struct MultTrait< StaticVector<T,N,true>, DiagonalMatrix<MT,SO,DF> >
1527 {
1528  using Type = MultTrait_< StaticVector<T,N,true>, MT >;
1529 };
1530 
1531 template< typename MT, bool SO, bool DF, typename T, size_t N >
1532 struct MultTrait< DiagonalMatrix<MT,SO,DF>, HybridVector<T,N,false> >
1533 {
1534  using Type = MultTrait_< MT, HybridVector<T,N,false> >;
1535 };
1536 
1537 template< typename T, size_t N, typename MT, bool SO, bool DF >
1538 struct MultTrait< HybridVector<T,N,true>, DiagonalMatrix<MT,SO,DF> >
1539 {
1540  using Type = MultTrait_< HybridVector<T,N,true>, MT >;
1541 };
1542 
1543 template< typename MT, bool SO, bool DF, typename T >
1544 struct MultTrait< DiagonalMatrix<MT,SO,DF>, DynamicVector<T,false> >
1545 {
1546  using Type = MultTrait_< MT, DynamicVector<T,false> >;
1547 };
1548 
1549 template< typename T, typename MT, bool SO, bool DF >
1550 struct MultTrait< DynamicVector<T,true>, DiagonalMatrix<MT,SO,DF> >
1551 {
1552  using Type = MultTrait_< DynamicVector<T,true>, MT >;
1553 };
1554 
1555 template< typename MT, bool SO, bool DF, typename T, bool AF, bool PF >
1556 struct MultTrait< DiagonalMatrix<MT,SO,DF>, CustomVector<T,AF,PF,false> >
1557 {
1558  using Type = MultTrait_< MT, CustomVector<T,AF,PF,false> >;
1559 };
1560 
1561 template< typename T, bool AF, bool PF, typename MT, bool SO, bool DF >
1562 struct MultTrait< CustomVector<T,AF,PF,true>, DiagonalMatrix<MT,SO,DF> >
1563 {
1564  using Type = MultTrait_< CustomVector<T,AF,PF,true>, MT >;
1565 };
1566 
1567 template< typename MT, bool SO, bool DF, typename T >
1568 struct MultTrait< DiagonalMatrix<MT,SO,DF>, CompressedVector<T,false> >
1569 {
1570  using Type = MultTrait_< MT, CompressedVector<T,false> >;
1571 };
1572 
1573 template< typename T, typename MT, bool SO, bool DF >
1574 struct MultTrait< CompressedVector<T,true>, DiagonalMatrix<MT,SO,DF> >
1575 {
1576  using Type = MultTrait_< CompressedVector<T,true>, MT >;
1577 };
1578 
1579 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1580 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1581 {
1582  using Type = MultTrait_< MT, StaticMatrix<T,M,N,SO2> >;
1583 };
1584 
1585 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1586 struct MultTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1587 {
1588  using Type = MultTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1589 };
1590 
1591 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1592 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1593 {
1594  using Type = MultTrait_< MT, HybridMatrix<T,M,N,SO2> >;
1595 };
1596 
1597 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1598 struct MultTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1599 {
1600  using Type = MultTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1601 };
1602 
1603 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1604 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1605 {
1606  using Type = MultTrait_< MT, DynamicMatrix<T,SO2> >;
1607 };
1608 
1609 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1610 struct MultTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1611 {
1612  using Type = MultTrait_< DynamicMatrix<T,SO1>, MT >;
1613 };
1614 
1615 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1616 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1617 {
1618  using Type = MultTrait_< MT, CustomMatrix<T,AF,PF,SO2> >;
1619 };
1620 
1621 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1622 struct MultTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1623 {
1624  using Type = MultTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1625 };
1626 
1627 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1628 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1629 {
1630  using Type = MultTrait_< MT, CompressedMatrix<T,SO2> >;
1631 };
1632 
1633 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1634 struct MultTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1635 {
1636  using Type = MultTrait_< CompressedMatrix<T,SO1>, MT >;
1637 };
1638 
1639 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1640 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1641 {
1642  using Type = MultTrait_<MT1,MT2>;
1643 };
1644 
1645 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1646 struct MultTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1647 {
1648  using Type = MultTrait_<MT1,MT2>;
1649 };
1650 
1651 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1652 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1653 {
1654  using Type = MultTrait_<MT1,MT2>;
1655 };
1656 
1657 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1658 struct MultTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1659 {
1660  using Type = MultTrait_<MT1,MT2>;
1661 };
1662 
1663 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1664 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1665 {
1666  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1667 };
1668 
1669 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1670 struct MultTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1671 {
1672  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1673 };
1674 
1675 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1676 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1677 {
1678  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1679 };
1680 
1681 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1682 struct MultTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1683 {
1684  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1685 };
1686 
1687 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1688 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyLowerMatrix<MT2,SO2,DF2> >
1689 {
1690  using Type = StrictlyLowerMatrix< MultTrait_<MT1,MT2> >;
1691 };
1692 
1693 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1694 struct MultTrait< StrictlyLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1695 {
1696  using Type = StrictlyLowerMatrix< MultTrait_<MT1,MT2> >;
1697 };
1698 
1699 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1700 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1701 {
1702  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1703 };
1704 
1705 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1706 struct MultTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1707 {
1708  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1709 };
1710 
1711 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1712 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1713 {
1714  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1715 };
1716 
1717 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1718 struct MultTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1719 {
1720  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1721 };
1722 
1723 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1724 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1725 {
1726  using Type = StrictlyUpperMatrix< MultTrait_<MT1,MT2> >;
1727 };
1728 
1729 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1730 struct MultTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1731 {
1732  using Type = StrictlyUpperMatrix< MultTrait_<MT1,MT2> >;
1733 };
1734 
1735 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1736 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1737 {
1738  using Type = DiagonalMatrix< MultTrait_<MT1,MT2> >;
1739 };
1741 //*************************************************************************************************
1742 
1743 
1744 
1745 
1746 //=================================================================================================
1747 //
1748 // DIVTRAIT SPECIALIZATIONS
1749 //
1750 //=================================================================================================
1751 
1752 //*************************************************************************************************
1754 template< typename MT, bool SO, bool DF, typename T >
1755 struct DivTrait< DiagonalMatrix<MT,SO,DF>, T, EnableIf_< IsNumeric<T> > >
1756 {
1757  using Type = DiagonalMatrix< DivTrait_<MT,T> >;
1758 };
1760 //*************************************************************************************************
1761 
1762 
1763 
1764 
1765 //=================================================================================================
1766 //
1767 // FOREACHTRAIT SPECIALIZATIONS
1768 //
1769 //=================================================================================================
1770 
1771 //*************************************************************************************************
1773 template< typename MT, bool SO, bool DF >
1774 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Abs >
1775 {
1776  using Type = DiagonalMatrix< ForEachTrait_<MT,Abs> >;
1777 };
1778 
1779 template< typename MT, bool SO, bool DF >
1780 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Floor >
1781 {
1782  using Type = DiagonalMatrix< ForEachTrait_<MT,Floor> >;
1783 };
1784 
1785 template< typename MT, bool SO, bool DF >
1786 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Ceil >
1787 {
1788  using Type = DiagonalMatrix< ForEachTrait_<MT,Ceil> >;
1789 };
1790 
1791 template< typename MT, bool SO, bool DF >
1792 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Conj >
1793 {
1794  using Type = DiagonalMatrix< ForEachTrait_<MT,Conj> >;
1795 };
1796 
1797 template< typename MT, bool SO, bool DF >
1798 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Real >
1799 {
1800  using Type = DiagonalMatrix< ForEachTrait_<MT,Real> >;
1801 };
1802 
1803 template< typename MT, bool SO, bool DF >
1804 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Imag >
1805 {
1806  using Type = DiagonalMatrix< ForEachTrait_<MT,Imag> >;
1807 };
1808 
1809 template< typename MT, bool SO, bool DF >
1810 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Sin >
1811 {
1812  using Type = DiagonalMatrix< ForEachTrait_<MT,Sin> >;
1813 };
1814 
1815 template< typename MT, bool SO, bool DF >
1816 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Asin >
1817 {
1818  using Type = DiagonalMatrix< ForEachTrait_<MT,Asin> >;
1819 };
1820 
1821 template< typename MT, bool SO, bool DF >
1822 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Sinh >
1823 {
1824  using Type = DiagonalMatrix< ForEachTrait_<MT,Sinh> >;
1825 };
1826 
1827 template< typename MT, bool SO, bool DF >
1828 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Asinh >
1829 {
1830  using Type = DiagonalMatrix< ForEachTrait_<MT,Asinh> >;
1831 };
1832 
1833 template< typename MT, bool SO, bool DF >
1834 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Tan >
1835 {
1836  using Type = DiagonalMatrix< ForEachTrait_<MT,Tan> >;
1837 };
1838 
1839 template< typename MT, bool SO, bool DF >
1840 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Atan >
1841 {
1842  using Type = DiagonalMatrix< ForEachTrait_<MT,Atan> >;
1843 };
1844 
1845 template< typename MT, bool SO, bool DF >
1846 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Tanh >
1847 {
1848  using Type = DiagonalMatrix< ForEachTrait_<MT,Tanh> >;
1849 };
1850 
1851 template< typename MT, bool SO, bool DF >
1852 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Atanh >
1853 {
1854  using Type = DiagonalMatrix< ForEachTrait_<MT,Atanh> >;
1855 };
1856 
1857 template< typename MT, bool SO, bool DF >
1858 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Erf >
1859 {
1860  using Type = DiagonalMatrix< ForEachTrait_<MT,Erf> >;
1861 };
1863 //*************************************************************************************************
1864 
1865 
1866 
1867 
1868 //=================================================================================================
1869 //
1870 // MATHTRAIT SPECIALIZATIONS
1871 //
1872 //=================================================================================================
1873 
1874 //*************************************************************************************************
1876 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1877 struct MathTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1878 {
1879  using HighType = DiagonalMatrix< typename MathTrait<MT1,MT2>::HighType >;
1880  using LowType = DiagonalMatrix< typename MathTrait<MT1,MT2>::LowType >;
1881 };
1883 //*************************************************************************************************
1884 
1885 
1886 
1887 
1888 //=================================================================================================
1889 //
1890 // SUBMATRIXTRAIT SPECIALIZATIONS
1891 //
1892 //=================================================================================================
1893 
1894 //*************************************************************************************************
1896 template< typename MT, bool SO, bool DF >
1897 struct SubmatrixTrait< DiagonalMatrix<MT,SO,DF> >
1898 {
1899  using Type = SubmatrixTrait_<MT>;
1900 };
1902 //*************************************************************************************************
1903 
1904 
1905 
1906 
1907 //=================================================================================================
1908 //
1909 // ROWTRAIT SPECIALIZATIONS
1910 //
1911 //=================================================================================================
1912 
1913 //*************************************************************************************************
1915 template< typename MT, bool SO, bool DF >
1916 struct RowTrait< DiagonalMatrix<MT,SO,DF> >
1917 {
1918  using Type = RowTrait_<MT>;
1919 };
1921 //*************************************************************************************************
1922 
1923 
1924 
1925 
1926 //=================================================================================================
1927 //
1928 // COLUMNTRAIT SPECIALIZATIONS
1929 //
1930 //=================================================================================================
1931 
1932 //*************************************************************************************************
1934 template< typename MT, bool SO, bool DF >
1935 struct ColumnTrait< DiagonalMatrix<MT,SO,DF> >
1936 {
1937  using Type = ColumnTrait_<MT>;
1938 };
1940 //*************************************************************************************************
1941 
1942 } // namespace blaze
1943 
1944 #endif
Header file for auxiliary alias declarations.
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for the implementation of the base template of the StrictlyLowerMatrix.
Header file for the row trait.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the dense matrix inversion flags.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:81
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
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Header file for the IsSquare type trait.
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:741
Constraint on the data type.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
void lu(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO1 > &L, DenseMatrix< MT3, SO1 > &U, Matrix< MT4, SO2 > &P)
LU decomposition of the given dense matrix.
Definition: LU.h:219
Header file for the Columns type trait.
DiagonalMatrix specialization for dense matrices.
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
Header file for the implementation of the base template of the StrictlyUpperMatrix.
InversionFlag
Inversion flag.The InversionFlag type enumeration represents the different types of matrix inversion ...
Definition: InversionFlag.h:101
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
Header file for the column trait.
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:258
#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
Constraint on the data type.
#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
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the mathematical trait.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
Header file for the implementation of the base template of the DiagonalMatrix.
Header file for the implementation of the base template of the LowerMatrix.
Header file for the IsBuiltin type trait.
Header file for the for-each trait.
Header file for the isDivisor shim.
Header file for the IntegralConstant class template.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
Matrix adapter for diagonal matrices.
Definition: BaseTemplate.h:556
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the implementation of the base template of the UpperMatrix.
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
#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
DiagonalMatrix specialization for sparse matrices.
Header file for the TrueType type/value trait base class.
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1593