Blaze  3.6
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>
54 #include <blaze/math/Exception.h>
55 #include <blaze/math/Forward.h>
103 #include <blaze/util/Assert.h>
104 #include <blaze/util/EnableIf.h>
106 #include <blaze/util/MaybeUnused.h>
107 #include <blaze/util/mpl/If.h>
110 
111 
112 namespace blaze {
113 
114 //=================================================================================================
115 //
116 // DIAGONALMATRIX OPERATORS
117 //
118 //=================================================================================================
119 
120 //*************************************************************************************************
123 template< typename MT, bool SO, bool DF >
124 void reset( DiagonalMatrix<MT,SO,DF>& m );
125 
126 template< typename MT, bool SO, bool DF >
127 void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i );
128 
129 template< typename MT, bool SO, bool DF >
130 void clear( DiagonalMatrix<MT,SO,DF>& m );
131 
132 template< bool RF, typename MT, bool SO, bool DF >
133 bool isDefault( const DiagonalMatrix<MT,SO,DF>& m );
134 
135 template< typename MT, bool SO, bool DF >
136 bool isIntact( const DiagonalMatrix<MT,SO,DF>& m );
137 
138 template< typename MT, bool SO, bool DF >
139 void swap( DiagonalMatrix<MT,SO,DF>& a, DiagonalMatrix<MT,SO,DF>& b ) noexcept;
141 //*************************************************************************************************
142 
143 
144 //*************************************************************************************************
151 template< typename MT // Type of the adapted matrix
152  , bool SO // Storage order of the adapted matrix
153  , bool DF > // Density flag
155 {
156  m.reset();
157 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
174 template< typename MT // Type of the adapted matrix
175  , bool SO // Storage order of the adapted matrix
176  , bool DF > // Density flag
177 inline void reset( DiagonalMatrix<MT,SO,DF>& m, size_t i )
178 {
179  m.reset( i );
180 }
181 //*************************************************************************************************
182 
183 
184 //*************************************************************************************************
191 template< typename MT // Type of the adapted matrix
192  , bool SO // Storage order of the adapted matrix
193  , bool DF > // Density flag
195 {
196  m.clear();
197 }
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
229 template< bool RF // Relaxation flag
230  , typename MT // Type of the adapted matrix
231  , bool SO // Storage order of the adapted matrix
232  , bool DF > // Density flag
233 inline bool isDefault( const DiagonalMatrix<MT,SO,DF>& m )
234 {
235  return isDefault<RF>( m.matrix_ );
236 }
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
261 template< typename MT // Type of the adapted matrix
262  , bool SO // Storage order of the adapted matrix
263  , bool DF > // Density flag
264 inline bool isIntact( const DiagonalMatrix<MT,SO,DF>& m )
265 {
266  return m.isIntact();
267 }
268 //*************************************************************************************************
269 
270 
271 //*************************************************************************************************
279 template< typename MT // Type of the adapted matrix
280  , bool SO // Storage order of the adapted matrix
281  , bool DF > // Density flag
283 {
284  a.swap( b );
285 }
286 //*************************************************************************************************
287 
288 
289 //*************************************************************************************************
312 template< InversionFlag IF // Inversion algorithm
313  , typename MT // Type of the dense matrix
314  , bool SO > // Storage order of the dense matrix
315 inline void invert( DiagonalMatrix<MT,SO,true>& m )
316 {
318 
319  if( IF == asUniLower || IF == asUniUpper ) {
320  BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
321  return;
322  }
323 
324  invert<asDiagonal>( derestrict( m ) );
325 
326  BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
327 }
329 //*************************************************************************************************
330 
331 
332 //*************************************************************************************************
351 template< typename MT1, bool SO1, typename MT2, typename MT3, typename MT4, bool SO2 >
352 inline void lu( const DiagonalMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
353  DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P )
354 {
355  BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE( ElementType_t<MT1> );
356 
361 
366 
367  using ET3 = ElementType_t<MT3>;
368  using ET4 = ElementType_t<MT4>;
369 
370  const size_t n( (~A).rows() );
371 
372  decltype(auto) U2( derestrict( ~U ) );
373 
374  (~L) = A;
375 
376  resize( ~U, n, n );
377  reset( U2 );
378 
379  resize( ~P, n, n );
380  reset( ~P );
381 
382  for( size_t i=0UL; i<n; ++i ) {
383  U2(i,i) = ET3(1);
384  (~P)(i,i) = ET4(1);
385  }
386 }
388 //*************************************************************************************************
389 
390 
391 //*************************************************************************************************
407 template< typename MT // Type of the adapted matrix
408  , bool SO // Storage order of the adapted matrix
409  , bool DF // Density flag
410  , typename ET > // Type of the element
411 inline bool trySet( const DiagonalMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
412 {
413  BLAZE_INTERNAL_ASSERT( i < (~mat).rows(), "Invalid row access index" );
414  BLAZE_INTERNAL_ASSERT( j < (~mat).columns(), "Invalid column access index" );
415 
416  MAYBE_UNUSED( mat );
417 
418  return ( i == j || isDefault( value ) );
419 }
421 //*************************************************************************************************
422 
423 
424 //*************************************************************************************************
442 template< typename MT // Type of the adapted matrix
443  , bool SO // Storage order of the adapted matrix
444  , bool DF // Density flag
445  , typename ET > // Type of the element
447  trySet( const DiagonalMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
448 {
449  BLAZE_INTERNAL_ASSERT( row <= (~mat).rows(), "Invalid row access index" );
450  BLAZE_INTERNAL_ASSERT( column <= (~mat).columns(), "Invalid column access index" );
451  BLAZE_INTERNAL_ASSERT( row + m <= (~mat).rows(), "Invalid number of rows" );
452  BLAZE_INTERNAL_ASSERT( column + n <= (~mat).columns(), "Invalid number of columns" );
453 
454  MAYBE_UNUSED( mat );
455 
456  return ( m == 0UL ) ||
457  ( n == 0UL ) ||
458  ( row == column && m == 1UL && n == 1UL ) ||
459  isDefault( value );
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 ET > // Type of the element
485 inline bool tryAdd( const DiagonalMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
486 {
487  return trySet( mat, i, j, value );
488 }
490 //*************************************************************************************************
491 
492 
493 //*************************************************************************************************
511 template< typename MT // Type of the adapted matrix
512  , bool SO // Storage order of the adapted matrix
513  , bool DF // Density flag
514  , typename ET > // Type of the element
516  tryAdd( const DiagonalMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
517 {
518  return trySet( mat, row, column, m, n, value );
519 }
521 //*************************************************************************************************
522 
523 
524 //*************************************************************************************************
540 template< typename MT // Type of the adapted matrix
541  , bool SO // Storage order of the adapted matrix
542  , bool DF // Density flag
543  , typename ET > // Type of the element
544 inline bool trySub( const DiagonalMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
545 {
546  return trySet( mat, i, j, value );
547 }
549 //*************************************************************************************************
550 
551 
552 //*************************************************************************************************
570 template< typename MT // Type of the adapted matrix
571  , bool SO // Storage order of the adapted matrix
572  , bool DF // Density flag
573  , typename ET > // Type of the element
575  trySub( const DiagonalMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
576 {
577  return trySet( mat, row, column, m, n, value );
578 }
580 //*************************************************************************************************
581 
582 
583 //*************************************************************************************************
599 template< typename MT // Type of the adapted matrix
600  , bool SO // Storage order of the adapted matrix
601  , bool DF // Density flag
602  , typename ET > // Type of the element
603 inline bool tryBitor( const DiagonalMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
604 {
605  return trySet( mat, i, j, value );
606 }
608 //*************************************************************************************************
609 
610 
611 //*************************************************************************************************
629 template< typename MT // Type of the adapted matrix
630  , bool SO // Storage order of the adapted matrix
631  , bool DF // Density flag
632  , typename ET > // Type of the element
634  tryBitor( const DiagonalMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
635 {
636  return trySet( mat, row, column, m, n, value );
637 }
639 //*************************************************************************************************
640 
641 
642 //*************************************************************************************************
658 template< typename MT // Type of the adapted matrix
659  , bool SO // Storage order of the adapted matrix
660  , bool DF // Density flag
661  , typename ET > // Type of the element
662 inline bool tryBitxor( const DiagonalMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
663 {
664  return tryAdd( mat, i, j, value );
665 }
667 //*************************************************************************************************
668 
669 
670 //*************************************************************************************************
688 template< typename MT // Type of the adapted matrix
689  , bool SO // Storage order of the adapted matrix
690  , bool DF // Density flag
691  , typename ET > // Type of the element
693  tryBitxor( const DiagonalMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
694 {
695  return tryAdd( mat, row, column, m, n, value );
696 }
698 //*************************************************************************************************
699 
700 
701 //*************************************************************************************************
717 template< typename MT // Type of the adapted matrix
718  , bool SO // Storage order of the adapted matrix
719  , bool DF // Density flag
720  , typename VT > // Type of the right-hand side dense vector
721 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
722  const DenseVector<VT,false>& rhs, size_t row, size_t column )
723 {
725 
726  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
727  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
728  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
729 
730  MAYBE_UNUSED( lhs );
731 
732  const size_t index( ( column <= row )?( 0UL ):( column - row ) );
733 
734  for( size_t i=0UL; i<index; ++i ) {
735  if( !isDefault( (~rhs)[i] ) )
736  return false;
737  }
738 
739  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
740  if( !isDefault( (~rhs)[i] ) )
741  return false;
742  }
743 
744  return true;
745 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
766 template< typename MT // Type of the adapted matrix
767  , bool SO // Storage order of the adapted matrix
768  , bool DF // Density flag
769  , typename VT > // Type of the right-hand side dense vector
770 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
771  const DenseVector<VT,true>& rhs, size_t row, size_t column )
772 {
774 
775  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
776  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
777  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
778 
779  MAYBE_UNUSED( lhs );
780 
781  const size_t index( ( row <= column )?( 0UL ):( row - column ) );
782 
783  for( size_t i=0UL; i<index; ++i ) {
784  if( !isDefault( (~rhs)[i] ) )
785  return false;
786  }
787 
788  for( size_t i=index+1UL; i<(~rhs).size(); ++i ) {
789  if( !isDefault( (~rhs)[i] ) )
790  return false;
791  }
792 
793  return true;
794 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
817 template< typename MT // Type of the adapted matrix
818  , bool SO // Storage order of the adapted matrix
819  , bool DF // Density flag
820  , typename VT // Type of the right-hand side dense vector
821  , bool TF > // Transpose flag of the right-hand side dense vector
822 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
823  ptrdiff_t band, size_t row, size_t column )
824 {
826 
827  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
828  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
829  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
830 
831  MAYBE_UNUSED( lhs, row, column );
832 
833  if( band != 0L ) {
834  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
835  if( !isDefault( (~rhs)[i] ) )
836  return false;
837  }
838  }
839 
840  return true;
841 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
862 template< typename MT // Type of the adapted matrix
863  , bool SO // Storage order of the adapted matrix
864  , bool DF // Density flag
865  , typename VT > // Type of the right-hand side sparse vector
866 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
867  const SparseVector<VT,false>& rhs, size_t row, size_t column )
868 {
870 
871  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
872  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
873  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
874 
875  MAYBE_UNUSED( lhs );
876 
877  const size_t index( column - row );
878 
879  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
880  if( element->index() != index && !isDefault( element->value() ) )
881  return false;
882  }
883 
884  return true;
885 }
887 //*************************************************************************************************
888 
889 
890 //*************************************************************************************************
906 template< typename MT // Type of the adapted matrix
907  , bool SO // Storage order of the adapted matrix
908  , bool DF // Density flag
909  , typename VT > // Type of the right-hand side sparse vector
910 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
911  const SparseVector<VT,true>& rhs, size_t row, size_t column )
912 {
914 
915  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
916  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
917  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
918 
919  MAYBE_UNUSED( lhs );
920 
921  const size_t index( row - column );
922 
923  for( auto element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
924  if( element->index() != index && !isDefault( element->value() ) )
925  return false;
926  }
927 
928  return true;
929 }
931 //*************************************************************************************************
932 
933 
934 //*************************************************************************************************
952 template< typename MT // Type of the adapted matrix
953  , bool SO // Storage order of the adapted matrix
954  , bool DF // Density flag
955  , typename VT // Type of the right-hand side sparse vector
956  , bool TF > // Transpose flag of the right-hand side sparse vector
957 inline bool tryAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
958  ptrdiff_t band, size_t row, size_t column )
959 {
961 
962  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
963  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
964  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
965 
966  MAYBE_UNUSED( lhs, row, column );
967 
968  if( band != 0L ) {
969  for( const auto& element : ~rhs ) {
970  if( !isDefault( element.value() ) )
971  return false;
972  }
973  }
974 
975  return true;
976 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
997 template< typename MT1 // Type of the adapted matrix
998  , bool SO // Storage order of the adapted matrix
999  , bool DF // Density flag
1000  , typename MT2 > // Type of the right-hand side dense matrix
1001 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
1002  const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1003 {
1005 
1006  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1007  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1008  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1009  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1010 
1011  MAYBE_UNUSED( lhs );
1012 
1013  const size_t M( (~rhs).rows() );
1014  const size_t N( (~rhs).columns() );
1015 
1016  for( size_t i=0UL; i<M; ++i ) {
1017  for( size_t j=0UL; j<N; ++j ) {
1018  if( ( row + i != column + j ) && !isDefault( (~rhs)(i,j) ) )
1019  return false;
1020  }
1021  }
1022 
1023  return true;
1024 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1045 template< typename MT1 // Type of the adapted matrix
1046  , bool SO // Storage order of the adapted matrix
1047  , bool DF // Density flag
1048  , typename MT2 > // Type of the right-hand side dense matrix
1049 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
1050  const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1051 {
1053 
1054  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1055  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1056  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1057  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1058 
1059  MAYBE_UNUSED( lhs );
1060 
1061  const size_t M( (~rhs).rows() );
1062  const size_t N( (~rhs).columns() );
1063 
1064  for( size_t j=0UL; j<N; ++j ) {
1065  for( size_t i=0UL; i<M; ++i ) {
1066  if( ( column + j != row + i ) && !isDefault( (~rhs)(i,j) ) )
1067  return false;
1068  }
1069  }
1070 
1071  return true;
1072 }
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1093 template< typename MT1 // Type of the adapted matrix
1094  , bool SO // Storage order of the adapted matrix
1095  , bool DF // Density flag
1096  , typename MT2 > // Type of the right-hand side sparse matrix
1097 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
1098  const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1099 {
1101 
1102  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1103  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1104  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1105  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1106 
1107  MAYBE_UNUSED( lhs );
1108 
1109  const size_t M( (~rhs).rows() );
1110 
1111  for( size_t i=0UL; i<M; ++i ) {
1112  for( auto element=(~rhs).begin(i); element!=(~rhs).end(i); ++element ) {
1113  if( ( row + i != column + element->index() ) && !isDefault( element->value() ) )
1114  return false;
1115  }
1116  }
1117 
1118  return true;
1119 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1140 template< typename MT1 // Type of the adapted matrix
1141  , bool SO // Storage order of the adapted matrix
1142  , bool DF // Density flag
1143  , typename MT2 > // Type of the right-hand side sparse matrix
1144 inline bool tryAssign( const DiagonalMatrix<MT1,SO,DF>& lhs,
1145  const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1146 {
1148 
1149  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1150  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1151  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1152  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1153 
1154  MAYBE_UNUSED( lhs );
1155 
1156  const size_t N( (~rhs).columns() );
1157 
1158  for( size_t j=0UL; j<N; ++j ) {
1159  for( auto element=(~rhs).begin(j); element!=(~rhs).end(j); ++element ) {
1160  if( ( column + j != row + element->index() ) && !isDefault( element->value() ) )
1161  return false;
1162  }
1163  }
1164 
1165  return true;
1166 }
1168 //*************************************************************************************************
1169 
1170 
1171 //*************************************************************************************************
1187 template< typename MT // Type of the adapted matrix
1188  , bool SO // Storage order of the adapted matrix
1189  , bool DF // Density flag
1190  , typename VT // Type of the right-hand side vector
1191  , bool TF > // Transpose flag of the right-hand side vector
1192 inline bool tryAddAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
1193  const Vector<VT,TF>& rhs, size_t row, size_t column )
1194 {
1195  return tryAssign( lhs, ~rhs, row, column );
1196 }
1198 //*************************************************************************************************
1199 
1200 
1201 //*************************************************************************************************
1219 template< typename MT // Type of the adapted matrix
1220  , bool SO // Storage order of the adapted matrix
1221  , bool DF // Density flag
1222  , typename VT // Type of the right-hand side vector
1223  , bool TF > // Transpose flag of the right-hand side vector
1224 inline bool tryAddAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1225  ptrdiff_t band, size_t row, size_t column )
1226 {
1227  return tryAssign( lhs, ~rhs, band, row, column );
1228 }
1230 //*************************************************************************************************
1231 
1232 
1233 //*************************************************************************************************
1249 template< typename MT1 // Type of the adapted matrix
1250  , bool SO1 // Storage order of the adapted matrix
1251  , bool DF // Density flag
1252  , typename MT2 // Type of the right-hand side matrix
1253  , bool SO2 > // Storage order of the right-hand side matrix
1254 inline bool tryAddAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
1255  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1256 {
1257  return tryAssign( lhs, ~rhs, row, column );
1258 }
1260 //*************************************************************************************************
1261 
1262 
1263 //*************************************************************************************************
1280 template< typename MT // Type of the adapted matrix
1281  , bool SO // Storage order of the adapted matrix
1282  , bool DF // Density flag
1283  , typename VT // Type of the right-hand side vector
1284  , bool TF > // Transpose flag of the right-hand side vector
1285 inline bool trySubAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
1286  const Vector<VT,TF>& rhs, size_t row, size_t column )
1287 {
1288  return tryAssign( lhs, ~rhs, row, column );
1289 }
1291 //*************************************************************************************************
1292 
1293 
1294 //*************************************************************************************************
1312 template< typename MT // Type of the adapted matrix
1313  , bool SO // Storage order of the adapted matrix
1314  , bool DF // Density flag
1315  , typename VT // Type of the right-hand side vector
1316  , bool TF > // Transpose flag of the right-hand side vector
1317 inline bool trySubAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1318  ptrdiff_t band, size_t row, size_t column )
1319 {
1320  return tryAssign( lhs, ~rhs, band, row, column );
1321 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1343 template< typename MT1 // Type of the adapted matrix
1344  , bool SO1 // Storage order of the adapted matrix
1345  , bool DF // Density flag
1346  , typename MT2 // Type of the right-hand side matrix
1347  , bool SO2 > // Storage order of the right-hand side matrix
1348 inline bool trySubAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
1349  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1350 {
1351  return tryAssign( lhs, ~rhs, row, column );
1352 }
1354 //*************************************************************************************************
1355 
1356 
1357 //*************************************************************************************************
1374 template< typename MT // Type of the adapted matrix
1375  , bool SO // Storage order of the adapted matrix
1376  , bool DF // Density flag
1377  , typename VT // Type of the right-hand side vector
1378  , bool TF > // Transpose flag of the right-hand side vector
1379 inline bool tryBitorAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
1380  const Vector<VT,TF>& rhs, size_t row, size_t column )
1381 {
1382  return tryAssign( lhs, ~rhs, row, column );
1383 }
1385 //*************************************************************************************************
1386 
1387 
1388 //*************************************************************************************************
1405 template< typename MT // Type of the adapted matrix
1406  , bool SO // Storage order of the adapted matrix
1407  , bool DF // Density flag
1408  , typename VT // Type of the right-hand side vector
1409  , bool TF > // Transpose flag of the right-hand side vector
1410 inline bool tryBitorAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1411  ptrdiff_t band, size_t row, size_t column )
1412 {
1413  return tryAssign( lhs, ~rhs, band, row, column );
1414 }
1416 //*************************************************************************************************
1417 
1418 
1419 //*************************************************************************************************
1435 template< typename MT1 // Type of the adapted matrix
1436  , bool SO1 // Storage order of the adapted matrix
1437  , bool DF // Density flag
1438  , typename MT2 // Type of the right-hand side matrix
1439  , bool SO2 > // Storage order of the right-hand side matrix
1440 inline bool tryBitorAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
1441  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1442 {
1443  return tryAssign( lhs, ~rhs, row, column );
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1466 template< typename MT // Type of the adapted matrix
1467  , bool SO // Storage order of the adapted matrix
1468  , bool DF // Density flag
1469  , typename VT // Type of the right-hand side vector
1470  , bool TF > // Transpose flag of the right-hand side vector
1471 inline bool tryBitxorAssign( const DiagonalMatrix<MT,SO,DF>& lhs,
1472  const Vector<VT,TF>& rhs, size_t row, size_t column )
1473 {
1474  return tryAssign( lhs, ~rhs, row, column );
1475 }
1477 //*************************************************************************************************
1478 
1479 
1480 //*************************************************************************************************
1497 template< typename MT // Type of the adapted matrix
1498  , bool SO // Storage order of the adapted matrix
1499  , bool DF // Density flag
1500  , typename VT // Type of the right-hand side vector
1501  , bool TF > // Transpose flag of the right-hand side vector
1502 inline bool tryBitxorAssign( const DiagonalMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1503  ptrdiff_t band, size_t row, size_t column )
1504 {
1505  return tryAssign( lhs, ~rhs, band, row, column );
1506 }
1508 //*************************************************************************************************
1509 
1510 
1511 //*************************************************************************************************
1528 template< typename MT1 // Type of the adapted matrix
1529  , bool SO1 // Storage order of the adapted matrix
1530  , bool DF // Density flag
1531  , typename MT2 // Type of the right-hand side matrix
1532  , bool SO2 > // Storage order of the right-hand side matrix
1533 inline bool tryBitxorAssign( const DiagonalMatrix<MT1,SO1,DF>& lhs,
1534  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1535 {
1536  return tryAssign( lhs, ~rhs, row, column );
1537 }
1539 //*************************************************************************************************
1540 
1541 
1542 //*************************************************************************************************
1557 template< typename MT // Type of the adapted matrix
1558  , bool SO // Storage order of the adapted matrix
1559  , bool DF > // Density flag
1560 inline MT& derestrict( DiagonalMatrix<MT,SO,DF>& m )
1561 {
1562  return m.matrix_;
1563 }
1565 //*************************************************************************************************
1566 
1567 
1568 
1569 
1570 //=================================================================================================
1571 //
1572 // SIZE SPECIALIZATIONS
1573 //
1574 //=================================================================================================
1575 
1576 //*************************************************************************************************
1578 template< typename MT, bool SO, bool DF >
1579 struct Size< DiagonalMatrix<MT,SO,DF>, 0UL >
1580  : public Size<MT,0UL>
1581 {};
1582 
1583 template< typename MT, bool SO, bool DF >
1584 struct Size< DiagonalMatrix<MT,SO,DF>, 1UL >
1585  : public Size<MT,1UL>
1586 {};
1588 //*************************************************************************************************
1589 
1590 
1591 
1592 
1593 //=================================================================================================
1594 //
1595 // SIZE SPECIALIZATIONS
1596 //
1597 //=================================================================================================
1598 
1599 //*************************************************************************************************
1601 template< typename MT, bool SO, bool DF >
1602 struct MaxSize< DiagonalMatrix<MT,SO,DF>, 0UL >
1603  : public MaxSize<MT,0UL>
1604 {};
1605 
1606 template< typename MT, bool SO, bool DF >
1607 struct MaxSize< DiagonalMatrix<MT,SO,DF>, 1UL >
1608  : public MaxSize<MT,1UL>
1609 {};
1611 //*************************************************************************************************
1612 
1613 
1614 
1615 
1616 //=================================================================================================
1617 //
1618 // ISSQUARE SPECIALIZATIONS
1619 //
1620 //=================================================================================================
1621 
1622 //*************************************************************************************************
1624 template< typename MT, bool SO, bool DF >
1625 struct IsSquare< DiagonalMatrix<MT,SO,DF> >
1626  : public TrueType
1627 {};
1629 //*************************************************************************************************
1630 
1631 
1632 
1633 
1634 //=================================================================================================
1635 //
1636 // ISUNIFORM SPECIALIZATIONS
1637 //
1638 //=================================================================================================
1639 
1640 //*************************************************************************************************
1642 template< typename MT, bool SO, bool DF >
1643 struct IsUniform< DiagonalMatrix<MT,SO,DF> >
1644  : public IsUniform<MT>
1645 {};
1647 //*************************************************************************************************
1648 
1649 
1650 
1651 
1652 //=================================================================================================
1653 //
1654 // ISSYMMETRIC SPECIALIZATIONS
1655 //
1656 //=================================================================================================
1657 
1658 //*************************************************************************************************
1660 template< typename MT, bool SO, bool DF >
1661 struct IsSymmetric< DiagonalMatrix<MT,SO,DF> >
1662  : public TrueType
1663 {};
1665 //*************************************************************************************************
1666 
1667 
1668 
1669 
1670 //=================================================================================================
1671 //
1672 // ISHERMITIAN SPECIALIZATIONS
1673 //
1674 //=================================================================================================
1675 
1676 //*************************************************************************************************
1678 template< typename MT, bool SO, bool DF >
1679 struct IsHermitian< DiagonalMatrix<MT,SO,DF> >
1680  : public IsBuiltin< ElementType_t<MT> >
1681 {};
1683 //*************************************************************************************************
1684 
1685 
1686 
1687 
1688 //=================================================================================================
1689 //
1690 // ISLOWER SPECIALIZATIONS
1691 //
1692 //=================================================================================================
1693 
1694 //*************************************************************************************************
1696 template< typename MT, bool SO, bool DF >
1697 struct IsLower< DiagonalMatrix<MT,SO,DF> >
1698  : public TrueType
1699 {};
1701 //*************************************************************************************************
1702 
1703 
1704 
1705 
1706 //=================================================================================================
1707 //
1708 // ISSTRICTLYLOWER SPECIALIZATIONS
1709 //
1710 //=================================================================================================
1711 
1712 //*************************************************************************************************
1714 template< typename MT, bool SO, bool DF >
1715 struct IsStrictlyLower< DiagonalMatrix<MT,SO,DF> >
1716  : public IsZero<MT>
1717 {};
1719 //*************************************************************************************************
1720 
1721 
1722 
1723 
1724 //=================================================================================================
1725 //
1726 // ISUPPER SPECIALIZATIONS
1727 //
1728 //=================================================================================================
1729 
1730 //*************************************************************************************************
1732 template< typename MT, bool SO, bool DF >
1733 struct IsUpper< DiagonalMatrix<MT,SO,DF> >
1734  : public TrueType
1735 {};
1737 //*************************************************************************************************
1738 
1739 
1740 
1741 
1742 //=================================================================================================
1743 //
1744 // ISSTRICTLYUPPER SPECIALIZATIONS
1745 //
1746 //=================================================================================================
1747 
1748 //*************************************************************************************************
1750 template< typename MT, bool SO, bool DF >
1751 struct IsStrictlyUpper< DiagonalMatrix<MT,SO,DF> >
1752  : public IsZero<MT>
1753 {};
1755 //*************************************************************************************************
1756 
1757 
1758 
1759 
1760 //=================================================================================================
1761 //
1762 // ISADAPTOR SPECIALIZATIONS
1763 //
1764 //=================================================================================================
1765 
1766 //*************************************************************************************************
1768 template< typename MT, bool SO, bool DF >
1769 struct IsAdaptor< DiagonalMatrix<MT,SO,DF> >
1770  : public TrueType
1771 {};
1773 //*************************************************************************************************
1774 
1775 
1776 
1777 
1778 //=================================================================================================
1779 //
1780 // ISRESTRICTED SPECIALIZATIONS
1781 //
1782 //=================================================================================================
1783 
1784 //*************************************************************************************************
1786 template< typename MT, bool SO, bool DF >
1787 struct IsRestricted< DiagonalMatrix<MT,SO,DF> >
1788  : public TrueType
1789 {};
1791 //*************************************************************************************************
1792 
1793 
1794 
1795 
1796 //=================================================================================================
1797 //
1798 // HASCONSTDATAACCESS SPECIALIZATIONS
1799 //
1800 //=================================================================================================
1801 
1802 //*************************************************************************************************
1804 template< typename MT, bool SO >
1805 struct HasConstDataAccess< DiagonalMatrix<MT,SO,true> >
1806  : public TrueType
1807 {};
1809 //*************************************************************************************************
1810 
1811 
1812 
1813 
1814 //=================================================================================================
1815 //
1816 // ISALIGNED SPECIALIZATIONS
1817 //
1818 //=================================================================================================
1819 
1820 //*************************************************************************************************
1822 template< typename MT, bool SO, bool DF >
1823 struct IsAligned< DiagonalMatrix<MT,SO,DF> >
1824  : public IsAligned<MT>
1825 {};
1827 //*************************************************************************************************
1828 
1829 
1830 
1831 
1832 //=================================================================================================
1833 //
1834 // ISCONTIGUOUS SPECIALIZATIONS
1835 //
1836 //=================================================================================================
1837 
1838 //*************************************************************************************************
1840 template< typename MT, bool SO, bool DF >
1841 struct IsContiguous< DiagonalMatrix<MT,SO,DF> >
1842  : public IsContiguous<MT>
1843 {};
1845 //*************************************************************************************************
1846 
1847 
1848 
1849 
1850 //=================================================================================================
1851 //
1852 // ISPADDED SPECIALIZATIONS
1853 //
1854 //=================================================================================================
1855 
1856 //*************************************************************************************************
1858 template< typename MT, bool SO, bool DF >
1859 struct IsPadded< DiagonalMatrix<MT,SO,DF> >
1860  : public IsPadded<MT>
1861 {};
1863 //*************************************************************************************************
1864 
1865 
1866 
1867 
1868 //=================================================================================================
1869 //
1870 // ISRESIZABLE SPECIALIZATIONS
1871 //
1872 //=================================================================================================
1873 
1874 //*************************************************************************************************
1876 template< typename MT, bool SO, bool DF >
1877 struct IsResizable< DiagonalMatrix<MT,SO,DF> >
1878  : public IsResizable<MT>
1879 {};
1881 //*************************************************************************************************
1882 
1883 
1884 
1885 
1886 //=================================================================================================
1887 //
1888 // ISSHRINKABLE SPECIALIZATIONS
1889 //
1890 //=================================================================================================
1891 
1892 //*************************************************************************************************
1894 template< typename MT, bool SO, bool DF >
1895 struct IsShrinkable< DiagonalMatrix<MT,SO,DF> >
1896  : public IsShrinkable<MT>
1897 {};
1899 //*************************************************************************************************
1900 
1901 
1902 
1903 
1904 //=================================================================================================
1905 //
1906 // REMOVEADAPTOR SPECIALIZATIONS
1907 //
1908 //=================================================================================================
1909 
1910 //*************************************************************************************************
1912 template< typename MT, bool SO, bool DF >
1913 struct RemoveAdaptor< DiagonalMatrix<MT,SO,DF> >
1914 {
1915  using Type = MT;
1916 };
1918 //*************************************************************************************************
1919 
1920 
1921 
1922 
1923 //=================================================================================================
1924 //
1925 // ADDTRAIT SPECIALIZATIONS
1926 //
1927 //=================================================================================================
1928 
1929 //*************************************************************************************************
1931 template< typename T1, typename T2 >
1932 struct AddTraitEval1< T1, T2
1933  , EnableIf_t< IsMatrix_v<T1> &&
1934  IsMatrix_v<T2> &&
1935  IsDiagonal_v<T1> && IsDiagonal_v<T2> &&
1936  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1937 {
1938  using Type = DiagonalMatrix< typename AddTraitEval2<T1,T2>::Type >;
1939 };
1941 //*************************************************************************************************
1942 
1943 
1944 
1945 
1946 //=================================================================================================
1947 //
1948 // SUBTRAIT SPECIALIZATIONS
1949 //
1950 //=================================================================================================
1951 
1952 //*************************************************************************************************
1954 template< typename T1, typename T2 >
1955 struct SubTraitEval1< T1, T2
1956  , EnableIf_t< IsMatrix_v<T1> &&
1957  IsMatrix_v<T2> &&
1958  IsDiagonal_v<T1> && IsDiagonal_v<T2> &&
1959  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1960 {
1961  using Type = DiagonalMatrix< typename SubTraitEval2<T1,T2>::Type >;
1962 };
1963 
1964 template< typename T1, typename T2 >
1965 struct SubTraitEval1< T1, T2
1966  , EnableIf_t< IsMatrix_v<T1> &&
1967  IsMatrix_v<T2> &&
1968  IsZero_v<T1> && IsIdentity_v<T2> > >
1969 {
1970  using Tmp = If_t< StorageOrder_v<T1> != StorageOrder_v<T2>, OppositeType_t<T1>, T1 >;
1971  using Type = DiagonalMatrix< typename SubTraitEval2<Tmp,T2>::Type >;
1972 };
1974 //*************************************************************************************************
1975 
1976 
1977 
1978 
1979 //=================================================================================================
1980 //
1981 // SCHURTRAIT SPECIALIZATIONS
1982 //
1983 //=================================================================================================
1984 
1985 //*************************************************************************************************
1987 template< typename T1, typename T2 >
1988 struct SchurTraitEval1< T1, T2
1989  , EnableIf_t< IsMatrix_v<T1> &&
1990  IsMatrix_v<T2> &&
1991  ( IsDiagonal_v<T1> ||
1992  IsDiagonal_v<T2> ||
1993  ( IsLower_v<T1> && IsUpper_v<T2> ) ||
1994  ( IsUpper_v<T1> && IsLower_v<T2> ) ) &&
1995  !( IsStrictlyLower_v<T1> && IsUpper_v<T2> ) &&
1996  !( IsStrictlyUpper_v<T1> && IsLower_v<T2> ) &&
1997  !( IsLower_v<T1> && IsStrictlyUpper_v<T2> ) &&
1998  !( IsUpper_v<T1> && IsStrictlyLower_v<T2> ) &&
1999  !( IsUniTriangular_v<T1> && IsUniTriangular_v<T2> ) &&
2000  !( IsZero_v<T1> || IsZero_v<T2> ) > >
2001 {
2002  using Type = DiagonalMatrix< typename SchurTraitEval2<T1,T2>::Type >;
2003 };
2005 //*************************************************************************************************
2006 
2007 
2008 
2009 
2010 //=================================================================================================
2011 //
2012 // MULTTRAIT SPECIALIZATIONS
2013 //
2014 //=================================================================================================
2015 
2016 //*************************************************************************************************
2018 template< typename T1, typename T2 >
2019 struct MultTraitEval1< T1, T2
2020  , EnableIf_t< IsMatrix_v<T1> &&
2021  IsNumeric_v<T2> &&
2022  ( IsDiagonal_v<T1> && !IsUniform_v<T1> ) > >
2023 {
2024  using Type = DiagonalMatrix< typename MultTraitEval2<T1,T2>::Type >;
2025 };
2026 
2027 template< typename T1, typename T2 >
2028 struct MultTraitEval1< T1, T2
2029  , EnableIf_t< IsNumeric_v<T1> &&
2030  IsMatrix_v<T2> &&
2031  ( IsDiagonal_v<T2> && !IsUniform_v<T2> ) > >
2032 {
2033  using Type = DiagonalMatrix< typename MultTraitEval2<T1,T2>::Type >;
2034 };
2035 
2036 template< typename T1, typename T2 >
2037 struct MultTraitEval1< T1, T2
2038  , EnableIf_t< IsMatrix_v<T1> &&
2039  IsMatrix_v<T2> &&
2040  ( IsDiagonal_v<T1> && IsDiagonal_v<T2> ) &&
2041  !( IsIdentity_v<T1> || IsIdentity_v<T2> ) &&
2042  !( IsZero_v<T1> || IsZero_v<T2> ) > >
2043 {
2044  using Type = DiagonalMatrix< typename MultTraitEval2<T1,T2>::Type >;
2045 };
2047 //*************************************************************************************************
2048 
2049 
2050 
2051 
2052 //=================================================================================================
2053 //
2054 // KRONTRAIT SPECIALIZATIONS
2055 //
2056 //=================================================================================================
2057 
2058 //*************************************************************************************************
2060 template< typename T1, typename T2 >
2061 struct KronTraitEval1< T1, T2
2062  , EnableIf_t< IsMatrix_v<T1> &&
2063  IsMatrix_v<T2> &&
2064  ( IsDiagonal_v<T1> && IsDiagonal_v<T2> ) &&
2065  !( IsIdentity_v<T1> && IsIdentity_v<T2> ) &&
2066  !( IsZero_v<T1> || IsZero_v<T2> ) > >
2067 {
2068  using Type = DiagonalMatrix< typename KronTraitEval2<T1,T2>::Type >;
2069 };
2071 //*************************************************************************************************
2072 
2073 
2074 
2075 
2076 //=================================================================================================
2077 //
2078 // DIVTRAIT SPECIALIZATIONS
2079 //
2080 //=================================================================================================
2081 
2082 //*************************************************************************************************
2084 template< typename T1, typename T2 >
2085 struct DivTraitEval1< T1, T2
2086  , EnableIf_t< IsDiagonal_v<T1> && IsNumeric_v<T2> > >
2087 {
2088  using Type = DiagonalMatrix< typename DivTraitEval2<T1,T2>::Type >;
2089 };
2091 //*************************************************************************************************
2092 
2093 
2094 
2095 
2096 //=================================================================================================
2097 //
2098 // MAPTRAIT SPECIALIZATIONS
2099 //
2100 //=================================================================================================
2101 
2102 //*************************************************************************************************
2104 template< typename T, typename OP >
2105 struct UnaryMapTraitEval1< T, OP
2106  , EnableIf_t< YieldsDiagonal_v<OP,T> &&
2107  !YieldsIdentity_v<OP,T> &&
2108  !YieldsZero_v<OP,T> > >
2109 {
2110  using Type = DiagonalMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
2111 };
2113 //*************************************************************************************************
2114 
2115 
2116 //*************************************************************************************************
2118 template< typename T1, typename T2, typename OP >
2119 struct BinaryMapTraitEval1< T1, T2, OP
2120  , EnableIf_t< YieldsDiagonal_v<OP,T1,T2> &&
2121  !YieldsIdentity_v<OP,T1,T2> &&
2122  !YieldsZero_v<OP,T1,T2> > >
2123 {
2124  using Type = DiagonalMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
2125 };
2127 //*************************************************************************************************
2128 
2129 
2130 
2131 
2132 //=================================================================================================
2133 //
2134 // DECLSYMTRAIT SPECIALIZATIONS
2135 //
2136 //=================================================================================================
2137 
2138 //*************************************************************************************************
2140 template< typename MT, bool SO, bool DF >
2141 struct DeclSymTrait< DiagonalMatrix<MT,SO,DF> >
2142 {
2143  using Type = DiagonalMatrix<MT,SO,DF>;
2144 };
2146 //*************************************************************************************************
2147 
2148 
2149 
2150 
2151 //=================================================================================================
2152 //
2153 // DECLHERMTRAIT SPECIALIZATIONS
2154 //
2155 //=================================================================================================
2156 
2157 //*************************************************************************************************
2159 template< typename MT, bool SO, bool DF >
2160 struct DeclHermTrait< DiagonalMatrix<MT,SO,DF> >
2161 {
2162  using Type = HermitianMatrix<MT,SO,DF>;
2163 };
2165 //*************************************************************************************************
2166 
2167 
2168 
2169 
2170 //=================================================================================================
2171 //
2172 // DECLLOWTRAIT SPECIALIZATIONS
2173 //
2174 //=================================================================================================
2175 
2176 //*************************************************************************************************
2178 template< typename MT, bool SO, bool DF >
2179 struct DeclLowTrait< DiagonalMatrix<MT,SO,DF> >
2180 {
2181  using Type = DiagonalMatrix<MT,SO,DF>;
2182 };
2184 //*************************************************************************************************
2185 
2186 
2187 
2188 
2189 //=================================================================================================
2190 //
2191 // DECLUPPTRAIT SPECIALIZATIONS
2192 //
2193 //=================================================================================================
2194 
2195 //*************************************************************************************************
2197 template< typename MT, bool SO, bool DF >
2198 struct DeclUppTrait< DiagonalMatrix<MT,SO,DF> >
2199 {
2200  using Type = DiagonalMatrix<MT,SO,DF>;
2201 };
2203 //*************************************************************************************************
2204 
2205 
2206 
2207 
2208 //=================================================================================================
2209 //
2210 // DECLDIAGTRAIT SPECIALIZATIONS
2211 //
2212 //=================================================================================================
2213 
2214 //*************************************************************************************************
2216 template< typename MT, bool SO, bool DF >
2217 struct DeclDiagTrait< DiagonalMatrix<MT,SO,DF> >
2218 {
2219  using Type = DiagonalMatrix<MT,SO,DF>;
2220 };
2222 //*************************************************************************************************
2223 
2224 
2225 
2226 
2227 //=================================================================================================
2228 //
2229 // HIGHTYPE SPECIALIZATIONS
2230 //
2231 //=================================================================================================
2232 
2233 //*************************************************************************************************
2235 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
2236 struct HighType< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
2237 {
2238  using Type = DiagonalMatrix< typename HighType<MT1,MT2>::Type >;
2239 };
2241 //*************************************************************************************************
2242 
2243 
2244 
2245 
2246 //=================================================================================================
2247 //
2248 // LOWTYPE SPECIALIZATIONS
2249 //
2250 //=================================================================================================
2251 
2252 //*************************************************************************************************
2254 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
2255 struct LowType< DiagonalMatrix<MT1,SO1,DF1>, DiagonalMatrix<MT2,SO2,DF2> >
2256 {
2257  using Type = DiagonalMatrix< typename LowType<MT1,MT2>::Type >;
2258 };
2260 //*************************************************************************************************
2261 
2262 
2263 
2264 
2265 //=================================================================================================
2266 //
2267 // SUBMATRIXTRAIT SPECIALIZATIONS
2268 //
2269 //=================================================================================================
2270 
2271 //*************************************************************************************************
2273 template< typename MT, size_t I, size_t N >
2274 struct SubmatrixTraitEval1< MT, I, I, N, N
2275  , EnableIf_t< IsDiagonal_v<MT> &&
2276  !IsIdentity_v<MT> > >
2277 {
2278  using Type = DiagonalMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
2279 };
2281 //*************************************************************************************************
2282 
2283 } // namespace blaze
2284 
2285 #endif
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the decldiag trait.
Header file for the Schur product trait.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
Header file for the subtraction trait.
Header file for the row trait.
Header file for the declherm trait.
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
Header file for the IsDiagonal type trait.
Header file for the YieldsZero type trait.
Header file for the dense matrix inversion flags.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the YieldsIdentity type trait.
constexpr bool YieldsDiagonal_v
Auxiliary variable template for the YieldsDiagonal type trait.The YieldsDiagonal_v variable template ...
Definition: YieldsDiagonal.h:126
#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
Header file for the MAYBE_UNUSED function template.
Header file for the IsIdentity type trait.
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
Constraint on the data type.
Header file for the MaxSize type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is an identity matrix.
Definition: DenseMatrix.h:2433
Constraint on the data type.
Header file for the IsMatrix type trait.
Header file for the IsSquare type trait.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:779
Constraint on the data type.
Header file for the LowType type trait.
Header file for the IsUniform type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
Header file for the IsShrinkable type trait.
Header file for the decllow trait.
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:222
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
DiagonalMatrix specialization for dense matrices.
Header file for the IsLower type trait.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for the IsAligned type trait.
Header file for the IsUniTriangular type trait.
Header file for the Kron product trait.
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:137
Constraint on the data type.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Header file for the declupp trait.
#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,...
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.
Header file for the IsContiguous type trait.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
Header file for the IsZero type trait.
#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 declsym 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:282
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i....
Definition: BLASCompatible.h:61
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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the implementation of the base template of the DiagonalMatrix.
Header file for the YieldsDiagonal type trait.
Header file for the IsBuiltin type trait.
Header file for the isDivisor shim.
Header file for the StorageOrder type trait.
Header file for the IntegralConstant class template.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#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,...
Definition: Hermitian.h:79
Matrix adapter for diagonal matrices.
Definition: BaseTemplate.h:560
Header file for the IsUpper type trait.
constexpr bool IsDiagonal_v
Auxiliary variable template for the IsDiagonal type trait.The IsDiagonal_v variable template provides...
Definition: IsDiagonal.h:148
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
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,...
Definition: Assert.h:101
DiagonalMatrix specialization for sparse matrices.
Header file for the HighType type trait.