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>
88 #include <blaze/util/Assert.h>
89 #include <blaze/util/EnableIf.h>
91 #include <blaze/util/TrueType.h>
94 #include <blaze/util/Unused.h>
95 
96 
97 namespace blaze {
98 
99 //=================================================================================================
100 //
101 // DIAGONALMATRIX OPERATORS
102 //
103 //=================================================================================================
104 
105 //*************************************************************************************************
108 template< typename MT, bool SO, bool DF >
109 inline void reset( DiagonalMatrix<MT,SO,DF>& m );
110 
111 template< typename MT, bool SO, bool DF >
112 inline void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i );
113 
114 template< typename MT, bool SO, bool DF >
115 inline void clear( DiagonalMatrix<MT,SO,DF>& m );
116 
117 template< bool RF, typename MT, bool SO, bool DF >
118 inline bool isDefault( const DiagonalMatrix<MT,SO,DF>& m );
119 
120 template< typename MT, bool SO, bool DF >
121 inline bool isIntact( const DiagonalMatrix<MT,SO,DF>& m );
122 
123 template< typename MT, bool SO, bool DF >
124 inline void swap( DiagonalMatrix<MT,SO,DF>& a, DiagonalMatrix<MT,SO,DF>& b ) noexcept;
126 //*************************************************************************************************
127 
128 
129 //*************************************************************************************************
136 template< typename MT // Type of the adapted matrix
137  , bool SO // Storage order of the adapted matrix
138  , bool DF > // Density flag
140 {
141  m.reset();
142 }
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
159 template< typename MT // Type of the adapted matrix
160  , bool SO // Storage order of the adapted matrix
161  , bool DF > // Density flag
162 inline void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i )
163 {
164  m.reset( i );
165 }
166 //*************************************************************************************************
167 
168 
169 //*************************************************************************************************
176 template< typename MT // Type of the adapted matrix
177  , bool SO // Storage order of the adapted matrix
178  , bool DF > // Density flag
180 {
181  m.clear();
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
214 template< bool RF // Relaxation flag
215  , typename MT // Type of the adapted matrix
216  , bool SO // Storage order of the adapted matrix
217  , bool DF > // Density flag
218 inline bool isDefault( const DiagonalMatrix<MT,SO,DF>& m )
219 {
220  return isDefault<RF>( m.matrix_ );
221 }
222 //*************************************************************************************************
223 
224 
225 //*************************************************************************************************
246 template< typename MT // Type of the adapted matrix
247  , bool SO // Storage order of the adapted matrix
248  , bool DF > // Density flag
249 inline bool isIntact( const DiagonalMatrix<MT,SO,DF>& m )
250 {
251  return m.isIntact();
252 }
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
264 template< typename MT // Type of the adapted matrix
265  , bool SO // Storage order of the adapted matrix
266  , bool DF > // Density flag
268 {
269  a.swap( b );
270 }
271 //*************************************************************************************************
272 
273 
274 //*************************************************************************************************
297 template< InversionFlag IF // Inversion algorithm
298  , typename MT // Type of the dense matrix
299  , bool SO > // Storage order of the dense matrix
300 inline void invert( DiagonalMatrix<MT,SO,true>& m )
301 {
303 
304  if( IF == asUniLower || IF == asUniUpper ) {
305  BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
306  return;
307  }
308 
309  invert<asDiagonal>( derestrict( m ) );
310 
311  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
312 }
314 //*************************************************************************************************
315 
316 
317 //*************************************************************************************************
336 template< typename MT1, bool SO1, typename MT2, typename MT3, typename MT4, bool SO2 >
337 inline void lu( const DiagonalMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
339 {
341 
346 
351 
352  typedef ElementType_<MT3> ET3;
353  typedef ElementType_<MT4> ET4;
354 
355  const size_t n( (~A).rows() );
356 
357  DerestrictTrait_<MT3> U2( derestrict( ~U ) );
358 
359  (~L) = A;
360 
361  resize( ~U, n, n );
362  reset( U2 );
363 
364  resize( ~P, n, n );
365  reset( ~P );
366 
367  for( size_t i=0UL; i<n; ++i ) {
368  U2(i,i) = ET3(1);
369  (~P)(i,i) = ET4(1);
370  }
371 }
373 //*************************************************************************************************
374 
375 
376 //*************************************************************************************************
392 template< typename MT // Type of the adapted matrix
393  , bool SO // Storage order of the adapted matrix
394  , bool DF // Density flag
395  , typename VT > // Type of the right-hand side dense vector
396 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
397  const DenseVector<VT,false>& rhs, size_t row, size_t column )
398 {
400 
401  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
402  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
403  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
404 
405  UNUSED_PARAMETER( lhs );
406 
407  const size_t index( ( column <= row )?( 0UL ):( column - row ) );
408 
409  for( size_t i=0UL; i<index; ++i ) {
410  if( !isDefault( (~rhs)[i] ) )
411  return false;
412  }
413 
414  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
415  if( !isDefault( (~rhs)[i] ) )
416  return false;
417  }
418 
419  return true;
420 }
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
441 template< typename MT // Type of the adapted matrix
442  , bool SO // Storage order of the adapted matrix
443  , bool DF // Density flag
444  , typename VT > // Type of the right-hand side dense vector
445 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
446  const DenseVector<VT,true>& rhs, size_t row, size_t column )
447 {
449 
450  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
451  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
452  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
453 
454  UNUSED_PARAMETER( lhs );
455 
456  const size_t index( ( row <= column )?( 0UL ):( row - column ) );
457 
458  for( size_t i=0UL; i<index; ++i ) {
459  if( !isDefault( (~rhs)[i] ) )
460  return false;
461  }
462 
463  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
464  if( !isDefault( (~rhs)[i] ) )
465  return false;
466  }
467 
468  return true;
469 }
471 //*************************************************************************************************
472 
473 
474 //*************************************************************************************************
490 template< typename MT // Type of the adapted matrix
491  , bool SO // Storage order of the adapted matrix
492  , bool DF // Density flag
493  , typename VT > // Type of the right-hand side sparse vector
494 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
495  const SparseVector<VT,false>& rhs, size_t row, size_t column )
496 {
498 
499  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
500  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
501  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.rows() - row, "Invalid number of rows" );
502 
503  UNUSED_PARAMETER( lhs );
504 
505  typedef typename VT::ConstIterator RhsIterator;
506 
507  const size_t index( column - row );
508 
509  for( RhsIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
510  if( element->index() != index && !isDefault( element->value() ) )
511  return false;
512  }
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 sparse vector
540 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
541  const SparseVector<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( (~rhs).size() <= lhs.columns() - column, "Invalid number of columns" );
548 
549  UNUSED_PARAMETER( lhs );
550 
551  typedef typename VT::ConstIterator RhsIterator;
552 
553  const size_t index( row - column );
554 
555  for( RhsIterator element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
556  if( element->index() != index && !isDefault( element->value() ) )
557  return false;
558  }
559 
560  return true;
561 }
563 //*************************************************************************************************
564 
565 
566 //*************************************************************************************************
582 template< typename MT1 // Type of the adapted matrix
583  , bool SO // Storage order of the adapted matrix
584  , bool DF // Density flag
585  , typename MT2 > // Type of the right-hand side dense matrix
586 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
587  const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
588 {
590 
591  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
592  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
593  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
594  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
595 
596  UNUSED_PARAMETER( lhs );
597 
598  const size_t M( (~rhs).rows() );
599  const size_t N( (~rhs).columns() );
600 
601  for( size_t i=0UL; i<M; ++i ) {
602  for( size_t j=0UL; j<N; ++j ) {
603  if( ( row + i != column + j ) && !isDefault( (~rhs)(i,j) ) )
604  return false;
605  }
606  }
607 
608  return true;
609 }
611 //*************************************************************************************************
612 
613 
614 //*************************************************************************************************
630 template< typename MT1 // Type of the adapted matrix
631  , bool SO // Storage order of the adapted matrix
632  , bool DF // Density flag
633  , typename MT2 > // Type of the right-hand side dense matrix
634 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
635  const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
636 {
638 
639  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
640  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
641  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
642  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
643 
644  UNUSED_PARAMETER( lhs );
645 
646  const size_t M( (~rhs).rows() );
647  const size_t N( (~rhs).columns() );
648 
649  for( size_t j=0UL; j<N; ++j ) {
650  for( size_t i=0UL; i<M; ++i ) {
651  if( ( column + j != row + i ) && !isDefault( (~rhs)(i,j) ) )
652  return false;
653  }
654  }
655 
656  return true;
657 }
659 //*************************************************************************************************
660 
661 
662 //*************************************************************************************************
678 template< typename MT1 // Type of the adapted matrix
679  , bool SO // Storage order of the adapted matrix
680  , bool DF // Density flag
681  , typename MT2 > // Type of the right-hand side sparse matrix
682 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
683  const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
684 {
686 
687  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
688  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
689  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
690  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
691 
692  UNUSED_PARAMETER( lhs );
693 
694  typedef typename MT2::ConstIterator RhsIterator;
695 
696  const size_t M( (~rhs).rows() );
697 
698  for( size_t i=0UL; i<M; ++i ) {
699  for( RhsIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
700  if( ( row + i != column + element->index() ) && !isDefault( element->value() ) )
701  return false;
702  }
703  }
704 
705  return true;
706 }
708 //*************************************************************************************************
709 
710 
711 //*************************************************************************************************
727 template< typename MT1 // Type of the adapted matrix
728  , bool SO // Storage order of the adapted matrix
729  , bool DF // Density flag
730  , typename MT2 > // Type of the right-hand side sparse matrix
731 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
732  const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
733 {
735 
736  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
737  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
738  BLAZE_INTERNAL_ASSERT( (~rhs).rows() <= lhs.rows() - row, "Invalid number of rows" );
739  BLAZE_INTERNAL_ASSERT( (~rhs).columns() <= lhs.columns() - column, "Invalid number of columns" );
740 
741  UNUSED_PARAMETER( lhs );
742 
743  typedef typename MT2::ConstIterator RhsIterator;
744 
745  const size_t N( (~rhs).columns() );
746 
747  for( size_t j=0UL; j<N; ++j ) {
748  for( RhsIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
749  if( ( column + j != row + element->index() ) && !isDefault( element->value() ) )
750  return false;
751  }
752  }
753 
754  return true;
755 }
757 //*************************************************************************************************
758 
759 
760 //*************************************************************************************************
776 template< typename MT // Type of the adapted matrix
777  , bool SO // Storage order of the adapted matrix
778  , bool DF // Density flag
779  , typename VT // Type of the right-hand side vector
780  , bool TF > // Transpose flag of the right-hand side vector
781 inline bool tryAddAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
782  const Vector<VT,TF>& rhs, size_t row, size_t column )
783 {
784  return tryAssign( lhs, ~rhs, row, column );
785 }
787 //*************************************************************************************************
788 
789 
790 //*************************************************************************************************
806 template< typename MT1 // Type of the adapted matrix
807  , bool SO1 // Storage order of the adapted matrix
808  , bool DF // Density flag
809  , typename MT2 // Type of the right-hand side matrix
810  , bool SO2 > // Storage order of the right-hand side matrix
811 inline bool tryAddAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
812  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
813 {
814  return tryAssign( lhs, ~rhs, row, column );
815 }
817 //*************************************************************************************************
818 
819 
820 //*************************************************************************************************
837 template< typename MT // Type of the adapted matrix
838  , bool SO // Storage order of the adapted matrix
839  , bool DF // Density flag
840  , typename VT // Type of the right-hand side vector
841  , bool TF > // Transpose flag of the right-hand side vector
842 inline bool trySubAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
843  const Vector<VT,TF>& rhs, size_t row, size_t column )
844 {
845  return tryAssign( lhs, ~rhs, row, column );
846 }
848 //*************************************************************************************************
849 
850 
851 //*************************************************************************************************
868 template< typename MT1 // Type of the adapted matrix
869  , bool SO1 // Storage order of the adapted matrix
870  , bool DF // Density flag
871  , typename MT2 // Type of the right-hand side matrix
872  , bool SO2 > // Storage order of the right-hand side matrix
873 inline bool trySubAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
874  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
875 {
876  return tryAssign( lhs, ~rhs, row, column );
877 }
879 //*************************************************************************************************
880 
881 
882 //*************************************************************************************************
897 template< typename MT // Type of the adapted matrix
898  , bool SO // Storage order of the adapted matrix
899  , bool DF > // Density flag
900 inline MT& derestrict( DiagonalMatrix<MT,SO,DF>& m )
901 {
902  return m.matrix_;
903 }
905 //*************************************************************************************************
906 
907 
908 
909 
910 //=================================================================================================
911 //
912 // ROWS SPECIALIZATIONS
913 //
914 //=================================================================================================
915 
916 //*************************************************************************************************
918 template< typename MT, bool SO, bool DF >
919 struct Rows< DiagonalMatrix<MT,SO,DF> > : public Rows<MT>
920 {};
922 //*************************************************************************************************
923 
924 
925 
926 
927 //=================================================================================================
928 //
929 // COLUMNS SPECIALIZATIONS
930 //
931 //=================================================================================================
932 
933 //*************************************************************************************************
935 template< typename MT, bool SO, bool DF >
936 struct Columns< DiagonalMatrix<MT,SO,DF> > : public Columns<MT>
937 {};
939 //*************************************************************************************************
940 
941 
942 
943 
944 //=================================================================================================
945 //
946 // ISSQUARE SPECIALIZATIONS
947 //
948 //=================================================================================================
949 
950 //*************************************************************************************************
952 template< typename MT, bool SO, bool DF >
953 struct IsSquare< DiagonalMatrix<MT,SO,DF> > : public TrueType
954 {};
956 //*************************************************************************************************
957 
958 
959 
960 
961 //=================================================================================================
962 //
963 // ISSYMMETRIC SPECIALIZATIONS
964 //
965 //=================================================================================================
966 
967 //*************************************************************************************************
969 template< typename MT, bool SO, bool DF >
970 struct IsSymmetric< DiagonalMatrix<MT,SO,DF> > : public TrueType
971 {};
973 //*************************************************************************************************
974 
975 
976 
977 
978 //=================================================================================================
979 //
980 // ISHERMITIAN SPECIALIZATIONS
981 //
982 //=================================================================================================
983 
984 //*************************************************************************************************
986 template< typename MT, bool SO, bool DF >
987 struct IsHermitian< DiagonalMatrix<MT,SO,DF> >
988  : public BoolConstant< IsBuiltin< ElementType_<MT> >::value >
989 {};
991 //*************************************************************************************************
992 
993 
994 
995 
996 //=================================================================================================
997 //
998 // ISLOWER SPECIALIZATIONS
999 //
1000 //=================================================================================================
1001 
1002 //*************************************************************************************************
1004 template< typename MT, bool SO, bool DF >
1005 struct IsLower< DiagonalMatrix<MT,SO,DF> > : public TrueType
1006 {};
1008 //*************************************************************************************************
1009 
1010 
1011 
1012 
1013 //=================================================================================================
1014 //
1015 // ISUPPER SPECIALIZATIONS
1016 //
1017 //=================================================================================================
1018 
1019 //*************************************************************************************************
1021 template< typename MT, bool SO, bool DF >
1022 struct IsUpper< DiagonalMatrix<MT,SO,DF> > : public TrueType
1023 {};
1025 //*************************************************************************************************
1026 
1027 
1028 
1029 
1030 //=================================================================================================
1031 //
1032 // ISADAPTOR SPECIALIZATIONS
1033 //
1034 //=================================================================================================
1035 
1036 //*************************************************************************************************
1038 template< typename MT, bool SO, bool DF >
1039 struct IsAdaptor< DiagonalMatrix<MT,SO,DF> > : public TrueType
1040 {};
1042 //*************************************************************************************************
1043 
1044 
1045 
1046 
1047 //=================================================================================================
1048 //
1049 // ISRESTRICTED SPECIALIZATIONS
1050 //
1051 //=================================================================================================
1052 
1053 //*************************************************************************************************
1055 template< typename MT, bool SO, bool DF >
1056 struct IsRestricted< DiagonalMatrix<MT,SO,DF> > : public TrueType
1057 {};
1059 //*************************************************************************************************
1060 
1061 
1062 
1063 
1064 //=================================================================================================
1065 //
1066 // HASCONSTDATAACCESS SPECIALIZATIONS
1067 //
1068 //=================================================================================================
1069 
1070 //*************************************************************************************************
1072 template< typename MT, bool SO >
1073 struct HasConstDataAccess< DiagonalMatrix<MT,SO,true> > : public TrueType
1074 {};
1076 //*************************************************************************************************
1077 
1078 
1079 
1080 
1081 //=================================================================================================
1082 //
1083 // ISALIGNED SPECIALIZATIONS
1084 //
1085 //=================================================================================================
1086 
1087 //*************************************************************************************************
1089 template< typename MT, bool SO, bool DF >
1090 struct IsAligned< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsAligned<MT>::value >
1091 {};
1093 //*************************************************************************************************
1094 
1095 
1096 
1097 
1098 //=================================================================================================
1099 //
1100 // ISPADDED SPECIALIZATIONS
1101 //
1102 //=================================================================================================
1103 
1104 //*************************************************************************************************
1106 template< typename MT, bool SO, bool DF >
1107 struct IsPadded< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsPadded<MT>::value >
1108 {};
1110 //*************************************************************************************************
1111 
1112 
1113 
1114 
1115 //=================================================================================================
1116 //
1117 // ISRESIZABLE SPECIALIZATIONS
1118 //
1119 //=================================================================================================
1120 
1121 //*************************************************************************************************
1123 template< typename MT, bool SO, bool DF >
1124 struct IsResizable< DiagonalMatrix<MT,SO,DF> > : public BoolConstant< IsResizable<MT>::value >
1125 {};
1127 //*************************************************************************************************
1128 
1129 
1130 
1131 
1132 //=================================================================================================
1133 //
1134 // REMOVEADAPTOR SPECIALIZATIONS
1135 //
1136 //=================================================================================================
1137 
1138 //*************************************************************************************************
1140 template< typename MT, bool SO, bool DF >
1141 struct RemoveAdaptor< DiagonalMatrix<MT,SO,DF> >
1142 {
1143  using Type = MT;
1144 };
1146 //*************************************************************************************************
1147 
1148 
1149 
1150 
1151 //=================================================================================================
1152 //
1153 // DERESTRICTTRAIT SPECIALIZATIONS
1154 //
1155 //=================================================================================================
1156 
1157 //*************************************************************************************************
1159 template< typename MT, bool SO, bool DF >
1160 struct DerestrictTrait< DiagonalMatrix<MT,SO,DF> >
1161 {
1162  using Type = MT&;
1163 };
1165 //*************************************************************************************************
1166 
1167 
1168 
1169 
1170 //=================================================================================================
1171 //
1172 // ADDTRAIT SPECIALIZATIONS
1173 //
1174 //=================================================================================================
1175 
1176 //*************************************************************************************************
1178 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1179 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1180 {
1182 };
1183 
1184 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1185 struct AddTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1186 {
1187  using Type = AddTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1188 };
1189 
1190 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1191 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1192 {
1194 };
1195 
1196 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1197 struct AddTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1198 {
1199  using Type = AddTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1200 };
1201 
1202 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1203 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1204 {
1205  using Type = AddTrait_< MT, DynamicMatrix<T,SO2> >;
1206 };
1207 
1208 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1209 struct AddTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1210 {
1211  using Type = AddTrait_< DynamicMatrix<T,SO1>, MT >;
1212 };
1213 
1214 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1215 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1216 {
1218 };
1219 
1220 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1221 struct AddTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1222 {
1223  using Type = AddTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1224 };
1225 
1226 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1227 struct AddTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1228 {
1230 };
1231 
1232 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1233 struct AddTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1234 {
1235  using Type = AddTrait_< CompressedMatrix<T,SO1>, MT >;
1236 };
1237 
1238 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1239 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1240 {
1241  using Type = AddTrait_<MT1,MT2>;
1242 };
1243 
1244 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1245 struct AddTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1246 {
1247  using Type = AddTrait_<MT1,MT2>;
1248 };
1249 
1250 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1251 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1252 {
1253  using Type = AddTrait_<MT1,MT2>;
1254 };
1255 
1256 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1257 struct AddTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1258 {
1259  using Type = AddTrait_<MT1,MT2>;
1260 };
1261 
1262 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1263 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1264 {
1265  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1266 };
1267 
1268 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1269 struct AddTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1270 {
1271  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1272 };
1273 
1274 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1275 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1276 {
1277  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1278 };
1279 
1280 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1281 struct AddTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1282 {
1283  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1284 };
1285 
1286 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1287 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyLowerMatrix<MT2,SO2,DF2> >
1288 {
1289  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1290 };
1291 
1292 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1293 struct AddTrait< StrictlyLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1294 {
1295  using Type = LowerMatrix< AddTrait_<MT1,MT2> >;
1296 };
1297 
1298 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1299 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1300 {
1301  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1302 };
1303 
1304 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1305 struct AddTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1306 {
1307  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1308 };
1309 
1310 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1311 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1312 {
1313  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1314 };
1315 
1316 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1317 struct AddTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1318 {
1319  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1320 };
1321 
1322 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1323 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1324 {
1325  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1326 };
1327 
1328 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1329 struct AddTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1330 {
1331  using Type = UpperMatrix< AddTrait_<MT1,MT2> >;
1332 };
1333 
1334 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1335 struct AddTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1336 {
1337  using Type = DiagonalMatrix< AddTrait_<MT1,MT2> >;
1338 };
1340 //*************************************************************************************************
1341 
1342 
1343 
1344 
1345 //=================================================================================================
1346 //
1347 // SUBTRAIT SPECIALIZATIONS
1348 //
1349 //=================================================================================================
1350 
1351 //*************************************************************************************************
1353 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1354 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1355 {
1357 };
1358 
1359 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1360 struct SubTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1361 {
1362  using Type = SubTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1363 };
1364 
1365 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1366 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1367 {
1369 };
1370 
1371 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1372 struct SubTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1373 {
1374  using Type = SubTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1375 };
1376 
1377 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1378 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1379 {
1380  using Type = SubTrait_< MT, DynamicMatrix<T,SO2> >;
1381 };
1382 
1383 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1384 struct SubTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1385 {
1386  using Type = SubTrait_< DynamicMatrix<T,SO1>, MT >;
1387 };
1388 
1389 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1390 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1391 {
1393 };
1394 
1395 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1396 struct SubTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1397 {
1398  using Type = SubTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1399 };
1400 
1401 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1402 struct SubTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1403 {
1405 };
1406 
1407 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1408 struct SubTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1409 {
1410  using Type = SubTrait_< CompressedMatrix<T,SO1>, MT >;
1411 };
1412 
1413 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1414 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1415 {
1416  using Type = SubTrait_<MT1,MT2>;
1417 };
1418 
1419 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1420 struct SubTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1421 {
1422  using Type = SubTrait_<MT1,MT2>;
1423 };
1424 
1425 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1426 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1427 {
1428  using Type = SubTrait_<MT1,MT2>;
1429 };
1430 
1431 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1432 struct SubTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1433 {
1434  using Type = SubTrait_<MT1,MT2>;
1435 };
1436 
1437 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1438 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1439 {
1440  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1441 };
1442 
1443 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1444 struct SubTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1445 {
1446  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1447 };
1448 
1449 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1450 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1451 {
1452  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1453 };
1454 
1455 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1456 struct SubTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1457 {
1458  using Type = LowerMatrix< SubTrait_<MT1,MT2> >;
1459 };
1460 
1461 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1462 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1463 {
1464  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1465 };
1466 
1467 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1468 struct SubTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1469 {
1470  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1471 };
1472 
1473 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1474 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1475 {
1476  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1477 };
1478 
1479 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1480 struct SubTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1481 {
1482  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1483 };
1484 
1485 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1486 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1487 {
1488  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1489 };
1490 
1491 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1492 struct SubTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1493 {
1494  using Type = UpperMatrix< SubTrait_<MT1,MT2> >;
1495 };
1496 
1497 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1498 struct SubTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1499 {
1500  using Type = DiagonalMatrix< SubTrait_<MT1,MT2> >;
1501 };
1503 //*************************************************************************************************
1504 
1505 
1506 
1507 
1508 //=================================================================================================
1509 //
1510 // MULTTRAIT SPECIALIZATIONS
1511 //
1512 //=================================================================================================
1513 
1514 //*************************************************************************************************
1516 template< typename MT, bool SO, bool DF, typename T >
1517 struct MultTrait< DiagonalMatrix<MT,SO,DF>, T, EnableIf_< IsNumeric<T> > >
1518 {
1519  using Type = DiagonalMatrix< MultTrait_<MT,T> >;
1520 };
1521 
1522 template< typename T, typename MT, bool SO, bool DF >
1523 struct MultTrait< T, DiagonalMatrix<MT,SO,DF>, EnableIf_< IsNumeric<T> > >
1524 {
1525  using Type = DiagonalMatrix< MultTrait_<T,MT> >;
1526 };
1527 
1528 template< typename MT, bool SO, bool DF, typename T, size_t N >
1529 struct MultTrait< DiagonalMatrix<MT,SO,DF>, StaticVector<T,N,false> >
1530 {
1532 };
1533 
1534 template< typename T, size_t N, typename MT, bool SO, bool DF >
1535 struct MultTrait< StaticVector<T,N,true>, DiagonalMatrix<MT,SO,DF> >
1536 {
1537  using Type = MultTrait_< StaticVector<T,N,true>, MT >;
1538 };
1539 
1540 template< typename MT, bool SO, bool DF, typename T, size_t N >
1541 struct MultTrait< DiagonalMatrix<MT,SO,DF>, HybridVector<T,N,false> >
1542 {
1544 };
1545 
1546 template< typename T, size_t N, typename MT, bool SO, bool DF >
1547 struct MultTrait< HybridVector<T,N,true>, DiagonalMatrix<MT,SO,DF> >
1548 {
1549  using Type = MultTrait_< HybridVector<T,N,true>, MT >;
1550 };
1551 
1552 template< typename MT, bool SO, bool DF, typename T >
1553 struct MultTrait< DiagonalMatrix<MT,SO,DF>, DynamicVector<T,false> >
1554 {
1556 };
1557 
1558 template< typename T, typename MT, bool SO, bool DF >
1559 struct MultTrait< DynamicVector<T,true>, DiagonalMatrix<MT,SO,DF> >
1560 {
1561  using Type = MultTrait_< DynamicVector<T,true>, MT >;
1562 };
1563 
1564 template< typename MT, bool SO, bool DF, typename T, bool AF, bool PF >
1565 struct MultTrait< DiagonalMatrix<MT,SO,DF>, CustomVector<T,AF,PF,false> >
1566 {
1568 };
1569 
1570 template< typename T, bool AF, bool PF, typename MT, bool SO, bool DF >
1571 struct MultTrait< CustomVector<T,AF,PF,true>, DiagonalMatrix<MT,SO,DF> >
1572 {
1573  using Type = MultTrait_< CustomVector<T,AF,PF,true>, MT >;
1574 };
1575 
1576 template< typename MT, bool SO, bool DF, typename T >
1577 struct MultTrait< DiagonalMatrix<MT,SO,DF>, CompressedVector<T,false> >
1578 {
1580 };
1581 
1582 template< typename T, typename MT, bool SO, bool DF >
1583 struct MultTrait< CompressedVector<T,true>, DiagonalMatrix<MT,SO,DF> >
1584 {
1585  using Type = MultTrait_< CompressedVector<T,true>, MT >;
1586 };
1587 
1588 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1589 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, StaticMatrix<T,M,N,SO2> >
1590 {
1592 };
1593 
1594 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1595 struct MultTrait< StaticMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1596 {
1597  using Type = MultTrait_< StaticMatrix<T,M,N,SO1>, MT >;
1598 };
1599 
1600 template< typename MT, bool SO1, bool DF, typename T, size_t M, size_t N, bool SO2 >
1601 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, HybridMatrix<T,M,N,SO2> >
1602 {
1604 };
1605 
1606 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF >
1607 struct MultTrait< HybridMatrix<T,M,N,SO1>, DiagonalMatrix<MT,SO2,DF> >
1608 {
1609  using Type = MultTrait_< HybridMatrix<T,M,N,SO1>, MT >;
1610 };
1611 
1612 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1613 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, DynamicMatrix<T,SO2> >
1614 {
1615  using Type = MultTrait_< MT, DynamicMatrix<T,SO2> >;
1616 };
1617 
1618 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1619 struct MultTrait< DynamicMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1620 {
1621  using Type = MultTrait_< DynamicMatrix<T,SO1>, MT >;
1622 };
1623 
1624 template< typename MT, bool SO1, bool DF, typename T, bool AF, bool PF, bool SO2 >
1625 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, CustomMatrix<T,AF,PF,SO2> >
1626 {
1628 };
1629 
1630 template< typename T, bool AF, bool PF, bool SO1, typename MT, bool SO2, bool DF >
1631 struct MultTrait< CustomMatrix<T,AF,PF,SO1>, DiagonalMatrix<MT,SO2,DF> >
1632 {
1633  using Type = MultTrait_< CustomMatrix<T,AF,PF,SO1>, MT >;
1634 };
1635 
1636 template< typename MT, bool SO1, bool DF, typename T, bool SO2 >
1637 struct MultTrait< DiagonalMatrix<MT,SO1,DF>, CompressedMatrix<T,SO2> >
1638 {
1640 };
1641 
1642 template< typename T, bool SO1, typename MT, bool SO2, bool DF >
1643 struct MultTrait< CompressedMatrix<T,SO1>, DiagonalMatrix<MT,SO2,DF> >
1644 {
1645  using Type = MultTrait_< CompressedMatrix<T,SO1>, MT >;
1646 };
1647 
1648 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2, bool NF >
1649 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, SymmetricMatrix<MT2,SO2,DF2,NF> >
1650 {
1651  using Type = MultTrait_<MT1,MT2>;
1652 };
1653 
1654 template< typename MT1, bool SO1, bool DF1, bool NF, typename MT2, bool SO2, bool DF2 >
1655 struct MultTrait< SymmetricMatrix<MT1,SO1,DF1,NF>, DiagonalMatrix<MT2,SO2,DF2> >
1656 {
1657  using Type = MultTrait_<MT1,MT2>;
1658 };
1659 
1660 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1661 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, HermitianMatrix<MT2,SO2,DF2> >
1662 {
1663  using Type = MultTrait_<MT1,MT2>;
1664 };
1665 
1666 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1667 struct MultTrait< HermitianMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1668 {
1669  using Type = MultTrait_<MT1,MT2>;
1670 };
1671 
1672 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1673 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, LowerMatrix<MT2,SO2,DF2> >
1674 {
1675  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1676 };
1677 
1678 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1679 struct MultTrait< LowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1680 {
1681  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1682 };
1683 
1684 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1685 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
1686 {
1687  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1688 };
1689 
1690 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1691 struct MultTrait< UniLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1692 {
1693  using Type = LowerMatrix< MultTrait_<MT1,MT2> >;
1694 };
1695 
1696 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1697 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyLowerMatrix<MT2,SO2,DF2> >
1698 {
1700 };
1701 
1702 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1703 struct MultTrait< StrictlyLowerMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1704 {
1706 };
1707 
1708 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1709 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UpperMatrix<MT2,SO2,DF2> >
1710 {
1711  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1712 };
1713 
1714 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1715 struct MultTrait< UpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1716 {
1717  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1718 };
1719 
1720 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1721 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
1722 {
1723  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1724 };
1725 
1726 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1727 struct MultTrait< UniUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1728 {
1729  using Type = UpperMatrix< MultTrait_<MT1,MT2> >;
1730 };
1731 
1732 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1733 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1734 {
1736 };
1737 
1738 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1739 struct MultTrait< StrictlyUpperMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1740 {
1742 };
1743 
1744 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1745 struct MultTrait< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1746 {
1747  using Type = DiagonalMatrix< MultTrait_<MT1,MT2> >;
1748 };
1750 //*************************************************************************************************
1751 
1752 
1753 
1754 
1755 //=================================================================================================
1756 //
1757 // DIVTRAIT SPECIALIZATIONS
1758 //
1759 //=================================================================================================
1760 
1761 //*************************************************************************************************
1763 template< typename MT, bool SO, bool DF, typename T >
1764 struct DivTrait< DiagonalMatrix<MT,SO,DF>, T, EnableIf_< IsNumeric<T> > >
1765 {
1766  using Type = DiagonalMatrix< DivTrait_<MT,T> >;
1767 };
1769 //*************************************************************************************************
1770 
1771 
1772 
1773 
1774 //=================================================================================================
1775 //
1776 // FOREACHTRAIT SPECIALIZATIONS
1777 //
1778 //=================================================================================================
1779 
1780 //*************************************************************************************************
1782 template< typename MT, bool SO, bool DF >
1783 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Abs >
1784 {
1786 };
1787 
1788 template< typename MT, bool SO, bool DF >
1789 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Floor >
1790 {
1792 };
1793 
1794 template< typename MT, bool SO, bool DF >
1795 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Ceil >
1796 {
1798 };
1799 
1800 template< typename MT, bool SO, bool DF >
1801 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Conj >
1802 {
1804 };
1805 
1806 template< typename MT, bool SO, bool DF >
1807 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Real >
1808 {
1810 };
1811 
1812 template< typename MT, bool SO, bool DF >
1813 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Imag >
1814 {
1816 };
1817 
1818 template< typename MT, bool SO, bool DF >
1819 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Sin >
1820 {
1822 };
1823 
1824 template< typename MT, bool SO, bool DF >
1825 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Asin >
1826 {
1828 };
1829 
1830 template< typename MT, bool SO, bool DF >
1831 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Sinh >
1832 {
1834 };
1835 
1836 template< typename MT, bool SO, bool DF >
1837 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Asinh >
1838 {
1840 };
1841 
1842 template< typename MT, bool SO, bool DF >
1843 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Tan >
1844 {
1846 };
1847 
1848 template< typename MT, bool SO, bool DF >
1849 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Atan >
1850 {
1852 };
1853 
1854 template< typename MT, bool SO, bool DF >
1855 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Tanh >
1856 {
1858 };
1859 
1860 template< typename MT, bool SO, bool DF >
1861 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Atanh >
1862 {
1864 };
1865 
1866 template< typename MT, bool SO, bool DF >
1867 struct ForEachTrait< DiagonalMatrix<MT,SO,DF>, Erf >
1868 {
1870 };
1872 //*************************************************************************************************
1873 
1874 
1875 
1876 
1877 //=================================================================================================
1878 //
1879 // HIGHTYPE SPECIALIZATIONS
1880 //
1881 //=================================================================================================
1882 
1883 //*************************************************************************************************
1885 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1886 struct HighType< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1887 {
1889 };
1891 //*************************************************************************************************
1892 
1893 
1894 
1895 
1896 //=================================================================================================
1897 //
1898 // LOWTYPE SPECIALIZATIONS
1899 //
1900 //=================================================================================================
1901 
1902 //*************************************************************************************************
1904 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1905 struct LowType< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
1906 {
1908 };
1910 //*************************************************************************************************
1911 
1912 
1913 
1914 
1915 //=================================================================================================
1916 //
1917 // SUBMATRIXTRAIT SPECIALIZATIONS
1918 //
1919 //=================================================================================================
1920 
1921 //*************************************************************************************************
1923 template< typename MT, bool SO, bool DF >
1924 struct SubmatrixTrait< DiagonalMatrix<MT,SO,DF> >
1925 {
1926  using Type = SubmatrixTrait_<MT>;
1927 };
1929 //*************************************************************************************************
1930 
1931 
1932 
1933 
1934 //=================================================================================================
1935 //
1936 // ROWTRAIT SPECIALIZATIONS
1937 //
1938 //=================================================================================================
1939 
1940 //*************************************************************************************************
1942 template< typename MT, bool SO, bool DF >
1943 struct RowTrait< DiagonalMatrix<MT,SO,DF> >
1944 {
1945  using Type = RowTrait_<MT>;
1946 };
1948 //*************************************************************************************************
1949 
1950 
1951 
1952 
1953 //=================================================================================================
1954 //
1955 // COLUMNTRAIT SPECIALIZATIONS
1956 //
1957 //=================================================================================================
1958 
1959 //*************************************************************************************************
1961 template< typename MT, bool SO, bool DF >
1962 struct ColumnTrait< DiagonalMatrix<MT,SO,DF> >
1963 {
1964  using Type = ColumnTrait_<MT>;
1965 };
1967 //*************************************************************************************************
1968 
1969 } // namespace blaze
1970 
1971 #endif
Header file for auxiliary alias declarations.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
Compile time check for low-level access to constant data.This type trait tests whether the given data...
Definition: HasConstDataAccess.h:75
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.
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:118
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
Base template for the ColumnTrait class.
Definition: ColumnTrait.h:117
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
typename RowTrait< MT >::Type RowTrait_
Auxiliary alias declaration for the RowTrait type trait.The RowTrait_ alias declaration provides a co...
Definition: RowTrait.h:152
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:261
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
Matrix adapter for lower triangular matrices.
Definition: Forward.h:48
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:194
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:88
#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
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:88
Constraint on the data type.
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:71
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:119
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:1679
Constraint on the data type.
Compile time check for data types with restricted data access.This type trait tests whether the given...
Definition: IsRestricted.h:82
Header file for the IsSquare type trait.
Compile time check for the alignment of data types.This type trait tests whether the given data type ...
Definition: IsAligned.h:87
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:741
Base template for the RowTrait class.
Definition: RowTrait.h:117
Constraint on the data type.
Header file for the LowType type trait.
Base template for the HighType type trait.
Definition: HighType.h:133
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Matrix adapter for strictly upper triangular matrices.
Definition: Forward.h:51
Base template for the ForEachTrait class.The ForEachTrait class template offers the possibility to se...
Definition: ForEachTrait.h:79
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
Compile time check for data types with padding.This type trait tests whether the given data type empl...
Definition: IsPadded.h:76
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.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
DiagonalMatrix specialization for dense matrices.
Header file for the IsLower type trait.
Compile time check for square matrices.This type trait tests whether or not the given template parame...
Definition: IsSquare.h:88
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:336
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
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:544
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:260
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Matrix adapter for upper triangular matrices.
Definition: Forward.h:55
Compile time check for adaptors.This type trait tests whether the given template parameter is an adap...
Definition: IsAdaptor.h:88
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
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.
Header file for the DerestrictTrait class template.
Constraint on the data type.
Header file for the IsNumeric type trait.
Base template for the LowType type trait.
Definition: LowType.h:133
Header file for the HasConstDataAccess type trait.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
#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.
Base template for the AddTrait class.
Definition: AddTrait.h:143
Base template for the MultTrait class.
Definition: MultTrait.h:143
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
Matrix adapter for strictly lower triangular matrices.
Definition: Forward.h:50
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:267
Compile time check for Hermitian matrices.This type trait tests whether or not the given template par...
Definition: IsHermitian.h:85
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:94
#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
typename SubmatrixTrait< MT >::Type SubmatrixTrait_
Auxiliary alias declaration for the SubmatrixTrait type trait.The SubmatrixTrait_ alias declaration p...
Definition: SubmatrixTrait.h:153
Evaluation of the return type of the derestrict function.Via this type trait it is possible to evalua...
Definition: DerestrictTrait.h:73
Base template for the DivTrait class.
Definition: DivTrait.h:143
typename ColumnTrait< MT >::Type ColumnTrait_
Auxiliary alias declaration for the ColumnTrait type trait.The ColumnTrait_ alias declaration provide...
Definition: ColumnTrait.h:152
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
Header file for the implementation of the base template of the DiagonalMatrix.
Removal of top level adaptor types.In case the given type is an adaptor type (SymmetricMatrix, LowerMatrix, UpperMatrix, ...), the RemoveAdaptor type trait removes the adaptor and extracts the contained general matrix type. Else the given type is returned as is. Note that cv-qualifiers are preserved.
Definition: RemoveAdaptor.h:76
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
Header file for the implementation of the base template of the LowerMatrix.
Header file for the IsBuiltin type trait.
typename SubTrait< T1, T2 >::Type SubTrait_
Auxiliary alias declaration for the SubTrait class template.The SubTrait_ alias declaration provides ...
Definition: SubTrait.h:245
Header file for the for-each trait.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:120
Header file for the isDivisor shim.
Header file for the IntegralConstant class template.
Compile time evaluation of the number of columns of a matrix.The Columns type trait evaluates the num...
Definition: Columns.h:76
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
Compile time evaluation of the number of rows of a matrix.The Rows type trait evaluates the number of...
Definition: Rows.h:76
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
#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
Base template for the SubTrait class.
Definition: SubTrait.h:143
Matrix adapter for diagonal matrices.
Definition: BaseTemplate.h:560
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.
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
typename AddTrait< T1, T2 >::Type AddTrait_
Auxiliary alias declaration for the AddTrait class template.The AddTrait_ alias declaration provides ...
Definition: AddTrait.h:245
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
DiagonalMatrix specialization for sparse matrices.
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.